Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015-2016 The Khronos Group Inc. |
| 3 | * Copyright (c) 2015-2016 Valve Corporation |
| 4 | * Copyright (c) 2015-2016 LunarG, Inc. |
Michael Lentine | 0a369f6 | 2016-02-03 16:51:46 -0600 | [diff] [blame] | 5 | * Copyright (c) 2015-2016 Google, Inc. |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6 | * |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 7 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | * you may not use this file except in compliance with the License. |
| 9 | * You may obtain a copy of the License at |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10 | * |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 11 | * http://www.apache.org/licenses/LICENSE-2.0 |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12 | * |
| 13 | * Author: Chia-I Wu <olvaffe@gmail.com> |
| 14 | * Author: Chris Forbes <chrisf@ijw.co.nz> |
| 15 | * Author: Courtney Goeltzenleuchter <courtney@LunarG.com> |
| 16 | * Author: Mark Lobodzinski <mark@lunarg.com> |
| 17 | * Author: Mike Stroyan <mike@LunarG.com> |
| 18 | * Author: Tobin Ehlis <tobine@google.com> |
| 19 | * Author: Tony Barbour <tony@LunarG.com> |
| 20 | */ |
Tony Barbour | 65c48b3 | 2015-11-17 10:02:56 -0700 | [diff] [blame] | 21 | |
Cody Northrop | 8e54a40 | 2016-03-08 22:25:52 -0700 | [diff] [blame] | 22 | #ifdef ANDROID |
| 23 | #include "vulkan_wrapper.h" |
| 24 | #else |
David Pinedo | 9316d3b | 2015-11-06 12:54:48 -0700 | [diff] [blame] | 25 | #include <vulkan/vulkan.h> |
Cody Northrop | 8e54a40 | 2016-03-08 22:25:52 -0700 | [diff] [blame] | 26 | #endif |
Courtney Goeltzenleuchter | 58f3eff | 2015-10-07 13:28:58 -0600 | [diff] [blame] | 27 | #include "test_common.h" |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 28 | #include "vkrenderframework.h" |
Tobin Ehlis | a0cb02e | 2015-07-03 10:15:26 -0600 | [diff] [blame] | 29 | #include "vk_layer_config.h" |
Jon Ashburn | 7fa7e22 | 2016-02-02 12:08:10 -0700 | [diff] [blame] | 30 | #include "icd-spv.h" |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 31 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 32 | #define GLM_FORCE_RADIANS |
| 33 | #include "glm/glm.hpp" |
| 34 | #include <glm/gtc/matrix_transform.hpp> |
| 35 | |
Dustin Graves | ffa90fa | 2016-05-06 11:20:38 -0600 | [diff] [blame] | 36 | #define PARAMETER_VALIDATION_TESTS 1 |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 37 | #define MEM_TRACKER_TESTS 1 |
| 38 | #define OBJ_TRACKER_TESTS 1 |
| 39 | #define DRAW_STATE_TESTS 1 |
| 40 | #define THREADING_TESTS 1 |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 41 | #define SHADER_CHECKER_TESTS 1 |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 42 | #define DEVICE_LIMITS_TESTS 1 |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 43 | #define IMAGE_TESTS 1 |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 44 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 45 | //-------------------------------------------------------------------------------------- |
| 46 | // Mesh and VertexFormat Data |
| 47 | //-------------------------------------------------------------------------------------- |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 48 | struct Vertex { |
| 49 | float posX, posY, posZ, posW; // Position data |
| 50 | float r, g, b, a; // Color |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 51 | }; |
| 52 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 53 | #define XYZ1(_x_, _y_, _z_) (_x_), (_y_), (_z_), 1.f |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 54 | |
| 55 | typedef enum _BsoFailSelect { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 56 | BsoFailNone = 0x00000000, |
| 57 | BsoFailLineWidth = 0x00000001, |
| 58 | BsoFailDepthBias = 0x00000002, |
| 59 | BsoFailViewport = 0x00000004, |
| 60 | BsoFailScissor = 0x00000008, |
| 61 | BsoFailBlend = 0x00000010, |
| 62 | BsoFailDepthBounds = 0x00000020, |
| 63 | BsoFailStencilReadMask = 0x00000040, |
| 64 | BsoFailStencilWriteMask = 0x00000080, |
| 65 | BsoFailStencilReference = 0x00000100, |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 66 | } BsoFailSelect; |
| 67 | |
| 68 | struct vktriangle_vs_uniform { |
| 69 | // Must start with MVP |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 70 | float mvp[4][4]; |
| 71 | float position[3][4]; |
| 72 | float color[3][4]; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 73 | }; |
| 74 | |
Mark Lobodzinski | 75a97e6 | 2015-06-02 09:41:30 -0500 | [diff] [blame] | 75 | static const char bindStateVertShaderText[] = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 76 | "#version 450\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 77 | "vec2 vertices[3];\n" |
| 78 | "out gl_PerVertex {\n" |
| 79 | " vec4 gl_Position;\n" |
| 80 | "};\n" |
| 81 | "void main() {\n" |
| 82 | " vertices[0] = vec2(-1.0, -1.0);\n" |
| 83 | " vertices[1] = vec2( 1.0, -1.0);\n" |
| 84 | " vertices[2] = vec2( 0.0, 1.0);\n" |
| 85 | " gl_Position = vec4(vertices[gl_VertexIndex % 3], 0.0, 1.0);\n" |
| 86 | "}\n"; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 87 | |
Mark Lobodzinski | 75a97e6 | 2015-06-02 09:41:30 -0500 | [diff] [blame] | 88 | static const char bindStateFragShaderText[] = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 89 | "#version 450\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 90 | "\n" |
| 91 | "layout(location = 0) out vec4 uFragColor;\n" |
| 92 | "void main(){\n" |
| 93 | " uFragColor = vec4(0,1,0,1);\n" |
| 94 | "}\n"; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 95 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 96 | static VKAPI_ATTR VkBool32 VKAPI_CALL |
| 97 | myDbgFunc(VkFlags msgFlags, VkDebugReportObjectTypeEXT objType, |
| 98 | uint64_t srcObject, size_t location, int32_t msgCode, |
| 99 | const char *pLayerPrefix, const char *pMsg, void *pUserData); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 100 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 101 | // ******************************************************** |
| 102 | // ErrorMonitor Usage: |
| 103 | // |
| 104 | // Call SetDesiredFailureMsg with a string to be compared against all |
| 105 | // encountered log messages. Passing NULL will match all log messages. |
| 106 | // logMsg will return true for skipCall only if msg is matched or NULL. |
| 107 | // |
| 108 | // Call DesiredMsgFound to determine if the desired failure message |
| 109 | // was encountered. |
| 110 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 111 | class ErrorMonitor { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 112 | public: |
| 113 | ErrorMonitor() { |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 114 | test_platform_thread_create_mutex(&m_mutex); |
| 115 | test_platform_thread_lock_mutex(&m_mutex); |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 116 | m_msgFlags = VK_DEBUG_REPORT_INFORMATION_BIT_EXT; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 117 | m_bailout = NULL; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 118 | test_platform_thread_unlock_mutex(&m_mutex); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 119 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 120 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 121 | ~ErrorMonitor() { test_platform_thread_delete_mutex(&m_mutex); } |
| 122 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 123 | void SetDesiredFailureMsg(VkFlags msgFlags, const char *msgString) { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 124 | // also discard all collected messages to this point |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 125 | test_platform_thread_lock_mutex(&m_mutex); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 126 | m_failureMsg.clear(); |
| 127 | m_otherMsgs.clear(); |
| 128 | m_desiredMsg = msgString; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 129 | m_msgFound = VK_FALSE; |
| 130 | m_msgFlags = msgFlags; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 131 | test_platform_thread_unlock_mutex(&m_mutex); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 132 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 133 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 134 | VkBool32 CheckForDesiredMsg(VkFlags msgFlags, const char *msgString) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 135 | VkBool32 result = VK_FALSE; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 136 | test_platform_thread_lock_mutex(&m_mutex); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 137 | if (m_bailout != NULL) { |
| 138 | *m_bailout = true; |
| 139 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 140 | string errorString(msgString); |
| 141 | if (msgFlags & m_msgFlags) { |
| 142 | if (errorString.find(m_desiredMsg) != string::npos) { |
Chris Forbes | c7b8ad7 | 2016-04-04 18:50:38 +1200 | [diff] [blame] | 143 | if (m_msgFound) { /* if multiple matches, don't lose all but the last! */ |
| 144 | m_otherMsgs.push_back(m_failureMsg); |
| 145 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 146 | m_failureMsg = errorString; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 147 | m_msgFound = VK_TRUE; |
| 148 | result = VK_TRUE; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 149 | } else { |
| 150 | m_otherMsgs.push_back(errorString); |
| 151 | } |
| 152 | } |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 153 | test_platform_thread_unlock_mutex(&m_mutex); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 154 | return result; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 155 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 156 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 157 | vector<string> GetOtherFailureMsgs(void) { return m_otherMsgs; } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 158 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 159 | string GetFailureMsg(void) { return m_failureMsg; } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 160 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 161 | VkBool32 DesiredMsgFound(void) { return m_msgFound; } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 162 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 163 | void SetBailout(bool *bailout) { m_bailout = bailout; } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 164 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 165 | void DumpFailureMsgs(void) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 166 | vector<string> otherMsgs = GetOtherFailureMsgs(); |
| 167 | cout << "Other error messages logged for this test were:" << endl; |
| 168 | for (auto iter = otherMsgs.begin(); iter != otherMsgs.end(); iter++) { |
| 169 | cout << " " << *iter << endl; |
| 170 | } |
| 171 | } |
| 172 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 173 | /* helpers */ |
| 174 | |
| 175 | void ExpectSuccess() { |
| 176 | // match anything |
| 177 | SetDesiredFailureMsg(~0u, ""); |
| 178 | } |
| 179 | |
| 180 | void VerifyFound() { |
| 181 | // Not seeing the desired message is a failure. /Before/ throwing, dump |
| 182 | // any other messages. |
| 183 | if (!DesiredMsgFound()) { |
| 184 | DumpFailureMsgs(); |
| 185 | FAIL() << "Did not receive expected error '" << m_desiredMsg << "'"; |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | void VerifyNotFound() { |
| 190 | // ExpectSuccess() configured us to match anything. Any error is a |
| 191 | // failure. |
| 192 | if (DesiredMsgFound()) { |
| 193 | DumpFailureMsgs(); |
| 194 | FAIL() << "Expected to succeed but got error: " << GetFailureMsg(); |
| 195 | } |
| 196 | } |
| 197 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 198 | private: |
| 199 | VkFlags m_msgFlags; |
| 200 | string m_desiredMsg; |
| 201 | string m_failureMsg; |
| 202 | vector<string> m_otherMsgs; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 203 | test_platform_thread_mutex m_mutex; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 204 | bool *m_bailout; |
| 205 | VkBool32 m_msgFound; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 206 | }; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 207 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 208 | static VKAPI_ATTR VkBool32 VKAPI_CALL |
| 209 | myDbgFunc(VkFlags msgFlags, VkDebugReportObjectTypeEXT objType, |
| 210 | uint64_t srcObject, size_t location, int32_t msgCode, |
| 211 | const char *pLayerPrefix, const char *pMsg, void *pUserData) { |
| 212 | if (msgFlags & |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 213 | (VK_DEBUG_REPORT_WARNING_BIT_EXT | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 214 | VK_DEBUG_REPORT_ERROR_BIT_EXT)) { |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 215 | ErrorMonitor *errMonitor = (ErrorMonitor *)pUserData; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 216 | return errMonitor->CheckForDesiredMsg(msgFlags, pMsg); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 217 | } |
Courtney Goeltzenleuchter | 0664083 | 2015-09-04 13:52:24 -0600 | [diff] [blame] | 218 | return false; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 219 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 220 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 221 | class VkLayerTest : public VkRenderFramework { |
| 222 | public: |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 223 | VkResult BeginCommandBuffer(VkCommandBufferObj &commandBuffer); |
| 224 | VkResult EndCommandBuffer(VkCommandBufferObj &commandBuffer); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 225 | void VKTriangleTest(const char *vertShaderText, const char *fragShaderText, |
| 226 | BsoFailSelect failMask); |
| 227 | void GenericDrawPreparation(VkCommandBufferObj *commandBuffer, |
| 228 | VkPipelineObj &pipelineobj, |
| 229 | VkDescriptorSetObj &descriptorSet, |
| 230 | BsoFailSelect failMask); |
| 231 | void GenericDrawPreparation(VkPipelineObj &pipelineobj, |
| 232 | VkDescriptorSetObj &descriptorSet, |
| 233 | BsoFailSelect failMask) { |
| 234 | GenericDrawPreparation(m_commandBuffer, pipelineobj, descriptorSet, |
| 235 | failMask); |
| 236 | } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 237 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 238 | /* Convenience functions that use built-in command buffer */ |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 239 | VkResult BeginCommandBuffer() { |
| 240 | return BeginCommandBuffer(*m_commandBuffer); |
| 241 | } |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 242 | VkResult EndCommandBuffer() { return EndCommandBuffer(*m_commandBuffer); } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 243 | void Draw(uint32_t vertexCount, uint32_t instanceCount, |
| 244 | uint32_t firstVertex, uint32_t firstInstance) { |
| 245 | m_commandBuffer->Draw(vertexCount, instanceCount, firstVertex, |
| 246 | firstInstance); |
| 247 | } |
| 248 | void DrawIndexed(uint32_t indexCount, uint32_t instanceCount, |
| 249 | uint32_t firstIndex, int32_t vertexOffset, |
| 250 | uint32_t firstInstance) { |
| 251 | m_commandBuffer->DrawIndexed(indexCount, instanceCount, firstIndex, |
| 252 | vertexOffset, firstInstance); |
| 253 | } |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 254 | void QueueCommandBuffer() { m_commandBuffer->QueueCommandBuffer(); } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 255 | void QueueCommandBuffer(const VkFence &fence) { |
| 256 | m_commandBuffer->QueueCommandBuffer(fence); |
| 257 | } |
| 258 | void BindVertexBuffer(VkConstantBufferObj *vertexBuffer, |
| 259 | VkDeviceSize offset, uint32_t binding) { |
| 260 | m_commandBuffer->BindVertexBuffer(vertexBuffer, offset, binding); |
| 261 | } |
| 262 | void BindIndexBuffer(VkIndexBufferObj *indexBuffer, VkDeviceSize offset) { |
| 263 | m_commandBuffer->BindIndexBuffer(indexBuffer, offset); |
| 264 | } |
| 265 | |
| 266 | protected: |
| 267 | ErrorMonitor *m_errorMonitor; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 268 | |
| 269 | virtual void SetUp() { |
Courtney Goeltzenleuchter | cd69eee | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 270 | std::vector<const char *> instance_layer_names; |
| 271 | std::vector<const char *> device_layer_names; |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 272 | std::vector<const char *> instance_extension_names; |
| 273 | std::vector<const char *> device_extension_names; |
Tony Barbour | 3fdff9e | 2015-04-23 12:55:36 -0600 | [diff] [blame] | 274 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 275 | instance_extension_names.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME); |
Courtney Goeltzenleuchter | c2b06fe | 2015-06-16 15:59:11 -0600 | [diff] [blame] | 276 | /* |
| 277 | * Since CreateDbgMsgCallback is an instance level extension call |
| 278 | * any extension / layer that utilizes that feature also needs |
| 279 | * to be enabled at create instance time. |
| 280 | */ |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 281 | // Use Threading layer first to protect others from |
| 282 | // ThreadCommandBufferCollision test |
Courtney Goeltzenleuchter | 7688532 | 2016-02-06 17:11:22 -0700 | [diff] [blame] | 283 | instance_layer_names.push_back("VK_LAYER_GOOGLE_threading"); |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 284 | instance_layer_names.push_back("VK_LAYER_LUNARG_parameter_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 285 | instance_layer_names.push_back("VK_LAYER_LUNARG_object_tracker"); |
Tobin Ehlis | c96f806 | 2016-03-09 16:12:48 -0700 | [diff] [blame] | 286 | instance_layer_names.push_back("VK_LAYER_LUNARG_core_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 287 | instance_layer_names.push_back("VK_LAYER_LUNARG_device_limits"); |
| 288 | instance_layer_names.push_back("VK_LAYER_LUNARG_image"); |
Ian Elliott | e48a138 | 2016-04-28 14:22:58 -0600 | [diff] [blame] | 289 | instance_layer_names.push_back("VK_LAYER_LUNARG_swapchain"); |
Dustin Graves | eaa78cd | 2016-01-26 16:30:22 -0700 | [diff] [blame] | 290 | instance_layer_names.push_back("VK_LAYER_GOOGLE_unique_objects"); |
Courtney Goeltzenleuchter | d971b61 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 291 | |
Courtney Goeltzenleuchter | 7688532 | 2016-02-06 17:11:22 -0700 | [diff] [blame] | 292 | device_layer_names.push_back("VK_LAYER_GOOGLE_threading"); |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 293 | device_layer_names.push_back("VK_LAYER_LUNARG_parameter_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 294 | device_layer_names.push_back("VK_LAYER_LUNARG_object_tracker"); |
Tobin Ehlis | c96f806 | 2016-03-09 16:12:48 -0700 | [diff] [blame] | 295 | device_layer_names.push_back("VK_LAYER_LUNARG_core_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 296 | device_layer_names.push_back("VK_LAYER_LUNARG_device_limits"); |
| 297 | device_layer_names.push_back("VK_LAYER_LUNARG_image"); |
Ian Elliott | e48a138 | 2016-04-28 14:22:58 -0600 | [diff] [blame] | 298 | device_layer_names.push_back("VK_LAYER_LUNARG_swapchain"); |
Dustin Graves | eaa78cd | 2016-01-26 16:30:22 -0700 | [diff] [blame] | 299 | device_layer_names.push_back("VK_LAYER_GOOGLE_unique_objects"); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 300 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 301 | this->app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 302 | this->app_info.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 303 | this->app_info.pApplicationName = "layer_tests"; |
| 304 | this->app_info.applicationVersion = 1; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 305 | this->app_info.pEngineName = "unittest"; |
| 306 | this->app_info.engineVersion = 1; |
Jon Ashburn | c5012ff | 2016-03-22 13:57:46 -0600 | [diff] [blame] | 307 | this->app_info.apiVersion = VK_API_VERSION_1_0; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 308 | |
Tony Barbour | 15524c3 | 2015-04-29 17:34:29 -0600 | [diff] [blame] | 309 | m_errorMonitor = new ErrorMonitor; |
Courtney Goeltzenleuchter | cd69eee | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 310 | InitFramework(instance_layer_names, device_layer_names, |
| 311 | instance_extension_names, device_extension_names, |
| 312 | myDbgFunc, m_errorMonitor); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 313 | } |
| 314 | |
| 315 | virtual void TearDown() { |
| 316 | // Clean up resources before we reset |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 317 | ShutdownFramework(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 318 | delete m_errorMonitor; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 319 | } |
| 320 | }; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 321 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 322 | VkResult VkLayerTest::BeginCommandBuffer(VkCommandBufferObj &commandBuffer) { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 323 | VkResult result; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 324 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 325 | result = commandBuffer.BeginCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 326 | |
| 327 | /* |
| 328 | * For render test all drawing happens in a single render pass |
| 329 | * on a single command buffer. |
| 330 | */ |
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 331 | if (VK_SUCCESS == result && renderPass()) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 332 | commandBuffer.BeginRenderPass(renderPassBeginInfo()); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 333 | } |
| 334 | |
| 335 | return result; |
| 336 | } |
| 337 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 338 | VkResult VkLayerTest::EndCommandBuffer(VkCommandBufferObj &commandBuffer) { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 339 | VkResult result; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 340 | |
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 341 | if (renderPass()) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 342 | commandBuffer.EndRenderPass(); |
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 343 | } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 344 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 345 | result = commandBuffer.EndCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 346 | |
| 347 | return result; |
| 348 | } |
| 349 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 350 | void VkLayerTest::VKTriangleTest(const char *vertShaderText, |
| 351 | const char *fragShaderText, |
| 352 | BsoFailSelect failMask) { |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 353 | // Create identity matrix |
| 354 | int i; |
| 355 | struct vktriangle_vs_uniform data; |
| 356 | |
| 357 | glm::mat4 Projection = glm::mat4(1.0f); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 358 | glm::mat4 View = glm::mat4(1.0f); |
| 359 | glm::mat4 Model = glm::mat4(1.0f); |
| 360 | glm::mat4 MVP = Projection * View * Model; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 361 | const int matrixSize = sizeof(MVP); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 362 | const int bufSize = sizeof(vktriangle_vs_uniform) / sizeof(float); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 363 | |
| 364 | memcpy(&data.mvp, &MVP[0][0], matrixSize); |
| 365 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 366 | static const Vertex tri_data[] = { |
| 367 | {XYZ1(-1, -1, 0), XYZ1(1.f, 0.f, 0.f)}, |
| 368 | {XYZ1(1, -1, 0), XYZ1(0.f, 1.f, 0.f)}, |
| 369 | {XYZ1(0, 1, 0), XYZ1(0.f, 0.f, 1.f)}, |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 370 | }; |
| 371 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 372 | for (i = 0; i < 3; i++) { |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 373 | data.position[i][0] = tri_data[i].posX; |
| 374 | data.position[i][1] = tri_data[i].posY; |
| 375 | data.position[i][2] = tri_data[i].posZ; |
| 376 | data.position[i][3] = tri_data[i].posW; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 377 | data.color[i][0] = tri_data[i].r; |
| 378 | data.color[i][1] = tri_data[i].g; |
| 379 | data.color[i][2] = tri_data[i].b; |
| 380 | data.color[i][3] = tri_data[i].a; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 381 | } |
| 382 | |
| 383 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 384 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 385 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 386 | VkConstantBufferObj constantBuffer(m_device, bufSize * 2, sizeof(float), |
| 387 | (const void *)&data); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 388 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 389 | VkShaderObj vs(m_device, vertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 390 | VkShaderObj ps(m_device, fragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, |
| 391 | this); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 392 | |
| 393 | VkPipelineObj pipelineobj(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 394 | pipelineobj.AddColorAttachment(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 395 | pipelineobj.AddShader(&vs); |
| 396 | pipelineobj.AddShader(&ps); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 397 | if (failMask & BsoFailLineWidth) { |
| 398 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_LINE_WIDTH); |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 399 | VkPipelineInputAssemblyStateCreateInfo ia_state = {}; |
| 400 | ia_state.sType = |
| 401 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 402 | ia_state.topology = VK_PRIMITIVE_TOPOLOGY_LINE_LIST; |
| 403 | pipelineobj.SetInputAssembly(&ia_state); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 404 | } |
| 405 | if (failMask & BsoFailDepthBias) { |
| 406 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_DEPTH_BIAS); |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 407 | VkPipelineRasterizationStateCreateInfo rs_state = {}; |
| 408 | rs_state.sType = |
| 409 | VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 410 | rs_state.depthBiasEnable = VK_TRUE; |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 411 | rs_state.lineWidth = 1.0f; |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 412 | pipelineobj.SetRasterization(&rs_state); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 413 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 414 | // Viewport and scissors must stay in synch or other errors will occur than |
| 415 | // the ones we want |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 416 | if (failMask & BsoFailViewport) { |
| 417 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_VIEWPORT); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 418 | m_viewports.clear(); |
| 419 | m_scissors.clear(); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 420 | } |
| 421 | if (failMask & BsoFailScissor) { |
| 422 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_SCISSOR); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 423 | m_scissors.clear(); |
| 424 | m_viewports.clear(); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 425 | } |
| 426 | if (failMask & BsoFailBlend) { |
| 427 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_BLEND_CONSTANTS); |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 428 | VkPipelineColorBlendAttachmentState att_state = {}; |
| 429 | att_state.dstAlphaBlendFactor = VK_BLEND_FACTOR_CONSTANT_COLOR; |
| 430 | att_state.blendEnable = VK_TRUE; |
| 431 | pipelineobj.AddColorAttachment(0, &att_state); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 432 | } |
| 433 | if (failMask & BsoFailDepthBounds) { |
| 434 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_DEPTH_BOUNDS); |
| 435 | } |
| 436 | if (failMask & BsoFailStencilReadMask) { |
| 437 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK); |
| 438 | } |
| 439 | if (failMask & BsoFailStencilWriteMask) { |
| 440 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_WRITE_MASK); |
| 441 | } |
| 442 | if (failMask & BsoFailStencilReference) { |
| 443 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_REFERENCE); |
| 444 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 445 | |
| 446 | VkDescriptorSetObj descriptorSet(m_device); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 447 | descriptorSet.AppendBuffer(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, |
| 448 | constantBuffer); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 449 | |
| 450 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 451 | ASSERT_VK_SUCCESS(BeginCommandBuffer()); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 452 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 453 | GenericDrawPreparation(pipelineobj, descriptorSet, failMask); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 454 | |
| 455 | // render triangle |
Courtney Goeltzenleuchter | 08c2637 | 2015-09-23 12:31:50 -0600 | [diff] [blame] | 456 | Draw(3, 1, 0, 0); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 457 | |
| 458 | // finalize recording of the command buffer |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 459 | EndCommandBuffer(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 460 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 461 | QueueCommandBuffer(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 462 | } |
| 463 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 464 | void VkLayerTest::GenericDrawPreparation(VkCommandBufferObj *commandBuffer, |
| 465 | VkPipelineObj &pipelineobj, |
| 466 | VkDescriptorSetObj &descriptorSet, |
| 467 | BsoFailSelect failMask) { |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 468 | if (m_depthStencil->Initialized()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 469 | commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 470 | m_stencil_clear_color, m_depthStencil); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 471 | } else { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 472 | commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 473 | m_stencil_clear_color, NULL); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 474 | } |
| 475 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 476 | commandBuffer->PrepareAttachments(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 477 | // Make sure depthWriteEnable is set so that Depth fail test will work |
| 478 | // correctly |
| 479 | // Make sure stencilTestEnable is set so that Stencil fail test will work |
| 480 | // correctly |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 481 | VkStencilOpState stencil = {}; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 482 | stencil.failOp = VK_STENCIL_OP_KEEP; |
| 483 | stencil.passOp = VK_STENCIL_OP_KEEP; |
| 484 | stencil.depthFailOp = VK_STENCIL_OP_KEEP; |
| 485 | stencil.compareOp = VK_COMPARE_OP_NEVER; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 486 | |
| 487 | VkPipelineDepthStencilStateCreateInfo ds_ci = {}; |
| 488 | ds_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO; |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 489 | ds_ci.pNext = NULL; |
| 490 | ds_ci.depthTestEnable = VK_FALSE; |
| 491 | ds_ci.depthWriteEnable = VK_TRUE; |
| 492 | ds_ci.depthCompareOp = VK_COMPARE_OP_NEVER; |
| 493 | ds_ci.depthBoundsTestEnable = VK_FALSE; |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 494 | if (failMask & BsoFailDepthBounds) { |
| 495 | ds_ci.depthBoundsTestEnable = VK_TRUE; |
| 496 | } |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 497 | ds_ci.stencilTestEnable = VK_TRUE; |
| 498 | ds_ci.front = stencil; |
| 499 | ds_ci.back = stencil; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 500 | |
Tobin Ehlis | 4bf96d1 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 501 | pipelineobj.SetDepthStencil(&ds_ci); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 502 | pipelineobj.SetViewport(m_viewports); |
| 503 | pipelineobj.SetScissor(m_scissors); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 504 | descriptorSet.CreateVKDescriptorSet(commandBuffer); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 505 | VkResult err = pipelineobj.CreateVKPipeline( |
| 506 | descriptorSet.GetPipelineLayout(), renderPass()); |
Cody Northrop | 29a08f2 | 2015-08-27 10:20:35 -0600 | [diff] [blame] | 507 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 508 | commandBuffer->BindPipeline(pipelineobj); |
| 509 | commandBuffer->BindDescriptorSet(descriptorSet); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 510 | } |
| 511 | |
| 512 | // ******************************************************************************************************************** |
| 513 | // ******************************************************************************************************************** |
| 514 | // ******************************************************************************************************************** |
| 515 | // ******************************************************************************************************************** |
Dustin Graves | ffa90fa | 2016-05-06 11:20:38 -0600 | [diff] [blame] | 516 | #if PARAMETER_VALIDATION_TESTS |
| 517 | TEST_F(VkLayerTest, RequiredParameter) { |
| 518 | TEST_DESCRIPTION("Specify VK_NULL_HANDLE, NULL, and 0 for required handle, " |
| 519 | "pointer, array, and array count parameters"); |
| 520 | |
| 521 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 522 | |
| 523 | m_errorMonitor->SetDesiredFailureMsg( |
| 524 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 525 | "required parameter pFeatures specified as NULL"); |
| 526 | // Specify NULL for a pointer to a handle |
| 527 | // Expected to trigger an error with |
| 528 | // parameter_validation::validate_required_pointer |
| 529 | vkGetPhysicalDeviceFeatures(gpu(), NULL); |
| 530 | m_errorMonitor->VerifyFound(); |
| 531 | |
| 532 | m_errorMonitor->SetDesiredFailureMsg( |
| 533 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 534 | "required parameter pPhysicalDeviceCount specified as NULL"); |
| 535 | // Specify NULL for pointer to array count |
| 536 | // Expected to trigger an error with parameter_validation::validate_array |
| 537 | vkEnumeratePhysicalDevices(instance(), NULL, NULL); |
| 538 | m_errorMonitor->VerifyFound(); |
| 539 | |
| 540 | m_errorMonitor->SetDesiredFailureMsg( |
| 541 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 542 | "parameter viewportCount must be greater than 0"); |
| 543 | // Specify 0 for a required array count |
| 544 | // Expected to trigger an error with parameter_validation::validate_array |
| 545 | VkViewport view_port = {}; |
| 546 | m_commandBuffer->SetViewport(0, 0, &view_port); |
| 547 | m_errorMonitor->VerifyFound(); |
| 548 | |
| 549 | m_errorMonitor->SetDesiredFailureMsg( |
| 550 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 551 | "required parameter pViewports specified as NULL"); |
| 552 | // Specify NULL for a required array |
| 553 | // Expected to trigger an error with parameter_validation::validate_array |
| 554 | m_commandBuffer->SetViewport(0, 1, NULL); |
| 555 | m_errorMonitor->VerifyFound(); |
| 556 | |
| 557 | m_errorMonitor->SetDesiredFailureMsg( |
| 558 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 559 | "required parameter memory specified as VK_NULL_HANDLE"); |
| 560 | // Specify VK_NULL_HANDLE for a required handle |
| 561 | // Expected to trigger an error with |
| 562 | // parameter_validation::validate_required_handle |
| 563 | vkUnmapMemory(device(), VK_NULL_HANDLE); |
| 564 | m_errorMonitor->VerifyFound(); |
| 565 | |
| 566 | m_errorMonitor->SetDesiredFailureMsg( |
| 567 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 568 | "required parameter pFences[0] specified as VK_NULL_HANDLE"); |
| 569 | // Specify VK_NULL_HANDLE for a required handle array entry |
| 570 | // Expected to trigger an error with |
| 571 | // parameter_validation::validate_required_handle_array |
| 572 | VkFence fence = VK_NULL_HANDLE; |
| 573 | vkResetFences(device(), 1, &fence); |
| 574 | m_errorMonitor->VerifyFound(); |
| 575 | |
| 576 | m_errorMonitor->SetDesiredFailureMsg( |
| 577 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 578 | "required parameter pAllocateInfo specified as NULL"); |
| 579 | // Specify NULL for a required struct pointer |
| 580 | // Expected to trigger an error with |
| 581 | // parameter_validation::validate_struct_type |
| 582 | VkDeviceMemory memory = VK_NULL_HANDLE; |
| 583 | vkAllocateMemory(device(), NULL, NULL, &memory); |
| 584 | m_errorMonitor->VerifyFound(); |
| 585 | |
| 586 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 587 | "value of faceMask must not be 0"); |
| 588 | // Specify 0 for a required VkFlags parameter |
| 589 | // Expected to trigger an error with parameter_validation::validate_flags |
| 590 | m_commandBuffer->SetStencilReference(0, 0); |
| 591 | m_errorMonitor->VerifyFound(); |
| 592 | |
| 593 | m_errorMonitor->SetDesiredFailureMsg( |
| 594 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 595 | "value of pSubmits[i].pWaitDstStageMask[0] must not be 0"); |
| 596 | // Specify 0 for a required VkFlags array entry |
| 597 | // Expected to trigger an error with |
| 598 | // parameter_validation::validate_flags_array |
| 599 | VkSemaphore semaphore = VK_NULL_HANDLE; |
| 600 | VkPipelineStageFlags stageFlags = 0; |
| 601 | VkSubmitInfo submitInfo = {}; |
| 602 | submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 603 | submitInfo.waitSemaphoreCount = 1; |
| 604 | submitInfo.pWaitSemaphores = &semaphore; |
| 605 | submitInfo.pWaitDstStageMask = &stageFlags; |
| 606 | vkQueueSubmit(m_device->m_queue, 1, &submitInfo, VK_NULL_HANDLE); |
| 607 | m_errorMonitor->VerifyFound(); |
| 608 | } |
| 609 | #endif // PARAMETER_VALIDATION_TESTS |
| 610 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 611 | #if MEM_TRACKER_TESTS |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 612 | #if 0 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 613 | TEST_F(VkLayerTest, CallResetCommandBufferBeforeCompletion) |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 614 | { |
| 615 | vk_testing::Fence testFence; |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 616 | VkFenceCreateInfo fenceInfo = {}; |
| 617 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 618 | fenceInfo.pNext = NULL; |
| 619 | fenceInfo.flags = 0; |
| 620 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 621 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "Resetting CB"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 622 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 623 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tony Barbour | c1eb1a5 | 2015-07-20 13:00:10 -0600 | [diff] [blame] | 624 | |
| 625 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 626 | vk_testing::Buffer buffer; |
| 627 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 628 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 629 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 630 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 4, 0x11111111); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 631 | EndCommandBuffer(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 632 | |
| 633 | testFence.init(*m_device, fenceInfo); |
| 634 | |
| 635 | // Bypass framework since it does the waits automatically |
| 636 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 637 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 638 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 639 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 640 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 641 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 642 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 643 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 644 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 645 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 646 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 647 | |
| 648 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 649 | ASSERT_VK_SUCCESS( err ); |
| 650 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 651 | // Introduce failure by calling begin again before checking fence |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 652 | vkResetCommandBuffer(m_commandBuffer->handle(), 0); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 653 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 654 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 655 | } |
| 656 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 657 | TEST_F(VkLayerTest, CallBeginCommandBufferBeforeCompletion) |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 658 | { |
| 659 | vk_testing::Fence testFence; |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 660 | VkFenceCreateInfo fenceInfo = {}; |
| 661 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 662 | fenceInfo.pNext = NULL; |
| 663 | fenceInfo.flags = 0; |
| 664 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 665 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "Calling vkBeginCommandBuffer() on active CB"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 666 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 667 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 668 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 669 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 670 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 671 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 672 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, m_stencil_clear_color, NULL); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 673 | EndCommandBuffer(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 674 | |
| 675 | testFence.init(*m_device, fenceInfo); |
| 676 | |
| 677 | // Bypass framework since it does the waits automatically |
| 678 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 679 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 680 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 681 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 682 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 683 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 684 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 685 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 686 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 687 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 688 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 689 | |
| 690 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 691 | ASSERT_VK_SUCCESS( err ); |
| 692 | |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 693 | VkCommandBufferInheritanceInfo hinfo = {}; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 694 | VkCommandBufferBeginInfo info = {}; |
| 695 | info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
| 696 | info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 697 | info.renderPass = VK_NULL_HANDLE; |
| 698 | info.subpass = 0; |
| 699 | info.framebuffer = VK_NULL_HANDLE; |
Chia-I Wu | b8d47ae | 2015-11-11 10:18:12 +0800 | [diff] [blame] | 700 | info.occlusionQueryEnable = VK_FALSE; |
| 701 | info.queryFlags = 0; |
| 702 | info.pipelineStatistics = 0; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 703 | |
| 704 | // Introduce failure by calling BCB again before checking fence |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 705 | vkBeginCommandBuffer(m_commandBuffer->handle(), &info); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 706 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 707 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 708 | } |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 709 | #endif |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 710 | |
Mark Lobodzinski | 152fe25 | 2016-05-03 16:49:15 -0600 | [diff] [blame] | 711 | // This is a positive test. No failures are expected. |
| 712 | TEST_F(VkLayerTest, TestAliasedMemoryTracking) { |
| 713 | VkResult err; |
| 714 | bool pass; |
| 715 | |
| 716 | TEST_DESCRIPTION("Create a buffer, allocate memory, bind memory, destroy " |
| 717 | "the buffer, create an image, and bind the same memory to " |
| 718 | "it"); |
| 719 | |
| 720 | m_errorMonitor->ExpectSuccess(); |
| 721 | |
| 722 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 723 | |
| 724 | VkBuffer buffer; |
| 725 | VkImage image; |
| 726 | VkDeviceMemory mem; |
| 727 | VkMemoryRequirements mem_reqs; |
| 728 | |
| 729 | VkBufferCreateInfo buf_info = {}; |
| 730 | buf_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 731 | buf_info.pNext = NULL; |
| 732 | buf_info.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 733 | buf_info.size = 256; |
| 734 | buf_info.queueFamilyIndexCount = 0; |
| 735 | buf_info.pQueueFamilyIndices = NULL; |
| 736 | buf_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 737 | buf_info.flags = 0; |
| 738 | err = vkCreateBuffer(m_device->device(), &buf_info, NULL, &buffer); |
| 739 | ASSERT_VK_SUCCESS(err); |
| 740 | |
| 741 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &mem_reqs); |
| 742 | |
| 743 | VkMemoryAllocateInfo alloc_info = {}; |
| 744 | alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 745 | alloc_info.pNext = NULL; |
| 746 | alloc_info.memoryTypeIndex = 0; |
| 747 | |
| 748 | // Ensure memory is big enough for both bindings |
| 749 | alloc_info.allocationSize = 0x10000; |
| 750 | |
| 751 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &alloc_info, |
| 752 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 753 | if (!pass) { |
| 754 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 755 | return; |
| 756 | } |
| 757 | |
| 758 | err = vkAllocateMemory(m_device->device(), &alloc_info, NULL, &mem); |
| 759 | ASSERT_VK_SUCCESS(err); |
| 760 | |
| 761 | uint8_t *pData; |
| 762 | err = vkMapMemory(m_device->device(), mem, 0, mem_reqs.size, 0, |
| 763 | (void **)&pData); |
| 764 | ASSERT_VK_SUCCESS(err); |
| 765 | |
Mark Lobodzinski | 2abefa9 | 2016-05-05 11:45:57 -0600 | [diff] [blame] | 766 | memset(pData, 0xCADECADE, static_cast<size_t>(mem_reqs.size)); |
Mark Lobodzinski | 152fe25 | 2016-05-03 16:49:15 -0600 | [diff] [blame] | 767 | |
| 768 | vkUnmapMemory(m_device->device(), mem); |
| 769 | |
| 770 | err = vkBindBufferMemory(m_device->device(), buffer, mem, 0); |
| 771 | ASSERT_VK_SUCCESS(err); |
| 772 | |
| 773 | // NOW, destroy the buffer. Obviously, the resource no longer occupies this |
| 774 | // memory. In fact, it was never used by the GPU. |
| 775 | // Just be be sure, wait for idle. |
| 776 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 777 | vkDeviceWaitIdle(m_device->device()); |
| 778 | |
| 779 | VkImageCreateInfo image_create_info = {}; |
| 780 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 781 | image_create_info.pNext = NULL; |
| 782 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 783 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 784 | image_create_info.extent.width = 64; |
| 785 | image_create_info.extent.height = 64; |
| 786 | image_create_info.extent.depth = 1; |
| 787 | image_create_info.mipLevels = 1; |
| 788 | image_create_info.arrayLayers = 1; |
| 789 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 790 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 791 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_PREINITIALIZED; |
| 792 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 793 | image_create_info.queueFamilyIndexCount = 0; |
| 794 | image_create_info.pQueueFamilyIndices = NULL; |
| 795 | image_create_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 796 | image_create_info.flags = 0; |
| 797 | |
| 798 | VkMemoryAllocateInfo mem_alloc = {}; |
| 799 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 800 | mem_alloc.pNext = NULL; |
| 801 | mem_alloc.allocationSize = 0; |
| 802 | mem_alloc.memoryTypeIndex = 0; |
| 803 | |
| 804 | /* Create a mappable image. It will be the texture if linear images are ok |
| 805 | * to be textures or it will be the staging image if they are not. |
| 806 | */ |
| 807 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 808 | ASSERT_VK_SUCCESS(err); |
| 809 | |
| 810 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
| 811 | |
| 812 | mem_alloc.allocationSize = mem_reqs.size; |
| 813 | |
| 814 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, |
| 815 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 816 | if (!pass) { |
| 817 | vkDestroyImage(m_device->device(), image, NULL); |
| 818 | return; |
| 819 | } |
| 820 | |
| 821 | // VALDIATION FAILURE: |
| 822 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 823 | ASSERT_VK_SUCCESS(err); |
| 824 | |
| 825 | m_errorMonitor->VerifyNotFound(); |
| 826 | |
| 827 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 828 | vkDestroyImage(m_device->device(), image, NULL); |
| 829 | } |
| 830 | |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 831 | TEST_F(VkLayerTest, EnableWsiBeforeUse) { |
| 832 | VkResult err; |
| 833 | bool pass; |
| 834 | |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 835 | // FIXME: After we turn on this code for non-Linux platforms, uncomment the |
| 836 | // following declaration (which is temporarily being moved below): |
| 837 | // VkSurfaceKHR surface = VK_NULL_HANDLE; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 838 | VkSwapchainKHR swapchain = VK_NULL_HANDLE; |
| 839 | VkSwapchainCreateInfoKHR swapchain_create_info = {}; |
| 840 | uint32_t swapchain_image_count = 0; |
| 841 | // VkImage swapchain_images[1] = {VK_NULL_HANDLE}; |
| 842 | uint32_t image_index = 0; |
| 843 | // VkPresentInfoKHR present_info = {}; |
| 844 | |
| 845 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 846 | |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 847 | #ifdef NEED_TO_TEST_THIS_ON_PLATFORM |
| 848 | #if defined(VK_USE_PLATFORM_ANDROID_KHR) |
| 849 | // Use the functions from the VK_KHR_android_surface extension without |
| 850 | // enabling that extension: |
| 851 | |
| 852 | // Create a surface: |
| 853 | VkAndroidSurfaceCreateInfoKHR android_create_info = {}; |
| 854 | #if 0 |
| 855 | #endif |
| 856 | m_errorMonitor->SetDesiredFailureMsg( |
| 857 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 858 | "extension was not enabled for this"); |
| 859 | err = vkCreateAndroidSurfaceKHR(instance(), &android_create_info, NULL, |
| 860 | &surface); |
| 861 | pass = (err != VK_SUCCESS); |
| 862 | ASSERT_TRUE(pass); |
| 863 | m_errorMonitor->VerifyFound(); |
| 864 | #endif // VK_USE_PLATFORM_ANDROID_KHR |
| 865 | |
| 866 | |
| 867 | #if defined(VK_USE_PLATFORM_MIR_KHR) |
| 868 | // Use the functions from the VK_KHR_mir_surface extension without enabling |
| 869 | // that extension: |
| 870 | |
| 871 | // Create a surface: |
| 872 | VkMirSurfaceCreateInfoKHR mir_create_info = {}; |
| 873 | #if 0 |
| 874 | #endif |
| 875 | m_errorMonitor->SetDesiredFailureMsg( |
| 876 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 877 | "extension was not enabled for this"); |
| 878 | err = vkCreateMirSurfaceKHR(instance(), &mir_create_info, NULL, &surface); |
| 879 | pass = (err != VK_SUCCESS); |
| 880 | ASSERT_TRUE(pass); |
| 881 | m_errorMonitor->VerifyFound(); |
| 882 | |
| 883 | // Tell whether an mir_connection supports presentation: |
| 884 | MirConnection *mir_connection = NULL; |
| 885 | m_errorMonitor->SetDesiredFailureMsg( |
| 886 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 887 | "extension was not enabled for this"); |
| 888 | vkGetPhysicalDeviceMirPresentationSupportKHR(gpu(), 0, mir_connection, |
| 889 | visual_id); |
| 890 | m_errorMonitor->VerifyFound(); |
| 891 | #endif // VK_USE_PLATFORM_MIR_KHR |
| 892 | |
| 893 | |
| 894 | #if defined(VK_USE_PLATFORM_WAYLAND_KHR) |
| 895 | // Use the functions from the VK_KHR_wayland_surface extension without |
| 896 | // enabling that extension: |
| 897 | |
| 898 | // Create a surface: |
| 899 | VkWaylandSurfaceCreateInfoKHR wayland_create_info = {}; |
| 900 | #if 0 |
| 901 | #endif |
| 902 | m_errorMonitor->SetDesiredFailureMsg( |
| 903 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 904 | "extension was not enabled for this"); |
| 905 | err = vkCreateWaylandSurfaceKHR(instance(), &wayland_create_info, NULL, |
| 906 | &surface); |
| 907 | pass = (err != VK_SUCCESS); |
| 908 | ASSERT_TRUE(pass); |
| 909 | m_errorMonitor->VerifyFound(); |
| 910 | |
| 911 | // Tell whether an wayland_display supports presentation: |
| 912 | struct wl_display wayland_display = {}; |
| 913 | m_errorMonitor->SetDesiredFailureMsg( |
| 914 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 915 | "extension was not enabled for this"); |
| 916 | vkGetPhysicalDeviceWaylandPresentationSupportKHR(gpu(), 0, |
| 917 | &wayland_display); |
| 918 | m_errorMonitor->VerifyFound(); |
| 919 | #endif // VK_USE_PLATFORM_WAYLAND_KHR |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 920 | #endif // NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 921 | |
| 922 | |
| 923 | #if defined(VK_USE_PLATFORM_WIN32_KHR) |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 924 | // FIXME: REMOVE THIS HERE, AND UNCOMMENT ABOVE, WHEN THIS TEST HAS BEEN PORTED |
| 925 | // TO NON-LINUX PLATFORMS: |
| 926 | VkSurfaceKHR surface = VK_NULL_HANDLE; |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 927 | // Use the functions from the VK_KHR_win32_surface extension without |
| 928 | // enabling that extension: |
| 929 | |
| 930 | // Create a surface: |
| 931 | VkWin32SurfaceCreateInfoKHR win32_create_info = {}; |
| 932 | #if 0 |
| 933 | #endif |
| 934 | m_errorMonitor->SetDesiredFailureMsg( |
| 935 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 936 | "extension was not enabled for this"); |
| 937 | err = vkCreateWin32SurfaceKHR(instance(), &win32_create_info, NULL, |
| 938 | &surface); |
| 939 | pass = (err != VK_SUCCESS); |
| 940 | ASSERT_TRUE(pass); |
| 941 | m_errorMonitor->VerifyFound(); |
| 942 | |
| 943 | // Tell whether win32 supports presentation: |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 944 | m_errorMonitor->SetDesiredFailureMsg( |
| 945 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 946 | "extension was not enabled for this"); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 947 | vkGetPhysicalDeviceWin32PresentationSupportKHR(gpu(), 0); |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 948 | m_errorMonitor->VerifyFound(); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 949 | // Set this (for now, until all platforms are supported and tested): |
| 950 | #define NEED_TO_TEST_THIS_ON_PLATFORM |
| 951 | #endif // VK_USE_PLATFORM_WIN32_KHR |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 952 | |
| 953 | |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 954 | #if defined(VK_USE_PLATFORM_XCB_KHR) |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 955 | // FIXME: REMOVE THIS HERE, AND UNCOMMENT ABOVE, WHEN THIS TEST HAS BEEN PORTED |
| 956 | // TO NON-LINUX PLATFORMS: |
| 957 | VkSurfaceKHR surface = VK_NULL_HANDLE; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 958 | // Use the functions from the VK_KHR_xcb_surface extension without enabling |
| 959 | // that extension: |
| 960 | |
| 961 | // Create a surface: |
| 962 | VkXcbSurfaceCreateInfoKHR xcb_create_info = {}; |
| 963 | #if 0 |
| 964 | #endif |
| 965 | m_errorMonitor->SetDesiredFailureMsg( |
| 966 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 967 | "extension was not enabled for this"); |
| 968 | err = vkCreateXcbSurfaceKHR(instance(), &xcb_create_info, NULL, &surface); |
| 969 | pass = (err != VK_SUCCESS); |
| 970 | ASSERT_TRUE(pass); |
| 971 | m_errorMonitor->VerifyFound(); |
| 972 | |
| 973 | // Tell whether an xcb_visualid_t supports presentation: |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 974 | xcb_connection_t *xcb_connection = NULL; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 975 | xcb_visualid_t visual_id = 0; |
| 976 | m_errorMonitor->SetDesiredFailureMsg( |
| 977 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 978 | "extension was not enabled for this"); |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 979 | vkGetPhysicalDeviceXcbPresentationSupportKHR(gpu(), 0, xcb_connection, |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 980 | visual_id); |
| 981 | m_errorMonitor->VerifyFound(); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 982 | // Set this (for now, until all platforms are supported and tested): |
| 983 | #define NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 984 | #endif // VK_USE_PLATFORM_XCB_KHR |
| 985 | |
| 986 | |
Ian Elliott | 1263081 | 2016-04-29 14:35:43 -0600 | [diff] [blame] | 987 | #if defined(VK_USE_PLATFORM_XLIB_KHR) |
| 988 | // Use the functions from the VK_KHR_xlib_surface extension without enabling |
| 989 | // that extension: |
| 990 | |
| 991 | // Create a surface: |
| 992 | VkXlibSurfaceCreateInfoKHR xlib_create_info = {}; |
| 993 | #if 0 |
| 994 | #endif |
| 995 | m_errorMonitor->SetDesiredFailureMsg( |
| 996 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 997 | "extension was not enabled for this"); |
| 998 | err = vkCreateXlibSurfaceKHR(instance(), &xlib_create_info, NULL, &surface); |
| 999 | pass = (err != VK_SUCCESS); |
| 1000 | ASSERT_TRUE(pass); |
| 1001 | m_errorMonitor->VerifyFound(); |
| 1002 | |
| 1003 | // Tell whether an Xlib VisualID supports presentation: |
| 1004 | Display *dpy = NULL; |
| 1005 | VisualID visual = 0; |
| 1006 | m_errorMonitor->SetDesiredFailureMsg( |
| 1007 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1008 | "extension was not enabled for this"); |
| 1009 | vkGetPhysicalDeviceXlibPresentationSupportKHR(gpu(), 0, dpy, visual); |
| 1010 | m_errorMonitor->VerifyFound(); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1011 | // Set this (for now, until all platforms are supported and tested): |
| 1012 | #define NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1263081 | 2016-04-29 14:35:43 -0600 | [diff] [blame] | 1013 | #endif // VK_USE_PLATFORM_XLIB_KHR |
| 1014 | |
| 1015 | |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1016 | // Use the functions from the VK_KHR_surface extension without enabling |
| 1017 | // that extension: |
| 1018 | |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1019 | #ifdef NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1020 | // Destroy a surface: |
| 1021 | m_errorMonitor->SetDesiredFailureMsg( |
| 1022 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1023 | "extension was not enabled for this"); |
| 1024 | vkDestroySurfaceKHR(instance(), surface, NULL); |
| 1025 | m_errorMonitor->VerifyFound(); |
| 1026 | |
| 1027 | // Check if surface supports presentation: |
| 1028 | VkBool32 supported = false; |
| 1029 | m_errorMonitor->SetDesiredFailureMsg( |
| 1030 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1031 | "extension was not enabled for this"); |
| 1032 | err = vkGetPhysicalDeviceSurfaceSupportKHR(gpu(), 0, surface, &supported); |
| 1033 | pass = (err != VK_SUCCESS); |
| 1034 | ASSERT_TRUE(pass); |
| 1035 | m_errorMonitor->VerifyFound(); |
| 1036 | |
| 1037 | // Check surface capabilities: |
| 1038 | VkSurfaceCapabilitiesKHR capabilities = {}; |
| 1039 | m_errorMonitor->SetDesiredFailureMsg( |
| 1040 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1041 | "extension was not enabled for this"); |
| 1042 | err = vkGetPhysicalDeviceSurfaceCapabilitiesKHR(gpu(), surface, |
| 1043 | &capabilities); |
| 1044 | pass = (err != VK_SUCCESS); |
| 1045 | ASSERT_TRUE(pass); |
| 1046 | m_errorMonitor->VerifyFound(); |
| 1047 | |
| 1048 | // Check surface formats: |
| 1049 | uint32_t format_count = 0; |
| 1050 | VkSurfaceFormatKHR *formats = NULL; |
| 1051 | m_errorMonitor->SetDesiredFailureMsg( |
| 1052 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1053 | "extension was not enabled for this"); |
| 1054 | err = vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, |
| 1055 | &format_count, formats); |
| 1056 | pass = (err != VK_SUCCESS); |
| 1057 | ASSERT_TRUE(pass); |
| 1058 | m_errorMonitor->VerifyFound(); |
| 1059 | |
| 1060 | // Check surface present modes: |
| 1061 | uint32_t present_mode_count = 0; |
| 1062 | VkSurfaceFormatKHR *present_modes = NULL; |
| 1063 | m_errorMonitor->SetDesiredFailureMsg( |
| 1064 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1065 | "extension was not enabled for this"); |
| 1066 | err = vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, |
| 1067 | &present_mode_count, present_modes); |
| 1068 | pass = (err != VK_SUCCESS); |
| 1069 | ASSERT_TRUE(pass); |
| 1070 | m_errorMonitor->VerifyFound(); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1071 | #endif // NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1072 | |
| 1073 | |
| 1074 | // Use the functions from the VK_KHR_swapchain extension without enabling |
| 1075 | // that extension: |
| 1076 | |
| 1077 | // Create a swapchain: |
| 1078 | m_errorMonitor->SetDesiredFailureMsg( |
| 1079 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1080 | "extension was not enabled for this"); |
| 1081 | swapchain_create_info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR; |
| 1082 | swapchain_create_info.pNext = NULL; |
| 1083 | #if 0 |
| 1084 | swapchain_create_info.flags = 0; |
| 1085 | swapchain_create_info.surface = 0; |
| 1086 | swapchain_create_info.minImageCount = 0; |
| 1087 | swapchain_create_info.imageFormat = 0; |
| 1088 | swapchain_create_info.imageColorSpace = 0; |
| 1089 | swapchain_create_info.imageExtent.width = 0; |
| 1090 | swapchain_create_info.imageExtent.height = 0; |
| 1091 | swapchain_create_info.imageArrayLayers = 0; |
| 1092 | swapchain_create_info.imageUsage = 0; |
| 1093 | swapchain_create_info.imageSharingMode = 0; |
| 1094 | swapchain_create_info.queueFamilyIndexCount = 0; |
| 1095 | swapchain_create_info.preTransform = 0; |
| 1096 | swapchain_create_info.compositeAlpha = 0; |
| 1097 | swapchain_create_info.presentMode = 0; |
| 1098 | swapchain_create_info.clipped = 0; |
| 1099 | swapchain_create_info.oldSwapchain = NULL; |
| 1100 | #endif |
| 1101 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, |
| 1102 | NULL, &swapchain); |
| 1103 | pass = (err != VK_SUCCESS); |
| 1104 | ASSERT_TRUE(pass); |
| 1105 | m_errorMonitor->VerifyFound(); |
| 1106 | |
| 1107 | // Get the images from the swapchain: |
| 1108 | m_errorMonitor->SetDesiredFailureMsg( |
| 1109 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1110 | "extension was not enabled for this"); |
| 1111 | err = vkGetSwapchainImagesKHR(m_device->device(), swapchain, |
| 1112 | &swapchain_image_count, NULL); |
| 1113 | pass = (err != VK_SUCCESS); |
| 1114 | ASSERT_TRUE(pass); |
| 1115 | m_errorMonitor->VerifyFound(); |
| 1116 | |
| 1117 | // Try to acquire an image: |
| 1118 | m_errorMonitor->SetDesiredFailureMsg( |
| 1119 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1120 | "extension was not enabled for this"); |
| 1121 | err = vkAcquireNextImageKHR(m_device->device(), swapchain, 0, |
| 1122 | VK_NULL_HANDLE, VK_NULL_HANDLE, &image_index); |
| 1123 | pass = (err != VK_SUCCESS); |
| 1124 | ASSERT_TRUE(pass); |
| 1125 | m_errorMonitor->VerifyFound(); |
| 1126 | |
| 1127 | // Try to present an image: |
| 1128 | #if 0 // NOTE: Currently can't test this because a real swapchain is needed |
| 1129 | // (as opposed to the fake one we created) in order for the layer to |
| 1130 | // lookup the VkDevice used to enable the extension: |
| 1131 | m_errorMonitor->SetDesiredFailureMsg( |
| 1132 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1133 | "extension was not enabled for this"); |
| 1134 | present_info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR; |
| 1135 | present_info.pNext = NULL; |
| 1136 | #if 0 |
| 1137 | #endif |
| 1138 | err = vkQueuePresentKHR(m_device->m_queue, &present_info); |
| 1139 | pass = (err != VK_SUCCESS); |
| 1140 | ASSERT_TRUE(pass); |
| 1141 | m_errorMonitor->VerifyFound(); |
| 1142 | #endif |
| 1143 | |
| 1144 | // Destroy the swapchain: |
| 1145 | m_errorMonitor->SetDesiredFailureMsg( |
| 1146 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1147 | "extension was not enabled for this"); |
| 1148 | vkDestroySwapchainKHR(m_device->device(), swapchain, NULL); |
| 1149 | m_errorMonitor->VerifyFound(); |
| 1150 | } |
| 1151 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1152 | TEST_F(VkLayerTest, MapMemWithoutHostVisibleBit) { |
| 1153 | VkResult err; |
| 1154 | bool pass; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1155 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1156 | m_errorMonitor->SetDesiredFailureMsg( |
| 1157 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1158 | "Mapping Memory without VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT"); |
| 1159 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1160 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1161 | |
| 1162 | // Create an image, allocate memory, free it, and then try to bind it |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1163 | VkImage image; |
| 1164 | VkDeviceMemory mem; |
| 1165 | VkMemoryRequirements mem_reqs; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1166 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1167 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 1168 | const int32_t tex_width = 32; |
| 1169 | const int32_t tex_height = 32; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1170 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1171 | VkImageCreateInfo image_create_info = {}; |
| 1172 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1173 | image_create_info.pNext = NULL; |
| 1174 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1175 | image_create_info.format = tex_format; |
| 1176 | image_create_info.extent.width = tex_width; |
| 1177 | image_create_info.extent.height = tex_height; |
| 1178 | image_create_info.extent.depth = 1; |
| 1179 | image_create_info.mipLevels = 1; |
| 1180 | image_create_info.arrayLayers = 1; |
| 1181 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1182 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1183 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 1184 | image_create_info.flags = 0; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1185 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1186 | VkMemoryAllocateInfo mem_alloc = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1187 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1188 | mem_alloc.pNext = NULL; |
| 1189 | mem_alloc.allocationSize = 0; |
| 1190 | // Introduce failure, do NOT set memProps to |
| 1191 | // VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
| 1192 | mem_alloc.memoryTypeIndex = 1; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1193 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1194 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1195 | ASSERT_VK_SUCCESS(err); |
| 1196 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1197 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1198 | |
Mark Lobodzinski | 2306535 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 1199 | mem_alloc.allocationSize = mem_reqs.size; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1200 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1201 | pass = |
| 1202 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0, |
| 1203 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 1204 | if (!pass) { // If we can't find any unmappable memory this test doesn't |
| 1205 | // make sense |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1206 | vkDestroyImage(m_device->device(), image, NULL); |
Tony Barbour | 02fdc7d | 2015-08-04 16:13:01 -0600 | [diff] [blame] | 1207 | return; |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1208 | } |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 1209 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1210 | // allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1211 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1212 | ASSERT_VK_SUCCESS(err); |
| 1213 | |
| 1214 | // Try to bind free memory that has been freed |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 1215 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1216 | ASSERT_VK_SUCCESS(err); |
| 1217 | |
| 1218 | // Map memory as if to initialize the image |
| 1219 | void *mappedAddress = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1220 | err = vkMapMemory(m_device->device(), mem, 0, VK_WHOLE_SIZE, 0, |
| 1221 | &mappedAddress); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1222 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1223 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1224 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1225 | vkDestroyImage(m_device->device(), image, NULL); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1226 | } |
| 1227 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1228 | TEST_F(VkLayerTest, RebindMemory) { |
| 1229 | VkResult err; |
| 1230 | bool pass; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1231 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1232 | m_errorMonitor->SetDesiredFailureMsg( |
| 1233 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1234 | "which has already been bound to mem object"); |
| 1235 | |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1236 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1237 | |
| 1238 | // Create an image, allocate memory, free it, and then try to bind it |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1239 | VkImage image; |
| 1240 | VkDeviceMemory mem1; |
| 1241 | VkDeviceMemory mem2; |
| 1242 | VkMemoryRequirements mem_reqs; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1243 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1244 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 1245 | const int32_t tex_width = 32; |
| 1246 | const int32_t tex_height = 32; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1247 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1248 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1249 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1250 | image_create_info.pNext = NULL; |
| 1251 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1252 | image_create_info.format = tex_format; |
| 1253 | image_create_info.extent.width = tex_width; |
| 1254 | image_create_info.extent.height = tex_height; |
| 1255 | image_create_info.extent.depth = 1; |
| 1256 | image_create_info.mipLevels = 1; |
| 1257 | image_create_info.arrayLayers = 1; |
| 1258 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1259 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1260 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 1261 | image_create_info.flags = 0; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1262 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1263 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1264 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1265 | mem_alloc.pNext = NULL; |
| 1266 | mem_alloc.allocationSize = 0; |
| 1267 | mem_alloc.memoryTypeIndex = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1268 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1269 | // Introduce failure, do NOT set memProps to |
| 1270 | // VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1271 | mem_alloc.memoryTypeIndex = 1; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1272 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1273 | ASSERT_VK_SUCCESS(err); |
| 1274 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1275 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1276 | |
| 1277 | mem_alloc.allocationSize = mem_reqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1278 | pass = |
| 1279 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 1280 | ASSERT_TRUE(pass); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1281 | |
| 1282 | // allocate 2 memory objects |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1283 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem1); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1284 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1285 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem2); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1286 | ASSERT_VK_SUCCESS(err); |
| 1287 | |
| 1288 | // Bind first memory object to Image object |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 1289 | err = vkBindImageMemory(m_device->device(), image, mem1, 0); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1290 | ASSERT_VK_SUCCESS(err); |
| 1291 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1292 | // Introduce validation failure, try to bind a different memory object to |
| 1293 | // the same image object |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 1294 | err = vkBindImageMemory(m_device->device(), image, mem2, 0); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1295 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1296 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1297 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1298 | vkDestroyImage(m_device->device(), image, NULL); |
| 1299 | vkFreeMemory(m_device->device(), mem1, NULL); |
| 1300 | vkFreeMemory(m_device->device(), mem2, NULL); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1301 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1302 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1303 | TEST_F(VkLayerTest, SubmitSignaledFence) { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1304 | vk_testing::Fence testFence; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1305 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1306 | m_errorMonitor->SetDesiredFailureMsg( |
| 1307 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "submitted in SIGNALED state. Fences " |
| 1308 | "must be reset before being submitted"); |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1309 | |
| 1310 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 1311 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 1312 | fenceInfo.pNext = NULL; |
| 1313 | fenceInfo.flags = VK_FENCE_CREATE_SIGNALED_BIT; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 1314 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 1315 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1316 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 1317 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1318 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1319 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1320 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 1321 | m_stencil_clear_color, NULL); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1322 | EndCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 1323 | |
| 1324 | testFence.init(*m_device, fenceInfo); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1325 | |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1326 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 1327 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1328 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1329 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1330 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 1331 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1332 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1333 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1334 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1335 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 1336 | |
| 1337 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1338 | vkQueueWaitIdle(m_device->m_queue); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1339 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1340 | m_errorMonitor->VerifyFound(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 1341 | } |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 1342 | // This is a positive test. We used to expect error in this case but spec now |
| 1343 | // allows it |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1344 | TEST_F(VkLayerTest, ResetUnsignaledFence) { |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 1345 | m_errorMonitor->ExpectSuccess(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 1346 | vk_testing::Fence testFence; |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1347 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 1348 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 1349 | fenceInfo.pNext = NULL; |
| 1350 | |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 1351 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1352 | testFence.init(*m_device, fenceInfo); |
Chia-I Wu | d9e8e82 | 2015-07-03 11:45:55 +0800 | [diff] [blame] | 1353 | VkFence fences[1] = {testFence.handle()}; |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 1354 | VkResult result = vkResetFences(m_device->device(), 1, fences); |
| 1355 | ASSERT_VK_SUCCESS(result); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 1356 | |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 1357 | m_errorMonitor->VerifyNotFound(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 1358 | } |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 1359 | |
| 1360 | TEST_F(VkLayerTest, InvalidUsageBits) |
| 1361 | { |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 1362 | TEST_DESCRIPTION( |
Karl Schultz | b5bc11e | 2016-05-04 08:36:08 -0600 | [diff] [blame] | 1363 | "Specify wrong usage for image then create conflicting view of image " |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 1364 | "Initialize buffer with wrong usage then perform copy expecting errors " |
| 1365 | "from both the image and the buffer (2 calls)"); |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1366 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1367 | "Invalid usage flag for image "); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 1368 | |
| 1369 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 1370 | VkImageObj image(m_device); |
| 1371 | // Initialize image with USAGE_INPUT_ATTACHMENT |
| 1372 | image.init(128, 128, VK_FORMAT_D32_SFLOAT_S8_UINT, |
Karl Schultz | b5bc11e | 2016-05-04 08:36:08 -0600 | [diff] [blame] | 1373 | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
| 1374 | ASSERT_TRUE(image.initialized()); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 1375 | |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 1376 | VkImageView dsv; |
| 1377 | VkImageViewCreateInfo dsvci = {}; |
| 1378 | dsvci.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 1379 | dsvci.image = image.handle(); |
| 1380 | dsvci.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 1381 | dsvci.format = VK_FORMAT_D32_SFLOAT_S8_UINT; |
| 1382 | dsvci.subresourceRange.layerCount = 1; |
| 1383 | dsvci.subresourceRange.baseMipLevel = 0; |
| 1384 | dsvci.subresourceRange.levelCount = 1; |
| 1385 | dsvci.subresourceRange.aspectMask = |
| 1386 | VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 1387 | |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 1388 | // Create a view with depth / stencil aspect for image with different usage |
| 1389 | vkCreateImageView(m_device->device(), &dsvci, NULL, &dsv); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1390 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1391 | m_errorMonitor->VerifyFound(); |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 1392 | |
| 1393 | // Initialize buffer with TRANSFER_DST usage |
| 1394 | vk_testing::Buffer buffer; |
| 1395 | VkMemoryPropertyFlags reqs = 0; |
| 1396 | buffer.init_as_dst(*m_device, 128 * 128, reqs); |
| 1397 | VkBufferImageCopy region = {}; |
| 1398 | region.bufferRowLength = 128; |
| 1399 | region.bufferImageHeight = 128; |
| 1400 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 1401 | region.imageSubresource.layerCount = 1; |
| 1402 | region.imageExtent.height = 16; |
| 1403 | region.imageExtent.width = 16; |
| 1404 | region.imageExtent.depth = 1; |
| 1405 | |
| 1406 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1407 | "Invalid usage flag for buffer "); |
| 1408 | // Buffer usage not set to TRANSFER_SRC and image usage not set to |
| 1409 | // TRANSFER_DST |
| 1410 | BeginCommandBuffer(); |
| 1411 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 1412 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 1413 | 1, ®ion); |
| 1414 | m_errorMonitor->VerifyFound(); |
| 1415 | |
| 1416 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1417 | "Invalid usage flag for image "); |
| 1418 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 1419 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 1420 | 1, ®ion); |
| 1421 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 1422 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 1423 | #endif // MEM_TRACKER_TESTS |
| 1424 | |
Tobin Ehlis | 4bf96d1 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 1425 | #if OBJ_TRACKER_TESTS |
Mark Lobodzinski | fc5cc66 | 2016-05-02 17:17:41 -0600 | [diff] [blame] | 1426 | |
| 1427 | TEST_F(VkLayerTest, LeakAnObject) { |
| 1428 | VkResult err; |
| 1429 | |
| 1430 | TEST_DESCRIPTION( |
| 1431 | "Create a fence and destroy its device without first destroying the fence."); |
| 1432 | |
| 1433 | // Note that we have to create a new device since destroying the |
| 1434 | // framework's device causes Teardown() to fail and just calling Teardown |
| 1435 | // will destroy the errorMonitor. |
| 1436 | |
| 1437 | m_errorMonitor->SetDesiredFailureMsg( |
| 1438 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1439 | "OBJ ERROR : VK_DEBUG_REPORT_OBJECT_TYPE_FENCE_EXT object"); |
| 1440 | |
| 1441 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1442 | |
| 1443 | const std::vector<VkQueueFamilyProperties> queue_props = |
| 1444 | m_device->queue_props; |
| 1445 | std::vector<VkDeviceQueueCreateInfo> queue_info; |
| 1446 | queue_info.reserve(queue_props.size()); |
| 1447 | std::vector<std::vector<float>> queue_priorities; |
| 1448 | for (uint32_t i = 0; i < (uint32_t)queue_props.size(); i++) { |
| 1449 | VkDeviceQueueCreateInfo qi = {}; |
| 1450 | qi.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO; |
| 1451 | qi.pNext = NULL; |
| 1452 | qi.queueFamilyIndex = i; |
| 1453 | qi.queueCount = queue_props[i].queueCount; |
| 1454 | queue_priorities.emplace_back(qi.queueCount, 0.0f); |
| 1455 | qi.pQueuePriorities = queue_priorities[i].data(); |
| 1456 | queue_info.push_back(qi); |
| 1457 | } |
| 1458 | |
| 1459 | std::vector<const char *> device_layer_names; |
| 1460 | std::vector<const char *> device_extension_names; |
| 1461 | device_layer_names.push_back("VK_LAYER_GOOGLE_threading"); |
| 1462 | device_layer_names.push_back("VK_LAYER_LUNARG_parameter_validation"); |
| 1463 | device_layer_names.push_back("VK_LAYER_LUNARG_object_tracker"); |
| 1464 | device_layer_names.push_back("VK_LAYER_LUNARG_core_validation"); |
| 1465 | device_layer_names.push_back("VK_LAYER_LUNARG_device_limits"); |
| 1466 | device_layer_names.push_back("VK_LAYER_LUNARG_image"); |
| 1467 | device_layer_names.push_back("VK_LAYER_GOOGLE_unique_objects"); |
| 1468 | |
| 1469 | // The sacrificial device object |
| 1470 | VkDevice testDevice; |
| 1471 | VkDeviceCreateInfo device_create_info = {}; |
| 1472 | auto features = m_device->phy().features(); |
| 1473 | device_create_info.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO; |
| 1474 | device_create_info.pNext = NULL; |
| 1475 | device_create_info.queueCreateInfoCount = queue_info.size(); |
| 1476 | device_create_info.pQueueCreateInfos = queue_info.data(); |
| 1477 | device_create_info.enabledLayerCount = device_layer_names.size(); |
| 1478 | device_create_info.ppEnabledLayerNames = device_layer_names.data(); |
| 1479 | device_create_info.pEnabledFeatures = &features; |
| 1480 | err = vkCreateDevice(gpu(), &device_create_info, NULL, &testDevice); |
| 1481 | ASSERT_VK_SUCCESS(err); |
| 1482 | |
| 1483 | VkFence fence; |
| 1484 | VkFenceCreateInfo fence_create_info = {}; |
| 1485 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 1486 | fence_create_info.pNext = NULL; |
| 1487 | fence_create_info.flags = 0; |
| 1488 | err = vkCreateFence(testDevice, &fence_create_info, NULL, &fence); |
| 1489 | ASSERT_VK_SUCCESS(err); |
| 1490 | |
| 1491 | // Induce failure by not calling vkDestroyFence |
| 1492 | vkDestroyDevice(testDevice, NULL); |
| 1493 | m_errorMonitor->VerifyFound(); |
| 1494 | } |
| 1495 | |
| 1496 | TEST_F(VkLayerTest, InvalidCommandPoolConsistency) { |
| 1497 | |
| 1498 | TEST_DESCRIPTION("Allocate command buffers from one command pool and " |
| 1499 | "attempt to delete them from another."); |
| 1500 | |
| 1501 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1502 | "FreeCommandBuffers is attempting to free Command Buffer"); |
| 1503 | |
| 1504 | VkCommandPool command_pool_one; |
| 1505 | VkCommandPool command_pool_two; |
| 1506 | |
| 1507 | VkCommandPoolCreateInfo pool_create_info{}; |
| 1508 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 1509 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 1510 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 1511 | |
| 1512 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 1513 | &command_pool_one); |
| 1514 | |
| 1515 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 1516 | &command_pool_two); |
| 1517 | |
| 1518 | VkCommandBuffer command_buffer[9]; |
| 1519 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 1520 | command_buffer_allocate_info.sType = |
| 1521 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 1522 | command_buffer_allocate_info.commandPool = command_pool_one; |
| 1523 | command_buffer_allocate_info.commandBufferCount = 9; |
| 1524 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 1525 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 1526 | command_buffer); |
| 1527 | |
| 1528 | vkFreeCommandBuffers(m_device->device(), command_pool_two, 4, |
| 1529 | &command_buffer[3]); |
| 1530 | |
| 1531 | m_errorMonitor->VerifyFound(); |
| 1532 | |
| 1533 | vkDestroyCommandPool(m_device->device(), command_pool_one, NULL); |
| 1534 | vkDestroyCommandPool(m_device->device(), command_pool_two, NULL); |
| 1535 | } |
| 1536 | |
| 1537 | TEST_F(VkLayerTest, InvalidDescriptorPoolConsistency) { |
| 1538 | VkResult err; |
| 1539 | |
| 1540 | TEST_DESCRIPTION("Allocate descriptor sets from one DS pool and " |
| 1541 | "attempt to delete them from another."); |
| 1542 | |
| 1543 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1544 | "FreeDescriptorSets is attempting to free descriptorSet"); |
| 1545 | |
| 1546 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1547 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1548 | |
| 1549 | VkDescriptorPoolSize ds_type_count = {}; |
| 1550 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 1551 | ds_type_count.descriptorCount = 1; |
| 1552 | |
| 1553 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1554 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1555 | ds_pool_ci.pNext = NULL; |
| 1556 | ds_pool_ci.flags = 0; |
| 1557 | ds_pool_ci.maxSets = 1; |
| 1558 | ds_pool_ci.poolSizeCount = 1; |
| 1559 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 1560 | |
| 1561 | VkDescriptorPool ds_pool_one; |
| 1562 | err = |
| 1563 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool_one); |
| 1564 | ASSERT_VK_SUCCESS(err); |
| 1565 | |
| 1566 | // Create a second descriptor pool |
| 1567 | VkDescriptorPool ds_pool_two; |
| 1568 | err = |
| 1569 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool_two); |
| 1570 | ASSERT_VK_SUCCESS(err); |
| 1571 | |
| 1572 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 1573 | dsl_binding.binding = 0; |
| 1574 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 1575 | dsl_binding.descriptorCount = 1; |
| 1576 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1577 | dsl_binding.pImmutableSamplers = NULL; |
| 1578 | |
| 1579 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1580 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1581 | ds_layout_ci.pNext = NULL; |
| 1582 | ds_layout_ci.bindingCount = 1; |
| 1583 | ds_layout_ci.pBindings = &dsl_binding; |
| 1584 | |
| 1585 | VkDescriptorSetLayout ds_layout; |
| 1586 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 1587 | &ds_layout); |
| 1588 | ASSERT_VK_SUCCESS(err); |
| 1589 | |
| 1590 | VkDescriptorSet descriptorSet; |
| 1591 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 1592 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 1593 | alloc_info.descriptorSetCount = 1; |
| 1594 | alloc_info.descriptorPool = ds_pool_one; |
| 1595 | alloc_info.pSetLayouts = &ds_layout; |
| 1596 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 1597 | &descriptorSet); |
| 1598 | ASSERT_VK_SUCCESS(err); |
| 1599 | |
| 1600 | err = vkFreeDescriptorSets(m_device->device(), ds_pool_two, 1, &descriptorSet); |
| 1601 | |
| 1602 | m_errorMonitor->VerifyFound(); |
| 1603 | |
| 1604 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1605 | vkDestroyDescriptorPool(m_device->device(), ds_pool_one, NULL); |
| 1606 | vkDestroyDescriptorPool(m_device->device(), ds_pool_two, NULL); |
| 1607 | } |
| 1608 | |
| 1609 | TEST_F(VkLayerTest, CreateUnknownObject) { |
| 1610 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1611 | "Invalid VkImage Object "); |
| 1612 | |
| 1613 | TEST_DESCRIPTION( |
| 1614 | "Pass an invalid image object handle into a Vulkan API call."); |
| 1615 | |
| 1616 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1617 | |
| 1618 | // Pass bogus handle into GetImageMemoryRequirements |
| 1619 | VkMemoryRequirements mem_reqs; |
| 1620 | uint64_t fakeImageHandle = 0xCADECADE; |
| 1621 | VkImage fauxImage = reinterpret_cast<VkImage &>(fakeImageHandle); |
| 1622 | |
| 1623 | vkGetImageMemoryRequirements(m_device->device(), fauxImage, &mem_reqs); |
| 1624 | |
| 1625 | m_errorMonitor->VerifyFound(); |
| 1626 | } |
| 1627 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1628 | TEST_F(VkLayerTest, PipelineNotBound) { |
| 1629 | VkResult err; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1630 | |
Mark Lobodzinski | fc5cc66 | 2016-05-02 17:17:41 -0600 | [diff] [blame] | 1631 | TEST_DESCRIPTION( |
| 1632 | "Pass in an invalid pipeline object handle into a Vulkan API call."); |
| 1633 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1634 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1635 | "Invalid VkPipeline Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1636 | |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1637 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1638 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1639 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1640 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1641 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1642 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1643 | |
| 1644 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1645 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1646 | ds_pool_ci.pNext = NULL; |
| 1647 | ds_pool_ci.maxSets = 1; |
| 1648 | ds_pool_ci.poolSizeCount = 1; |
| 1649 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1650 | |
| 1651 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1652 | err = |
| 1653 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1654 | ASSERT_VK_SUCCESS(err); |
| 1655 | |
| 1656 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1657 | dsl_binding.binding = 0; |
| 1658 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1659 | dsl_binding.descriptorCount = 1; |
| 1660 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1661 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1662 | |
| 1663 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1664 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1665 | ds_layout_ci.pNext = NULL; |
| 1666 | ds_layout_ci.bindingCount = 1; |
| 1667 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1668 | |
| 1669 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1670 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 1671 | &ds_layout); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1672 | ASSERT_VK_SUCCESS(err); |
| 1673 | |
| 1674 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1675 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1676 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 1677 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1678 | alloc_info.descriptorPool = ds_pool; |
| 1679 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1680 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 1681 | &descriptorSet); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1682 | ASSERT_VK_SUCCESS(err); |
| 1683 | |
| 1684 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1685 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 1686 | pipeline_layout_ci.pNext = NULL; |
| 1687 | pipeline_layout_ci.setLayoutCount = 1; |
| 1688 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1689 | |
| 1690 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1691 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 1692 | &pipeline_layout); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1693 | ASSERT_VK_SUCCESS(err); |
| 1694 | |
Mark Young | ad77905 | 2016-01-06 14:26:04 -0700 | [diff] [blame] | 1695 | VkPipeline badPipeline = (VkPipeline)((size_t)0xbaadb1be); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1696 | |
| 1697 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1698 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 1699 | VK_PIPELINE_BIND_POINT_GRAPHICS, badPipeline); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1700 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1701 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1702 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1703 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 1704 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1705 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1706 | } |
| 1707 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1708 | TEST_F(VkLayerTest, BindInvalidMemory) { |
| 1709 | VkResult err; |
| 1710 | bool pass; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1711 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1712 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1713 | "Invalid VkDeviceMemory Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1714 | |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1715 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1716 | |
| 1717 | // Create an image, allocate memory, free it, and then try to bind it |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1718 | VkImage image; |
| 1719 | VkDeviceMemory mem; |
| 1720 | VkMemoryRequirements mem_reqs; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1721 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1722 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 1723 | const int32_t tex_width = 32; |
| 1724 | const int32_t tex_height = 32; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1725 | |
| 1726 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1727 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1728 | image_create_info.pNext = NULL; |
| 1729 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1730 | image_create_info.format = tex_format; |
| 1731 | image_create_info.extent.width = tex_width; |
| 1732 | image_create_info.extent.height = tex_height; |
| 1733 | image_create_info.extent.depth = 1; |
| 1734 | image_create_info.mipLevels = 1; |
| 1735 | image_create_info.arrayLayers = 1; |
| 1736 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1737 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1738 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 1739 | image_create_info.flags = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1740 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1741 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1742 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1743 | mem_alloc.pNext = NULL; |
| 1744 | mem_alloc.allocationSize = 0; |
| 1745 | mem_alloc.memoryTypeIndex = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1746 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1747 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1748 | ASSERT_VK_SUCCESS(err); |
| 1749 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1750 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1751 | |
| 1752 | mem_alloc.allocationSize = mem_reqs.size; |
| 1753 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1754 | pass = |
| 1755 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 1756 | ASSERT_TRUE(pass); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1757 | |
| 1758 | // allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1759 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1760 | ASSERT_VK_SUCCESS(err); |
| 1761 | |
| 1762 | // Introduce validation failure, free memory before binding |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1763 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1764 | |
| 1765 | // Try to bind free memory that has been freed |
| 1766 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 1767 | // This may very well return an error. |
| 1768 | (void)err; |
| 1769 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1770 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1771 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1772 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1773 | } |
| 1774 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1775 | TEST_F(VkLayerTest, BindMemoryToDestroyedObject) { |
| 1776 | VkResult err; |
| 1777 | bool pass; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1778 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1779 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1780 | "Invalid VkImage Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1781 | |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1782 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1783 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1784 | // Create an image object, allocate memory, destroy the object and then try |
| 1785 | // to bind it |
| 1786 | VkImage image; |
| 1787 | VkDeviceMemory mem; |
| 1788 | VkMemoryRequirements mem_reqs; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1789 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1790 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 1791 | const int32_t tex_width = 32; |
| 1792 | const int32_t tex_height = 32; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1793 | |
| 1794 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1795 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1796 | image_create_info.pNext = NULL; |
| 1797 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1798 | image_create_info.format = tex_format; |
| 1799 | image_create_info.extent.width = tex_width; |
| 1800 | image_create_info.extent.height = tex_height; |
| 1801 | image_create_info.extent.depth = 1; |
| 1802 | image_create_info.mipLevels = 1; |
| 1803 | image_create_info.arrayLayers = 1; |
| 1804 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1805 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1806 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 1807 | image_create_info.flags = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1808 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1809 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1810 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1811 | mem_alloc.pNext = NULL; |
| 1812 | mem_alloc.allocationSize = 0; |
| 1813 | mem_alloc.memoryTypeIndex = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1814 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1815 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1816 | ASSERT_VK_SUCCESS(err); |
| 1817 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1818 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1819 | |
| 1820 | mem_alloc.allocationSize = mem_reqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1821 | pass = |
| 1822 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 1823 | ASSERT_TRUE(pass); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1824 | |
| 1825 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1826 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1827 | ASSERT_VK_SUCCESS(err); |
| 1828 | |
| 1829 | // Introduce validation failure, destroy Image object before binding |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1830 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1831 | ASSERT_VK_SUCCESS(err); |
| 1832 | |
| 1833 | // Now Try to bind memory to this destroyed object |
| 1834 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 1835 | // This may very well return an error. |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1836 | (void)err; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1837 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1838 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1839 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1840 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1841 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1842 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 1843 | #endif // OBJ_TRACKER_TESTS |
| 1844 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 1845 | #if DRAW_STATE_TESTS |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 1846 | |
| 1847 | // This is a positive test. No errors should be generated. |
| 1848 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceQWI) { |
| 1849 | |
| 1850 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 1851 | "submitted on separate queues followed by a QueueWaitIdle."); |
| 1852 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 1853 | if ((m_device->queue_props.empty()) || |
| 1854 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 1855 | return; |
| 1856 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 1857 | m_errorMonitor->ExpectSuccess(); |
| 1858 | |
| 1859 | VkSemaphore semaphore; |
| 1860 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 1861 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 1862 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 1863 | &semaphore); |
| 1864 | |
| 1865 | VkCommandPool command_pool; |
| 1866 | VkCommandPoolCreateInfo pool_create_info{}; |
| 1867 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 1868 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 1869 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 1870 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 1871 | &command_pool); |
| 1872 | |
| 1873 | VkCommandBuffer command_buffer[2]; |
| 1874 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 1875 | command_buffer_allocate_info.sType = |
| 1876 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 1877 | command_buffer_allocate_info.commandPool = command_pool; |
| 1878 | command_buffer_allocate_info.commandBufferCount = 2; |
| 1879 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 1880 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 1881 | command_buffer); |
| 1882 | |
| 1883 | VkQueue queue = VK_NULL_HANDLE; |
| 1884 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 1885 | 1, &queue); |
| 1886 | |
| 1887 | { |
| 1888 | VkCommandBufferBeginInfo begin_info{}; |
| 1889 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 1890 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 1891 | |
| 1892 | vkCmdPipelineBarrier(command_buffer[0], |
| 1893 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 1894 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 1895 | 0, nullptr, 0, nullptr); |
| 1896 | |
| 1897 | VkViewport viewport{}; |
| 1898 | viewport.maxDepth = 1.0f; |
| 1899 | viewport.minDepth = 0.0f; |
| 1900 | viewport.width = 512; |
| 1901 | viewport.height = 512; |
| 1902 | viewport.x = 0; |
| 1903 | viewport.y = 0; |
| 1904 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 1905 | vkEndCommandBuffer(command_buffer[0]); |
| 1906 | } |
| 1907 | { |
| 1908 | VkCommandBufferBeginInfo begin_info{}; |
| 1909 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 1910 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 1911 | |
| 1912 | VkViewport viewport{}; |
| 1913 | viewport.maxDepth = 1.0f; |
| 1914 | viewport.minDepth = 0.0f; |
| 1915 | viewport.width = 512; |
| 1916 | viewport.height = 512; |
| 1917 | viewport.x = 0; |
| 1918 | viewport.y = 0; |
| 1919 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 1920 | vkEndCommandBuffer(command_buffer[1]); |
| 1921 | } |
| 1922 | { |
| 1923 | VkSubmitInfo submit_info{}; |
| 1924 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1925 | submit_info.commandBufferCount = 1; |
| 1926 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 1927 | submit_info.signalSemaphoreCount = 1; |
| 1928 | submit_info.pSignalSemaphores = &semaphore; |
| 1929 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 1930 | } |
| 1931 | { |
| 1932 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 1933 | VkSubmitInfo submit_info{}; |
| 1934 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1935 | submit_info.commandBufferCount = 1; |
| 1936 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 1937 | submit_info.waitSemaphoreCount = 1; |
| 1938 | submit_info.pWaitSemaphores = &semaphore; |
| 1939 | submit_info.pWaitDstStageMask = flags; |
| 1940 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 1941 | } |
| 1942 | |
| 1943 | vkQueueWaitIdle(m_device->m_queue); |
| 1944 | |
| 1945 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 1946 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 1947 | &command_buffer[0]); |
| 1948 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 1949 | |
| 1950 | m_errorMonitor->VerifyNotFound(); |
| 1951 | } |
| 1952 | |
| 1953 | // This is a positive test. No errors should be generated. |
| 1954 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceQWIFence) { |
| 1955 | |
| 1956 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 1957 | "submitted on separate queues, the second having a fence" |
| 1958 | "followed by a QueueWaitIdle."); |
| 1959 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 1960 | if ((m_device->queue_props.empty()) || |
| 1961 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 1962 | return; |
| 1963 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 1964 | m_errorMonitor->ExpectSuccess(); |
| 1965 | |
| 1966 | VkFence fence; |
| 1967 | VkFenceCreateInfo fence_create_info{}; |
| 1968 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 1969 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 1970 | |
| 1971 | VkSemaphore semaphore; |
| 1972 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 1973 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 1974 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 1975 | &semaphore); |
| 1976 | |
| 1977 | VkCommandPool command_pool; |
| 1978 | VkCommandPoolCreateInfo pool_create_info{}; |
| 1979 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 1980 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 1981 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 1982 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 1983 | &command_pool); |
| 1984 | |
| 1985 | VkCommandBuffer command_buffer[2]; |
| 1986 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 1987 | command_buffer_allocate_info.sType = |
| 1988 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 1989 | command_buffer_allocate_info.commandPool = command_pool; |
| 1990 | command_buffer_allocate_info.commandBufferCount = 2; |
| 1991 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 1992 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 1993 | command_buffer); |
| 1994 | |
| 1995 | VkQueue queue = VK_NULL_HANDLE; |
| 1996 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 1997 | 1, &queue); |
| 1998 | |
| 1999 | { |
| 2000 | VkCommandBufferBeginInfo begin_info{}; |
| 2001 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2002 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2003 | |
| 2004 | vkCmdPipelineBarrier(command_buffer[0], |
| 2005 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2006 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 2007 | 0, nullptr, 0, nullptr); |
| 2008 | |
| 2009 | VkViewport viewport{}; |
| 2010 | viewport.maxDepth = 1.0f; |
| 2011 | viewport.minDepth = 0.0f; |
| 2012 | viewport.width = 512; |
| 2013 | viewport.height = 512; |
| 2014 | viewport.x = 0; |
| 2015 | viewport.y = 0; |
| 2016 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 2017 | vkEndCommandBuffer(command_buffer[0]); |
| 2018 | } |
| 2019 | { |
| 2020 | VkCommandBufferBeginInfo begin_info{}; |
| 2021 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2022 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 2023 | |
| 2024 | VkViewport viewport{}; |
| 2025 | viewport.maxDepth = 1.0f; |
| 2026 | viewport.minDepth = 0.0f; |
| 2027 | viewport.width = 512; |
| 2028 | viewport.height = 512; |
| 2029 | viewport.x = 0; |
| 2030 | viewport.y = 0; |
| 2031 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 2032 | vkEndCommandBuffer(command_buffer[1]); |
| 2033 | } |
| 2034 | { |
| 2035 | VkSubmitInfo submit_info{}; |
| 2036 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2037 | submit_info.commandBufferCount = 1; |
| 2038 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 2039 | submit_info.signalSemaphoreCount = 1; |
| 2040 | submit_info.pSignalSemaphores = &semaphore; |
| 2041 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2042 | } |
| 2043 | { |
| 2044 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 2045 | VkSubmitInfo submit_info{}; |
| 2046 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2047 | submit_info.commandBufferCount = 1; |
| 2048 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 2049 | submit_info.waitSemaphoreCount = 1; |
| 2050 | submit_info.pWaitSemaphores = &semaphore; |
| 2051 | submit_info.pWaitDstStageMask = flags; |
| 2052 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 2053 | } |
| 2054 | |
| 2055 | vkQueueWaitIdle(m_device->m_queue); |
| 2056 | |
| 2057 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 2058 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 2059 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 2060 | &command_buffer[0]); |
| 2061 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2062 | |
| 2063 | m_errorMonitor->VerifyNotFound(); |
| 2064 | } |
| 2065 | |
| 2066 | // This is a positive test. No errors should be generated. |
| 2067 | TEST_F(VkLayerTest, |
| 2068 | TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceTwoWFF) { |
| 2069 | |
| 2070 | TEST_DESCRIPTION( |
| 2071 | "Two command buffers, each in a separate QueueSubmit call " |
| 2072 | "submitted on separate queues, the second having a fence" |
| 2073 | "followed by two consecutive WaitForFences calls on the same fence."); |
| 2074 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 2075 | if ((m_device->queue_props.empty()) || |
| 2076 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 2077 | return; |
| 2078 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 2079 | m_errorMonitor->ExpectSuccess(); |
| 2080 | |
| 2081 | VkFence fence; |
| 2082 | VkFenceCreateInfo fence_create_info{}; |
| 2083 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2084 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 2085 | |
| 2086 | VkSemaphore semaphore; |
| 2087 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 2088 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 2089 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 2090 | &semaphore); |
| 2091 | |
| 2092 | VkCommandPool command_pool; |
| 2093 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2094 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2095 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2096 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2097 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2098 | &command_pool); |
| 2099 | |
| 2100 | VkCommandBuffer command_buffer[2]; |
| 2101 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2102 | command_buffer_allocate_info.sType = |
| 2103 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2104 | command_buffer_allocate_info.commandPool = command_pool; |
| 2105 | command_buffer_allocate_info.commandBufferCount = 2; |
| 2106 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2107 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2108 | command_buffer); |
| 2109 | |
| 2110 | VkQueue queue = VK_NULL_HANDLE; |
| 2111 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 2112 | 1, &queue); |
| 2113 | |
| 2114 | { |
| 2115 | VkCommandBufferBeginInfo begin_info{}; |
| 2116 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2117 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2118 | |
| 2119 | vkCmdPipelineBarrier(command_buffer[0], |
| 2120 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2121 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 2122 | 0, nullptr, 0, nullptr); |
| 2123 | |
| 2124 | VkViewport viewport{}; |
| 2125 | viewport.maxDepth = 1.0f; |
| 2126 | viewport.minDepth = 0.0f; |
| 2127 | viewport.width = 512; |
| 2128 | viewport.height = 512; |
| 2129 | viewport.x = 0; |
| 2130 | viewport.y = 0; |
| 2131 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 2132 | vkEndCommandBuffer(command_buffer[0]); |
| 2133 | } |
| 2134 | { |
| 2135 | VkCommandBufferBeginInfo begin_info{}; |
| 2136 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2137 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 2138 | |
| 2139 | VkViewport viewport{}; |
| 2140 | viewport.maxDepth = 1.0f; |
| 2141 | viewport.minDepth = 0.0f; |
| 2142 | viewport.width = 512; |
| 2143 | viewport.height = 512; |
| 2144 | viewport.x = 0; |
| 2145 | viewport.y = 0; |
| 2146 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 2147 | vkEndCommandBuffer(command_buffer[1]); |
| 2148 | } |
| 2149 | { |
| 2150 | VkSubmitInfo submit_info{}; |
| 2151 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2152 | submit_info.commandBufferCount = 1; |
| 2153 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 2154 | submit_info.signalSemaphoreCount = 1; |
| 2155 | submit_info.pSignalSemaphores = &semaphore; |
| 2156 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2157 | } |
| 2158 | { |
| 2159 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 2160 | VkSubmitInfo submit_info{}; |
| 2161 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2162 | submit_info.commandBufferCount = 1; |
| 2163 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 2164 | submit_info.waitSemaphoreCount = 1; |
| 2165 | submit_info.pWaitSemaphores = &semaphore; |
| 2166 | submit_info.pWaitDstStageMask = flags; |
| 2167 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 2168 | } |
| 2169 | |
| 2170 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 2171 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 2172 | |
| 2173 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 2174 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 2175 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 2176 | &command_buffer[0]); |
| 2177 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2178 | |
| 2179 | m_errorMonitor->VerifyNotFound(); |
| 2180 | } |
| 2181 | |
| 2182 | // This is a positive test. No errors should be generated. |
| 2183 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFence) { |
| 2184 | |
| 2185 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 2186 | "submitted on separate queues, the second having a fence, " |
| 2187 | "followed by a WaitForFences call."); |
| 2188 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 2189 | if ((m_device->queue_props.empty()) || |
| 2190 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 2191 | return; |
| 2192 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 2193 | m_errorMonitor->ExpectSuccess(); |
| 2194 | |
| 2195 | VkFence fence; |
| 2196 | VkFenceCreateInfo fence_create_info{}; |
| 2197 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2198 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 2199 | |
| 2200 | VkSemaphore semaphore; |
| 2201 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 2202 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 2203 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 2204 | &semaphore); |
| 2205 | |
| 2206 | VkCommandPool command_pool; |
| 2207 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2208 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2209 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2210 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2211 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2212 | &command_pool); |
| 2213 | |
| 2214 | VkCommandBuffer command_buffer[2]; |
| 2215 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2216 | command_buffer_allocate_info.sType = |
| 2217 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2218 | command_buffer_allocate_info.commandPool = command_pool; |
| 2219 | command_buffer_allocate_info.commandBufferCount = 2; |
| 2220 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2221 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2222 | command_buffer); |
| 2223 | |
| 2224 | VkQueue queue = VK_NULL_HANDLE; |
| 2225 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 2226 | 1, &queue); |
| 2227 | |
| 2228 | |
| 2229 | { |
| 2230 | VkCommandBufferBeginInfo begin_info{}; |
| 2231 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2232 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2233 | |
| 2234 | vkCmdPipelineBarrier(command_buffer[0], |
| 2235 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2236 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 2237 | 0, nullptr, 0, nullptr); |
| 2238 | |
| 2239 | VkViewport viewport{}; |
| 2240 | viewport.maxDepth = 1.0f; |
| 2241 | viewport.minDepth = 0.0f; |
| 2242 | viewport.width = 512; |
| 2243 | viewport.height = 512; |
| 2244 | viewport.x = 0; |
| 2245 | viewport.y = 0; |
| 2246 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 2247 | vkEndCommandBuffer(command_buffer[0]); |
| 2248 | } |
| 2249 | { |
| 2250 | VkCommandBufferBeginInfo begin_info{}; |
| 2251 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2252 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 2253 | |
| 2254 | VkViewport viewport{}; |
| 2255 | viewport.maxDepth = 1.0f; |
| 2256 | viewport.minDepth = 0.0f; |
| 2257 | viewport.width = 512; |
| 2258 | viewport.height = 512; |
| 2259 | viewport.x = 0; |
| 2260 | viewport.y = 0; |
| 2261 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 2262 | vkEndCommandBuffer(command_buffer[1]); |
| 2263 | } |
| 2264 | { |
| 2265 | VkSubmitInfo submit_info{}; |
| 2266 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2267 | submit_info.commandBufferCount = 1; |
| 2268 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 2269 | submit_info.signalSemaphoreCount = 1; |
| 2270 | submit_info.pSignalSemaphores = &semaphore; |
| 2271 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2272 | } |
| 2273 | { |
| 2274 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 2275 | VkSubmitInfo submit_info{}; |
| 2276 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2277 | submit_info.commandBufferCount = 1; |
| 2278 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 2279 | submit_info.waitSemaphoreCount = 1; |
| 2280 | submit_info.pWaitSemaphores = &semaphore; |
| 2281 | submit_info.pWaitDstStageMask = flags; |
| 2282 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 2283 | } |
| 2284 | |
| 2285 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 2286 | |
| 2287 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 2288 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 2289 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 2290 | &command_buffer[0]); |
| 2291 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2292 | |
| 2293 | m_errorMonitor->VerifyNotFound(); |
| 2294 | } |
| 2295 | |
| 2296 | // This is a positive test. No errors should be generated. |
| 2297 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueWithSemaphoreAndOneFence) { |
| 2298 | |
| 2299 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 2300 | "on the same queue, sharing a signal/wait semaphore, the " |
| 2301 | "second having a fence, " |
| 2302 | "followed by a WaitForFences call."); |
| 2303 | |
| 2304 | m_errorMonitor->ExpectSuccess(); |
| 2305 | |
| 2306 | VkFence fence; |
| 2307 | VkFenceCreateInfo fence_create_info{}; |
| 2308 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2309 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 2310 | |
| 2311 | VkSemaphore semaphore; |
| 2312 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 2313 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 2314 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 2315 | &semaphore); |
| 2316 | |
| 2317 | VkCommandPool command_pool; |
| 2318 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2319 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2320 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2321 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2322 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2323 | &command_pool); |
| 2324 | |
| 2325 | VkCommandBuffer command_buffer[2]; |
| 2326 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2327 | command_buffer_allocate_info.sType = |
| 2328 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2329 | command_buffer_allocate_info.commandPool = command_pool; |
| 2330 | command_buffer_allocate_info.commandBufferCount = 2; |
| 2331 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2332 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2333 | command_buffer); |
| 2334 | |
| 2335 | { |
| 2336 | VkCommandBufferBeginInfo begin_info{}; |
| 2337 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2338 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2339 | |
| 2340 | vkCmdPipelineBarrier(command_buffer[0], |
| 2341 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2342 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 2343 | 0, nullptr, 0, nullptr); |
| 2344 | |
| 2345 | VkViewport viewport{}; |
| 2346 | viewport.maxDepth = 1.0f; |
| 2347 | viewport.minDepth = 0.0f; |
| 2348 | viewport.width = 512; |
| 2349 | viewport.height = 512; |
| 2350 | viewport.x = 0; |
| 2351 | viewport.y = 0; |
| 2352 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 2353 | vkEndCommandBuffer(command_buffer[0]); |
| 2354 | } |
| 2355 | { |
| 2356 | VkCommandBufferBeginInfo begin_info{}; |
| 2357 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2358 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 2359 | |
| 2360 | VkViewport viewport{}; |
| 2361 | viewport.maxDepth = 1.0f; |
| 2362 | viewport.minDepth = 0.0f; |
| 2363 | viewport.width = 512; |
| 2364 | viewport.height = 512; |
| 2365 | viewport.x = 0; |
| 2366 | viewport.y = 0; |
| 2367 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 2368 | vkEndCommandBuffer(command_buffer[1]); |
| 2369 | } |
| 2370 | { |
| 2371 | VkSubmitInfo submit_info{}; |
| 2372 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2373 | submit_info.commandBufferCount = 1; |
| 2374 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 2375 | submit_info.signalSemaphoreCount = 1; |
| 2376 | submit_info.pSignalSemaphores = &semaphore; |
| 2377 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2378 | } |
| 2379 | { |
| 2380 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 2381 | VkSubmitInfo submit_info{}; |
| 2382 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2383 | submit_info.commandBufferCount = 1; |
| 2384 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 2385 | submit_info.waitSemaphoreCount = 1; |
| 2386 | submit_info.pWaitSemaphores = &semaphore; |
| 2387 | submit_info.pWaitDstStageMask = flags; |
| 2388 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 2389 | } |
| 2390 | |
| 2391 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 2392 | |
| 2393 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 2394 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 2395 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 2396 | &command_buffer[0]); |
| 2397 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2398 | |
| 2399 | m_errorMonitor->VerifyNotFound(); |
| 2400 | } |
| 2401 | |
| 2402 | // This is a positive test. No errors should be generated. |
| 2403 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueNullQueueSubmitWithFence) { |
| 2404 | |
| 2405 | TEST_DESCRIPTION( |
| 2406 | "Two command buffers, each in a separate QueueSubmit call " |
| 2407 | "on the same queue, no fences, followed by a third QueueSubmit with NO " |
| 2408 | "SubmitInfos but with a fence, followed by a WaitForFences call."); |
| 2409 | |
| 2410 | m_errorMonitor->ExpectSuccess(); |
| 2411 | |
| 2412 | VkFence fence; |
| 2413 | VkFenceCreateInfo fence_create_info{}; |
| 2414 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2415 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 2416 | |
| 2417 | VkCommandPool command_pool; |
| 2418 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2419 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2420 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2421 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2422 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2423 | &command_pool); |
| 2424 | |
| 2425 | VkCommandBuffer command_buffer[2]; |
| 2426 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2427 | command_buffer_allocate_info.sType = |
| 2428 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2429 | command_buffer_allocate_info.commandPool = command_pool; |
| 2430 | command_buffer_allocate_info.commandBufferCount = 2; |
| 2431 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2432 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2433 | command_buffer); |
| 2434 | |
| 2435 | { |
| 2436 | VkCommandBufferBeginInfo begin_info{}; |
| 2437 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2438 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2439 | |
| 2440 | vkCmdPipelineBarrier(command_buffer[0], |
| 2441 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2442 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 2443 | 0, nullptr, 0, nullptr); |
| 2444 | |
| 2445 | VkViewport viewport{}; |
| 2446 | viewport.maxDepth = 1.0f; |
| 2447 | viewport.minDepth = 0.0f; |
| 2448 | viewport.width = 512; |
| 2449 | viewport.height = 512; |
| 2450 | viewport.x = 0; |
| 2451 | viewport.y = 0; |
| 2452 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 2453 | vkEndCommandBuffer(command_buffer[0]); |
| 2454 | } |
| 2455 | { |
| 2456 | VkCommandBufferBeginInfo begin_info{}; |
| 2457 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2458 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 2459 | |
| 2460 | VkViewport viewport{}; |
| 2461 | viewport.maxDepth = 1.0f; |
| 2462 | viewport.minDepth = 0.0f; |
| 2463 | viewport.width = 512; |
| 2464 | viewport.height = 512; |
| 2465 | viewport.x = 0; |
| 2466 | viewport.y = 0; |
| 2467 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 2468 | vkEndCommandBuffer(command_buffer[1]); |
| 2469 | } |
| 2470 | { |
| 2471 | VkSubmitInfo submit_info{}; |
| 2472 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2473 | submit_info.commandBufferCount = 1; |
| 2474 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 2475 | submit_info.signalSemaphoreCount = 0; |
| 2476 | submit_info.pSignalSemaphores = VK_NULL_HANDLE; |
| 2477 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2478 | } |
| 2479 | { |
| 2480 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 2481 | VkSubmitInfo submit_info{}; |
| 2482 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2483 | submit_info.commandBufferCount = 1; |
| 2484 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 2485 | submit_info.waitSemaphoreCount = 0; |
| 2486 | submit_info.pWaitSemaphores = VK_NULL_HANDLE; |
| 2487 | submit_info.pWaitDstStageMask = flags; |
| 2488 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2489 | } |
| 2490 | |
| 2491 | vkQueueSubmit(m_device->m_queue, 0, NULL, fence); |
| 2492 | |
| 2493 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 2494 | |
| 2495 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 2496 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 2497 | &command_buffer[0]); |
| 2498 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2499 | |
| 2500 | m_errorMonitor->VerifyNotFound(); |
| 2501 | } |
| 2502 | |
| 2503 | // This is a positive test. No errors should be generated. |
| 2504 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueOneFence) { |
| 2505 | |
| 2506 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 2507 | "on the same queue, the second having a fence, followed " |
| 2508 | "by a WaitForFences call."); |
| 2509 | |
| 2510 | m_errorMonitor->ExpectSuccess(); |
| 2511 | |
| 2512 | VkFence fence; |
| 2513 | VkFenceCreateInfo fence_create_info{}; |
| 2514 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2515 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 2516 | |
| 2517 | VkCommandPool command_pool; |
| 2518 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2519 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2520 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2521 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2522 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2523 | &command_pool); |
| 2524 | |
| 2525 | VkCommandBuffer command_buffer[2]; |
| 2526 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2527 | command_buffer_allocate_info.sType = |
| 2528 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2529 | command_buffer_allocate_info.commandPool = command_pool; |
| 2530 | command_buffer_allocate_info.commandBufferCount = 2; |
| 2531 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2532 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2533 | command_buffer); |
| 2534 | |
| 2535 | { |
| 2536 | VkCommandBufferBeginInfo begin_info{}; |
| 2537 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2538 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2539 | |
| 2540 | vkCmdPipelineBarrier(command_buffer[0], |
| 2541 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2542 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 2543 | 0, nullptr, 0, nullptr); |
| 2544 | |
| 2545 | VkViewport viewport{}; |
| 2546 | viewport.maxDepth = 1.0f; |
| 2547 | viewport.minDepth = 0.0f; |
| 2548 | viewport.width = 512; |
| 2549 | viewport.height = 512; |
| 2550 | viewport.x = 0; |
| 2551 | viewport.y = 0; |
| 2552 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 2553 | vkEndCommandBuffer(command_buffer[0]); |
| 2554 | } |
| 2555 | { |
| 2556 | VkCommandBufferBeginInfo begin_info{}; |
| 2557 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2558 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 2559 | |
| 2560 | VkViewport viewport{}; |
| 2561 | viewport.maxDepth = 1.0f; |
| 2562 | viewport.minDepth = 0.0f; |
| 2563 | viewport.width = 512; |
| 2564 | viewport.height = 512; |
| 2565 | viewport.x = 0; |
| 2566 | viewport.y = 0; |
| 2567 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 2568 | vkEndCommandBuffer(command_buffer[1]); |
| 2569 | } |
| 2570 | { |
| 2571 | VkSubmitInfo submit_info{}; |
| 2572 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2573 | submit_info.commandBufferCount = 1; |
| 2574 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 2575 | submit_info.signalSemaphoreCount = 0; |
| 2576 | submit_info.pSignalSemaphores = VK_NULL_HANDLE; |
| 2577 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2578 | } |
| 2579 | { |
| 2580 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 2581 | VkSubmitInfo submit_info{}; |
| 2582 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2583 | submit_info.commandBufferCount = 1; |
| 2584 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 2585 | submit_info.waitSemaphoreCount = 0; |
| 2586 | submit_info.pWaitSemaphores = VK_NULL_HANDLE; |
| 2587 | submit_info.pWaitDstStageMask = flags; |
| 2588 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 2589 | } |
| 2590 | |
| 2591 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 2592 | |
| 2593 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 2594 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 2595 | &command_buffer[0]); |
| 2596 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2597 | |
| 2598 | m_errorMonitor->VerifyNotFound(); |
| 2599 | } |
| 2600 | |
| 2601 | // This is a positive test. No errors should be generated. |
| 2602 | TEST_F(VkLayerTest, TwoSubmitInfosWithSemaphoreOneQueueSubmitsOneFence) { |
| 2603 | |
| 2604 | TEST_DESCRIPTION( |
| 2605 | "Two command buffers each in a separate SubmitInfo sent in a single " |
| 2606 | "QueueSubmit call followed by a WaitForFences call."); |
| 2607 | |
| 2608 | m_errorMonitor->ExpectSuccess(); |
| 2609 | |
| 2610 | VkFence fence; |
| 2611 | VkFenceCreateInfo fence_create_info{}; |
| 2612 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2613 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 2614 | |
| 2615 | VkSemaphore semaphore; |
| 2616 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 2617 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 2618 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 2619 | &semaphore); |
| 2620 | |
| 2621 | VkCommandPool command_pool; |
| 2622 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2623 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2624 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2625 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2626 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2627 | &command_pool); |
| 2628 | |
| 2629 | VkCommandBuffer command_buffer[2]; |
| 2630 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2631 | command_buffer_allocate_info.sType = |
| 2632 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2633 | command_buffer_allocate_info.commandPool = command_pool; |
| 2634 | command_buffer_allocate_info.commandBufferCount = 2; |
| 2635 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2636 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2637 | command_buffer); |
| 2638 | |
| 2639 | { |
| 2640 | VkCommandBufferBeginInfo begin_info{}; |
| 2641 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2642 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2643 | |
| 2644 | vkCmdPipelineBarrier(command_buffer[0], |
| 2645 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2646 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 2647 | 0, nullptr, 0, nullptr); |
| 2648 | |
| 2649 | VkViewport viewport{}; |
| 2650 | viewport.maxDepth = 1.0f; |
| 2651 | viewport.minDepth = 0.0f; |
| 2652 | viewport.width = 512; |
| 2653 | viewport.height = 512; |
| 2654 | viewport.x = 0; |
| 2655 | viewport.y = 0; |
| 2656 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 2657 | vkEndCommandBuffer(command_buffer[0]); |
| 2658 | } |
| 2659 | { |
| 2660 | VkCommandBufferBeginInfo begin_info{}; |
| 2661 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2662 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 2663 | |
| 2664 | VkViewport viewport{}; |
| 2665 | viewport.maxDepth = 1.0f; |
| 2666 | viewport.minDepth = 0.0f; |
| 2667 | viewport.width = 512; |
| 2668 | viewport.height = 512; |
| 2669 | viewport.x = 0; |
| 2670 | viewport.y = 0; |
| 2671 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 2672 | vkEndCommandBuffer(command_buffer[1]); |
| 2673 | } |
| 2674 | { |
| 2675 | VkSubmitInfo submit_info[2]; |
| 2676 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 2677 | |
| 2678 | submit_info[0].sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2679 | submit_info[0].pNext = NULL; |
| 2680 | submit_info[0].commandBufferCount = 1; |
| 2681 | submit_info[0].pCommandBuffers = &command_buffer[0]; |
| 2682 | submit_info[0].signalSemaphoreCount = 1; |
| 2683 | submit_info[0].pSignalSemaphores = &semaphore; |
| 2684 | submit_info[0].waitSemaphoreCount = 0; |
| 2685 | submit_info[0].pWaitSemaphores = NULL; |
| 2686 | submit_info[0].pWaitDstStageMask = 0; |
| 2687 | |
| 2688 | submit_info[1].sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2689 | submit_info[1].pNext = NULL; |
| 2690 | submit_info[1].commandBufferCount = 1; |
| 2691 | submit_info[1].pCommandBuffers = &command_buffer[1]; |
| 2692 | submit_info[1].waitSemaphoreCount = 1; |
| 2693 | submit_info[1].pWaitSemaphores = &semaphore; |
| 2694 | submit_info[1].pWaitDstStageMask = flags; |
| 2695 | submit_info[1].signalSemaphoreCount = 0; |
| 2696 | submit_info[1].pSignalSemaphores = NULL; |
| 2697 | vkQueueSubmit(m_device->m_queue, 2, &submit_info[0], fence); |
| 2698 | } |
| 2699 | |
| 2700 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 2701 | |
| 2702 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 2703 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 2704 | &command_buffer[0]); |
| 2705 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2706 | |
| 2707 | m_errorMonitor->VerifyNotFound(); |
| 2708 | } |
| 2709 | |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2710 | TEST_F(VkLayerTest, DynamicStatesNotBound) { |
| 2711 | TEST_DESCRIPTION( |
| 2712 | "Run a series of simple draw calls to validate all the different " |
| 2713 | "failure cases that can occur when dynamic state is required but not " |
| 2714 | "correctly bound." |
| 2715 | "Here are the different dynamic state cases verified by this test:\n" |
| 2716 | "-Line Width\n-Depth Bias\n-Viewport State\n-Scissor State\n-Blend " |
| 2717 | "State\n-Depth Bounds\n-Stencil Read Mask\n-Stencil Write " |
| 2718 | "Mask\n-Stencil Reference"); |
| 2719 | |
| 2720 | // Dynamic line width |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2721 | m_errorMonitor->SetDesiredFailureMsg( |
| 2722 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2723 | "Dynamic line width state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2724 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2725 | BsoFailLineWidth); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2726 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2727 | // Dynamic depth bias |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2728 | m_errorMonitor->SetDesiredFailureMsg( |
| 2729 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2730 | "Dynamic depth bias state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2731 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2732 | BsoFailDepthBias); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2733 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2734 | // Dynamic viewport state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2735 | m_errorMonitor->SetDesiredFailureMsg( |
| 2736 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2737 | "Dynamic viewport state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2738 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2739 | BsoFailViewport); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2740 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2741 | // Dynamic scissor state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2742 | m_errorMonitor->SetDesiredFailureMsg( |
| 2743 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2744 | "Dynamic scissor state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2745 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2746 | BsoFailScissor); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2747 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2748 | // Dynamic blend state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2749 | m_errorMonitor->SetDesiredFailureMsg( |
| 2750 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2751 | "Dynamic depth bounds state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2752 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2753 | BsoFailDepthBounds); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2754 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2755 | // Dynamic stencil read mask |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2756 | m_errorMonitor->SetDesiredFailureMsg( |
| 2757 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2758 | "Dynamic stencil read mask state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2759 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2760 | BsoFailStencilReadMask); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2761 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2762 | // Dynamic stencil write mask |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2763 | m_errorMonitor->SetDesiredFailureMsg( |
| 2764 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2765 | "Dynamic stencil write mask state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2766 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2767 | BsoFailStencilWriteMask); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2768 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2769 | // Dynamic stencil reference |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2770 | m_errorMonitor->SetDesiredFailureMsg( |
| 2771 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2772 | "Dynamic stencil reference state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2773 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2774 | BsoFailStencilReference); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2775 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 2776 | } |
| 2777 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2778 | TEST_F(VkLayerTest, CommandBufferTwoSubmits) { |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 2779 | vk_testing::Fence testFence; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2780 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2781 | m_errorMonitor->SetDesiredFailureMsg( |
| 2782 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2783 | "was begun w/ VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set, but has " |
| 2784 | "been submitted"); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 2785 | |
| 2786 | VkFenceCreateInfo fenceInfo = {}; |
| 2787 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2788 | fenceInfo.pNext = NULL; |
| 2789 | fenceInfo.flags = 0; |
| 2790 | |
| 2791 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2792 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 2793 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2794 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2795 | // We luck out b/c by default the framework creates CB w/ the |
| 2796 | // VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 2797 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2798 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 2799 | m_stencil_clear_color, NULL); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 2800 | EndCommandBuffer(); |
| 2801 | |
| 2802 | testFence.init(*m_device, fenceInfo); |
| 2803 | |
| 2804 | // Bypass framework since it does the waits automatically |
| 2805 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2806 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 2807 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2808 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2809 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2810 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 2811 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2812 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2813 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2814 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2815 | submit_info.pSignalSemaphores = NULL; |
| 2816 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2817 | err = vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
| 2818 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 2819 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2820 | // Cause validation error by re-submitting cmd buffer that should only be |
| 2821 | // submitted once |
| 2822 | err = vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 2823 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2824 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 2825 | } |
| 2826 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2827 | TEST_F(VkLayerTest, AllocDescriptorFromEmptyPool) { |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2828 | // Initiate Draw w/o a PSO bound |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2829 | VkResult err; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2830 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2831 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2832 | "Unable to allocate 1 descriptors of " |
| 2833 | "type " |
| 2834 | "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2835 | |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2836 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2837 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2838 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2839 | // Create Pool w/ 1 Sampler descriptor, but try to alloc Uniform Buffer |
| 2840 | // descriptor from it |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2841 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2842 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 2843 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2844 | |
| 2845 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2846 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2847 | ds_pool_ci.pNext = NULL; |
| 2848 | ds_pool_ci.flags = 0; |
| 2849 | ds_pool_ci.maxSets = 1; |
| 2850 | ds_pool_ci.poolSizeCount = 1; |
| 2851 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2852 | |
| 2853 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2854 | err = |
| 2855 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2856 | ASSERT_VK_SUCCESS(err); |
| 2857 | |
| 2858 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2859 | dsl_binding.binding = 0; |
| 2860 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2861 | dsl_binding.descriptorCount = 1; |
| 2862 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2863 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2864 | |
| 2865 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2866 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2867 | ds_layout_ci.pNext = NULL; |
| 2868 | ds_layout_ci.bindingCount = 1; |
| 2869 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2870 | |
| 2871 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2872 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2873 | &ds_layout); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2874 | ASSERT_VK_SUCCESS(err); |
| 2875 | |
| 2876 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2877 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2878 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2879 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2880 | alloc_info.descriptorPool = ds_pool; |
| 2881 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2882 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 2883 | &descriptorSet); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2884 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2885 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2886 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2887 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2888 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2889 | } |
| 2890 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2891 | TEST_F(VkLayerTest, FreeDescriptorFromOneShotPool) { |
| 2892 | VkResult err; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2893 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2894 | m_errorMonitor->SetDesiredFailureMsg( |
| 2895 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2896 | "It is invalid to call vkFreeDescriptorSets() with a pool created " |
| 2897 | "without setting VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2898 | |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2899 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2900 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2901 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2902 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2903 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2904 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2905 | |
| 2906 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2907 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2908 | ds_pool_ci.pNext = NULL; |
| 2909 | ds_pool_ci.maxSets = 1; |
| 2910 | ds_pool_ci.poolSizeCount = 1; |
| 2911 | ds_pool_ci.flags = 0; |
| 2912 | // Not specifying VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT means |
| 2913 | // app can only call vkResetDescriptorPool on this pool.; |
| 2914 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2915 | |
| 2916 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2917 | err = |
| 2918 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2919 | ASSERT_VK_SUCCESS(err); |
| 2920 | |
| 2921 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2922 | dsl_binding.binding = 0; |
| 2923 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2924 | dsl_binding.descriptorCount = 1; |
| 2925 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2926 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2927 | |
| 2928 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2929 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2930 | ds_layout_ci.pNext = NULL; |
| 2931 | ds_layout_ci.bindingCount = 1; |
| 2932 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2933 | |
| 2934 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2935 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2936 | &ds_layout); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2937 | ASSERT_VK_SUCCESS(err); |
| 2938 | |
| 2939 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2940 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2941 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2942 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2943 | alloc_info.descriptorPool = ds_pool; |
| 2944 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2945 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 2946 | &descriptorSet); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2947 | ASSERT_VK_SUCCESS(err); |
| 2948 | |
| 2949 | err = vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptorSet); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2950 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2951 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2952 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2953 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 2954 | } |
| 2955 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2956 | TEST_F(VkLayerTest, InvalidDescriptorPool) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 2957 | // Attempt to clear Descriptor Pool with bad object. |
| 2958 | // ObjectTracker should catch this. |
| 2959 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2960 | "Invalid VkDescriptorPool Object 0xbaad6001"); |
| 2961 | VkDescriptorPool badPool = (VkDescriptorPool)0xbaad6001; |
| 2962 | vkResetDescriptorPool(device(), badPool, 0); |
| 2963 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2964 | } |
| 2965 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2966 | TEST_F(VkLayerTest, InvalidDescriptorSet) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 2967 | // Attempt to bind an invalid Descriptor Set to a valid Command Buffer |
| 2968 | // ObjectTracker should catch this. |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2969 | // Create a valid cmd buffer |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 2970 | // call vkCmdBindDescriptorSets w/ false Descriptor Set |
| 2971 | VkDescriptorSet badSet = (VkDescriptorSet)0xbaad6001; |
| 2972 | VkResult err; |
| 2973 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2974 | "Invalid VkDescriptorSet Object 0xbaad6001"); |
| 2975 | |
| 2976 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2977 | |
| 2978 | VkDescriptorSetLayoutBinding layout_bindings[1] = {}; |
| 2979 | layout_bindings[0].binding = 0; |
| 2980 | layout_bindings[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2981 | layout_bindings[0].descriptorCount = 1; |
| 2982 | layout_bindings[0].stageFlags = VK_SHADER_STAGE_VERTEX_BIT; |
| 2983 | layout_bindings[0].pImmutableSamplers = NULL; |
| 2984 | |
| 2985 | VkDescriptorSetLayout descriptor_set_layout; |
| 2986 | VkDescriptorSetLayoutCreateInfo dslci = {}; |
| 2987 | dslci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2988 | dslci.pNext = NULL; |
| 2989 | dslci.bindingCount = 1; |
| 2990 | dslci.pBindings = layout_bindings; |
| 2991 | err = vkCreateDescriptorSetLayout(device(), &dslci, NULL, &descriptor_set_layout); |
Karl Schultz | 5cb2111 | 2016-04-21 17:17:40 -0600 | [diff] [blame] | 2992 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 2993 | |
| 2994 | VkPipelineLayout pipeline_layout; |
| 2995 | VkPipelineLayoutCreateInfo plci = {}; |
| 2996 | plci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 2997 | plci.pNext = NULL; |
| 2998 | plci.setLayoutCount = 1; |
| 2999 | plci.pSetLayouts = &descriptor_set_layout; |
| 3000 | err = vkCreatePipelineLayout(device(), &plci, NULL, &pipeline_layout); |
Karl Schultz | 5cb2111 | 2016-04-21 17:17:40 -0600 | [diff] [blame] | 3001 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3002 | |
| 3003 | BeginCommandBuffer(); |
| 3004 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3005 | pipeline_layout, 0, 1, &badSet, 0, NULL); |
| 3006 | m_errorMonitor->VerifyFound(); |
| 3007 | EndCommandBuffer(); |
| 3008 | vkDestroyPipelineLayout(device(), pipeline_layout, NULL); |
| 3009 | vkDestroyDescriptorSetLayout(device(), descriptor_set_layout, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3010 | } |
| 3011 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3012 | TEST_F(VkLayerTest, InvalidDescriptorSetLayout) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3013 | // Attempt to create a Pipeline Layout with an invalid Descriptor Set Layout. |
| 3014 | // ObjectTracker should catch this. |
| 3015 | VkDescriptorSetLayout bad_layout = (VkDescriptorSetLayout)0xbaad6001; |
| 3016 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3017 | "Invalid VkDescriptorSetLayout Object 0xbaad6001"); |
| 3018 | |
| 3019 | VkPipelineLayout pipeline_layout; |
| 3020 | VkPipelineLayoutCreateInfo plci = {}; |
| 3021 | plci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3022 | plci.pNext = NULL; |
| 3023 | plci.setLayoutCount = 1; |
| 3024 | plci.pSetLayouts = &bad_layout; |
| 3025 | vkCreatePipelineLayout(device(), &plci, NULL, &pipeline_layout); |
| 3026 | |
| 3027 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3028 | } |
| 3029 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3030 | TEST_F(VkLayerTest, InvalidPipeline) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3031 | // Attempt to bind an invalid Pipeline to a valid Command Buffer |
| 3032 | // ObjectTracker should catch this. |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3033 | // Create a valid cmd buffer |
| 3034 | // call vkCmdBindPipeline w/ false Pipeline |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3035 | VkPipeline bad_pipeline = (VkPipeline)0xbaad6001; |
| 3036 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3037 | "Invalid VkPipeline Object 0xbaad6001"); |
| 3038 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3039 | BeginCommandBuffer(); |
| 3040 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 3041 | VK_PIPELINE_BIND_POINT_GRAPHICS, bad_pipeline); |
| 3042 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b8b6b27 | 2016-05-02 13:26:06 -0600 | [diff] [blame] | 3043 | |
| 3044 | // Now issue a draw call with no pipeline bound |
| 3045 | m_errorMonitor->SetDesiredFailureMsg( |
| 3046 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3047 | "At Draw/Dispatch time no valid VkPipeline is bound!"); |
| 3048 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3049 | BeginCommandBuffer(); |
| 3050 | Draw(1, 0, 0, 0); |
| 3051 | m_errorMonitor->VerifyFound(); |
| 3052 | // Finally same check once more but with Dispatch/Compute |
| 3053 | m_errorMonitor->SetDesiredFailureMsg( |
| 3054 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3055 | "At Draw/Dispatch time no valid VkPipeline is bound!"); |
| 3056 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3057 | BeginCommandBuffer(); |
| 3058 | vkCmdDispatch(m_commandBuffer->GetBufferHandle(), 0, 0, 0); |
| 3059 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3060 | } |
| 3061 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3062 | TEST_F(VkLayerTest, DescriptorSetNotUpdated) { |
| 3063 | // Create and update CommandBuffer then call QueueSubmit w/o calling End on |
| 3064 | // CommandBuffer |
| 3065 | VkResult err; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3066 | |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 3067 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3068 | " bound but it was never updated. "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3069 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3070 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 3071 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 3072 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3073 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3074 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3075 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3076 | |
| 3077 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3078 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3079 | ds_pool_ci.pNext = NULL; |
| 3080 | ds_pool_ci.maxSets = 1; |
| 3081 | ds_pool_ci.poolSizeCount = 1; |
| 3082 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 3083 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3084 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3085 | err = |
| 3086 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3087 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3088 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3089 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3090 | dsl_binding.binding = 0; |
| 3091 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3092 | dsl_binding.descriptorCount = 1; |
| 3093 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3094 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3095 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3096 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3097 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3098 | ds_layout_ci.pNext = NULL; |
| 3099 | ds_layout_ci.bindingCount = 1; |
| 3100 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3101 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3102 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3103 | &ds_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3104 | ASSERT_VK_SUCCESS(err); |
| 3105 | |
| 3106 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3107 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3108 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3109 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3110 | alloc_info.descriptorPool = ds_pool; |
| 3111 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3112 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3113 | &descriptorSet); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3114 | ASSERT_VK_SUCCESS(err); |
| 3115 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3116 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3117 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3118 | pipeline_layout_ci.pNext = NULL; |
| 3119 | pipeline_layout_ci.setLayoutCount = 1; |
| 3120 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3121 | |
| 3122 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3123 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3124 | &pipeline_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3125 | ASSERT_VK_SUCCESS(err); |
| 3126 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3127 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 3128 | VK_SHADER_STAGE_VERTEX_BIT, this); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3129 | // 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] | 3130 | // on more devices |
| 3131 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 3132 | VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3133 | |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 3134 | VkPipelineObj pipe(m_device); |
| 3135 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 3136 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 3137 | pipe.AddColorAttachment(); |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 3138 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 3139 | |
| 3140 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3141 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 3142 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 3143 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3144 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3145 | 1, &descriptorSet, 0, NULL); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3146 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3147 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3148 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3149 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3150 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3151 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3152 | } |
| 3153 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3154 | TEST_F(VkLayerTest, InvalidBufferViewObject) { |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3155 | // Create a single TEXEL_BUFFER descriptor and send it an invalid bufferView |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3156 | VkResult err; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3157 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3158 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 3159 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Attempted write update to texel buffer " |
| 3160 | "descriptor with invalid buffer view"); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3161 | |
| 3162 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3163 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3164 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 3165 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3166 | |
| 3167 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3168 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3169 | ds_pool_ci.pNext = NULL; |
| 3170 | ds_pool_ci.maxSets = 1; |
| 3171 | ds_pool_ci.poolSizeCount = 1; |
| 3172 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3173 | |
| 3174 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3175 | err = |
| 3176 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3177 | ASSERT_VK_SUCCESS(err); |
| 3178 | |
| 3179 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3180 | dsl_binding.binding = 0; |
| 3181 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 3182 | dsl_binding.descriptorCount = 1; |
| 3183 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3184 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3185 | |
| 3186 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3187 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3188 | ds_layout_ci.pNext = NULL; |
| 3189 | ds_layout_ci.bindingCount = 1; |
| 3190 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3191 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3192 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3193 | &ds_layout); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3194 | ASSERT_VK_SUCCESS(err); |
| 3195 | |
| 3196 | VkDescriptorSet descriptorSet; |
| 3197 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3198 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3199 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3200 | alloc_info.descriptorPool = ds_pool; |
| 3201 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3202 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3203 | &descriptorSet); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3204 | ASSERT_VK_SUCCESS(err); |
| 3205 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3206 | VkBufferView view = |
| 3207 | (VkBufferView)((size_t)0xbaadbeef); // invalid bufferView object |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3208 | VkWriteDescriptorSet descriptor_write; |
| 3209 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3210 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 3211 | descriptor_write.dstSet = descriptorSet; |
| 3212 | descriptor_write.dstBinding = 0; |
| 3213 | descriptor_write.descriptorCount = 1; |
| 3214 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 3215 | descriptor_write.pTexelBufferView = &view; |
| 3216 | |
| 3217 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3218 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3219 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3220 | |
| 3221 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3222 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 3223 | } |
| 3224 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3225 | TEST_F(VkLayerTest, InvalidDynamicOffsetCases) { |
| 3226 | // Create a descriptorSet w/ dynamic descriptor and then hit 3 offset error |
| 3227 | // cases: |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3228 | // 1. No dynamicOffset supplied |
| 3229 | // 2. Too many dynamicOffsets supplied |
| 3230 | // 3. Dynamic offset oversteps buffer being updated |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3231 | VkResult err; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3232 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3233 | " requires 1 dynamicOffsets, but only " |
| 3234 | "0 dynamicOffsets are left in " |
| 3235 | "pDynamicOffsets "); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3236 | |
| 3237 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3238 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 3239 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3240 | |
| 3241 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3242 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 3243 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3244 | |
| 3245 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3246 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3247 | ds_pool_ci.pNext = NULL; |
| 3248 | ds_pool_ci.maxSets = 1; |
| 3249 | ds_pool_ci.poolSizeCount = 1; |
| 3250 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3251 | |
| 3252 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3253 | err = |
| 3254 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3255 | ASSERT_VK_SUCCESS(err); |
| 3256 | |
| 3257 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3258 | dsl_binding.binding = 0; |
| 3259 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 3260 | dsl_binding.descriptorCount = 1; |
| 3261 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3262 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3263 | |
| 3264 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3265 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3266 | ds_layout_ci.pNext = NULL; |
| 3267 | ds_layout_ci.bindingCount = 1; |
| 3268 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3269 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3270 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3271 | &ds_layout); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3272 | ASSERT_VK_SUCCESS(err); |
| 3273 | |
| 3274 | VkDescriptorSet descriptorSet; |
| 3275 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3276 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3277 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3278 | alloc_info.descriptorPool = ds_pool; |
| 3279 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3280 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3281 | &descriptorSet); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3282 | ASSERT_VK_SUCCESS(err); |
| 3283 | |
| 3284 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3285 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3286 | pipeline_layout_ci.pNext = NULL; |
| 3287 | pipeline_layout_ci.setLayoutCount = 1; |
| 3288 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3289 | |
| 3290 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3291 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3292 | &pipeline_layout); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3293 | ASSERT_VK_SUCCESS(err); |
| 3294 | |
| 3295 | // Create a buffer to update the descriptor with |
| 3296 | uint32_t qfi = 0; |
| 3297 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3298 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 3299 | buffCI.size = 1024; |
| 3300 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 3301 | buffCI.queueFamilyIndexCount = 1; |
| 3302 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3303 | |
| 3304 | VkBuffer dyub; |
| 3305 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 3306 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 3307 | // Allocate memory and bind to buffer so we can make it to the appropriate |
| 3308 | // error |
| 3309 | VkMemoryAllocateInfo mem_alloc = {}; |
| 3310 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 3311 | mem_alloc.pNext = NULL; |
| 3312 | mem_alloc.allocationSize = 1024; |
Chris Forbes | b6116cc | 2016-05-08 11:39:59 +1200 | [diff] [blame] | 3313 | mem_alloc.memoryTypeIndex = 0; |
| 3314 | |
| 3315 | VkMemoryRequirements memReqs; |
| 3316 | vkGetBufferMemoryRequirements(m_device->device(), dyub, &memReqs); |
| 3317 | bool pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &mem_alloc, |
| 3318 | 0); |
| 3319 | if (!pass) { |
| 3320 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
| 3321 | return; |
| 3322 | } |
| 3323 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 3324 | VkDeviceMemory mem; |
| 3325 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
| 3326 | ASSERT_VK_SUCCESS(err); |
| 3327 | err = vkBindBufferMemory(m_device->device(), dyub, mem, 0); |
| 3328 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3329 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 3330 | VkDescriptorBufferInfo buffInfo = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3331 | buffInfo.buffer = dyub; |
| 3332 | buffInfo.offset = 0; |
| 3333 | buffInfo.range = 1024; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3334 | |
| 3335 | VkWriteDescriptorSet descriptor_write; |
| 3336 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3337 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 3338 | descriptor_write.dstSet = descriptorSet; |
| 3339 | descriptor_write.dstBinding = 0; |
| 3340 | descriptor_write.descriptorCount = 1; |
| 3341 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 3342 | descriptor_write.pBufferInfo = &buffInfo; |
| 3343 | |
| 3344 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3345 | |
| 3346 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3347 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3348 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3349 | 1, &descriptorSet, 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3350 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3351 | uint32_t pDynOff[2] = {512, 756}; |
| 3352 | // 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] | 3353 | m_errorMonitor->SetDesiredFailureMsg( |
| 3354 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3355 | "Attempting to bind 1 descriptorSets with 1 dynamic descriptors, but "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3356 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3357 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3358 | 1, &descriptorSet, 2, pDynOff); |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 3359 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3360 | // Finally cause error due to dynamicOffset being too big |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 3361 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3362 | " dynamic offset 512 combined with " |
| 3363 | "offset 0 and range 1024 that " |
| 3364 | "oversteps the buffer size of 1024"); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3365 | // Create PSO to be used for draw-time errors below |
| 3366 | char const *vsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 3367 | "#version 450\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3368 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 3369 | "out gl_PerVertex { \n" |
| 3370 | " vec4 gl_Position;\n" |
| 3371 | "};\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3372 | "void main(){\n" |
| 3373 | " gl_Position = vec4(1);\n" |
| 3374 | "}\n"; |
| 3375 | char const *fsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 3376 | "#version 450\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3377 | "\n" |
| 3378 | "layout(location=0) out vec4 x;\n" |
| 3379 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 3380 | "void main(){\n" |
| 3381 | " x = vec4(bar.y);\n" |
| 3382 | "}\n"; |
| 3383 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 3384 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 3385 | VkPipelineObj pipe(m_device); |
| 3386 | pipe.AddShader(&vs); |
| 3387 | pipe.AddShader(&fs); |
| 3388 | pipe.AddColorAttachment(); |
| 3389 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 3390 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3391 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 3392 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 3393 | // This update should succeed, but offset size of 512 will overstep buffer |
| 3394 | // /w range 1024 & size 1024 |
| 3395 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3396 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3397 | 1, &descriptorSet, 1, pDynOff); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3398 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3399 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3400 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 3401 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
Tobin Ehlis | 512098e | 2016-05-05 09:06:12 -0600 | [diff] [blame] | 3402 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 3403 | |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3404 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3405 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 3406 | } |
| 3407 | |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 3408 | TEST_F(VkLayerTest, InvalidPushConstants) { |
| 3409 | // Hit push constant error cases: |
| 3410 | // 1. Create PipelineLayout where push constant overstep maxPushConstantSize |
| 3411 | // 2. Incorrectly set push constant size to 0 |
| 3412 | // 3. Incorrectly set push constant size to non-multiple of 4 |
| 3413 | // 4. Attempt push constant update that exceeds maxPushConstantSize |
| 3414 | VkResult err; |
| 3415 | m_errorMonitor->SetDesiredFailureMsg( |
| 3416 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3417 | "vkCreatePipelineLayout() call has push constants with offset "); |
| 3418 | |
| 3419 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3420 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 3421 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3422 | |
| 3423 | VkPushConstantRange pc_range = {}; |
| 3424 | pc_range.size = 0xFFFFFFFFu; |
| 3425 | pc_range.stageFlags = VK_SHADER_STAGE_VERTEX_BIT; |
| 3426 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 3427 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3428 | pipeline_layout_ci.pushConstantRangeCount = 1; |
| 3429 | pipeline_layout_ci.pPushConstantRanges = &pc_range; |
| 3430 | |
| 3431 | VkPipelineLayout pipeline_layout; |
| 3432 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3433 | &pipeline_layout); |
| 3434 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3435 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 3436 | // Now cause errors due to size 0 and non-4 byte aligned size |
| 3437 | pc_range.size = 0; |
| 3438 | m_errorMonitor->SetDesiredFailureMsg( |
| 3439 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3440 | "vkCreatePipelineLayout() call has push constant index 0 with size 0"); |
| 3441 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3442 | &pipeline_layout); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3443 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 3444 | pc_range.size = 1; |
| 3445 | m_errorMonitor->SetDesiredFailureMsg( |
| 3446 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3447 | "vkCreatePipelineLayout() call has push constant index 0 with size 1"); |
| 3448 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3449 | &pipeline_layout); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3450 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 3451 | // Cause error due to bad size in vkCmdPushConstants() call |
| 3452 | m_errorMonitor->SetDesiredFailureMsg( |
| 3453 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3454 | "vkCmdPushConstants() call has push constants with offset "); |
| 3455 | pipeline_layout_ci.pushConstantRangeCount = 0; |
| 3456 | pipeline_layout_ci.pPushConstantRanges = NULL; |
| 3457 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3458 | &pipeline_layout); |
| 3459 | ASSERT_VK_SUCCESS(err); |
| 3460 | BeginCommandBuffer(); |
| 3461 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, |
| 3462 | VK_SHADER_STAGE_VERTEX_BIT, 0, 0xFFFFFFFFu, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3463 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 3464 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3465 | } |
| 3466 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3467 | TEST_F(VkLayerTest, DescriptorSetCompatibility) { |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3468 | // Test various desriptorSet errors with bad binding combinations |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3469 | VkResult err; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3470 | |
| 3471 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3472 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 3473 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3474 | |
| 3475 | static const uint32_t NUM_DESCRIPTOR_TYPES = 5; |
| 3476 | VkDescriptorPoolSize ds_type_count[NUM_DESCRIPTOR_TYPES] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3477 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3478 | ds_type_count[0].descriptorCount = 10; |
| 3479 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 3480 | ds_type_count[1].descriptorCount = 2; |
| 3481 | ds_type_count[2].type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 3482 | ds_type_count[2].descriptorCount = 2; |
| 3483 | ds_type_count[3].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 3484 | ds_type_count[3].descriptorCount = 5; |
| 3485 | // TODO : LunarG ILO driver currently asserts in desc.c w/ INPUT_ATTACHMENT |
| 3486 | // type |
| 3487 | // ds_type_count[4].type = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; |
| 3488 | ds_type_count[4].type = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
| 3489 | ds_type_count[4].descriptorCount = 2; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3490 | |
| 3491 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3492 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3493 | ds_pool_ci.pNext = NULL; |
| 3494 | ds_pool_ci.maxSets = 5; |
| 3495 | ds_pool_ci.poolSizeCount = NUM_DESCRIPTOR_TYPES; |
| 3496 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3497 | |
| 3498 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3499 | err = |
| 3500 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3501 | ASSERT_VK_SUCCESS(err); |
| 3502 | |
| 3503 | static const uint32_t MAX_DS_TYPES_IN_LAYOUT = 2; |
| 3504 | VkDescriptorSetLayoutBinding dsl_binding[MAX_DS_TYPES_IN_LAYOUT] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3505 | dsl_binding[0].binding = 0; |
| 3506 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3507 | dsl_binding[0].descriptorCount = 5; |
| 3508 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 3509 | dsl_binding[0].pImmutableSamplers = NULL; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3510 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3511 | // Create layout identical to set0 layout but w/ different stageFlags |
| 3512 | VkDescriptorSetLayoutBinding dsl_fs_stage_only = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3513 | dsl_fs_stage_only.binding = 0; |
| 3514 | dsl_fs_stage_only.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3515 | dsl_fs_stage_only.descriptorCount = 5; |
| 3516 | dsl_fs_stage_only.stageFlags = |
| 3517 | VK_SHADER_STAGE_FRAGMENT_BIT; // Different stageFlags to cause error at |
| 3518 | // bind time |
| 3519 | dsl_fs_stage_only.pImmutableSamplers = NULL; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3520 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3521 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3522 | ds_layout_ci.pNext = NULL; |
| 3523 | ds_layout_ci.bindingCount = 1; |
| 3524 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3525 | static const uint32_t NUM_LAYOUTS = 4; |
| 3526 | VkDescriptorSetLayout ds_layout[NUM_LAYOUTS] = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3527 | VkDescriptorSetLayout ds_layout_fs_only = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3528 | // Create 4 unique layouts for full pipelineLayout, and 1 special fs-only |
| 3529 | // layout for error case |
| 3530 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3531 | &ds_layout[0]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3532 | ASSERT_VK_SUCCESS(err); |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 3533 | ds_layout_ci.pBindings = &dsl_fs_stage_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3534 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3535 | &ds_layout_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3536 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3537 | dsl_binding[0].binding = 0; |
| 3538 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3539 | dsl_binding[0].descriptorCount = 2; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 3540 | dsl_binding[1].binding = 1; |
| 3541 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 3542 | dsl_binding[1].descriptorCount = 2; |
| 3543 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 3544 | dsl_binding[1].pImmutableSamplers = NULL; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 3545 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3546 | ds_layout_ci.bindingCount = 2; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3547 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3548 | &ds_layout[1]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3549 | ASSERT_VK_SUCCESS(err); |
| 3550 | dsl_binding[0].binding = 0; |
| 3551 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3552 | dsl_binding[0].descriptorCount = 5; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3553 | ds_layout_ci.bindingCount = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3554 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3555 | &ds_layout[2]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3556 | ASSERT_VK_SUCCESS(err); |
| 3557 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3558 | dsl_binding[0].descriptorCount = 2; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3559 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3560 | &ds_layout[3]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3561 | ASSERT_VK_SUCCESS(err); |
| 3562 | |
| 3563 | static const uint32_t NUM_SETS = 4; |
| 3564 | VkDescriptorSet descriptorSet[NUM_SETS] = {}; |
| 3565 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3566 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3567 | alloc_info.descriptorSetCount = NUM_LAYOUTS; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3568 | alloc_info.descriptorPool = ds_pool; |
| 3569 | alloc_info.pSetLayouts = ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3570 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3571 | descriptorSet); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3572 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3573 | VkDescriptorSet ds0_fs_only = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3574 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3575 | alloc_info.pSetLayouts = &ds_layout_fs_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3576 | err = |
| 3577 | vkAllocateDescriptorSets(m_device->device(), &alloc_info, &ds0_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3578 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3579 | |
| 3580 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3581 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3582 | pipeline_layout_ci.pNext = NULL; |
| 3583 | pipeline_layout_ci.setLayoutCount = NUM_LAYOUTS; |
| 3584 | pipeline_layout_ci.pSetLayouts = ds_layout; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3585 | |
| 3586 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3587 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3588 | &pipeline_layout); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3589 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3590 | // Create pipelineLayout with only one setLayout |
| 3591 | pipeline_layout_ci.setLayoutCount = 1; |
| 3592 | VkPipelineLayout single_pipe_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3593 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3594 | &single_pipe_layout); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3595 | ASSERT_VK_SUCCESS(err); |
| 3596 | // Create pipelineLayout with 2 descriptor setLayout at index 0 |
| 3597 | pipeline_layout_ci.pSetLayouts = &ds_layout[3]; |
| 3598 | VkPipelineLayout pipe_layout_one_desc; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3599 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3600 | &pipe_layout_one_desc); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3601 | ASSERT_VK_SUCCESS(err); |
| 3602 | // Create pipelineLayout with 5 SAMPLER descriptor setLayout at index 0 |
| 3603 | pipeline_layout_ci.pSetLayouts = &ds_layout[2]; |
| 3604 | VkPipelineLayout pipe_layout_five_samp; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3605 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3606 | &pipe_layout_five_samp); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3607 | ASSERT_VK_SUCCESS(err); |
| 3608 | // Create pipelineLayout with UB type, but stageFlags for FS only |
| 3609 | pipeline_layout_ci.pSetLayouts = &ds_layout_fs_only; |
| 3610 | VkPipelineLayout pipe_layout_fs_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3611 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3612 | &pipe_layout_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3613 | ASSERT_VK_SUCCESS(err); |
| 3614 | // Create pipelineLayout w/ incompatible set0 layout, but set1 is fine |
| 3615 | VkDescriptorSetLayout pl_bad_s0[2] = {}; |
| 3616 | pl_bad_s0[0] = ds_layout_fs_only; |
| 3617 | pl_bad_s0[1] = ds_layout[1]; |
| 3618 | pipeline_layout_ci.setLayoutCount = 2; |
| 3619 | pipeline_layout_ci.pSetLayouts = pl_bad_s0; |
| 3620 | VkPipelineLayout pipe_layout_bad_set0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3621 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3622 | &pipe_layout_bad_set0); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3623 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3624 | |
| 3625 | // Create a buffer to update the descriptor with |
| 3626 | uint32_t qfi = 0; |
| 3627 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3628 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 3629 | buffCI.size = 1024; |
| 3630 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 3631 | buffCI.queueFamilyIndexCount = 1; |
| 3632 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3633 | |
| 3634 | VkBuffer dyub; |
| 3635 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 3636 | ASSERT_VK_SUCCESS(err); |
| 3637 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 3638 | static const uint32_t NUM_BUFFS = 5; |
| 3639 | VkDescriptorBufferInfo buffInfo[NUM_BUFFS] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3640 | for (uint32_t i = 0; i < NUM_BUFFS; ++i) { |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3641 | buffInfo[i].buffer = dyub; |
| 3642 | buffInfo[i].offset = 0; |
| 3643 | buffInfo[i].range = 1024; |
| 3644 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3645 | VkImage image; |
| 3646 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 3647 | const int32_t tex_width = 32; |
| 3648 | const int32_t tex_height = 32; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3649 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3650 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 3651 | image_create_info.pNext = NULL; |
| 3652 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 3653 | image_create_info.format = tex_format; |
| 3654 | image_create_info.extent.width = tex_width; |
| 3655 | image_create_info.extent.height = tex_height; |
| 3656 | image_create_info.extent.depth = 1; |
| 3657 | image_create_info.mipLevels = 1; |
| 3658 | image_create_info.arrayLayers = 1; |
| 3659 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 3660 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 3661 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 3662 | image_create_info.flags = 0; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3663 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 3664 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3665 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3666 | VkMemoryRequirements memReqs; |
| 3667 | VkDeviceMemory imageMem; |
| 3668 | bool pass; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 3669 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3670 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 3671 | memAlloc.pNext = NULL; |
| 3672 | memAlloc.allocationSize = 0; |
| 3673 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 3674 | vkGetImageMemoryRequirements(m_device->device(), image, &memReqs); |
| 3675 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3676 | pass = |
| 3677 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 3678 | ASSERT_TRUE(pass); |
| 3679 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &imageMem); |
| 3680 | ASSERT_VK_SUCCESS(err); |
| 3681 | err = vkBindImageMemory(m_device->device(), image, imageMem, 0); |
| 3682 | ASSERT_VK_SUCCESS(err); |
| 3683 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3684 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3685 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 3686 | image_view_create_info.image = image; |
| 3687 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 3688 | image_view_create_info.format = tex_format; |
| 3689 | image_view_create_info.subresourceRange.layerCount = 1; |
| 3690 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 3691 | image_view_create_info.subresourceRange.levelCount = 1; |
| 3692 | image_view_create_info.subresourceRange.aspectMask = |
| 3693 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3694 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3695 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3696 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 3697 | &view); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3698 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 3699 | VkDescriptorImageInfo imageInfo[4] = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3700 | imageInfo[0].imageView = view; |
| 3701 | imageInfo[0].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 3702 | imageInfo[1].imageView = view; |
| 3703 | imageInfo[1].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 3704 | imageInfo[2].imageView = view; |
| 3705 | imageInfo[2].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 3706 | imageInfo[3].imageView = view; |
| 3707 | imageInfo[3].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3708 | |
| 3709 | static const uint32_t NUM_SET_UPDATES = 3; |
| 3710 | VkWriteDescriptorSet descriptor_write[NUM_SET_UPDATES] = {}; |
| 3711 | descriptor_write[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 3712 | descriptor_write[0].dstSet = descriptorSet[0]; |
| 3713 | descriptor_write[0].dstBinding = 0; |
| 3714 | descriptor_write[0].descriptorCount = 5; |
| 3715 | descriptor_write[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3716 | descriptor_write[0].pBufferInfo = buffInfo; |
| 3717 | descriptor_write[1].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 3718 | descriptor_write[1].dstSet = descriptorSet[1]; |
| 3719 | descriptor_write[1].dstBinding = 0; |
| 3720 | descriptor_write[1].descriptorCount = 2; |
| 3721 | descriptor_write[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 3722 | descriptor_write[1].pImageInfo = imageInfo; |
| 3723 | descriptor_write[2].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 3724 | descriptor_write[2].dstSet = descriptorSet[1]; |
| 3725 | descriptor_write[2].dstBinding = 1; |
| 3726 | descriptor_write[2].descriptorCount = 2; |
| 3727 | descriptor_write[2].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 3728 | descriptor_write[2].pImageInfo = &imageInfo[2]; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3729 | |
| 3730 | vkUpdateDescriptorSets(m_device->device(), 3, descriptor_write, 0, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3731 | |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3732 | // Create PSO to be used for draw-time errors below |
| 3733 | char const *vsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 3734 | "#version 450\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3735 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 3736 | "out gl_PerVertex {\n" |
| 3737 | " vec4 gl_Position;\n" |
| 3738 | "};\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3739 | "void main(){\n" |
| 3740 | " gl_Position = vec4(1);\n" |
| 3741 | "}\n"; |
| 3742 | char const *fsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 3743 | "#version 450\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3744 | "\n" |
| 3745 | "layout(location=0) out vec4 x;\n" |
| 3746 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 3747 | "void main(){\n" |
| 3748 | " x = vec4(bar.y);\n" |
| 3749 | "}\n"; |
| 3750 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 3751 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3752 | VkPipelineObj pipe(m_device); |
| 3753 | pipe.AddShader(&vs); |
| 3754 | pipe.AddShader(&fs); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3755 | pipe.AddColorAttachment(); |
| 3756 | pipe.CreateVKPipeline(pipe_layout_fs_only, renderPass()); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3757 | |
| 3758 | BeginCommandBuffer(); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3759 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3760 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 3761 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 3762 | // NOTE : I believe LunarG ilo driver has bug (LX#189) that requires binding |
| 3763 | // of PSO |
| 3764 | // here before binding DSs. Otherwise we assert in cmd_copy_dset_data() of |
| 3765 | // cmd_pipeline.c |
| 3766 | // due to the fact that cmd_alloc_dset_data() has not been called in |
| 3767 | // cmd_bind_graphics_pipeline() |
| 3768 | // TODO : Want to cause various binding incompatibility issues here to test |
| 3769 | // DrawState |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3770 | // First cause various verify_layout_compatibility() fails |
| 3771 | // Second disturb early and late sets and verify INFO msgs |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3772 | // verify_set_layout_compatibility fail cases: |
| 3773 | // 1. invalid VkPipelineLayout (layout) passed into vkCmdBindDescriptorSets |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3774 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3775 | " due to: invalid VkPipelineLayout "); |
| 3776 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3777 | VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3778 | (VkPipelineLayout)((size_t)0xbaadb1be), 0, 1, |
| 3779 | &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3780 | m_errorMonitor->VerifyFound(); |
| 3781 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3782 | // 2. layoutIndex exceeds # of layouts in layout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3783 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3784 | " attempting to bind set to index 1"); |
| 3785 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3786 | VK_PIPELINE_BIND_POINT_GRAPHICS, single_pipe_layout, |
| 3787 | 0, 2, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3788 | m_errorMonitor->VerifyFound(); |
| 3789 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3790 | vkDestroyPipelineLayout(m_device->device(), single_pipe_layout, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3791 | // 3. Pipeline setLayout[0] has 2 descriptors, but set being bound has 5 |
| 3792 | // descriptors |
| 3793 | m_errorMonitor->SetDesiredFailureMsg( |
| 3794 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 3795 | " has 2 descriptors, but DescriptorSetLayout "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3796 | vkCmdBindDescriptorSets( |
| 3797 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3798 | pipe_layout_one_desc, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3799 | m_errorMonitor->VerifyFound(); |
| 3800 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3801 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_one_desc, NULL); |
| 3802 | // 4. same # of descriptors but mismatch in type |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3803 | m_errorMonitor->SetDesiredFailureMsg( |
| 3804 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 3805 | " is type 'VK_DESCRIPTOR_TYPE_SAMPLER' but binding "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3806 | vkCmdBindDescriptorSets( |
| 3807 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3808 | pipe_layout_five_samp, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3809 | m_errorMonitor->VerifyFound(); |
| 3810 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3811 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_five_samp, NULL); |
| 3812 | // 5. same # of descriptors but mismatch in stageFlags |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3813 | m_errorMonitor->SetDesiredFailureMsg( |
| 3814 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 3815 | " has stageFlags 16 but binding 0 for DescriptorSetLayout "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3816 | vkCmdBindDescriptorSets( |
| 3817 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3818 | pipe_layout_fs_only, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3819 | m_errorMonitor->VerifyFound(); |
| 3820 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3821 | // Cause INFO messages due to disturbing previously bound Sets |
| 3822 | // First bind sets 0 & 1 |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3823 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3824 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3825 | 2, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3826 | // 1. Disturb bound set0 by re-binding set1 w/ updated pipelineLayout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3827 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 3828 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3829 | " previously bound as set #0 was disturbed "); |
| 3830 | vkCmdBindDescriptorSets( |
| 3831 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3832 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3833 | m_errorMonitor->VerifyFound(); |
| 3834 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3835 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3836 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3837 | 2, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3838 | // 2. Disturb set after last bound set |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 3839 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3840 | " newly bound as set #0 so set #1 and " |
| 3841 | "any subsequent sets were disturbed "); |
| 3842 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3843 | VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3844 | pipe_layout_fs_only, 0, 1, &ds0_fs_only, 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3845 | m_errorMonitor->VerifyFound(); |
| 3846 | |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3847 | // Cause draw-time errors due to PSO incompatibilities |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3848 | // 1. Error due to not binding required set (we actually use same code as |
| 3849 | // above to disturb set0) |
| 3850 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3851 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3852 | 2, &descriptorSet[0], 0, NULL); |
| 3853 | vkCmdBindDescriptorSets( |
| 3854 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3855 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
| 3856 | m_errorMonitor->SetDesiredFailureMsg( |
| 3857 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3858 | " uses set #0 but that set is not bound."); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3859 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3860 | m_errorMonitor->VerifyFound(); |
| 3861 | |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 3862 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_bad_set0, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3863 | // 2. Error due to bound set not being compatible with PSO's |
| 3864 | // VkPipelineLayout (diff stageFlags in this case) |
| 3865 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3866 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3867 | 2, &descriptorSet[0], 0, NULL); |
| 3868 | m_errorMonitor->SetDesiredFailureMsg( |
| 3869 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3870 | " bound as set #0 is not compatible with "); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3871 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3872 | m_errorMonitor->VerifyFound(); |
| 3873 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3874 | // Remaining clean-up |
| 3875 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_fs_only, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3876 | for (uint32_t i = 0; i < NUM_LAYOUTS; ++i) { |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3877 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout[i], NULL); |
| 3878 | } |
| 3879 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout_fs_only, NULL); |
Tobin Ehlis | 9bfd449 | 2016-05-05 15:09:11 -0600 | [diff] [blame] | 3880 | vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &ds0_fs_only); |
| 3881 | vkFreeDescriptorSets(m_device->device(), ds_pool, NUM_SETS, descriptorSet); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3882 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3883 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3884 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 3885 | } |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3886 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3887 | TEST_F(VkLayerTest, NoBeginCommandBuffer) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3888 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3889 | m_errorMonitor->SetDesiredFailureMsg( |
| 3890 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3891 | "You must call vkBeginCommandBuffer() before this call to "); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3892 | |
| 3893 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3894 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3895 | // Call EndCommandBuffer() w/o calling BeginCommandBuffer() |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3896 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3897 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3898 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3899 | } |
| 3900 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3901 | TEST_F(VkLayerTest, SecondaryCommandBufferNullRenderpass) { |
| 3902 | VkResult err; |
| 3903 | VkCommandBuffer draw_cmd; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3904 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3905 | m_errorMonitor->SetDesiredFailureMsg( |
| 3906 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 61b36f3 | 2015-12-16 08:19:42 -0700 | [diff] [blame] | 3907 | " must specify a valid renderpass parameter."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3908 | |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 3909 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 3910 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3911 | VkCommandBufferAllocateInfo cmd = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3912 | cmd.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 3913 | cmd.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3914 | cmd.commandPool = m_commandPool; |
| 3915 | cmd.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3916 | cmd.commandBufferCount = 1; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 3917 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3918 | err = vkAllocateCommandBuffers(m_device->device(), &cmd, &draw_cmd); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3919 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 3920 | |
| 3921 | // Force the failure by not setting the Renderpass and Framebuffer fields |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3922 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3923 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3924 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 3925 | cmd_buf_info.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3926 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT | |
| 3927 | VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3928 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 3929 | |
| 3930 | // The error should be caught by validation of the BeginCommandBuffer call |
| 3931 | vkBeginCommandBuffer(draw_cmd, &cmd_buf_info); |
| 3932 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3933 | m_errorMonitor->VerifyFound(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3934 | vkFreeCommandBuffers(m_device->device(), m_commandPool, 1, &draw_cmd); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 3935 | } |
| 3936 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3937 | TEST_F(VkLayerTest, CommandBufferResetErrors) { |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 3938 | // Cause error due to Begin while recording CB |
| 3939 | // Then cause 2 errors for attempting to reset CB w/o having |
| 3940 | // VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT set for the pool from |
| 3941 | // which CBs were allocated. Note that this bit is off by default. |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3942 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3943 | "Cannot call Begin on CB"); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 3944 | |
| 3945 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3946 | |
| 3947 | // Calls AllocateCommandBuffers |
| 3948 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
| 3949 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3950 | // Force the failure by setting the Renderpass and Framebuffer fields with |
| 3951 | // (fake) data |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 3952 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3953 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 3954 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3955 | cmd_buf_info.pNext = NULL; |
| 3956 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3957 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 3958 | |
| 3959 | // Begin CB to transition to recording state |
| 3960 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
| 3961 | // Can't re-begin. This should trigger error |
| 3962 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3963 | m_errorMonitor->VerifyFound(); |
| 3964 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3965 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3966 | "Attempt to reset command buffer "); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 3967 | VkCommandBufferResetFlags flags = 0; // Don't care about flags for this test |
| 3968 | // Reset attempt will trigger error due to incorrect CommandPool state |
| 3969 | vkResetCommandBuffer(commandBuffer.GetBufferHandle(), flags); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3970 | m_errorMonitor->VerifyFound(); |
| 3971 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3972 | m_errorMonitor->SetDesiredFailureMsg( |
| 3973 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3974 | " attempts to implicitly reset cmdBuffer created from "); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 3975 | // Transition CB to RECORDED state |
| 3976 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
| 3977 | // Now attempting to Begin will implicitly reset, which triggers error |
| 3978 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3979 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 3980 | } |
| 3981 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3982 | TEST_F(VkLayerTest, InvalidPipelineCreateState) { |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3983 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3984 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3985 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3986 | m_errorMonitor->SetDesiredFailureMsg( |
| 3987 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3988 | "Invalid Pipeline CreateInfo State: Vtx Shader required"); |
| 3989 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3990 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 3991 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3992 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3993 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3994 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3995 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3996 | |
| 3997 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3998 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3999 | ds_pool_ci.pNext = NULL; |
| 4000 | ds_pool_ci.maxSets = 1; |
| 4001 | ds_pool_ci.poolSizeCount = 1; |
| 4002 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4003 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4004 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4005 | err = |
| 4006 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4007 | ASSERT_VK_SUCCESS(err); |
| 4008 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4009 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4010 | dsl_binding.binding = 0; |
| 4011 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4012 | dsl_binding.descriptorCount = 1; |
| 4013 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4014 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4015 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4016 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4017 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4018 | ds_layout_ci.pNext = NULL; |
| 4019 | ds_layout_ci.bindingCount = 1; |
| 4020 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4021 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4022 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4023 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4024 | &ds_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4025 | ASSERT_VK_SUCCESS(err); |
| 4026 | |
| 4027 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4028 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4029 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4030 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4031 | alloc_info.descriptorPool = ds_pool; |
| 4032 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4033 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4034 | &descriptorSet); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4035 | ASSERT_VK_SUCCESS(err); |
| 4036 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4037 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4038 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4039 | pipeline_layout_ci.setLayoutCount = 1; |
| 4040 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4041 | |
| 4042 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4043 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4044 | &pipeline_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4045 | ASSERT_VK_SUCCESS(err); |
| 4046 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4047 | VkViewport vp = {}; // Just need dummy vp to point to |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4048 | VkRect2D sc = {}; // dummy scissor to point to |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4049 | |
| 4050 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4051 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 4052 | vp_state_ci.scissorCount = 1; |
| 4053 | vp_state_ci.pScissors = ≻ |
| 4054 | vp_state_ci.viewportCount = 1; |
| 4055 | vp_state_ci.pViewports = &vp; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4056 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 4057 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 4058 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 4059 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 4060 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 4061 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 4062 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 4063 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 4064 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 4065 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4066 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4067 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 4068 | gp_ci.pViewportState = &vp_state_ci; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 4069 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4070 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 4071 | gp_ci.layout = pipeline_layout; |
| 4072 | gp_ci.renderPass = renderPass(); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4073 | |
| 4074 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4075 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 4076 | pc_ci.initialDataSize = 0; |
| 4077 | pc_ci.pInitialData = 0; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4078 | |
| 4079 | VkPipeline pipeline; |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 4080 | VkPipelineCache pipelineCache; |
| 4081 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4082 | err = |
| 4083 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 4084 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4085 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4086 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4087 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4088 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 4089 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4090 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 4091 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4092 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4093 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4094 | } |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4095 | /*// TODO : This test should be good, but needs Tess support in compiler to run |
| 4096 | TEST_F(VkLayerTest, InvalidPatchControlPoints) |
| 4097 | { |
| 4098 | // Attempt to Create Gfx Pipeline w/o a VS |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4099 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4100 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4101 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4102 | "Invalid Pipeline CreateInfo State: VK_PRIMITIVE_TOPOLOGY_PATCH |
| 4103 | primitive "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4104 | |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4105 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4106 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4107 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4108 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4109 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4110 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4111 | |
| 4112 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 4113 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4114 | ds_pool_ci.pNext = NULL; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4115 | ds_pool_ci.poolSizeCount = 1; |
| 4116 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4117 | |
| 4118 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4119 | err = vkCreateDescriptorPool(m_device->device(), |
| 4120 | 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] | 4121 | ASSERT_VK_SUCCESS(err); |
| 4122 | |
| 4123 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4124 | dsl_binding.binding = 0; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4125 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 4126 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4127 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4128 | dsl_binding.pImmutableSamplers = NULL; |
| 4129 | |
| 4130 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4131 | ds_layout_ci.sType = |
| 4132 | VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4133 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4134 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 4135 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4136 | |
| 4137 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4138 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4139 | &ds_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4140 | ASSERT_VK_SUCCESS(err); |
| 4141 | |
| 4142 | VkDescriptorSet descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4143 | err = vkAllocateDescriptorSets(m_device->device(), ds_pool, |
| 4144 | VK_DESCRIPTOR_SET_USAGE_NON_FREE, 1, &ds_layout, &descriptorSet); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4145 | ASSERT_VK_SUCCESS(err); |
| 4146 | |
| 4147 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4148 | pipeline_layout_ci.sType = |
| 4149 | VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4150 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4151 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4152 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 4153 | |
| 4154 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4155 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4156 | &pipeline_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4157 | ASSERT_VK_SUCCESS(err); |
| 4158 | |
| 4159 | VkPipelineShaderStageCreateInfo shaderStages[3]; |
| 4160 | memset(&shaderStages, 0, 3 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 4161 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4162 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, |
| 4163 | this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4164 | // 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] | 4165 | VkShaderObj |
| 4166 | tc(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, |
| 4167 | this); |
| 4168 | VkShaderObj |
| 4169 | te(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, |
| 4170 | this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4171 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4172 | shaderStages[0].sType = |
| 4173 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4174 | shaderStages[0].stage = VK_SHADER_STAGE_VERTEX_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4175 | shaderStages[0].shader = vs.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4176 | shaderStages[1].sType = |
| 4177 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4178 | shaderStages[1].stage = VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4179 | shaderStages[1].shader = tc.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4180 | shaderStages[2].sType = |
| 4181 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4182 | shaderStages[2].stage = VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4183 | shaderStages[2].shader = te.handle(); |
| 4184 | |
| 4185 | VkPipelineInputAssemblyStateCreateInfo iaCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4186 | iaCI.sType = |
| 4187 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
Chia-I Wu | 515eb8f | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4188 | iaCI.topology = VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4189 | |
| 4190 | VkPipelineTessellationStateCreateInfo tsCI = {}; |
| 4191 | tsCI.sType = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO; |
| 4192 | tsCI.patchControlPoints = 0; // This will cause an error |
| 4193 | |
| 4194 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 4195 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 4196 | gp_ci.pNext = NULL; |
| 4197 | gp_ci.stageCount = 3; |
| 4198 | gp_ci.pStages = shaderStages; |
| 4199 | gp_ci.pVertexInputState = NULL; |
| 4200 | gp_ci.pInputAssemblyState = &iaCI; |
| 4201 | gp_ci.pTessellationState = &tsCI; |
| 4202 | gp_ci.pViewportState = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4203 | gp_ci.pRasterizationState = NULL; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4204 | gp_ci.pMultisampleState = NULL; |
| 4205 | gp_ci.pDepthStencilState = NULL; |
| 4206 | gp_ci.pColorBlendState = NULL; |
| 4207 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 4208 | gp_ci.layout = pipeline_layout; |
| 4209 | gp_ci.renderPass = renderPass(); |
| 4210 | |
| 4211 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 4212 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 4213 | pc_ci.pNext = NULL; |
| 4214 | pc_ci.initialSize = 0; |
| 4215 | pc_ci.initialData = 0; |
| 4216 | pc_ci.maxSize = 0; |
| 4217 | |
| 4218 | VkPipeline pipeline; |
| 4219 | VkPipelineCache pipelineCache; |
| 4220 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4221 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, |
| 4222 | &pipelineCache); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4223 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4224 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4225 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4226 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4227 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 4228 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4229 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 4230 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4231 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4232 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4233 | } |
| 4234 | */ |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4235 | // Set scissor and viewport counts to different numbers |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4236 | TEST_F(VkLayerTest, PSOViewportScissorCountMismatch) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4237 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4238 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4239 | m_errorMonitor->SetDesiredFailureMsg( |
| 4240 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4241 | "Gfx Pipeline viewport count (1) must match scissor count (0)."); |
| 4242 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4243 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4244 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4245 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4246 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4247 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4248 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4249 | |
| 4250 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4251 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4252 | ds_pool_ci.maxSets = 1; |
| 4253 | ds_pool_ci.poolSizeCount = 1; |
| 4254 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4255 | |
| 4256 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4257 | err = |
| 4258 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4259 | ASSERT_VK_SUCCESS(err); |
| 4260 | |
| 4261 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4262 | dsl_binding.binding = 0; |
| 4263 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4264 | dsl_binding.descriptorCount = 1; |
| 4265 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4266 | |
| 4267 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4268 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4269 | ds_layout_ci.bindingCount = 1; |
| 4270 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4271 | |
| 4272 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4273 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4274 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4275 | ASSERT_VK_SUCCESS(err); |
| 4276 | |
| 4277 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4278 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4279 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4280 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4281 | alloc_info.descriptorPool = ds_pool; |
| 4282 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4283 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4284 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4285 | ASSERT_VK_SUCCESS(err); |
| 4286 | |
| 4287 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4288 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4289 | pipeline_layout_ci.setLayoutCount = 1; |
| 4290 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4291 | |
| 4292 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4293 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4294 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4295 | ASSERT_VK_SUCCESS(err); |
| 4296 | |
| 4297 | VkViewport vp = {}; // Just need dummy vp to point to |
| 4298 | |
| 4299 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4300 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 4301 | vp_state_ci.scissorCount = 0; |
| 4302 | vp_state_ci.viewportCount = 1; // Count mismatch should cause error |
| 4303 | vp_state_ci.pViewports = &vp; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4304 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 4305 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 4306 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 4307 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 4308 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 4309 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 4310 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 4311 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 4312 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 4313 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 4314 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4315 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4316 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4317 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4318 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4319 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4320 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4321 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4322 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4323 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 4324 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4325 | |
| 4326 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4327 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 4328 | gp_ci.stageCount = 2; |
| 4329 | gp_ci.pStages = shaderStages; |
| 4330 | gp_ci.pViewportState = &vp_state_ci; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 4331 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4332 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 4333 | gp_ci.layout = pipeline_layout; |
| 4334 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4335 | |
| 4336 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4337 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4338 | |
| 4339 | VkPipeline pipeline; |
| 4340 | VkPipelineCache pipelineCache; |
| 4341 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4342 | err = |
| 4343 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4344 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4345 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4346 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4347 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4348 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4349 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4350 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 4351 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4352 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4353 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4354 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4355 | // Don't set viewport state in PSO. This is an error b/c we always need this |
| 4356 | // state |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4357 | // 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] | 4358 | TEST_F(VkLayerTest, PSOViewportStateNotSet) { |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4359 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4360 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4361 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4362 | m_errorMonitor->SetDesiredFailureMsg( |
| 4363 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4364 | "Gfx Pipeline pViewportState is null. Even if "); |
| 4365 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4366 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4367 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4368 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4369 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4370 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4371 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4372 | |
| 4373 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4374 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4375 | ds_pool_ci.maxSets = 1; |
| 4376 | ds_pool_ci.poolSizeCount = 1; |
| 4377 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4378 | |
| 4379 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4380 | err = |
| 4381 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4382 | ASSERT_VK_SUCCESS(err); |
| 4383 | |
| 4384 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4385 | dsl_binding.binding = 0; |
| 4386 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4387 | dsl_binding.descriptorCount = 1; |
| 4388 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4389 | |
| 4390 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4391 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4392 | ds_layout_ci.bindingCount = 1; |
| 4393 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4394 | |
| 4395 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4396 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4397 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4398 | ASSERT_VK_SUCCESS(err); |
| 4399 | |
| 4400 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4401 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4402 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4403 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4404 | alloc_info.descriptorPool = ds_pool; |
| 4405 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4406 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4407 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4408 | ASSERT_VK_SUCCESS(err); |
| 4409 | |
| 4410 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4411 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4412 | pipeline_layout_ci.setLayoutCount = 1; |
| 4413 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4414 | |
| 4415 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4416 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4417 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4418 | ASSERT_VK_SUCCESS(err); |
| 4419 | |
| 4420 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 4421 | // Set scissor as dynamic to avoid second error |
| 4422 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4423 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 4424 | dyn_state_ci.dynamicStateCount = 1; |
| 4425 | dyn_state_ci.pDynamicStates = &sc_state; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4426 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 4427 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4428 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4429 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4430 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4431 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4432 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4433 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4434 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4435 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4436 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 4437 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4438 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 4439 | |
| 4440 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 4441 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 4442 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 4443 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 4444 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 4445 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 4446 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 4447 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 4448 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4449 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4450 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 4451 | gp_ci.stageCount = 2; |
| 4452 | gp_ci.pStages = shaderStages; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 4453 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4454 | gp_ci.pViewportState = NULL; // Not setting VP state w/o dynamic vp state |
| 4455 | // should cause validation error |
| 4456 | gp_ci.pDynamicState = &dyn_state_ci; |
| 4457 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 4458 | gp_ci.layout = pipeline_layout; |
| 4459 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4460 | |
| 4461 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4462 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4463 | |
| 4464 | VkPipeline pipeline; |
| 4465 | VkPipelineCache pipelineCache; |
| 4466 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4467 | err = |
| 4468 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4469 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4470 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4471 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4472 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4473 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4474 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4475 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 4476 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4477 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4478 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4479 | } |
| 4480 | // Create PSO w/o non-zero viewportCount but no viewport data |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4481 | // Then run second test where dynamic scissor count doesn't match PSO scissor |
| 4482 | // count |
| 4483 | TEST_F(VkLayerTest, PSOViewportCountWithoutDataAndDynScissorMismatch) { |
| 4484 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4485 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4486 | m_errorMonitor->SetDesiredFailureMsg( |
| 4487 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4488 | "Gfx Pipeline viewportCount is 1, but pViewports is NULL. "); |
| 4489 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4490 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4491 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4492 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4493 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4494 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4495 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4496 | |
| 4497 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4498 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4499 | ds_pool_ci.maxSets = 1; |
| 4500 | ds_pool_ci.poolSizeCount = 1; |
| 4501 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4502 | |
| 4503 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4504 | err = |
| 4505 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4506 | ASSERT_VK_SUCCESS(err); |
| 4507 | |
| 4508 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4509 | dsl_binding.binding = 0; |
| 4510 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4511 | dsl_binding.descriptorCount = 1; |
| 4512 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4513 | |
| 4514 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4515 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4516 | ds_layout_ci.bindingCount = 1; |
| 4517 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4518 | |
| 4519 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4520 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4521 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4522 | ASSERT_VK_SUCCESS(err); |
| 4523 | |
| 4524 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4525 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4526 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4527 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4528 | alloc_info.descriptorPool = ds_pool; |
| 4529 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4530 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4531 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4532 | ASSERT_VK_SUCCESS(err); |
| 4533 | |
| 4534 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4535 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4536 | pipeline_layout_ci.setLayoutCount = 1; |
| 4537 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4538 | |
| 4539 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4540 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4541 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4542 | ASSERT_VK_SUCCESS(err); |
| 4543 | |
| 4544 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4545 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 4546 | vp_state_ci.viewportCount = 1; |
| 4547 | vp_state_ci.pViewports = NULL; // Null vp w/ count of 1 should cause error |
| 4548 | vp_state_ci.scissorCount = 1; |
| 4549 | vp_state_ci.pScissors = |
| 4550 | NULL; // Scissor is dynamic (below) so this won't cause error |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4551 | |
| 4552 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 4553 | // Set scissor as dynamic to avoid that error |
| 4554 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4555 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 4556 | dyn_state_ci.dynamicStateCount = 1; |
| 4557 | dyn_state_ci.pDynamicStates = &sc_state; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4558 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 4559 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4560 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4561 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4562 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4563 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4564 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4565 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4566 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4567 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4568 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 4569 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4570 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 4571 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 4572 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 4573 | vi_ci.pNext = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4574 | vi_ci.vertexBindingDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 4575 | vi_ci.pVertexBindingDescriptions = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4576 | vi_ci.vertexAttributeDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 4577 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 4578 | |
| 4579 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 4580 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 4581 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 4582 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4583 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4584 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 4585 | rs_ci.pNext = nullptr; |
| 4586 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 4587 | VkPipelineColorBlendAttachmentState att = {}; |
| 4588 | att.blendEnable = VK_FALSE; |
| 4589 | att.colorWriteMask = 0xf; |
| 4590 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 4591 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 4592 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 4593 | cb_ci.pNext = nullptr; |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 4594 | cb_ci.attachmentCount = 1; |
| 4595 | cb_ci.pAttachments = &att; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 4596 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4597 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4598 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 4599 | gp_ci.stageCount = 2; |
| 4600 | gp_ci.pStages = shaderStages; |
| 4601 | gp_ci.pVertexInputState = &vi_ci; |
| 4602 | gp_ci.pInputAssemblyState = &ia_ci; |
| 4603 | gp_ci.pViewportState = &vp_state_ci; |
| 4604 | gp_ci.pRasterizationState = &rs_ci; |
| 4605 | gp_ci.pColorBlendState = &cb_ci; |
| 4606 | gp_ci.pDynamicState = &dyn_state_ci; |
| 4607 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 4608 | gp_ci.layout = pipeline_layout; |
| 4609 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4610 | |
| 4611 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4612 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4613 | |
| 4614 | VkPipeline pipeline; |
| 4615 | VkPipelineCache pipelineCache; |
| 4616 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4617 | err = |
| 4618 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4619 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4620 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4621 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4622 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4623 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4624 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4625 | // 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] | 4626 | // First need to successfully create the PSO from above by setting |
| 4627 | // pViewports |
| 4628 | m_errorMonitor->SetDesiredFailureMsg( |
| 4629 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4630 | "Dynamic scissorCount from vkCmdSetScissor() is 2, but PSO " |
| 4631 | "scissorCount is 1. These counts must match."); |
| 4632 | |
| 4633 | VkViewport vp = {}; // Just need dummy vp to point to |
| 4634 | vp_state_ci.pViewports = &vp; |
| 4635 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4636 | &gp_ci, NULL, &pipeline); |
| 4637 | ASSERT_VK_SUCCESS(err); |
| 4638 | BeginCommandBuffer(); |
| 4639 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4640 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
| 4641 | VkRect2D scissors[2] = {}; // don't care about data |
| 4642 | // Count of 2 doesn't match PSO count of 1 |
| 4643 | vkCmdSetScissor(m_commandBuffer->GetBufferHandle(), 0, 2, scissors); |
| 4644 | Draw(1, 0, 0, 0); |
| 4645 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4646 | m_errorMonitor->VerifyFound(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4647 | |
| 4648 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 4649 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4650 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4651 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 4652 | } |
| 4653 | // Create PSO w/o non-zero scissorCount but no scissor data |
| 4654 | // Then run second test where dynamic viewportCount doesn't match PSO |
| 4655 | // viewportCount |
| 4656 | TEST_F(VkLayerTest, PSOScissorCountWithoutDataAndDynViewportMismatch) { |
| 4657 | VkResult err; |
| 4658 | |
| 4659 | m_errorMonitor->SetDesiredFailureMsg( |
| 4660 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4661 | "Gfx Pipeline scissorCount is 1, but pScissors is NULL. "); |
| 4662 | |
| 4663 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4664 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4665 | |
| 4666 | VkDescriptorPoolSize ds_type_count = {}; |
| 4667 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4668 | ds_type_count.descriptorCount = 1; |
| 4669 | |
| 4670 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 4671 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4672 | ds_pool_ci.maxSets = 1; |
| 4673 | ds_pool_ci.poolSizeCount = 1; |
| 4674 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 4675 | |
| 4676 | VkDescriptorPool ds_pool; |
| 4677 | err = |
| 4678 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 4679 | ASSERT_VK_SUCCESS(err); |
| 4680 | |
| 4681 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 4682 | dsl_binding.binding = 0; |
| 4683 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4684 | dsl_binding.descriptorCount = 1; |
| 4685 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4686 | |
| 4687 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 4688 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4689 | ds_layout_ci.bindingCount = 1; |
| 4690 | ds_layout_ci.pBindings = &dsl_binding; |
| 4691 | |
| 4692 | VkDescriptorSetLayout ds_layout; |
| 4693 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4694 | &ds_layout); |
| 4695 | ASSERT_VK_SUCCESS(err); |
| 4696 | |
| 4697 | VkDescriptorSet descriptorSet; |
| 4698 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 4699 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 4700 | alloc_info.descriptorSetCount = 1; |
| 4701 | alloc_info.descriptorPool = ds_pool; |
| 4702 | alloc_info.pSetLayouts = &ds_layout; |
| 4703 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4704 | &descriptorSet); |
| 4705 | ASSERT_VK_SUCCESS(err); |
| 4706 | |
| 4707 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 4708 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4709 | pipeline_layout_ci.setLayoutCount = 1; |
| 4710 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 4711 | |
| 4712 | VkPipelineLayout pipeline_layout; |
| 4713 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4714 | &pipeline_layout); |
| 4715 | ASSERT_VK_SUCCESS(err); |
| 4716 | |
| 4717 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 4718 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 4719 | vp_state_ci.scissorCount = 1; |
| 4720 | vp_state_ci.pScissors = |
| 4721 | NULL; // Null scissor w/ count of 1 should cause error |
| 4722 | vp_state_ci.viewportCount = 1; |
| 4723 | vp_state_ci.pViewports = |
| 4724 | NULL; // vp is dynamic (below) so this won't cause error |
| 4725 | |
| 4726 | VkDynamicState vp_state = VK_DYNAMIC_STATE_VIEWPORT; |
| 4727 | // Set scissor as dynamic to avoid that error |
| 4728 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 4729 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 4730 | dyn_state_ci.dynamicStateCount = 1; |
| 4731 | dyn_state_ci.pDynamicStates = &vp_state; |
| 4732 | |
| 4733 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 4734 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 4735 | |
| 4736 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4737 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4738 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4739 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4740 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4741 | // but add it to be able to run on more devices |
| 4742 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 4743 | shaderStages[1] = fs.GetStageCreateInfo(); |
| 4744 | |
| 4745 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 4746 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 4747 | vi_ci.pNext = nullptr; |
| 4748 | vi_ci.vertexBindingDescriptionCount = 0; |
| 4749 | vi_ci.pVertexBindingDescriptions = nullptr; |
| 4750 | vi_ci.vertexAttributeDescriptionCount = 0; |
| 4751 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 4752 | |
| 4753 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 4754 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 4755 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 4756 | |
| 4757 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
| 4758 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 4759 | rs_ci.pNext = nullptr; |
| 4760 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 4761 | VkPipelineColorBlendAttachmentState att = {}; |
| 4762 | att.blendEnable = VK_FALSE; |
| 4763 | att.colorWriteMask = 0xf; |
| 4764 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4765 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 4766 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 4767 | cb_ci.pNext = nullptr; |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 4768 | cb_ci.attachmentCount = 1; |
| 4769 | cb_ci.pAttachments = &att; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4770 | |
| 4771 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 4772 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 4773 | gp_ci.stageCount = 2; |
| 4774 | gp_ci.pStages = shaderStages; |
| 4775 | gp_ci.pVertexInputState = &vi_ci; |
| 4776 | gp_ci.pInputAssemblyState = &ia_ci; |
| 4777 | gp_ci.pViewportState = &vp_state_ci; |
| 4778 | gp_ci.pRasterizationState = &rs_ci; |
| 4779 | gp_ci.pColorBlendState = &cb_ci; |
| 4780 | gp_ci.pDynamicState = &dyn_state_ci; |
| 4781 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 4782 | gp_ci.layout = pipeline_layout; |
| 4783 | gp_ci.renderPass = renderPass(); |
| 4784 | |
| 4785 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 4786 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 4787 | |
| 4788 | VkPipeline pipeline; |
| 4789 | VkPipelineCache pipelineCache; |
| 4790 | |
| 4791 | err = |
| 4792 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 4793 | ASSERT_VK_SUCCESS(err); |
| 4794 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4795 | &gp_ci, NULL, &pipeline); |
| 4796 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4797 | m_errorMonitor->VerifyFound(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4798 | |
| 4799 | // Now hit second fail case where we set scissor w/ different count than PSO |
| 4800 | // First need to successfully create the PSO from above by setting |
| 4801 | // pViewports |
| 4802 | m_errorMonitor->SetDesiredFailureMsg( |
| 4803 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4804 | "Dynamic viewportCount from vkCmdSetViewport() is 2, but PSO " |
| 4805 | "viewportCount is 1. These counts must match."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4806 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4807 | VkRect2D sc = {}; // Just need dummy vp to point to |
| 4808 | vp_state_ci.pScissors = ≻ |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4809 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4810 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4811 | ASSERT_VK_SUCCESS(err); |
| 4812 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4813 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4814 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4815 | VkViewport viewports[2] = {}; // don't care about data |
| 4816 | // Count of 2 doesn't match PSO count of 1 |
Jon Ashburn | 19d3bf1 | 2015-12-30 14:06:55 -0700 | [diff] [blame] | 4817 | vkCmdSetViewport(m_commandBuffer->GetBufferHandle(), 0, 2, viewports); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4818 | Draw(1, 0, 0, 0); |
| 4819 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4820 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4821 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4822 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 4823 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4824 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4825 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4826 | } |
| 4827 | |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 4828 | TEST_F(VkLayerTest, PSOLineWidthInvalid) { |
| 4829 | VkResult err; |
| 4830 | |
| 4831 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 4832 | "Attempt to set lineWidth to -1"); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 4833 | |
| 4834 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4835 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4836 | |
| 4837 | VkDescriptorPoolSize ds_type_count = {}; |
| 4838 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4839 | ds_type_count.descriptorCount = 1; |
| 4840 | |
| 4841 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 4842 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4843 | ds_pool_ci.maxSets = 1; |
| 4844 | ds_pool_ci.poolSizeCount = 1; |
| 4845 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 4846 | |
| 4847 | VkDescriptorPool ds_pool; |
| 4848 | err = |
| 4849 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 4850 | ASSERT_VK_SUCCESS(err); |
| 4851 | |
| 4852 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 4853 | dsl_binding.binding = 0; |
| 4854 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4855 | dsl_binding.descriptorCount = 1; |
| 4856 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4857 | |
| 4858 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 4859 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4860 | ds_layout_ci.bindingCount = 1; |
| 4861 | ds_layout_ci.pBindings = &dsl_binding; |
| 4862 | |
| 4863 | VkDescriptorSetLayout ds_layout; |
| 4864 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4865 | &ds_layout); |
| 4866 | ASSERT_VK_SUCCESS(err); |
| 4867 | |
| 4868 | VkDescriptorSet descriptorSet; |
| 4869 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 4870 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 4871 | alloc_info.descriptorSetCount = 1; |
| 4872 | alloc_info.descriptorPool = ds_pool; |
| 4873 | alloc_info.pSetLayouts = &ds_layout; |
| 4874 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4875 | &descriptorSet); |
| 4876 | ASSERT_VK_SUCCESS(err); |
| 4877 | |
| 4878 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 4879 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4880 | pipeline_layout_ci.setLayoutCount = 1; |
| 4881 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 4882 | |
| 4883 | VkPipelineLayout pipeline_layout; |
| 4884 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4885 | &pipeline_layout); |
| 4886 | ASSERT_VK_SUCCESS(err); |
| 4887 | |
| 4888 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 4889 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 4890 | vp_state_ci.scissorCount = 1; |
| 4891 | vp_state_ci.pScissors = NULL; |
| 4892 | vp_state_ci.viewportCount = 1; |
| 4893 | vp_state_ci.pViewports = NULL; |
| 4894 | |
| 4895 | VkDynamicState dynamic_states[3] = {VK_DYNAMIC_STATE_VIEWPORT, |
| 4896 | VK_DYNAMIC_STATE_SCISSOR, |
| 4897 | VK_DYNAMIC_STATE_LINE_WIDTH}; |
| 4898 | // Set scissor as dynamic to avoid that error |
| 4899 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 4900 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 4901 | dyn_state_ci.dynamicStateCount = 2; |
| 4902 | dyn_state_ci.pDynamicStates = dynamic_states; |
| 4903 | |
| 4904 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 4905 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 4906 | |
| 4907 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4908 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4909 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4910 | VK_SHADER_STAGE_FRAGMENT_BIT, |
| 4911 | this); // TODO - We shouldn't need a fragment shader |
| 4912 | // but add it to be able to run on more devices |
| 4913 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 4914 | shaderStages[1] = fs.GetStageCreateInfo(); |
| 4915 | |
| 4916 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 4917 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 4918 | vi_ci.pNext = nullptr; |
| 4919 | vi_ci.vertexBindingDescriptionCount = 0; |
| 4920 | vi_ci.pVertexBindingDescriptions = nullptr; |
| 4921 | vi_ci.vertexAttributeDescriptionCount = 0; |
| 4922 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 4923 | |
| 4924 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 4925 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 4926 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 4927 | |
| 4928 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
| 4929 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 4930 | rs_ci.pNext = nullptr; |
| 4931 | |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 4932 | // Check too low (line width of -1.0f). |
| 4933 | rs_ci.lineWidth = -1.0f; |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 4934 | |
| 4935 | VkPipelineColorBlendAttachmentState att = {}; |
| 4936 | att.blendEnable = VK_FALSE; |
| 4937 | att.colorWriteMask = 0xf; |
| 4938 | |
| 4939 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 4940 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 4941 | cb_ci.pNext = nullptr; |
| 4942 | cb_ci.attachmentCount = 1; |
| 4943 | cb_ci.pAttachments = &att; |
| 4944 | |
| 4945 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 4946 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 4947 | gp_ci.stageCount = 2; |
| 4948 | gp_ci.pStages = shaderStages; |
| 4949 | gp_ci.pVertexInputState = &vi_ci; |
| 4950 | gp_ci.pInputAssemblyState = &ia_ci; |
| 4951 | gp_ci.pViewportState = &vp_state_ci; |
| 4952 | gp_ci.pRasterizationState = &rs_ci; |
| 4953 | gp_ci.pColorBlendState = &cb_ci; |
| 4954 | gp_ci.pDynamicState = &dyn_state_ci; |
| 4955 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 4956 | gp_ci.layout = pipeline_layout; |
| 4957 | gp_ci.renderPass = renderPass(); |
| 4958 | |
| 4959 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 4960 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 4961 | |
| 4962 | VkPipeline pipeline; |
| 4963 | VkPipelineCache pipelineCache; |
| 4964 | |
| 4965 | err = |
| 4966 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 4967 | ASSERT_VK_SUCCESS(err); |
| 4968 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4969 | &gp_ci, NULL, &pipeline); |
| 4970 | |
| 4971 | m_errorMonitor->VerifyFound(); |
| 4972 | |
| 4973 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4974 | "Attempt to set lineWidth to 65536"); |
| 4975 | |
| 4976 | // Check too high (line width of 65536.0f). |
| 4977 | rs_ci.lineWidth = 65536.0f; |
| 4978 | |
| 4979 | err = |
| 4980 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 4981 | ASSERT_VK_SUCCESS(err); |
| 4982 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4983 | &gp_ci, NULL, &pipeline); |
| 4984 | |
| 4985 | m_errorMonitor->VerifyFound(); |
| 4986 | |
| 4987 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 4988 | "Attempt to set lineWidth to -1"); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 4989 | |
| 4990 | dyn_state_ci.dynamicStateCount = 3; |
| 4991 | |
| 4992 | rs_ci.lineWidth = 1.0f; |
| 4993 | |
| 4994 | err = |
| 4995 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 4996 | ASSERT_VK_SUCCESS(err); |
| 4997 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4998 | &gp_ci, NULL, &pipeline); |
| 4999 | BeginCommandBuffer(); |
| 5000 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 5001 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
| 5002 | |
| 5003 | // Check too low with dynamic setting. |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 5004 | vkCmdSetLineWidth(m_commandBuffer->GetBufferHandle(), -1.0f); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 5005 | m_errorMonitor->VerifyFound(); |
| 5006 | |
| 5007 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5008 | "Attempt to set lineWidth to 65536"); |
| 5009 | |
| 5010 | // Check too high with dynamic setting. |
| 5011 | vkCmdSetLineWidth(m_commandBuffer->GetBufferHandle(), 65536.0f); |
| 5012 | m_errorMonitor->VerifyFound(); |
| 5013 | EndCommandBuffer(); |
| 5014 | |
| 5015 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 5016 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5017 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5018 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 5019 | } |
| 5020 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5021 | TEST_F(VkLayerTest, NullRenderPass) { |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 5022 | // Bind a NULL RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5023 | m_errorMonitor->SetDesiredFailureMsg( |
| 5024 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5025 | "You cannot use a NULL RenderPass object in vkCmdBeginRenderPass()"); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 5026 | |
| 5027 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5028 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 5029 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 5030 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5031 | // Don't care about RenderPass handle b/c error should be flagged before |
| 5032 | // that |
| 5033 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), NULL, |
| 5034 | VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 5035 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5036 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 5037 | } |
| 5038 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5039 | TEST_F(VkLayerTest, RenderPassWithinRenderPass) { |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5040 | // Bind a BeginRenderPass within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5041 | m_errorMonitor->SetDesiredFailureMsg( |
| 5042 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5043 | "It is invalid to issue this call inside an active render pass"); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5044 | |
| 5045 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5046 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5047 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 5048 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5049 | // Just create a dummy Renderpass that's non-NULL so we can get to the |
| 5050 | // proper error |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5051 | VkRenderPassBeginInfo rp_begin = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5052 | rp_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; |
| 5053 | rp_begin.pNext = NULL; |
| 5054 | rp_begin.renderPass = renderPass(); |
| 5055 | rp_begin.framebuffer = framebuffer(); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 5056 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5057 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &rp_begin, |
| 5058 | VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5059 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5060 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5061 | } |
| 5062 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5063 | TEST_F(VkLayerTest, FillBufferWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5064 | // Call CmdFillBuffer within an active renderpass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5065 | m_errorMonitor->SetDesiredFailureMsg( |
| 5066 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5067 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5068 | |
| 5069 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5070 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5071 | |
| 5072 | // Renderpass is started here |
| 5073 | BeginCommandBuffer(); |
| 5074 | |
| 5075 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5076 | vk_testing::Buffer dstBuffer; |
| 5077 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5078 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5079 | m_commandBuffer->FillBuffer(dstBuffer.handle(), 0, 4, 0x11111111); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5080 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5081 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5082 | } |
| 5083 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5084 | TEST_F(VkLayerTest, UpdateBufferWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5085 | // Call CmdUpdateBuffer within an active renderpass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5086 | m_errorMonitor->SetDesiredFailureMsg( |
| 5087 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5088 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5089 | |
| 5090 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5091 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5092 | |
| 5093 | // Renderpass is started here |
| 5094 | BeginCommandBuffer(); |
| 5095 | |
| 5096 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5097 | vk_testing::Buffer dstBuffer; |
| 5098 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5099 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5100 | VkDeviceSize dstOffset = 0; |
| 5101 | VkDeviceSize dataSize = 1024; |
| 5102 | const uint32_t *pData = NULL; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5103 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5104 | vkCmdUpdateBuffer(m_commandBuffer->GetBufferHandle(), dstBuffer.handle(), |
| 5105 | dstOffset, dataSize, pData); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5106 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5107 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5108 | } |
| 5109 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5110 | TEST_F(VkLayerTest, ClearColorImageWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5111 | // Call CmdClearColorImage within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5112 | m_errorMonitor->SetDesiredFailureMsg( |
| 5113 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5114 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5115 | |
| 5116 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5117 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5118 | |
| 5119 | // Renderpass is started here |
| 5120 | BeginCommandBuffer(); |
| 5121 | |
Michael Lentine | 0a369f6 | 2016-02-03 16:51:46 -0600 | [diff] [blame] | 5122 | VkClearColorValue clear_color; |
| 5123 | memset(clear_color.uint32, 0, sizeof(uint32_t) * 4); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5124 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 5125 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5126 | const int32_t tex_width = 32; |
| 5127 | const int32_t tex_height = 32; |
| 5128 | VkImageCreateInfo image_create_info = {}; |
| 5129 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5130 | image_create_info.pNext = NULL; |
| 5131 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5132 | image_create_info.format = tex_format; |
| 5133 | image_create_info.extent.width = tex_width; |
| 5134 | image_create_info.extent.height = tex_height; |
| 5135 | image_create_info.extent.depth = 1; |
| 5136 | image_create_info.mipLevels = 1; |
| 5137 | image_create_info.arrayLayers = 1; |
| 5138 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 5139 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 5140 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5141 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5142 | vk_testing::Image dstImage; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5143 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 5144 | reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5145 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5146 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
| 5147 | image_create_info, VK_IMAGE_ASPECT_COLOR_BIT); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5148 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5149 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), dstImage.handle(), |
| 5150 | VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1, &range); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5151 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5152 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5153 | } |
| 5154 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5155 | TEST_F(VkLayerTest, ClearDepthStencilImageWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5156 | // Call CmdClearDepthStencilImage within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5157 | m_errorMonitor->SetDesiredFailureMsg( |
| 5158 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5159 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5160 | |
| 5161 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5162 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5163 | |
| 5164 | // Renderpass is started here |
| 5165 | BeginCommandBuffer(); |
| 5166 | |
| 5167 | VkClearDepthStencilValue clear_value = {0}; |
Dustin Graves | a2e5c94 | 2016-02-11 18:28:06 -0700 | [diff] [blame] | 5168 | VkMemoryPropertyFlags reqs = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5169 | VkImageCreateInfo image_create_info = vk_testing::Image::create_info(); |
| 5170 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5171 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 5172 | image_create_info.extent.width = 64; |
| 5173 | image_create_info.extent.height = 64; |
| 5174 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 5175 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5176 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5177 | vk_testing::Image dstImage; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5178 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 5179 | reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5180 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5181 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
| 5182 | image_create_info, VK_IMAGE_ASPECT_DEPTH_BIT); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5183 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5184 | vkCmdClearDepthStencilImage( |
| 5185 | m_commandBuffer->GetBufferHandle(), dstImage.handle(), |
| 5186 | VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, &clear_value, 1, |
| 5187 | &range); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5188 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5189 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5190 | } |
| 5191 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5192 | TEST_F(VkLayerTest, ClearColorAttachmentsOutsideRenderPass) { |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 5193 | // Call CmdClearAttachmentss outside of an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5194 | VkResult err; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5195 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5196 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5197 | "vkCmdClearAttachments: This call " |
| 5198 | "must be issued inside an active " |
| 5199 | "render pass"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5200 | |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5201 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5202 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5203 | |
| 5204 | // Start no RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5205 | err = m_commandBuffer->BeginCommandBuffer(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5206 | ASSERT_VK_SUCCESS(err); |
| 5207 | |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 5208 | VkClearAttachment color_attachment; |
| 5209 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 5210 | color_attachment.clearValue.color.float32[0] = 0; |
| 5211 | color_attachment.clearValue.color.float32[1] = 0; |
| 5212 | color_attachment.clearValue.color.float32[2] = 0; |
| 5213 | color_attachment.clearValue.color.float32[3] = 0; |
| 5214 | color_attachment.colorAttachment = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5215 | VkClearRect clear_rect = {{{0, 0}, {32, 32}}}; |
| 5216 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
| 5217 | &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5218 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5219 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5220 | } |
| 5221 | |
Karl Schultz | 9e66a29 | 2016-04-21 15:57:51 -0600 | [diff] [blame] | 5222 | TEST_F(VkLayerTest, BufferMemoryBarrierNoBuffer) { |
| 5223 | // Try to add a buffer memory barrier with no buffer. |
| 5224 | m_errorMonitor->SetDesiredFailureMsg( |
| 5225 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5226 | "required parameter pBufferMemoryBarriers[i].buffer specified as VK_NULL_HANDLE"); |
| 5227 | |
| 5228 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5229 | BeginCommandBuffer(); |
| 5230 | |
| 5231 | VkBufferMemoryBarrier buf_barrier = {}; |
| 5232 | buf_barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; |
| 5233 | buf_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 5234 | buf_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 5235 | buf_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 5236 | buf_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 5237 | buf_barrier.buffer = VK_NULL_HANDLE; |
| 5238 | buf_barrier.offset = 0; |
| 5239 | buf_barrier.size = VK_WHOLE_SIZE; |
| 5240 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 5241 | VK_PIPELINE_STAGE_HOST_BIT, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, |
| 5242 | 0, 0, nullptr, 1, &buf_barrier, 0, nullptr); |
| 5243 | |
| 5244 | m_errorMonitor->VerifyFound(); |
| 5245 | } |
| 5246 | |
Tony Barbour | 7fd5c0f | 2016-05-03 16:11:53 -0600 | [diff] [blame] | 5247 | TEST_F(VkLayerTest, InvalidBarriers) { |
| 5248 | TEST_DESCRIPTION("A variety of ways to get VK_INVALID_BARRIER "); |
| 5249 | |
| 5250 | m_errorMonitor->SetDesiredFailureMsg( |
| 5251 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Barriers cannot be set during subpass"); |
| 5252 | |
| 5253 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5254 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5255 | |
| 5256 | VkMemoryBarrier mem_barrier = {}; |
| 5257 | mem_barrier.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER; |
| 5258 | mem_barrier.pNext = NULL; |
| 5259 | mem_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 5260 | mem_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 5261 | BeginCommandBuffer(); |
| 5262 | // BeginCommandBuffer() starts a render pass |
| 5263 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 5264 | VK_PIPELINE_STAGE_HOST_BIT, |
| 5265 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 1, |
| 5266 | &mem_barrier, 0, nullptr, 0, nullptr); |
| 5267 | m_errorMonitor->VerifyFound(); |
| 5268 | |
| 5269 | m_errorMonitor->SetDesiredFailureMsg( |
| 5270 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5271 | "Image Layout cannot be transitioned to UNDEFINED"); |
| 5272 | VkImageObj image(m_device); |
| 5273 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 5274 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
| 5275 | ASSERT_TRUE(image.initialized()); |
| 5276 | VkImageMemoryBarrier img_barrier = {}; |
| 5277 | img_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; |
| 5278 | img_barrier.pNext = NULL; |
| 5279 | img_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 5280 | img_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 5281 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 5282 | // New layout can't be UNDEFINED |
| 5283 | img_barrier.newLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 5284 | img_barrier.image = image.handle(); |
| 5285 | img_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 5286 | img_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 5287 | img_barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 5288 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 5289 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 5290 | img_barrier.subresourceRange.layerCount = 1; |
| 5291 | img_barrier.subresourceRange.levelCount = 1; |
| 5292 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 5293 | VK_PIPELINE_STAGE_HOST_BIT, |
| 5294 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 5295 | nullptr, 1, &img_barrier); |
| 5296 | m_errorMonitor->VerifyFound(); |
| 5297 | img_barrier.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 5298 | |
| 5299 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5300 | "Subresource must have the sum of the " |
| 5301 | "baseArrayLayer"); |
| 5302 | // baseArrayLayer + layerCount must be <= image's arrayLayers |
| 5303 | img_barrier.subresourceRange.baseArrayLayer = 1; |
| 5304 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 5305 | VK_PIPELINE_STAGE_HOST_BIT, |
| 5306 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 5307 | nullptr, 1, &img_barrier); |
| 5308 | m_errorMonitor->VerifyFound(); |
| 5309 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 5310 | |
| 5311 | m_errorMonitor->SetDesiredFailureMsg( |
| 5312 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5313 | "Subresource must have the sum of the baseMipLevel"); |
| 5314 | // baseMipLevel + levelCount must be <= image's mipLevels |
| 5315 | img_barrier.subresourceRange.baseMipLevel = 1; |
| 5316 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 5317 | VK_PIPELINE_STAGE_HOST_BIT, |
| 5318 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 5319 | nullptr, 1, &img_barrier); |
| 5320 | m_errorMonitor->VerifyFound(); |
| 5321 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 5322 | |
| 5323 | m_errorMonitor->SetDesiredFailureMsg( |
| 5324 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5325 | "Buffer Barriers cannot be used during a render pass"); |
| 5326 | vk_testing::Buffer buffer; |
| 5327 | buffer.init(*m_device, 256); |
| 5328 | VkBufferMemoryBarrier buf_barrier = {}; |
| 5329 | buf_barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; |
| 5330 | buf_barrier.pNext = NULL; |
| 5331 | buf_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 5332 | buf_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 5333 | buf_barrier.buffer = buffer.handle(); |
| 5334 | buf_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 5335 | buf_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 5336 | buf_barrier.offset = 0; |
| 5337 | buf_barrier.size = VK_WHOLE_SIZE; |
| 5338 | // Can't send buffer barrier during a render pass |
| 5339 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 5340 | VK_PIPELINE_STAGE_HOST_BIT, |
| 5341 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 5342 | &buf_barrier, 0, nullptr); |
| 5343 | m_errorMonitor->VerifyFound(); |
| 5344 | vkCmdEndRenderPass(m_commandBuffer->GetBufferHandle()); |
| 5345 | |
| 5346 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5347 | "which is not less than total size"); |
| 5348 | buf_barrier.offset = 257; |
| 5349 | // Offset greater than total size |
| 5350 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 5351 | VK_PIPELINE_STAGE_HOST_BIT, |
| 5352 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 5353 | &buf_barrier, 0, nullptr); |
| 5354 | m_errorMonitor->VerifyFound(); |
| 5355 | buf_barrier.offset = 0; |
| 5356 | |
| 5357 | m_errorMonitor->SetDesiredFailureMsg( |
| 5358 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "whose sum is greater than total size"); |
| 5359 | buf_barrier.size = 257; |
| 5360 | // Size greater than total size |
| 5361 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 5362 | VK_PIPELINE_STAGE_HOST_BIT, |
| 5363 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 5364 | &buf_barrier, 0, nullptr); |
| 5365 | m_errorMonitor->VerifyFound(); |
| 5366 | buf_barrier.size = VK_WHOLE_SIZE; |
| 5367 | |
| 5368 | m_errorMonitor->SetDesiredFailureMsg( |
| 5369 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5370 | "Image is a depth and stencil format and thus must " |
| 5371 | "have both VK_IMAGE_ASPECT_DEPTH_BIT and " |
| 5372 | "VK_IMAGE_ASPECT_STENCIL_BIT set."); |
| 5373 | VkDepthStencilObj ds_image(m_device); |
| 5374 | ds_image.Init(m_device, 128, 128, VK_FORMAT_D24_UNORM_S8_UINT); |
| 5375 | ASSERT_TRUE(ds_image.initialized()); |
| 5376 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 5377 | img_barrier.newLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; |
| 5378 | img_barrier.image = ds_image.handle(); |
| 5379 | // Leave aspectMask at COLOR on purpose |
| 5380 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 5381 | VK_PIPELINE_STAGE_HOST_BIT, |
| 5382 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 5383 | nullptr, 1, &img_barrier); |
| 5384 | m_errorMonitor->VerifyFound(); |
| 5385 | } |
| 5386 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5387 | TEST_F(VkLayerTest, IdxBufferAlignmentError) { |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5388 | // Bind a BeginRenderPass within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5389 | VkResult err; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5390 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5391 | m_errorMonitor->SetDesiredFailureMsg( |
| 5392 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5393 | "vkCmdBindIndexBuffer() offset (0x7) does not fall on "); |
| 5394 | |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5395 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5396 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5397 | uint32_t qfi = 0; |
| 5398 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5399 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 5400 | buffCI.size = 1024; |
| 5401 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
| 5402 | buffCI.queueFamilyIndexCount = 1; |
| 5403 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5404 | |
| 5405 | VkBuffer ib; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5406 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5407 | ASSERT_VK_SUCCESS(err); |
| 5408 | |
| 5409 | BeginCommandBuffer(); |
| 5410 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5411 | // vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 5412 | // VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5413 | // 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] | 5414 | vkCmdBindIndexBuffer(m_commandBuffer->GetBufferHandle(), ib, 7, |
| 5415 | VK_INDEX_TYPE_UINT16); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5416 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5417 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5418 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5419 | vkDestroyBuffer(m_device->device(), ib, NULL); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5420 | } |
| 5421 | |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 5422 | TEST_F(VkLayerTest, InvalidQueueFamilyIndex) { |
| 5423 | // Create an out-of-range queueFamilyIndex |
| 5424 | m_errorMonitor->SetDesiredFailureMsg( |
| 5425 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 5426 | "queueFamilyIndex 777, must have been given when the device was created."); |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 5427 | |
| 5428 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5429 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5430 | VkBufferCreateInfo buffCI = {}; |
| 5431 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 5432 | buffCI.size = 1024; |
| 5433 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
| 5434 | buffCI.queueFamilyIndexCount = 1; |
| 5435 | // Introduce failure by specifying invalid queue_family_index |
| 5436 | uint32_t qfi = 777; |
| 5437 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 5438 | buffCI.sharingMode = VK_SHARING_MODE_CONCURRENT; // qfi only matters in CONCURRENT mode |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 5439 | |
| 5440 | VkBuffer ib; |
| 5441 | vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
| 5442 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5443 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 5444 | } |
| 5445 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5446 | TEST_F(VkLayerTest, ExecuteCommandsPrimaryCB) { |
| 5447 | // Attempt vkCmdExecuteCommands w/ a primary cmd buffer (should only be |
| 5448 | // secondary) |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5449 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5450 | m_errorMonitor->SetDesiredFailureMsg( |
| 5451 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5452 | "vkCmdExecuteCommands() called w/ Primary Cmd Buffer "); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 5453 | |
| 5454 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5455 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 5456 | |
| 5457 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5458 | // ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5459 | VkCommandBuffer primCB = m_commandBuffer->GetBufferHandle(); |
| 5460 | vkCmdExecuteCommands(m_commandBuffer->GetBufferHandle(), 1, &primCB); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 5461 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5462 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 5463 | } |
| 5464 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5465 | TEST_F(VkLayerTest, DSTypeMismatch) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5466 | // 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] | 5467 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5468 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5469 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5470 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5471 | " binding #0 with type VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER but update " |
| 5472 | "type is VK_DESCRIPTOR_TYPE_SAMPLER"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5473 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5474 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5475 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5476 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5477 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5478 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5479 | |
| 5480 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5481 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5482 | ds_pool_ci.pNext = NULL; |
| 5483 | ds_pool_ci.maxSets = 1; |
| 5484 | ds_pool_ci.poolSizeCount = 1; |
| 5485 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5486 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5487 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5488 | err = |
| 5489 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5490 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5491 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5492 | dsl_binding.binding = 0; |
| 5493 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5494 | dsl_binding.descriptorCount = 1; |
| 5495 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5496 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5497 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5498 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5499 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5500 | ds_layout_ci.pNext = NULL; |
| 5501 | ds_layout_ci.bindingCount = 1; |
| 5502 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5503 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5504 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5505 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5506 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5507 | ASSERT_VK_SUCCESS(err); |
| 5508 | |
| 5509 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5510 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5511 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5512 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5513 | alloc_info.descriptorPool = ds_pool; |
| 5514 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5515 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5516 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5517 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5518 | |
Tobin Ehlis | 30db8f8 | 2016-05-05 08:19:48 -0600 | [diff] [blame] | 5519 | VkSamplerCreateInfo sampler_ci = {}; |
| 5520 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 5521 | sampler_ci.pNext = NULL; |
| 5522 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 5523 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 5524 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 5525 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5526 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5527 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5528 | sampler_ci.mipLodBias = 1.0; |
| 5529 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 5530 | sampler_ci.maxAnisotropy = 1; |
| 5531 | sampler_ci.compareEnable = VK_FALSE; |
| 5532 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 5533 | sampler_ci.minLod = 1.0; |
| 5534 | sampler_ci.maxLod = 1.0; |
| 5535 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 5536 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
| 5537 | VkSampler sampler; |
| 5538 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
| 5539 | ASSERT_VK_SUCCESS(err); |
| 5540 | |
| 5541 | VkDescriptorImageInfo info = {}; |
| 5542 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5543 | |
| 5544 | VkWriteDescriptorSet descriptor_write; |
| 5545 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 5546 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5547 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5548 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5549 | // This is a mismatched type for the layout which expects BUFFER |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5550 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 5551 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5552 | |
| 5553 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5554 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5555 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5556 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5557 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 5558 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5559 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5560 | } |
| 5561 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5562 | TEST_F(VkLayerTest, DSUpdateOutOfBounds) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5563 | // For overlapping Update, have arrayIndex exceed that of layout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5564 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5565 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5566 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5567 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5568 | " binding #0 with 1 total descriptors but update of 1 descriptors " |
| 5569 | "starting at binding offset of 0 combined with update array element " |
| 5570 | "offset of 1 oversteps the size of this descriptor set."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5571 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5572 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5573 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5574 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5575 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5576 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5577 | |
| 5578 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5579 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5580 | ds_pool_ci.pNext = NULL; |
| 5581 | ds_pool_ci.maxSets = 1; |
| 5582 | ds_pool_ci.poolSizeCount = 1; |
| 5583 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5584 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5585 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5586 | err = |
| 5587 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5588 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5589 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5590 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5591 | dsl_binding.binding = 0; |
| 5592 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5593 | dsl_binding.descriptorCount = 1; |
| 5594 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5595 | dsl_binding.pImmutableSamplers = NULL; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5596 | |
| 5597 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5598 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5599 | ds_layout_ci.pNext = NULL; |
| 5600 | ds_layout_ci.bindingCount = 1; |
| 5601 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5602 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5603 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5604 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5605 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5606 | ASSERT_VK_SUCCESS(err); |
| 5607 | |
| 5608 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5609 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5610 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5611 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5612 | alloc_info.descriptorPool = ds_pool; |
| 5613 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5614 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5615 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5616 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5617 | |
Tobin Ehlis | 30db8f8 | 2016-05-05 08:19:48 -0600 | [diff] [blame] | 5618 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 5619 | VkDescriptorBufferInfo buff_info = {}; |
| 5620 | buff_info.buffer = |
| 5621 | VkBuffer(0); // Don't care about buffer handle for this test |
| 5622 | buff_info.offset = 0; |
| 5623 | buff_info.range = 1024; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5624 | |
| 5625 | VkWriteDescriptorSet descriptor_write; |
| 5626 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 5627 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5628 | descriptor_write.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5629 | descriptor_write.dstArrayElement = |
| 5630 | 1; /* This index out of bounds for the update */ |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5631 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5632 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5633 | descriptor_write.pBufferInfo = &buff_info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5634 | |
| 5635 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5636 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5637 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5638 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5639 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5640 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5641 | } |
| 5642 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5643 | TEST_F(VkLayerTest, InvalidDSUpdateIndex) { |
| 5644 | // Create layout w/ count of 1 and attempt update to that layout w/ binding |
| 5645 | // index 2 |
| 5646 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5647 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5648 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5649 | " does not have binding 2."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5650 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5651 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5652 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5653 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5654 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5655 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5656 | |
| 5657 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5658 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5659 | ds_pool_ci.pNext = NULL; |
| 5660 | ds_pool_ci.maxSets = 1; |
| 5661 | ds_pool_ci.poolSizeCount = 1; |
| 5662 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 5663 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5664 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5665 | err = |
| 5666 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5667 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5668 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5669 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5670 | dsl_binding.binding = 0; |
| 5671 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5672 | dsl_binding.descriptorCount = 1; |
| 5673 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5674 | dsl_binding.pImmutableSamplers = NULL; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5675 | |
| 5676 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5677 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5678 | ds_layout_ci.pNext = NULL; |
| 5679 | ds_layout_ci.bindingCount = 1; |
| 5680 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5681 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5682 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5683 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5684 | ASSERT_VK_SUCCESS(err); |
| 5685 | |
| 5686 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5687 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5688 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5689 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5690 | alloc_info.descriptorPool = ds_pool; |
| 5691 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5692 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5693 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5694 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5695 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5696 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5697 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 5698 | sampler_ci.pNext = NULL; |
| 5699 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 5700 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 5701 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 5702 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5703 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5704 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5705 | sampler_ci.mipLodBias = 1.0; |
| 5706 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 5707 | sampler_ci.maxAnisotropy = 1; |
| 5708 | sampler_ci.compareEnable = VK_FALSE; |
| 5709 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 5710 | sampler_ci.minLod = 1.0; |
| 5711 | sampler_ci.maxLod = 1.0; |
| 5712 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 5713 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5714 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5715 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5716 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5717 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5718 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 5719 | VkDescriptorImageInfo info = {}; |
| 5720 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5721 | |
| 5722 | VkWriteDescriptorSet descriptor_write; |
| 5723 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 5724 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5725 | descriptor_write.dstSet = descriptorSet; |
| 5726 | descriptor_write.dstBinding = 2; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5727 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5728 | // 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] | 5729 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 5730 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5731 | |
| 5732 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5733 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5734 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5735 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5736 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 5737 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5738 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5739 | } |
| 5740 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5741 | TEST_F(VkLayerTest, InvalidDSUpdateStruct) { |
| 5742 | // Call UpdateDS w/ struct type other than valid VK_STRUCTUR_TYPE_UPDATE_* |
| 5743 | // types |
| 5744 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5745 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5746 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5747 | "Unexpected UPDATE struct of type "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5748 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5749 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 5750 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5751 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5752 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5753 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5754 | |
| 5755 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5756 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5757 | ds_pool_ci.pNext = NULL; |
| 5758 | ds_pool_ci.maxSets = 1; |
| 5759 | ds_pool_ci.poolSizeCount = 1; |
| 5760 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 5761 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5762 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5763 | err = |
| 5764 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5765 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5766 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5767 | dsl_binding.binding = 0; |
| 5768 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5769 | dsl_binding.descriptorCount = 1; |
| 5770 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5771 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5772 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5773 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5774 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5775 | ds_layout_ci.pNext = NULL; |
| 5776 | ds_layout_ci.bindingCount = 1; |
| 5777 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5778 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5779 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5780 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5781 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5782 | ASSERT_VK_SUCCESS(err); |
| 5783 | |
| 5784 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5785 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5786 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5787 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5788 | alloc_info.descriptorPool = ds_pool; |
| 5789 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5790 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5791 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5792 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5793 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5794 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5795 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 5796 | sampler_ci.pNext = NULL; |
| 5797 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 5798 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 5799 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 5800 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5801 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5802 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5803 | sampler_ci.mipLodBias = 1.0; |
| 5804 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 5805 | sampler_ci.maxAnisotropy = 1; |
| 5806 | sampler_ci.compareEnable = VK_FALSE; |
| 5807 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 5808 | sampler_ci.minLod = 1.0; |
| 5809 | sampler_ci.maxLod = 1.0; |
| 5810 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 5811 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5812 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5813 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5814 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5815 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 5816 | VkDescriptorImageInfo info = {}; |
| 5817 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5818 | |
| 5819 | VkWriteDescriptorSet descriptor_write; |
| 5820 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5821 | descriptor_write.sType = |
| 5822 | (VkStructureType)0x99999999; /* Intentionally broken struct type */ |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5823 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5824 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5825 | // 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] | 5826 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 5827 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5828 | |
| 5829 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5830 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5831 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5832 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5833 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 5834 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5835 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5836 | } |
| 5837 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5838 | TEST_F(VkLayerTest, SampleDescriptorUpdateError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5839 | // Create a single Sampler descriptor and send it an invalid Sampler |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5840 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5841 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5842 | m_errorMonitor->SetDesiredFailureMsg( |
| 5843 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5844 | "Attempted write update to sampler descriptor with invalid sampler"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5845 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5846 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5847 | // TODO : Farm Descriptor setup code to helper function(s) to reduce copied |
| 5848 | // code |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5849 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5850 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 5851 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5852 | |
| 5853 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5854 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5855 | ds_pool_ci.pNext = NULL; |
| 5856 | ds_pool_ci.maxSets = 1; |
| 5857 | ds_pool_ci.poolSizeCount = 1; |
| 5858 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5859 | |
| 5860 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5861 | err = |
| 5862 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5863 | ASSERT_VK_SUCCESS(err); |
| 5864 | |
| 5865 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5866 | dsl_binding.binding = 0; |
| 5867 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 5868 | dsl_binding.descriptorCount = 1; |
| 5869 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5870 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5871 | |
| 5872 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5873 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5874 | ds_layout_ci.pNext = NULL; |
| 5875 | ds_layout_ci.bindingCount = 1; |
| 5876 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5877 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5878 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5879 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5880 | ASSERT_VK_SUCCESS(err); |
| 5881 | |
| 5882 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5883 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5884 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5885 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5886 | alloc_info.descriptorPool = ds_pool; |
| 5887 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5888 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5889 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5890 | ASSERT_VK_SUCCESS(err); |
| 5891 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5892 | VkSampler sampler = |
| 5893 | (VkSampler)((size_t)0xbaadbeef); // Sampler with invalid handle |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5894 | |
| 5895 | VkDescriptorImageInfo descriptor_info; |
| 5896 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 5897 | descriptor_info.sampler = sampler; |
| 5898 | |
| 5899 | VkWriteDescriptorSet descriptor_write; |
| 5900 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 5901 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5902 | descriptor_write.dstSet = descriptorSet; |
| 5903 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5904 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5905 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 5906 | descriptor_write.pImageInfo = &descriptor_info; |
| 5907 | |
| 5908 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5909 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5910 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5911 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5912 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5913 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5914 | } |
| 5915 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5916 | TEST_F(VkLayerTest, ImageViewDescriptorUpdateError) { |
| 5917 | // Create a single combined Image/Sampler descriptor and send it an invalid |
| 5918 | // imageView |
| 5919 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5920 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5921 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5922 | "Attempted write update to combined " |
| 5923 | "image sampler descriptor failed due " |
Tobin Ehlis | 63c4b8a | 2016-05-09 10:29:34 -0600 | [diff] [blame] | 5924 | "to: Invalid VkImageView:"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5925 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5926 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5927 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5928 | ds_type_count.type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 5929 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5930 | |
| 5931 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5932 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5933 | ds_pool_ci.pNext = NULL; |
| 5934 | ds_pool_ci.maxSets = 1; |
| 5935 | ds_pool_ci.poolSizeCount = 1; |
| 5936 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5937 | |
| 5938 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5939 | err = |
| 5940 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5941 | ASSERT_VK_SUCCESS(err); |
| 5942 | |
| 5943 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5944 | dsl_binding.binding = 0; |
| 5945 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 5946 | dsl_binding.descriptorCount = 1; |
| 5947 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5948 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5949 | |
| 5950 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5951 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5952 | ds_layout_ci.pNext = NULL; |
| 5953 | ds_layout_ci.bindingCount = 1; |
| 5954 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5955 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5956 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5957 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5958 | ASSERT_VK_SUCCESS(err); |
| 5959 | |
| 5960 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5961 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5962 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5963 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5964 | alloc_info.descriptorPool = ds_pool; |
| 5965 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5966 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5967 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5968 | ASSERT_VK_SUCCESS(err); |
| 5969 | |
| 5970 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5971 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 5972 | sampler_ci.pNext = NULL; |
| 5973 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 5974 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 5975 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 5976 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5977 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5978 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5979 | sampler_ci.mipLodBias = 1.0; |
| 5980 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 5981 | sampler_ci.maxAnisotropy = 1; |
| 5982 | sampler_ci.compareEnable = VK_FALSE; |
| 5983 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 5984 | sampler_ci.minLod = 1.0; |
| 5985 | sampler_ci.maxLod = 1.0; |
| 5986 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 5987 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5988 | |
| 5989 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5990 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5991 | ASSERT_VK_SUCCESS(err); |
| 5992 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5993 | VkImageView view = |
| 5994 | (VkImageView)((size_t)0xbaadbeef); // invalid imageView object |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5995 | |
| 5996 | VkDescriptorImageInfo descriptor_info; |
| 5997 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 5998 | descriptor_info.sampler = sampler; |
| 5999 | descriptor_info.imageView = view; |
| 6000 | |
| 6001 | VkWriteDescriptorSet descriptor_write; |
| 6002 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 6003 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6004 | descriptor_write.dstSet = descriptorSet; |
| 6005 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6006 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6007 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 6008 | descriptor_write.pImageInfo = &descriptor_info; |
| 6009 | |
| 6010 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 6011 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6012 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6013 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6014 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 6015 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6016 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6017 | } |
| 6018 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6019 | TEST_F(VkLayerTest, CopyDescriptorUpdateErrors) { |
| 6020 | // Create DS w/ layout of 2 types, write update 1 and attempt to copy-update |
| 6021 | // into the other |
| 6022 | VkResult err; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6023 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 6024 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6025 | " binding #1 with type " |
| 6026 | "VK_DESCRIPTOR_TYPE_SAMPLER. Types do " |
| 6027 | "not match."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6028 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6029 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6030 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6031 | VkDescriptorPoolSize ds_type_count[2] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6032 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6033 | ds_type_count[0].descriptorCount = 1; |
| 6034 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 6035 | ds_type_count[1].descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6036 | |
| 6037 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6038 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6039 | ds_pool_ci.pNext = NULL; |
| 6040 | ds_pool_ci.maxSets = 1; |
| 6041 | ds_pool_ci.poolSizeCount = 2; |
| 6042 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6043 | |
| 6044 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6045 | err = |
| 6046 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6047 | ASSERT_VK_SUCCESS(err); |
| 6048 | VkDescriptorSetLayoutBinding dsl_binding[2] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6049 | dsl_binding[0].binding = 0; |
| 6050 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6051 | dsl_binding[0].descriptorCount = 1; |
| 6052 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 6053 | dsl_binding[0].pImmutableSamplers = NULL; |
| 6054 | dsl_binding[1].binding = 1; |
| 6055 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 6056 | dsl_binding[1].descriptorCount = 1; |
| 6057 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 6058 | dsl_binding[1].pImmutableSamplers = NULL; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6059 | |
| 6060 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6061 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6062 | ds_layout_ci.pNext = NULL; |
| 6063 | ds_layout_ci.bindingCount = 2; |
| 6064 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6065 | |
| 6066 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6067 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6068 | &ds_layout); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6069 | ASSERT_VK_SUCCESS(err); |
| 6070 | |
| 6071 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6072 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6073 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6074 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6075 | alloc_info.descriptorPool = ds_pool; |
| 6076 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6077 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6078 | &descriptorSet); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6079 | ASSERT_VK_SUCCESS(err); |
| 6080 | |
| 6081 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6082 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 6083 | sampler_ci.pNext = NULL; |
| 6084 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 6085 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 6086 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 6087 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 6088 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 6089 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 6090 | sampler_ci.mipLodBias = 1.0; |
| 6091 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 6092 | sampler_ci.maxAnisotropy = 1; |
| 6093 | sampler_ci.compareEnable = VK_FALSE; |
| 6094 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 6095 | sampler_ci.minLod = 1.0; |
| 6096 | sampler_ci.maxLod = 1.0; |
| 6097 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 6098 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6099 | |
| 6100 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6101 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6102 | ASSERT_VK_SUCCESS(err); |
| 6103 | |
| 6104 | VkDescriptorImageInfo info = {}; |
| 6105 | info.sampler = sampler; |
| 6106 | |
| 6107 | VkWriteDescriptorSet descriptor_write; |
| 6108 | memset(&descriptor_write, 0, sizeof(VkWriteDescriptorSet)); |
| 6109 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6110 | descriptor_write.dstSet = descriptorSet; |
| 6111 | descriptor_write.dstBinding = 1; // SAMPLER binding from layout above |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6112 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6113 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 6114 | descriptor_write.pImageInfo = &info; |
| 6115 | // This write update should succeed |
| 6116 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 6117 | // Now perform a copy update that fails due to type mismatch |
| 6118 | VkCopyDescriptorSet copy_ds_update; |
| 6119 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 6120 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 6121 | copy_ds_update.srcSet = descriptorSet; |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 6122 | copy_ds_update.srcBinding = 1; // Copy from SAMPLER binding |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6123 | copy_ds_update.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6124 | copy_ds_update.dstBinding = 0; // ERROR : copy to UNIFORM binding |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6125 | copy_ds_update.descriptorCount = 1; // copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6126 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 6127 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6128 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6129 | // 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] | 6130 | m_errorMonitor->SetDesiredFailureMsg( |
| 6131 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 6132 | " does not have copy update src binding of 3."); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6133 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 6134 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 6135 | copy_ds_update.srcSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6136 | copy_ds_update.srcBinding = |
| 6137 | 3; // ERROR : Invalid binding for matching layout |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6138 | copy_ds_update.dstSet = descriptorSet; |
| 6139 | copy_ds_update.dstBinding = 0; |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 6140 | copy_ds_update.descriptorCount = 1; // Copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6141 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 6142 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6143 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6144 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6145 | // 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] | 6146 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 6147 | VK_DEBUG_REPORT_ERROR_BIT_EXT, " binding#1 with offset index of 1 plus " |
| 6148 | "update array offset of 0 and update of " |
| 6149 | "5 descriptors oversteps total number " |
| 6150 | "of descriptors in set: 2."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6151 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6152 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 6153 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 6154 | copy_ds_update.srcSet = descriptorSet; |
| 6155 | copy_ds_update.srcBinding = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6156 | copy_ds_update.dstSet = descriptorSet; |
| 6157 | copy_ds_update.dstBinding = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6158 | copy_ds_update.descriptorCount = |
| 6159 | 5; // ERROR copy 5 descriptors (out of bounds for layout) |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6160 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 6161 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6162 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6163 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6164 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 6165 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6166 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6167 | } |
| 6168 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6169 | TEST_F(VkLayerTest, NumSamplesMismatch) { |
| 6170 | // Create CommandBuffer where MSAA samples doesn't match RenderPass |
| 6171 | // sampleCount |
| 6172 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6173 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6174 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6175 | "Num samples mismatch! "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6176 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6177 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6178 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6179 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6180 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6181 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6182 | |
| 6183 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6184 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6185 | ds_pool_ci.pNext = NULL; |
| 6186 | ds_pool_ci.maxSets = 1; |
| 6187 | ds_pool_ci.poolSizeCount = 1; |
| 6188 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 6189 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6190 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6191 | err = |
| 6192 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6193 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6194 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6195 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 6196 | dsl_binding.binding = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6197 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 6198 | dsl_binding.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6199 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6200 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6201 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6202 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 6203 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6204 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6205 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 6206 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6207 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6208 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6209 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6210 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6211 | ASSERT_VK_SUCCESS(err); |
| 6212 | |
| 6213 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6214 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6215 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6216 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 6217 | alloc_info.descriptorPool = ds_pool; |
| 6218 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6219 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6220 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6221 | ASSERT_VK_SUCCESS(err); |
| 6222 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6223 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6224 | pipe_ms_state_ci.sType = |
| 6225 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 6226 | pipe_ms_state_ci.pNext = NULL; |
| 6227 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
| 6228 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 6229 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 6230 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6231 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6232 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6233 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6234 | pipeline_layout_ci.pNext = NULL; |
| 6235 | pipeline_layout_ci.setLayoutCount = 1; |
| 6236 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6237 | |
| 6238 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6239 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6240 | &pipeline_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6241 | ASSERT_VK_SUCCESS(err); |
| 6242 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6243 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6244 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6245 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6246 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6247 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6248 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 6249 | VkPipelineObj pipe(m_device); |
| 6250 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 6251 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6252 | pipe.AddColorAttachment(); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 6253 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 6254 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6255 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 6256 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6257 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 6258 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6259 | |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 6260 | // Render triangle (the error should trigger on the attempt to draw). |
| 6261 | Draw(3, 1, 0, 0); |
| 6262 | |
| 6263 | // Finalize recording of the command buffer |
| 6264 | EndCommandBuffer(); |
| 6265 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6266 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 6267 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6268 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6269 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6270 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 6271 | } |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 6272 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6273 | TEST_F(VkLayerTest, NumBlendAttachMismatch) { |
| 6274 | // Create Pipeline where the number of blend attachments doesn't match the |
| 6275 | // number of color attachments. In this case, we don't add any color |
| 6276 | // blend attachments even though we have a color attachment. |
| 6277 | VkResult err; |
| 6278 | |
| 6279 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 6280 | "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] | 6281 | |
| 6282 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6283 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6284 | VkDescriptorPoolSize ds_type_count = {}; |
| 6285 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6286 | ds_type_count.descriptorCount = 1; |
| 6287 | |
| 6288 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 6289 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6290 | ds_pool_ci.pNext = NULL; |
| 6291 | ds_pool_ci.maxSets = 1; |
| 6292 | ds_pool_ci.poolSizeCount = 1; |
| 6293 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 6294 | |
| 6295 | VkDescriptorPool ds_pool; |
| 6296 | err = |
| 6297 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 6298 | ASSERT_VK_SUCCESS(err); |
| 6299 | |
| 6300 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 6301 | dsl_binding.binding = 0; |
| 6302 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6303 | dsl_binding.descriptorCount = 1; |
| 6304 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6305 | dsl_binding.pImmutableSamplers = NULL; |
| 6306 | |
| 6307 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 6308 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6309 | ds_layout_ci.pNext = NULL; |
| 6310 | ds_layout_ci.bindingCount = 1; |
| 6311 | ds_layout_ci.pBindings = &dsl_binding; |
| 6312 | |
| 6313 | VkDescriptorSetLayout ds_layout; |
| 6314 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6315 | &ds_layout); |
| 6316 | ASSERT_VK_SUCCESS(err); |
| 6317 | |
| 6318 | VkDescriptorSet descriptorSet; |
| 6319 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 6320 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 6321 | alloc_info.descriptorSetCount = 1; |
| 6322 | alloc_info.descriptorPool = ds_pool; |
| 6323 | alloc_info.pSetLayouts = &ds_layout; |
| 6324 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6325 | &descriptorSet); |
| 6326 | ASSERT_VK_SUCCESS(err); |
| 6327 | |
| 6328 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 6329 | pipe_ms_state_ci.sType = |
| 6330 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 6331 | pipe_ms_state_ci.pNext = NULL; |
| 6332 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 6333 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 6334 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 6335 | pipe_ms_state_ci.pSampleMask = NULL; |
| 6336 | |
| 6337 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 6338 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6339 | pipeline_layout_ci.pNext = NULL; |
| 6340 | pipeline_layout_ci.setLayoutCount = 1; |
| 6341 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 6342 | |
| 6343 | VkPipelineLayout pipeline_layout; |
| 6344 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6345 | &pipeline_layout); |
| 6346 | ASSERT_VK_SUCCESS(err); |
| 6347 | |
| 6348 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6349 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6350 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6351 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6352 | this); // We shouldn't need a fragment shader |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6353 | // but add it to be able to run on more devices |
| 6354 | VkPipelineObj pipe(m_device); |
| 6355 | pipe.AddShader(&vs); |
| 6356 | pipe.AddShader(&fs); |
| 6357 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 6358 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 6359 | |
| 6360 | BeginCommandBuffer(); |
| 6361 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 6362 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 6363 | |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 6364 | // Render triangle (the error should trigger on the attempt to draw). |
| 6365 | Draw(3, 1, 0, 0); |
| 6366 | |
| 6367 | // Finalize recording of the command buffer |
| 6368 | EndCommandBuffer(); |
| 6369 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6370 | m_errorMonitor->VerifyFound(); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6371 | |
| 6372 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6373 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6374 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 6375 | } |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 6376 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6377 | TEST_F(VkLayerTest, ClearCmdNoDraw) { |
| 6378 | // Create CommandBuffer where we add ClearCmd for FB Color attachment prior |
| 6379 | // to issuing a Draw |
| 6380 | VkResult err; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6381 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6382 | m_errorMonitor->SetDesiredFailureMsg( |
Tony Barbour | 7e56d30 | 2016-03-02 15:12:01 -0700 | [diff] [blame] | 6383 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6384 | "vkCmdClearAttachments() issued on CB object "); |
| 6385 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6386 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6387 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6388 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6389 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6390 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6391 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6392 | |
| 6393 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6394 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6395 | ds_pool_ci.pNext = NULL; |
| 6396 | ds_pool_ci.maxSets = 1; |
| 6397 | ds_pool_ci.poolSizeCount = 1; |
| 6398 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6399 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6400 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6401 | err = |
| 6402 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6403 | ASSERT_VK_SUCCESS(err); |
| 6404 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6405 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6406 | dsl_binding.binding = 0; |
| 6407 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6408 | dsl_binding.descriptorCount = 1; |
| 6409 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6410 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6411 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6412 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6413 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6414 | ds_layout_ci.pNext = NULL; |
| 6415 | ds_layout_ci.bindingCount = 1; |
| 6416 | ds_layout_ci.pBindings = &dsl_binding; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6417 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6418 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6419 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6420 | &ds_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6421 | ASSERT_VK_SUCCESS(err); |
| 6422 | |
| 6423 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6424 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6425 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6426 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 6427 | alloc_info.descriptorPool = ds_pool; |
| 6428 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6429 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6430 | &descriptorSet); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6431 | ASSERT_VK_SUCCESS(err); |
| 6432 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6433 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6434 | pipe_ms_state_ci.sType = |
| 6435 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 6436 | pipe_ms_state_ci.pNext = NULL; |
| 6437 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
| 6438 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 6439 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 6440 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6441 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6442 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6443 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6444 | pipeline_layout_ci.pNext = NULL; |
| 6445 | pipeline_layout_ci.setLayoutCount = 1; |
| 6446 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6447 | |
| 6448 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6449 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6450 | &pipeline_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6451 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6452 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6453 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6454 | VK_SHADER_STAGE_VERTEX_BIT, this); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6455 | // 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] | 6456 | // on more devices |
| 6457 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6458 | VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6459 | |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 6460 | VkPipelineObj pipe(m_device); |
| 6461 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 6462 | pipe.AddShader(&fs); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 6463 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 6464 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 6465 | |
| 6466 | BeginCommandBuffer(); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6467 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6468 | // Main thing we care about for this test is that the VkImage obj we're |
| 6469 | // clearing matches Color Attachment of FB |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6470 | // Also pass down other dummy params to keep driver and paramchecker happy |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 6471 | VkClearAttachment color_attachment; |
| 6472 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 6473 | color_attachment.clearValue.color.float32[0] = 1.0; |
| 6474 | color_attachment.clearValue.color.float32[1] = 1.0; |
| 6475 | color_attachment.clearValue.color.float32[2] = 1.0; |
| 6476 | color_attachment.clearValue.color.float32[3] = 1.0; |
| 6477 | color_attachment.colorAttachment = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6478 | VkClearRect clear_rect = { |
| 6479 | {{0, 0}, {(uint32_t)m_width, (uint32_t)m_height}}}; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6480 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6481 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
| 6482 | &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6483 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6484 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 6485 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6486 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6487 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6488 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6489 | } |
| 6490 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6491 | TEST_F(VkLayerTest, VtxBufferBadIndex) { |
| 6492 | VkResult err; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6493 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6494 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 6495 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | dfcd9b6 | 2015-12-14 15:14:10 -0700 | [diff] [blame] | 6496 | "but no vertex buffers are attached to this Pipeline State Object"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6497 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6498 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6499 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6500 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6501 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6502 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6503 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6504 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6505 | |
| 6506 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6507 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6508 | ds_pool_ci.pNext = NULL; |
| 6509 | ds_pool_ci.maxSets = 1; |
| 6510 | ds_pool_ci.poolSizeCount = 1; |
| 6511 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6512 | |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 6513 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6514 | err = |
| 6515 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6516 | ASSERT_VK_SUCCESS(err); |
| 6517 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6518 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6519 | dsl_binding.binding = 0; |
| 6520 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6521 | dsl_binding.descriptorCount = 1; |
| 6522 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6523 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6524 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6525 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6526 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6527 | ds_layout_ci.pNext = NULL; |
| 6528 | ds_layout_ci.bindingCount = 1; |
| 6529 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6530 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6531 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6532 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6533 | &ds_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6534 | ASSERT_VK_SUCCESS(err); |
| 6535 | |
| 6536 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6537 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6538 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6539 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 6540 | alloc_info.descriptorPool = ds_pool; |
| 6541 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6542 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6543 | &descriptorSet); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6544 | ASSERT_VK_SUCCESS(err); |
| 6545 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6546 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6547 | pipe_ms_state_ci.sType = |
| 6548 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 6549 | pipe_ms_state_ci.pNext = NULL; |
| 6550 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 6551 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 6552 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 6553 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6554 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6555 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6556 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6557 | pipeline_layout_ci.pNext = NULL; |
| 6558 | pipeline_layout_ci.setLayoutCount = 1; |
| 6559 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 6560 | VkPipelineLayout pipeline_layout; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6561 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6562 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6563 | &pipeline_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6564 | ASSERT_VK_SUCCESS(err); |
| 6565 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6566 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6567 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6568 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6569 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6570 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6571 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 6572 | VkPipelineObj pipe(m_device); |
| 6573 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 6574 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6575 | pipe.AddColorAttachment(); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 6576 | pipe.SetMSAA(&pipe_ms_state_ci); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6577 | pipe.SetViewport(m_viewports); |
| 6578 | pipe.SetScissor(m_scissors); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 6579 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 6580 | |
| 6581 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6582 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 6583 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 6584 | // Don't care about actual data, just need to get to draw to flag error |
| 6585 | static const float vbo_data[3] = {1.f, 0.f, 1.f}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6586 | VkConstantBufferObj vbo(m_device, sizeof(vbo_data), sizeof(float), |
| 6587 | (const void *)&vbo_data); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 6588 | 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] | 6589 | Draw(1, 0, 0, 0); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6590 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6591 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 6592 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6593 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6594 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6595 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6596 | } |
Tobin Ehlis | c555a3c | 2016-05-04 14:08:34 -0600 | [diff] [blame] | 6597 | // INVALID_IMAGE_LAYOUT tests (one other case is hit by MapMemWithoutHostVisibleBit and not here) |
| 6598 | TEST_F(VkLayerTest, InvalidImageLayout) { |
| 6599 | TEST_DESCRIPTION("Hit all possible validation checks associated with the " |
| 6600 | "DRAWSTATE_INVALID_IMAGE_LAYOUT enum. Generally these involve having" |
| 6601 | "images in the wrong layout when they're copied or transitioned."); |
| 6602 | // 3 in ValidateCmdBufImageLayouts |
| 6603 | // * -1 Attempt to submit cmd buf w/ deleted image |
| 6604 | // * -2 Cmd buf submit of image w/ layout not matching first use w/ subresource |
| 6605 | // * -3 Cmd buf submit of image w/ layout not matching first use w/o subresource |
| 6606 | m_errorMonitor->SetDesiredFailureMsg( |
| 6607 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 6608 | "Layout for input image should be TRANSFER_SRC_OPTIMAL instead of GENERAL."); |
| 6609 | |
| 6610 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6611 | // Create src & dst images to use for copy operations |
| 6612 | VkImage src_image; |
| 6613 | VkImage dst_image; |
| 6614 | |
| 6615 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6616 | const int32_t tex_width = 32; |
| 6617 | const int32_t tex_height = 32; |
| 6618 | |
| 6619 | VkImageCreateInfo image_create_info = {}; |
| 6620 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6621 | image_create_info.pNext = NULL; |
| 6622 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6623 | image_create_info.format = tex_format; |
| 6624 | image_create_info.extent.width = tex_width; |
| 6625 | image_create_info.extent.height = tex_height; |
| 6626 | image_create_info.extent.depth = 1; |
| 6627 | image_create_info.mipLevels = 1; |
| 6628 | image_create_info.arrayLayers = 4; |
| 6629 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 6630 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 6631 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 6632 | image_create_info.flags = 0; |
| 6633 | |
| 6634 | VkResult err = vkCreateImage(m_device->device(), &image_create_info, NULL, &src_image); |
| 6635 | ASSERT_VK_SUCCESS(err); |
| 6636 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dst_image); |
| 6637 | ASSERT_VK_SUCCESS(err); |
| 6638 | |
| 6639 | BeginCommandBuffer(); |
| 6640 | VkImageCopy copyRegion; |
| 6641 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 6642 | copyRegion.srcSubresource.mipLevel = 0; |
| 6643 | copyRegion.srcSubresource.baseArrayLayer = 0; |
| 6644 | copyRegion.srcSubresource.layerCount = 1; |
| 6645 | copyRegion.srcOffset.x = 0; |
| 6646 | copyRegion.srcOffset.y = 0; |
| 6647 | copyRegion.srcOffset.z = 0; |
| 6648 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 6649 | copyRegion.dstSubresource.mipLevel = 0; |
| 6650 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 6651 | copyRegion.dstSubresource.layerCount = 1; |
| 6652 | copyRegion.dstOffset.x = 0; |
| 6653 | copyRegion.dstOffset.y = 0; |
| 6654 | copyRegion.dstOffset.z = 0; |
| 6655 | copyRegion.extent.width = 1; |
| 6656 | copyRegion.extent.height = 1; |
| 6657 | copyRegion.extent.depth = 1; |
| 6658 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 6659 | m_errorMonitor->VerifyFound(); |
| 6660 | // Now cause error due to src image layout changing |
| 6661 | m_errorMonitor->SetDesiredFailureMsg( |
| 6662 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6663 | "Cannot copy from an image whose source layout is VK_IMAGE_LAYOUT_UNDEFINED and doesn't match the current layout VK_IMAGE_LAYOUT_GENERAL."); |
| 6664 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_UNDEFINED, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 6665 | m_errorMonitor->VerifyFound(); |
| 6666 | // Final src error is due to bad layout type |
| 6667 | m_errorMonitor->SetDesiredFailureMsg( |
| 6668 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6669 | "Layout for input image is VK_IMAGE_LAYOUT_UNDEFINED but can only be TRANSFER_SRC_OPTIMAL or GENERAL."); |
| 6670 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_UNDEFINED, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 6671 | m_errorMonitor->VerifyFound(); |
| 6672 | // Now verify same checks for dst |
| 6673 | m_errorMonitor->SetDesiredFailureMsg( |
| 6674 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 6675 | "Layout for output image should be TRANSFER_DST_OPTIMAL instead of GENERAL."); |
| 6676 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 6677 | m_errorMonitor->VerifyFound(); |
| 6678 | // Now cause error due to src image layout changing |
| 6679 | m_errorMonitor->SetDesiredFailureMsg( |
| 6680 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6681 | "Cannot copy from an image whose dest layout is VK_IMAGE_LAYOUT_UNDEFINED and doesn't match the current layout VK_IMAGE_LAYOUT_GENERAL."); |
| 6682 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_UNDEFINED, 1, ©Region); |
| 6683 | m_errorMonitor->VerifyFound(); |
| 6684 | m_errorMonitor->SetDesiredFailureMsg( |
| 6685 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6686 | "Layout for output image is VK_IMAGE_LAYOUT_UNDEFINED but can only be TRANSFER_DST_OPTIMAL or GENERAL."); |
| 6687 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_UNDEFINED, 1, ©Region); |
| 6688 | m_errorMonitor->VerifyFound(); |
| 6689 | // Now cause error due to bad image layout transition in PipelineBarrier |
| 6690 | VkImageMemoryBarrier image_barrier[1] = {}; |
| 6691 | image_barrier[0].oldLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; |
| 6692 | image_barrier[0].image = src_image; |
| 6693 | image_barrier[0].subresourceRange.layerCount = 2; |
| 6694 | image_barrier[0].subresourceRange.levelCount = 2; |
| 6695 | image_barrier[0].subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 6696 | m_errorMonitor->SetDesiredFailureMsg( |
| 6697 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6698 | "You cannot transition the layout from VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL when current layout is VK_IMAGE_LAYOUT_GENERAL."); |
| 6699 | vkCmdPipelineBarrier(m_commandBuffer->handle(), VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, NULL, 0, NULL, 1, image_barrier); |
| 6700 | m_errorMonitor->VerifyFound(); |
| 6701 | |
| 6702 | // Finally some layout errors at RenderPass create time |
| 6703 | // Just hacking in specific state to get to the errors we want so don't copy this unless you know what you're doing. |
| 6704 | VkAttachmentReference attach = {}; |
| 6705 | // perf warning for GENERAL layout w/ non-DS input attachment |
| 6706 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 6707 | VkSubpassDescription subpass = {}; |
| 6708 | subpass.inputAttachmentCount = 1; |
| 6709 | subpass.pInputAttachments = &attach; |
| 6710 | VkRenderPassCreateInfo rpci = {}; |
| 6711 | rpci.subpassCount = 1; |
| 6712 | rpci.pSubpasses = &subpass; |
| 6713 | rpci.attachmentCount = 1; |
| 6714 | VkAttachmentDescription attach_desc = {}; |
| 6715 | attach_desc.format = VK_FORMAT_UNDEFINED; |
| 6716 | rpci.pAttachments = &attach_desc; |
| 6717 | VkRenderPass rp; |
| 6718 | m_errorMonitor->SetDesiredFailureMsg( |
| 6719 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 6720 | "Layout for input attachment is GENERAL but should be READ_ONLY_OPTIMAL."); |
| 6721 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 6722 | m_errorMonitor->VerifyFound(); |
| 6723 | // error w/ non-general layout |
| 6724 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; |
| 6725 | |
| 6726 | m_errorMonitor->SetDesiredFailureMsg( |
| 6727 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6728 | "Layout for input attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be READ_ONLY_OPTIMAL or GENERAL."); |
| 6729 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 6730 | m_errorMonitor->VerifyFound(); |
| 6731 | subpass.inputAttachmentCount = 0; |
| 6732 | subpass.colorAttachmentCount = 1; |
| 6733 | subpass.pColorAttachments = &attach; |
| 6734 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 6735 | // perf warning for GENERAL layout on color attachment |
| 6736 | m_errorMonitor->SetDesiredFailureMsg( |
| 6737 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 6738 | "Layout for color attachment is GENERAL but should be COLOR_ATTACHMENT_OPTIMAL."); |
| 6739 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 6740 | m_errorMonitor->VerifyFound(); |
| 6741 | // error w/ non-color opt or GENERAL layout for color attachment |
| 6742 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; |
| 6743 | m_errorMonitor->SetDesiredFailureMsg( |
| 6744 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6745 | "Layout for color attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be COLOR_ATTACHMENT_OPTIMAL or GENERAL."); |
| 6746 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 6747 | m_errorMonitor->VerifyFound(); |
| 6748 | subpass.colorAttachmentCount = 0; |
| 6749 | subpass.pDepthStencilAttachment = &attach; |
| 6750 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 6751 | // perf warning for GENERAL layout on DS attachment |
| 6752 | m_errorMonitor->SetDesiredFailureMsg( |
| 6753 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 6754 | "Layout for depth attachment is GENERAL but should be DEPTH_STENCIL_ATTACHMENT_OPTIMAL."); |
| 6755 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 6756 | m_errorMonitor->VerifyFound(); |
| 6757 | // error w/ non-ds opt or GENERAL layout for color attachment |
| 6758 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; |
| 6759 | m_errorMonitor->SetDesiredFailureMsg( |
| 6760 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6761 | "Layout for depth attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be DEPTH_STENCIL_ATTACHMENT_OPTIMAL or GENERAL."); |
| 6762 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 6763 | m_errorMonitor->VerifyFound(); |
| 6764 | |
| 6765 | vkDestroyImage(m_device->device(), src_image, NULL); |
| 6766 | vkDestroyImage(m_device->device(), dst_image, NULL); |
| 6767 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6768 | #endif // DRAW_STATE_TESTS |
| 6769 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 6770 | #if THREADING_TESTS |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6771 | #if GTEST_IS_THREADSAFE |
| 6772 | struct thread_data_struct { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6773 | VkCommandBuffer commandBuffer; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6774 | VkEvent event; |
| 6775 | bool bailout; |
| 6776 | }; |
| 6777 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6778 | extern "C" void *AddToCommandBuffer(void *arg) { |
| 6779 | struct thread_data_struct *data = (struct thread_data_struct *)arg; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6780 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6781 | for (int i = 0; i < 10000; i++) { |
| 6782 | vkCmdSetEvent(data->commandBuffer, data->event, |
| 6783 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6784 | if (data->bailout) { |
| 6785 | break; |
| 6786 | } |
| 6787 | } |
| 6788 | return NULL; |
| 6789 | } |
| 6790 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6791 | TEST_F(VkLayerTest, ThreadCommandBufferCollision) { |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 6792 | test_platform_thread thread; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6793 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6794 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6795 | "THREADING ERROR"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6796 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6797 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6798 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 6799 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6800 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6801 | // Calls AllocateCommandBuffers |
| 6802 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 6803 | |
| 6804 | // Avoid creating RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6805 | commandBuffer.BeginCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6806 | |
| 6807 | VkEventCreateInfo event_info; |
| 6808 | VkEvent event; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6809 | VkResult err; |
| 6810 | |
| 6811 | memset(&event_info, 0, sizeof(event_info)); |
| 6812 | event_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 6813 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6814 | err = vkCreateEvent(device(), &event_info, NULL, &event); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6815 | ASSERT_VK_SUCCESS(err); |
| 6816 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6817 | err = vkResetEvent(device(), event); |
| 6818 | ASSERT_VK_SUCCESS(err); |
| 6819 | |
| 6820 | struct thread_data_struct data; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6821 | data.commandBuffer = commandBuffer.GetBufferHandle(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6822 | data.event = event; |
| 6823 | data.bailout = false; |
| 6824 | m_errorMonitor->SetBailout(&data.bailout); |
| 6825 | // Add many entries to command buffer from another thread. |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 6826 | test_platform_thread_create(&thread, AddToCommandBuffer, (void *)&data); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6827 | // Add many entries to command buffer from this thread at the same time. |
| 6828 | AddToCommandBuffer(&data); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 6829 | |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 6830 | test_platform_thread_join(thread, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6831 | commandBuffer.EndCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6832 | |
Mike Stroyan | 10b8cb7 | 2016-01-22 15:22:03 -0700 | [diff] [blame] | 6833 | m_errorMonitor->SetBailout(NULL); |
| 6834 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6835 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6836 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6837 | vkDestroyEvent(device(), event, NULL); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6838 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6839 | #endif // GTEST_IS_THREADSAFE |
| 6840 | #endif // THREADING_TESTS |
| 6841 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6842 | #if SHADER_CHECKER_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6843 | TEST_F(VkLayerTest, InvalidSPIRVCodeSize) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6844 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 6845 | "Invalid SPIR-V header"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6846 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6847 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6848 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6849 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6850 | VkShaderModule module; |
| 6851 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 6852 | struct icd_spv_header spv; |
| 6853 | |
| 6854 | spv.magic = ICD_SPV_MAGIC; |
| 6855 | spv.version = ICD_SPV_VERSION; |
| 6856 | spv.gen_magic = 0; |
| 6857 | |
| 6858 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 6859 | moduleCreateInfo.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6860 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6861 | moduleCreateInfo.codeSize = 4; |
| 6862 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6863 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6864 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6865 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6866 | } |
| 6867 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6868 | TEST_F(VkLayerTest, InvalidSPIRVMagic) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6869 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 6870 | "Invalid SPIR-V magic number"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6871 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6872 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6873 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6874 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6875 | VkShaderModule module; |
| 6876 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 6877 | struct icd_spv_header spv; |
| 6878 | |
| 6879 | spv.magic = ~ICD_SPV_MAGIC; |
| 6880 | spv.version = ICD_SPV_VERSION; |
| 6881 | spv.gen_magic = 0; |
| 6882 | |
| 6883 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 6884 | moduleCreateInfo.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6885 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6886 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 6887 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6888 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6889 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6890 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6891 | } |
| 6892 | |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 6893 | #if 0 |
| 6894 | // Not currently covered by SPIRV-Tools validator |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6895 | TEST_F(VkLayerTest, InvalidSPIRVVersion) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6896 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 6897 | "Invalid SPIR-V header"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6898 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6899 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6900 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6901 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6902 | VkShaderModule module; |
| 6903 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 6904 | struct icd_spv_header spv; |
| 6905 | |
| 6906 | spv.magic = ICD_SPV_MAGIC; |
| 6907 | spv.version = ~ICD_SPV_VERSION; |
| 6908 | spv.gen_magic = 0; |
| 6909 | |
| 6910 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 6911 | moduleCreateInfo.pNext = NULL; |
| 6912 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6913 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6914 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 6915 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6916 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6917 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6918 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6919 | } |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 6920 | #endif |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6921 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6922 | TEST_F(VkLayerTest, CreatePipelineVertexOutputNotConsumed) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 6923 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6924 | "not consumed by fragment shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6925 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6926 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 6927 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6928 | |
| 6929 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6930 | "#version 450\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6931 | "\n" |
| 6932 | "layout(location=0) out float x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 6933 | "out gl_PerVertex {\n" |
| 6934 | " vec4 gl_Position;\n" |
| 6935 | "};\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6936 | "void main(){\n" |
| 6937 | " gl_Position = vec4(1);\n" |
| 6938 | " x = 0;\n" |
| 6939 | "}\n"; |
| 6940 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6941 | "#version 450\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6942 | "\n" |
| 6943 | "layout(location=0) out vec4 color;\n" |
| 6944 | "void main(){\n" |
| 6945 | " color = vec4(1);\n" |
| 6946 | "}\n"; |
| 6947 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 6948 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6949 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6950 | |
| 6951 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 6952 | pipe.AddColorAttachment(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6953 | pipe.AddShader(&vs); |
| 6954 | pipe.AddShader(&fs); |
| 6955 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6956 | VkDescriptorSetObj descriptorSet(m_device); |
| 6957 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6958 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6959 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 6960 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6961 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6962 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6963 | } |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6964 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6965 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvided) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6966 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6967 | "not written by vertex shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6968 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6969 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 6970 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6971 | |
| 6972 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6973 | "#version 450\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6974 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 6975 | "out gl_PerVertex {\n" |
| 6976 | " vec4 gl_Position;\n" |
| 6977 | "};\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6978 | "void main(){\n" |
| 6979 | " gl_Position = vec4(1);\n" |
| 6980 | "}\n"; |
| 6981 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 6982 | "#version 450\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6983 | "\n" |
| 6984 | "layout(location=0) in float x;\n" |
| 6985 | "layout(location=0) out vec4 color;\n" |
| 6986 | "void main(){\n" |
| 6987 | " color = vec4(x);\n" |
| 6988 | "}\n"; |
| 6989 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 6990 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6991 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6992 | |
| 6993 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 6994 | pipe.AddColorAttachment(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6995 | pipe.AddShader(&vs); |
| 6996 | pipe.AddShader(&fs); |
| 6997 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 6998 | VkDescriptorSetObj descriptorSet(m_device); |
| 6999 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7000 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 7001 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 7002 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 7003 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7004 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 7005 | } |
| 7006 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7007 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvidedInBlock) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 7008 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7009 | "not written by vertex shader"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 7010 | |
| 7011 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7012 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7013 | |
| 7014 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7015 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 7016 | "\n" |
| 7017 | "out gl_PerVertex {\n" |
| 7018 | " vec4 gl_Position;\n" |
| 7019 | "};\n" |
| 7020 | "void main(){\n" |
| 7021 | " gl_Position = vec4(1);\n" |
| 7022 | "}\n"; |
| 7023 | char const *fsSource = |
| 7024 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 7025 | "\n" |
| 7026 | "in block { layout(location=0) float x; } ins;\n" |
| 7027 | "layout(location=0) out vec4 color;\n" |
| 7028 | "void main(){\n" |
| 7029 | " color = vec4(ins.x);\n" |
| 7030 | "}\n"; |
| 7031 | |
| 7032 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7033 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7034 | |
| 7035 | VkPipelineObj pipe(m_device); |
| 7036 | pipe.AddColorAttachment(); |
| 7037 | pipe.AddShader(&vs); |
| 7038 | pipe.AddShader(&fs); |
| 7039 | |
| 7040 | VkDescriptorSetObj descriptorSet(m_device); |
| 7041 | descriptorSet.AppendDummy(); |
| 7042 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7043 | |
| 7044 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7045 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7046 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 7047 | } |
| 7048 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7049 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchArraySize) { |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 7050 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 7051 | "Type mismatch on location 0.0: 'ptr to " |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7052 | "output arr[2] of float32' vs 'ptr to " |
| 7053 | "input arr[3] of float32'"); |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 7054 | |
| 7055 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7056 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7057 | |
| 7058 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7059 | "#version 450\n" |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 7060 | "\n" |
| 7061 | "layout(location=0) out float x[2];\n" |
| 7062 | "out gl_PerVertex {\n" |
| 7063 | " vec4 gl_Position;\n" |
| 7064 | "};\n" |
| 7065 | "void main(){\n" |
| 7066 | " x[0] = 0; x[1] = 0;\n" |
| 7067 | " gl_Position = vec4(1);\n" |
| 7068 | "}\n"; |
| 7069 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7070 | "#version 450\n" |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 7071 | "\n" |
| 7072 | "layout(location=0) in float x[3];\n" |
| 7073 | "layout(location=0) out vec4 color;\n" |
| 7074 | "void main(){\n" |
| 7075 | " color = vec4(x[0] + x[1] + x[2]);\n" |
| 7076 | "}\n"; |
| 7077 | |
| 7078 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7079 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7080 | |
| 7081 | VkPipelineObj pipe(m_device); |
| 7082 | pipe.AddColorAttachment(); |
| 7083 | pipe.AddShader(&vs); |
| 7084 | pipe.AddShader(&fs); |
| 7085 | |
| 7086 | VkDescriptorSetObj descriptorSet(m_device); |
| 7087 | descriptorSet.AppendDummy(); |
| 7088 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7089 | |
| 7090 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7091 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7092 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 7093 | } |
| 7094 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7095 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatch) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7096 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7097 | "Type mismatch on location 0"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7098 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 7099 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 7100 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 7101 | |
| 7102 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7103 | "#version 450\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 7104 | "\n" |
| 7105 | "layout(location=0) out int x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7106 | "out gl_PerVertex {\n" |
| 7107 | " vec4 gl_Position;\n" |
| 7108 | "};\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 7109 | "void main(){\n" |
| 7110 | " x = 0;\n" |
| 7111 | " gl_Position = vec4(1);\n" |
| 7112 | "}\n"; |
| 7113 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7114 | "#version 450\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 7115 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7116 | "layout(location=0) in float x;\n" /* VS writes int */ |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 7117 | "layout(location=0) out vec4 color;\n" |
| 7118 | "void main(){\n" |
| 7119 | " color = vec4(x);\n" |
| 7120 | "}\n"; |
| 7121 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 7122 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7123 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 7124 | |
| 7125 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 7126 | pipe.AddColorAttachment(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 7127 | pipe.AddShader(&vs); |
| 7128 | pipe.AddShader(&fs); |
| 7129 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 7130 | VkDescriptorSetObj descriptorSet(m_device); |
| 7131 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7132 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 7133 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 7134 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 7135 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7136 | m_errorMonitor->VerifyFound(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 7137 | } |
| 7138 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7139 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchInBlock) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 7140 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7141 | "Type mismatch on location 0"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 7142 | |
| 7143 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7144 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7145 | |
| 7146 | char const *vsSource = |
| 7147 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 7148 | "\n" |
| 7149 | "out block { layout(location=0) int x; } outs;\n" |
| 7150 | "out gl_PerVertex {\n" |
| 7151 | " vec4 gl_Position;\n" |
| 7152 | "};\n" |
| 7153 | "void main(){\n" |
| 7154 | " outs.x = 0;\n" |
| 7155 | " gl_Position = vec4(1);\n" |
| 7156 | "}\n"; |
| 7157 | char const *fsSource = |
| 7158 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 7159 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7160 | "in block { layout(location=0) float x; } ins;\n" /* VS writes int */ |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 7161 | "layout(location=0) out vec4 color;\n" |
| 7162 | "void main(){\n" |
| 7163 | " color = vec4(ins.x);\n" |
| 7164 | "}\n"; |
| 7165 | |
| 7166 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7167 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7168 | |
| 7169 | VkPipelineObj pipe(m_device); |
| 7170 | pipe.AddColorAttachment(); |
| 7171 | pipe.AddShader(&vs); |
| 7172 | pipe.AddShader(&fs); |
| 7173 | |
| 7174 | VkDescriptorSetObj descriptorSet(m_device); |
| 7175 | descriptorSet.AppendDummy(); |
| 7176 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7177 | |
| 7178 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7179 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7180 | m_errorMonitor->VerifyFound(); |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 7181 | } |
| 7182 | |
| 7183 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByLocation) { |
| 7184 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7185 | "location 0.0 which is not written by vertex shader"); |
| 7186 | |
| 7187 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7188 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7189 | |
| 7190 | char const *vsSource = |
| 7191 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 7192 | "\n" |
| 7193 | "out block { layout(location=1) float x; } outs;\n" |
| 7194 | "out gl_PerVertex {\n" |
| 7195 | " vec4 gl_Position;\n" |
| 7196 | "};\n" |
| 7197 | "void main(){\n" |
| 7198 | " outs.x = 0;\n" |
| 7199 | " gl_Position = vec4(1);\n" |
| 7200 | "}\n"; |
| 7201 | char const *fsSource = |
| 7202 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 7203 | "\n" |
| 7204 | "in block { layout(location=0) float x; } ins;\n" |
| 7205 | "layout(location=0) out vec4 color;\n" |
| 7206 | "void main(){\n" |
| 7207 | " color = vec4(ins.x);\n" |
| 7208 | "}\n"; |
| 7209 | |
| 7210 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7211 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7212 | |
| 7213 | VkPipelineObj pipe(m_device); |
| 7214 | pipe.AddColorAttachment(); |
| 7215 | pipe.AddShader(&vs); |
| 7216 | pipe.AddShader(&fs); |
| 7217 | |
| 7218 | VkDescriptorSetObj descriptorSet(m_device); |
| 7219 | descriptorSet.AppendDummy(); |
| 7220 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7221 | |
| 7222 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7223 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7224 | m_errorMonitor->VerifyFound(); |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 7225 | } |
| 7226 | |
| 7227 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByComponent) { |
| 7228 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7229 | "location 0.1 which is not written by vertex shader"); |
| 7230 | |
| 7231 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7232 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7233 | |
| 7234 | char const *vsSource = |
| 7235 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 7236 | "\n" |
| 7237 | "out block { layout(location=0, component=0) float x; } outs;\n" |
| 7238 | "out gl_PerVertex {\n" |
| 7239 | " vec4 gl_Position;\n" |
| 7240 | "};\n" |
| 7241 | "void main(){\n" |
| 7242 | " outs.x = 0;\n" |
| 7243 | " gl_Position = vec4(1);\n" |
| 7244 | "}\n"; |
| 7245 | char const *fsSource = |
| 7246 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 7247 | "\n" |
| 7248 | "in block { layout(location=0, component=1) float x; } ins;\n" |
| 7249 | "layout(location=0) out vec4 color;\n" |
| 7250 | "void main(){\n" |
| 7251 | " color = vec4(ins.x);\n" |
| 7252 | "}\n"; |
| 7253 | |
| 7254 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7255 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7256 | |
| 7257 | VkPipelineObj pipe(m_device); |
| 7258 | pipe.AddColorAttachment(); |
| 7259 | pipe.AddShader(&vs); |
| 7260 | pipe.AddShader(&fs); |
| 7261 | |
| 7262 | VkDescriptorSetObj descriptorSet(m_device); |
| 7263 | descriptorSet.AppendDummy(); |
| 7264 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7265 | |
| 7266 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7267 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7268 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 7269 | } |
| 7270 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7271 | TEST_F(VkLayerTest, CreatePipelineAttribNotConsumed) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 7272 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7273 | "location 0 not consumed by VS"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7274 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7275 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 7276 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7277 | |
| 7278 | VkVertexInputBindingDescription input_binding; |
| 7279 | memset(&input_binding, 0, sizeof(input_binding)); |
| 7280 | |
| 7281 | VkVertexInputAttributeDescription input_attrib; |
| 7282 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 7283 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 7284 | |
| 7285 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7286 | "#version 450\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7287 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7288 | "out gl_PerVertex {\n" |
| 7289 | " vec4 gl_Position;\n" |
| 7290 | "};\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7291 | "void main(){\n" |
| 7292 | " gl_Position = vec4(1);\n" |
| 7293 | "}\n"; |
| 7294 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7295 | "#version 450\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7296 | "\n" |
| 7297 | "layout(location=0) out vec4 color;\n" |
| 7298 | "void main(){\n" |
| 7299 | " color = vec4(1);\n" |
| 7300 | "}\n"; |
| 7301 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 7302 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7303 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7304 | |
| 7305 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 7306 | pipe.AddColorAttachment(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7307 | pipe.AddShader(&vs); |
| 7308 | pipe.AddShader(&fs); |
| 7309 | |
| 7310 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 7311 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 7312 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7313 | VkDescriptorSetObj descriptorSet(m_device); |
| 7314 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7315 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7316 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 7317 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7318 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7319 | m_errorMonitor->VerifyFound(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7320 | } |
| 7321 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7322 | TEST_F(VkLayerTest, CreatePipelineAttribLocationMismatch) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 7323 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7324 | "location 0 not consumed by VS"); |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 7325 | |
| 7326 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7327 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7328 | |
| 7329 | VkVertexInputBindingDescription input_binding; |
| 7330 | memset(&input_binding, 0, sizeof(input_binding)); |
| 7331 | |
| 7332 | VkVertexInputAttributeDescription input_attrib; |
| 7333 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 7334 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 7335 | |
| 7336 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7337 | "#version 450\n" |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 7338 | "\n" |
| 7339 | "layout(location=1) in float x;\n" |
| 7340 | "out gl_PerVertex {\n" |
| 7341 | " vec4 gl_Position;\n" |
| 7342 | "};\n" |
| 7343 | "void main(){\n" |
| 7344 | " gl_Position = vec4(x);\n" |
| 7345 | "}\n"; |
| 7346 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7347 | "#version 450\n" |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 7348 | "\n" |
| 7349 | "layout(location=0) out vec4 color;\n" |
| 7350 | "void main(){\n" |
| 7351 | " color = vec4(1);\n" |
| 7352 | "}\n"; |
| 7353 | |
| 7354 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7355 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7356 | |
| 7357 | VkPipelineObj pipe(m_device); |
| 7358 | pipe.AddColorAttachment(); |
| 7359 | pipe.AddShader(&vs); |
| 7360 | pipe.AddShader(&fs); |
| 7361 | |
| 7362 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 7363 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 7364 | |
| 7365 | VkDescriptorSetObj descriptorSet(m_device); |
| 7366 | descriptorSet.AppendDummy(); |
| 7367 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7368 | |
| 7369 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7370 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7371 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 7372 | } |
| 7373 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7374 | TEST_F(VkLayerTest, CreatePipelineAttribNotProvided) { |
| 7375 | m_errorMonitor->SetDesiredFailureMsg( |
| 7376 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7377 | "VS consumes input at location 0 but not provided"); |
| 7378 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7379 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 7380 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7381 | |
| 7382 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7383 | "#version 450\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7384 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7385 | "layout(location=0) in vec4 x;\n" /* not provided */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7386 | "out gl_PerVertex {\n" |
| 7387 | " vec4 gl_Position;\n" |
| 7388 | "};\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7389 | "void main(){\n" |
| 7390 | " gl_Position = x;\n" |
| 7391 | "}\n"; |
| 7392 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7393 | "#version 450\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7394 | "\n" |
| 7395 | "layout(location=0) out vec4 color;\n" |
| 7396 | "void main(){\n" |
| 7397 | " color = vec4(1);\n" |
| 7398 | "}\n"; |
| 7399 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 7400 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7401 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7402 | |
| 7403 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 7404 | pipe.AddColorAttachment(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7405 | pipe.AddShader(&vs); |
| 7406 | pipe.AddShader(&fs); |
| 7407 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7408 | VkDescriptorSetObj descriptorSet(m_device); |
| 7409 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7410 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7411 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 7412 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7413 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7414 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7415 | } |
| 7416 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7417 | TEST_F(VkLayerTest, CreatePipelineAttribTypeMismatch) { |
| 7418 | m_errorMonitor->SetDesiredFailureMsg( |
| 7419 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7420 | "location 0 does not match VS input type"); |
| 7421 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7422 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 7423 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7424 | |
| 7425 | VkVertexInputBindingDescription input_binding; |
| 7426 | memset(&input_binding, 0, sizeof(input_binding)); |
| 7427 | |
| 7428 | VkVertexInputAttributeDescription input_attrib; |
| 7429 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 7430 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 7431 | |
| 7432 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7433 | "#version 450\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7434 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7435 | "layout(location=0) in int x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7436 | "out gl_PerVertex {\n" |
| 7437 | " vec4 gl_Position;\n" |
| 7438 | "};\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7439 | "void main(){\n" |
| 7440 | " gl_Position = vec4(x);\n" |
| 7441 | "}\n"; |
| 7442 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7443 | "#version 450\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7444 | "\n" |
| 7445 | "layout(location=0) out vec4 color;\n" |
| 7446 | "void main(){\n" |
| 7447 | " color = vec4(1);\n" |
| 7448 | "}\n"; |
| 7449 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 7450 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7451 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7452 | |
| 7453 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 7454 | pipe.AddColorAttachment(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7455 | pipe.AddShader(&vs); |
| 7456 | pipe.AddShader(&fs); |
| 7457 | |
| 7458 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 7459 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 7460 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7461 | VkDescriptorSetObj descriptorSet(m_device); |
| 7462 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7463 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7464 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 7465 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7466 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7467 | m_errorMonitor->VerifyFound(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7468 | } |
| 7469 | |
Chris Forbes | c68b43c | 2016-04-06 11:18:47 +1200 | [diff] [blame] | 7470 | TEST_F(VkLayerTest, CreatePipelineDuplicateStage) { |
| 7471 | m_errorMonitor->SetDesiredFailureMsg( |
| 7472 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7473 | "Multiple shaders provided for stage VK_SHADER_STAGE_VERTEX_BIT"); |
| 7474 | |
| 7475 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7476 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7477 | |
| 7478 | char const *vsSource = |
| 7479 | "#version 450\n" |
| 7480 | "\n" |
| 7481 | "out gl_PerVertex {\n" |
| 7482 | " vec4 gl_Position;\n" |
| 7483 | "};\n" |
| 7484 | "void main(){\n" |
| 7485 | " gl_Position = vec4(1);\n" |
| 7486 | "}\n"; |
| 7487 | char const *fsSource = |
| 7488 | "#version 450\n" |
| 7489 | "\n" |
| 7490 | "layout(location=0) out vec4 color;\n" |
| 7491 | "void main(){\n" |
| 7492 | " color = vec4(1);\n" |
| 7493 | "}\n"; |
| 7494 | |
| 7495 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7496 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7497 | |
| 7498 | VkPipelineObj pipe(m_device); |
| 7499 | pipe.AddColorAttachment(); |
| 7500 | pipe.AddShader(&vs); |
| 7501 | pipe.AddShader(&vs); |
| 7502 | pipe.AddShader(&fs); |
| 7503 | |
| 7504 | VkDescriptorSetObj descriptorSet(m_device); |
| 7505 | descriptorSet.AppendDummy(); |
| 7506 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7507 | |
| 7508 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7509 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7510 | m_errorMonitor->VerifyFound(); |
Chris Forbes | c68b43c | 2016-04-06 11:18:47 +1200 | [diff] [blame] | 7511 | } |
| 7512 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7513 | TEST_F(VkLayerTest, CreatePipelineAttribMatrixType) { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7514 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7515 | |
| 7516 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7517 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7518 | |
| 7519 | VkVertexInputBindingDescription input_binding; |
| 7520 | memset(&input_binding, 0, sizeof(input_binding)); |
| 7521 | |
| 7522 | VkVertexInputAttributeDescription input_attribs[2]; |
| 7523 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 7524 | |
| 7525 | for (int i = 0; i < 2; i++) { |
| 7526 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 7527 | input_attribs[i].location = i; |
| 7528 | } |
| 7529 | |
| 7530 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7531 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7532 | "\n" |
| 7533 | "layout(location=0) in mat2x4 x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7534 | "out gl_PerVertex {\n" |
| 7535 | " vec4 gl_Position;\n" |
| 7536 | "};\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7537 | "void main(){\n" |
| 7538 | " gl_Position = x[0] + x[1];\n" |
| 7539 | "}\n"; |
| 7540 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7541 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7542 | "\n" |
| 7543 | "layout(location=0) out vec4 color;\n" |
| 7544 | "void main(){\n" |
| 7545 | " color = vec4(1);\n" |
| 7546 | "}\n"; |
| 7547 | |
| 7548 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7549 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7550 | |
| 7551 | VkPipelineObj pipe(m_device); |
| 7552 | pipe.AddColorAttachment(); |
| 7553 | pipe.AddShader(&vs); |
| 7554 | pipe.AddShader(&fs); |
| 7555 | |
| 7556 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 7557 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 7558 | |
| 7559 | VkDescriptorSetObj descriptorSet(m_device); |
| 7560 | descriptorSet.AppendDummy(); |
| 7561 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7562 | |
| 7563 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7564 | |
| 7565 | /* expect success */ |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7566 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7567 | } |
| 7568 | |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7569 | TEST_F(VkLayerTest, CreatePipelineAttribArrayType) |
| 7570 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7571 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7572 | |
| 7573 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7574 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7575 | |
| 7576 | VkVertexInputBindingDescription input_binding; |
| 7577 | memset(&input_binding, 0, sizeof(input_binding)); |
| 7578 | |
| 7579 | VkVertexInputAttributeDescription input_attribs[2]; |
| 7580 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 7581 | |
| 7582 | for (int i = 0; i < 2; i++) { |
| 7583 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 7584 | input_attribs[i].location = i; |
| 7585 | } |
| 7586 | |
| 7587 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7588 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7589 | "\n" |
| 7590 | "layout(location=0) in vec4 x[2];\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7591 | "out gl_PerVertex {\n" |
| 7592 | " vec4 gl_Position;\n" |
| 7593 | "};\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7594 | "void main(){\n" |
| 7595 | " gl_Position = x[0] + x[1];\n" |
| 7596 | "}\n"; |
| 7597 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7598 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7599 | "\n" |
| 7600 | "layout(location=0) out vec4 color;\n" |
| 7601 | "void main(){\n" |
| 7602 | " color = vec4(1);\n" |
| 7603 | "}\n"; |
| 7604 | |
| 7605 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7606 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7607 | |
| 7608 | VkPipelineObj pipe(m_device); |
| 7609 | pipe.AddColorAttachment(); |
| 7610 | pipe.AddShader(&vs); |
| 7611 | pipe.AddShader(&fs); |
| 7612 | |
| 7613 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 7614 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 7615 | |
| 7616 | VkDescriptorSetObj descriptorSet(m_device); |
| 7617 | descriptorSet.AppendDummy(); |
| 7618 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7619 | |
| 7620 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7621 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7622 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7623 | } |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7624 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7625 | TEST_F(VkLayerTest, CreatePipelineSimplePositive) |
| 7626 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7627 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7628 | |
| 7629 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7630 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7631 | |
| 7632 | char const *vsSource = |
| 7633 | "#version 450\n" |
| 7634 | "out gl_PerVertex {\n" |
| 7635 | " vec4 gl_Position;\n" |
| 7636 | "};\n" |
| 7637 | "void main(){\n" |
| 7638 | " gl_Position = vec4(0);\n" |
| 7639 | "}\n"; |
| 7640 | char const *fsSource = |
| 7641 | "#version 450\n" |
| 7642 | "\n" |
| 7643 | "layout(location=0) out vec4 color;\n" |
| 7644 | "void main(){\n" |
| 7645 | " color = vec4(1);\n" |
| 7646 | "}\n"; |
| 7647 | |
| 7648 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7649 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7650 | |
| 7651 | VkPipelineObj pipe(m_device); |
| 7652 | pipe.AddColorAttachment(); |
| 7653 | pipe.AddShader(&vs); |
| 7654 | pipe.AddShader(&fs); |
| 7655 | |
| 7656 | VkDescriptorSetObj descriptorSet(m_device); |
| 7657 | descriptorSet.AppendDummy(); |
| 7658 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7659 | |
| 7660 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7661 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7662 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7663 | } |
| 7664 | |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 7665 | TEST_F(VkLayerTest, CreatePipelineRelaxedTypeMatch) |
| 7666 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7667 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 7668 | |
| 7669 | // VK 1.0.8 Specification, 14.1.3 "Additionally,..." block |
| 7670 | |
| 7671 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7672 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7673 | |
| 7674 | char const *vsSource = |
| 7675 | "#version 450\n" |
| 7676 | "out gl_PerVertex {\n" |
| 7677 | " vec4 gl_Position;\n" |
| 7678 | "};\n" |
| 7679 | "layout(location=0) out vec3 x;\n" |
| 7680 | "layout(location=1) out ivec3 y;\n" |
| 7681 | "layout(location=2) out vec3 z;\n" |
| 7682 | "void main(){\n" |
| 7683 | " gl_Position = vec4(0);\n" |
| 7684 | " x = vec3(0); y = ivec3(0); z = vec3(0);\n" |
| 7685 | "}\n"; |
| 7686 | char const *fsSource = |
| 7687 | "#version 450\n" |
| 7688 | "\n" |
| 7689 | "layout(location=0) out vec4 color;\n" |
| 7690 | "layout(location=0) in float x;\n" |
| 7691 | "layout(location=1) flat in int y;\n" |
| 7692 | "layout(location=2) in vec2 z;\n" |
| 7693 | "void main(){\n" |
| 7694 | " color = vec4(1 + x + y + z.x);\n" |
| 7695 | "}\n"; |
| 7696 | |
| 7697 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7698 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7699 | |
| 7700 | VkPipelineObj pipe(m_device); |
| 7701 | pipe.AddColorAttachment(); |
| 7702 | pipe.AddShader(&vs); |
| 7703 | pipe.AddShader(&fs); |
| 7704 | |
| 7705 | VkDescriptorSetObj descriptorSet(m_device); |
| 7706 | descriptorSet.AppendDummy(); |
| 7707 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7708 | |
| 7709 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7710 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7711 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 7712 | } |
| 7713 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7714 | TEST_F(VkLayerTest, CreatePipelineTessPerVertex) |
| 7715 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7716 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7717 | |
| 7718 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7719 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7720 | |
Chris Forbes | c1e852d | 2016-04-04 19:26:42 +1200 | [diff] [blame] | 7721 | if (!m_device->phy().features().tessellationShader) { |
| 7722 | printf("Device does not support tessellation shaders; skipped.\n"); |
| 7723 | return; |
| 7724 | } |
| 7725 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7726 | char const *vsSource = |
| 7727 | "#version 450\n" |
| 7728 | "void main(){}\n"; |
| 7729 | char const *tcsSource = |
| 7730 | "#version 450\n" |
| 7731 | "layout(location=0) out int x[];\n" |
| 7732 | "layout(vertices=3) out;\n" |
| 7733 | "void main(){\n" |
| 7734 | " gl_TessLevelOuter[0] = gl_TessLevelOuter[1] = gl_TessLevelOuter[2] = 1;\n" |
| 7735 | " gl_TessLevelInner[0] = 1;\n" |
| 7736 | " x[gl_InvocationID] = gl_InvocationID;\n" |
| 7737 | "}\n"; |
| 7738 | char const *tesSource = |
| 7739 | "#version 450\n" |
| 7740 | "layout(triangles, equal_spacing, cw) in;\n" |
| 7741 | "layout(location=0) in int x[];\n" |
| 7742 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 7743 | "void main(){\n" |
| 7744 | " gl_Position.xyz = gl_TessCoord;\n" |
| 7745 | " gl_Position.w = x[0] + x[1] + x[2];\n" |
| 7746 | "}\n"; |
| 7747 | char const *fsSource = |
| 7748 | "#version 450\n" |
| 7749 | "layout(location=0) out vec4 color;\n" |
| 7750 | "void main(){\n" |
| 7751 | " color = vec4(1);\n" |
| 7752 | "}\n"; |
| 7753 | |
| 7754 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7755 | VkShaderObj tcs(m_device, tcsSource, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 7756 | VkShaderObj tes(m_device, tesSource, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
| 7757 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7758 | |
| 7759 | VkPipelineInputAssemblyStateCreateInfo iasci{ |
| 7760 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, |
| 7761 | nullptr, |
| 7762 | 0, |
| 7763 | VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, |
| 7764 | VK_FALSE}; |
| 7765 | |
Chris Forbes | b4cacb6 | 2016-04-04 19:15:00 +1200 | [diff] [blame] | 7766 | VkPipelineTessellationStateCreateInfo tsci{ |
| 7767 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, |
| 7768 | nullptr, |
| 7769 | 0, |
| 7770 | 3}; |
| 7771 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7772 | VkPipelineObj pipe(m_device); |
| 7773 | pipe.SetInputAssembly(&iasci); |
Chris Forbes | b4cacb6 | 2016-04-04 19:15:00 +1200 | [diff] [blame] | 7774 | pipe.SetTessellation(&tsci); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7775 | pipe.AddColorAttachment(); |
| 7776 | pipe.AddShader(&vs); |
| 7777 | pipe.AddShader(&tcs); |
| 7778 | pipe.AddShader(&tes); |
| 7779 | pipe.AddShader(&fs); |
| 7780 | |
| 7781 | VkDescriptorSetObj descriptorSet(m_device); |
| 7782 | descriptorSet.AppendDummy(); |
| 7783 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7784 | |
| 7785 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7786 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7787 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7788 | } |
| 7789 | |
Chris Forbes | a0ab815 | 2016-04-20 13:34:27 +1200 | [diff] [blame] | 7790 | TEST_F(VkLayerTest, CreatePipelineGeometryInputBlockPositive) |
| 7791 | { |
| 7792 | m_errorMonitor->ExpectSuccess(); |
| 7793 | |
| 7794 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7795 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7796 | |
| 7797 | if (!m_device->phy().features().geometryShader) { |
| 7798 | printf("Device does not support geometry shaders; skipped.\n"); |
| 7799 | return; |
| 7800 | } |
| 7801 | |
| 7802 | char const *vsSource = |
| 7803 | "#version 450\n" |
| 7804 | "layout(location=0) out VertexData { vec4 x; } vs_out;\n" |
| 7805 | "void main(){\n" |
| 7806 | " vs_out.x = vec4(1);\n" |
| 7807 | "}\n"; |
| 7808 | char const *gsSource = |
| 7809 | "#version 450\n" |
| 7810 | "layout(triangles) in;\n" |
| 7811 | "layout(triangle_strip, max_vertices=3) out;\n" |
| 7812 | "layout(location=0) in VertexData { vec4 x; } gs_in[];\n" |
| 7813 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 7814 | "void main() {\n" |
| 7815 | " gl_Position = gs_in[0].x;\n" |
| 7816 | " EmitVertex();\n" |
| 7817 | "}\n"; |
| 7818 | char const *fsSource = |
| 7819 | "#version 450\n" |
| 7820 | "layout(location=0) out vec4 color;\n" |
| 7821 | "void main(){\n" |
| 7822 | " color = vec4(1);\n" |
| 7823 | "}\n"; |
| 7824 | |
| 7825 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7826 | VkShaderObj gs(m_device, gsSource, VK_SHADER_STAGE_GEOMETRY_BIT, this); |
| 7827 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7828 | |
| 7829 | VkPipelineObj pipe(m_device); |
| 7830 | pipe.AddColorAttachment(); |
| 7831 | pipe.AddShader(&vs); |
| 7832 | pipe.AddShader(&gs); |
| 7833 | pipe.AddShader(&fs); |
| 7834 | |
| 7835 | VkDescriptorSetObj descriptorSet(m_device); |
| 7836 | descriptorSet.AppendDummy(); |
| 7837 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7838 | |
| 7839 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7840 | |
| 7841 | m_errorMonitor->VerifyNotFound(); |
| 7842 | } |
| 7843 | |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 7844 | TEST_F(VkLayerTest, CreatePipelineTessPatchDecorationMismatch) |
| 7845 | { |
| 7846 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7847 | "is per-vertex in tessellation control shader stage " |
| 7848 | "but per-patch in tessellation evaluation shader stage"); |
| 7849 | |
| 7850 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7851 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7852 | |
Chris Forbes | c1e852d | 2016-04-04 19:26:42 +1200 | [diff] [blame] | 7853 | if (!m_device->phy().features().tessellationShader) { |
| 7854 | printf("Device does not support tessellation shaders; skipped.\n"); |
| 7855 | return; |
| 7856 | } |
| 7857 | |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 7858 | char const *vsSource = |
| 7859 | "#version 450\n" |
| 7860 | "void main(){}\n"; |
| 7861 | char const *tcsSource = |
| 7862 | "#version 450\n" |
| 7863 | "layout(location=0) out int x[];\n" |
| 7864 | "layout(vertices=3) out;\n" |
| 7865 | "void main(){\n" |
| 7866 | " gl_TessLevelOuter[0] = gl_TessLevelOuter[1] = gl_TessLevelOuter[2] = 1;\n" |
| 7867 | " gl_TessLevelInner[0] = 1;\n" |
| 7868 | " x[gl_InvocationID] = gl_InvocationID;\n" |
| 7869 | "}\n"; |
| 7870 | char const *tesSource = |
| 7871 | "#version 450\n" |
| 7872 | "layout(triangles, equal_spacing, cw) in;\n" |
| 7873 | "layout(location=0) patch in int x;\n" |
| 7874 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 7875 | "void main(){\n" |
| 7876 | " gl_Position.xyz = gl_TessCoord;\n" |
| 7877 | " gl_Position.w = x;\n" |
| 7878 | "}\n"; |
| 7879 | char const *fsSource = |
| 7880 | "#version 450\n" |
| 7881 | "layout(location=0) out vec4 color;\n" |
| 7882 | "void main(){\n" |
| 7883 | " color = vec4(1);\n" |
| 7884 | "}\n"; |
| 7885 | |
| 7886 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7887 | VkShaderObj tcs(m_device, tcsSource, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 7888 | VkShaderObj tes(m_device, tesSource, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
| 7889 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7890 | |
| 7891 | VkPipelineInputAssemblyStateCreateInfo iasci{ |
| 7892 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, |
| 7893 | nullptr, |
| 7894 | 0, |
| 7895 | VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, |
| 7896 | VK_FALSE}; |
| 7897 | |
| 7898 | VkPipelineTessellationStateCreateInfo tsci{ |
| 7899 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, |
| 7900 | nullptr, |
| 7901 | 0, |
| 7902 | 3}; |
| 7903 | |
| 7904 | VkPipelineObj pipe(m_device); |
| 7905 | pipe.SetInputAssembly(&iasci); |
| 7906 | pipe.SetTessellation(&tsci); |
| 7907 | pipe.AddColorAttachment(); |
| 7908 | pipe.AddShader(&vs); |
| 7909 | pipe.AddShader(&tcs); |
| 7910 | pipe.AddShader(&tes); |
| 7911 | pipe.AddShader(&fs); |
| 7912 | |
| 7913 | VkDescriptorSetObj descriptorSet(m_device); |
| 7914 | descriptorSet.AppendDummy(); |
| 7915 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7916 | |
| 7917 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7918 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7919 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 7920 | } |
| 7921 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7922 | TEST_F(VkLayerTest, CreatePipelineAttribBindingConflict) { |
| 7923 | m_errorMonitor->SetDesiredFailureMsg( |
| 7924 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7925 | "Duplicate vertex input binding descriptions for binding 0"); |
| 7926 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7927 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 7928 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7929 | |
| 7930 | /* Two binding descriptions for binding 0 */ |
| 7931 | VkVertexInputBindingDescription input_bindings[2]; |
| 7932 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 7933 | |
| 7934 | VkVertexInputAttributeDescription input_attrib; |
| 7935 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 7936 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 7937 | |
| 7938 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7939 | "#version 450\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7940 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7941 | "layout(location=0) in float x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7942 | "out gl_PerVertex {\n" |
| 7943 | " vec4 gl_Position;\n" |
| 7944 | "};\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7945 | "void main(){\n" |
| 7946 | " gl_Position = vec4(x);\n" |
| 7947 | "}\n"; |
| 7948 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7949 | "#version 450\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7950 | "\n" |
| 7951 | "layout(location=0) out vec4 color;\n" |
| 7952 | "void main(){\n" |
| 7953 | " color = vec4(1);\n" |
| 7954 | "}\n"; |
| 7955 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 7956 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7957 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7958 | |
| 7959 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 7960 | pipe.AddColorAttachment(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7961 | pipe.AddShader(&vs); |
| 7962 | pipe.AddShader(&fs); |
| 7963 | |
| 7964 | pipe.AddVertexInputBindings(input_bindings, 2); |
| 7965 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 7966 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7967 | VkDescriptorSetObj descriptorSet(m_device); |
| 7968 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7969 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7970 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 7971 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7972 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7973 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 7974 | } |
Chris Forbes | 8f68b56 | 2015-05-25 11:13:32 +1200 | [diff] [blame] | 7975 | |
Chris Forbes | 35efec7 | 2016-04-21 14:32:08 +1200 | [diff] [blame] | 7976 | TEST_F(VkLayerTest, CreatePipeline64BitAttributesPositive) { |
| 7977 | m_errorMonitor->ExpectSuccess(); |
| 7978 | |
| 7979 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7980 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7981 | |
| 7982 | if (!m_device->phy().features().tessellationShader) { |
| 7983 | printf("Device does not support 64bit vertex attributes; skipped.\n"); |
| 7984 | return; |
| 7985 | } |
| 7986 | |
| 7987 | VkVertexInputBindingDescription input_bindings[1]; |
| 7988 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 7989 | |
| 7990 | VkVertexInputAttributeDescription input_attribs[4]; |
| 7991 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 7992 | input_attribs[0].location = 0; |
| 7993 | input_attribs[0].offset = 0; |
| 7994 | input_attribs[0].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 7995 | input_attribs[1].location = 2; |
| 7996 | input_attribs[1].offset = 32; |
| 7997 | input_attribs[1].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 7998 | input_attribs[2].location = 4; |
| 7999 | input_attribs[2].offset = 64; |
| 8000 | input_attribs[2].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 8001 | input_attribs[3].location = 6; |
| 8002 | input_attribs[3].offset = 96; |
| 8003 | input_attribs[3].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 8004 | |
| 8005 | char const *vsSource = |
| 8006 | "#version 450\n" |
| 8007 | "\n" |
| 8008 | "layout(location=0) in dmat4 x;\n" |
| 8009 | "out gl_PerVertex {\n" |
| 8010 | " vec4 gl_Position;\n" |
| 8011 | "};\n" |
| 8012 | "void main(){\n" |
| 8013 | " gl_Position = vec4(x[0][0]);\n" |
| 8014 | "}\n"; |
| 8015 | char const *fsSource = |
| 8016 | "#version 450\n" |
| 8017 | "\n" |
| 8018 | "layout(location=0) out vec4 color;\n" |
| 8019 | "void main(){\n" |
| 8020 | " color = vec4(1);\n" |
| 8021 | "}\n"; |
| 8022 | |
| 8023 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8024 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8025 | |
| 8026 | VkPipelineObj pipe(m_device); |
| 8027 | pipe.AddColorAttachment(); |
| 8028 | pipe.AddShader(&vs); |
| 8029 | pipe.AddShader(&fs); |
| 8030 | |
| 8031 | pipe.AddVertexInputBindings(input_bindings, 1); |
| 8032 | pipe.AddVertexInputAttribs(input_attribs, 4); |
| 8033 | |
| 8034 | VkDescriptorSetObj descriptorSet(m_device); |
| 8035 | descriptorSet.AppendDummy(); |
| 8036 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8037 | |
| 8038 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8039 | |
| 8040 | m_errorMonitor->VerifyNotFound(); |
| 8041 | } |
| 8042 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8043 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotWritten) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8044 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8045 | "Attachment 0 not written by FS"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8046 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 8047 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 8048 | |
| 8049 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8050 | "#version 450\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 8051 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8052 | "out gl_PerVertex {\n" |
| 8053 | " vec4 gl_Position;\n" |
| 8054 | "};\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 8055 | "void main(){\n" |
| 8056 | " gl_Position = vec4(1);\n" |
| 8057 | "}\n"; |
| 8058 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8059 | "#version 450\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 8060 | "\n" |
| 8061 | "void main(){\n" |
| 8062 | "}\n"; |
| 8063 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8064 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8065 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 8066 | |
| 8067 | VkPipelineObj pipe(m_device); |
| 8068 | pipe.AddShader(&vs); |
| 8069 | pipe.AddShader(&fs); |
| 8070 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 8071 | /* set up CB 0, not written */ |
| 8072 | pipe.AddColorAttachment(); |
| 8073 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 8074 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 8075 | VkDescriptorSetObj descriptorSet(m_device); |
| 8076 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8077 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 8078 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 8079 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 8080 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8081 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 8082 | } |
| 8083 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8084 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotConsumed) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8085 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 8086 | VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8087 | "FS writes to output location 1 with no matching attachment"); |
| 8088 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 8089 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 8090 | |
| 8091 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8092 | "#version 450\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 8093 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8094 | "out gl_PerVertex {\n" |
| 8095 | " vec4 gl_Position;\n" |
| 8096 | "};\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 8097 | "void main(){\n" |
| 8098 | " gl_Position = vec4(1);\n" |
| 8099 | "}\n"; |
| 8100 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8101 | "#version 450\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 8102 | "\n" |
| 8103 | "layout(location=0) out vec4 x;\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8104 | "layout(location=1) out vec4 y;\n" /* no matching attachment for this */ |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 8105 | "void main(){\n" |
| 8106 | " x = vec4(1);\n" |
| 8107 | " y = vec4(1);\n" |
| 8108 | "}\n"; |
| 8109 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8110 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8111 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 8112 | |
| 8113 | VkPipelineObj pipe(m_device); |
| 8114 | pipe.AddShader(&vs); |
| 8115 | pipe.AddShader(&fs); |
| 8116 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 8117 | /* set up CB 0, not written */ |
| 8118 | pipe.AddColorAttachment(); |
| 8119 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 8120 | /* FS writes CB 1, but we don't configure it */ |
| 8121 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 8122 | VkDescriptorSetObj descriptorSet(m_device); |
| 8123 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8124 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 8125 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 8126 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 8127 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8128 | m_errorMonitor->VerifyFound(); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 8129 | } |
| 8130 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8131 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputTypeMismatch) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8132 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8133 | "does not match FS output type"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8134 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 8135 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 8136 | |
| 8137 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8138 | "#version 450\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 8139 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8140 | "out gl_PerVertex {\n" |
| 8141 | " vec4 gl_Position;\n" |
| 8142 | "};\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 8143 | "void main(){\n" |
| 8144 | " gl_Position = vec4(1);\n" |
| 8145 | "}\n"; |
| 8146 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8147 | "#version 450\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 8148 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8149 | "layout(location=0) out ivec4 x;\n" /* not UNORM */ |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 8150 | "void main(){\n" |
| 8151 | " x = ivec4(1);\n" |
| 8152 | "}\n"; |
| 8153 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8154 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8155 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 8156 | |
| 8157 | VkPipelineObj pipe(m_device); |
| 8158 | pipe.AddShader(&vs); |
| 8159 | pipe.AddShader(&fs); |
| 8160 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 8161 | /* set up CB 0; type is UNORM by default */ |
| 8162 | pipe.AddColorAttachment(); |
| 8163 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 8164 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 8165 | VkDescriptorSetObj descriptorSet(m_device); |
| 8166 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8167 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 8168 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 8169 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 8170 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8171 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 8172 | } |
Chris Forbes | 7b1b893 | 2015-06-05 14:43:36 +1200 | [diff] [blame] | 8173 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8174 | TEST_F(VkLayerTest, CreatePipelineUniformBlockNotProvided) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8175 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8176 | "not declared in pipeline layout"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8177 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 8178 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 8179 | |
| 8180 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8181 | "#version 450\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 8182 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8183 | "out gl_PerVertex {\n" |
| 8184 | " vec4 gl_Position;\n" |
| 8185 | "};\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 8186 | "void main(){\n" |
| 8187 | " gl_Position = vec4(1);\n" |
| 8188 | "}\n"; |
| 8189 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8190 | "#version 450\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 8191 | "\n" |
| 8192 | "layout(location=0) out vec4 x;\n" |
| 8193 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 8194 | "void main(){\n" |
| 8195 | " x = vec4(bar.y);\n" |
| 8196 | "}\n"; |
| 8197 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8198 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8199 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 8200 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 8201 | VkPipelineObj pipe(m_device); |
| 8202 | pipe.AddShader(&vs); |
| 8203 | pipe.AddShader(&fs); |
| 8204 | |
| 8205 | /* set up CB 0; type is UNORM by default */ |
| 8206 | pipe.AddColorAttachment(); |
| 8207 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8208 | |
| 8209 | VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8210 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 8211 | |
| 8212 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8213 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8214 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 8215 | } |
| 8216 | |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 8217 | TEST_F(VkLayerTest, CreatePipelinePushConstantsNotInLayout) { |
| 8218 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8219 | "not declared in layout"); |
| 8220 | |
| 8221 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8222 | |
| 8223 | char const *vsSource = |
| 8224 | "#version 450\n" |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 8225 | "\n" |
| 8226 | "layout(push_constant, std430) uniform foo { float x; } consts;\n" |
| 8227 | "out gl_PerVertex {\n" |
| 8228 | " vec4 gl_Position;\n" |
| 8229 | "};\n" |
| 8230 | "void main(){\n" |
| 8231 | " gl_Position = vec4(consts.x);\n" |
| 8232 | "}\n"; |
| 8233 | char const *fsSource = |
| 8234 | "#version 450\n" |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 8235 | "\n" |
| 8236 | "layout(location=0) out vec4 x;\n" |
| 8237 | "void main(){\n" |
| 8238 | " x = vec4(1);\n" |
| 8239 | "}\n"; |
| 8240 | |
| 8241 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8242 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8243 | |
| 8244 | VkPipelineObj pipe(m_device); |
| 8245 | pipe.AddShader(&vs); |
| 8246 | pipe.AddShader(&fs); |
| 8247 | |
| 8248 | /* set up CB 0; type is UNORM by default */ |
| 8249 | pipe.AddColorAttachment(); |
| 8250 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8251 | |
| 8252 | VkDescriptorSetObj descriptorSet(m_device); |
| 8253 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8254 | |
| 8255 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8256 | |
| 8257 | /* should have generated an error -- no push constant ranges provided! */ |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8258 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 8259 | } |
| 8260 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 8261 | #endif // SHADER_CHECKER_TESTS |
| 8262 | |
| 8263 | #if DEVICE_LIMITS_TESTS |
Mark Young | c48c4c1 | 2016-04-11 14:26:49 -0600 | [diff] [blame] | 8264 | TEST_F(VkLayerTest, CreateImageLimitsViolationMaxWidth) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8265 | m_errorMonitor->SetDesiredFailureMsg( |
| 8266 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8267 | "CreateImage extents exceed allowable limits for format"); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 8268 | |
| 8269 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 8270 | |
| 8271 | // Create an image |
| 8272 | VkImage image; |
| 8273 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8274 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8275 | const int32_t tex_width = 32; |
| 8276 | const int32_t tex_height = 32; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 8277 | |
| 8278 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8279 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8280 | image_create_info.pNext = NULL; |
| 8281 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8282 | image_create_info.format = tex_format; |
| 8283 | image_create_info.extent.width = tex_width; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 8284 | image_create_info.extent.height = tex_height; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8285 | image_create_info.extent.depth = 1; |
| 8286 | image_create_info.mipLevels = 1; |
| 8287 | image_create_info.arrayLayers = 1; |
| 8288 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8289 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 8290 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 8291 | image_create_info.flags = 0; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 8292 | |
| 8293 | // Introduce error by sending down a bogus width extent |
| 8294 | image_create_info.extent.width = 65536; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8295 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 8296 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8297 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 8298 | } |
| 8299 | |
Mark Young | c48c4c1 | 2016-04-11 14:26:49 -0600 | [diff] [blame] | 8300 | TEST_F(VkLayerTest, CreateImageLimitsViolationMinWidth) { |
| 8301 | m_errorMonitor->SetDesiredFailureMsg( |
| 8302 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8303 | "CreateImage extents is 0 for at least one required dimension"); |
| 8304 | |
| 8305 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8306 | |
| 8307 | // Create an image |
| 8308 | VkImage image; |
| 8309 | |
| 8310 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8311 | const int32_t tex_width = 32; |
| 8312 | const int32_t tex_height = 32; |
| 8313 | |
| 8314 | VkImageCreateInfo image_create_info = {}; |
| 8315 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8316 | image_create_info.pNext = NULL; |
| 8317 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8318 | image_create_info.format = tex_format; |
| 8319 | image_create_info.extent.width = tex_width; |
| 8320 | image_create_info.extent.height = tex_height; |
| 8321 | image_create_info.extent.depth = 1; |
| 8322 | image_create_info.mipLevels = 1; |
| 8323 | image_create_info.arrayLayers = 1; |
| 8324 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8325 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 8326 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 8327 | image_create_info.flags = 0; |
| 8328 | |
| 8329 | // Introduce error by sending down a bogus width extent |
| 8330 | image_create_info.extent.width = 0; |
| 8331 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 8332 | |
| 8333 | m_errorMonitor->VerifyFound(); |
| 8334 | } |
| 8335 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8336 | TEST_F(VkLayerTest, UpdateBufferAlignment) { |
| 8337 | uint32_t updateData[] = {1, 2, 3, 4, 5, 6, 7, 8}; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8338 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8339 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8340 | "dstOffset, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8341 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8342 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8343 | |
| 8344 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 8345 | vk_testing::Buffer buffer; |
| 8346 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 8347 | |
| 8348 | BeginCommandBuffer(); |
| 8349 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8350 | m_commandBuffer->UpdateBuffer(buffer.handle(), 1, 4, updateData); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8351 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8352 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8353 | // Introduce failure by using size that is not multiple of 4 |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8354 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8355 | "dataSize, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8356 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8357 | m_commandBuffer->UpdateBuffer(buffer.handle(), 0, 6, updateData); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8358 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8359 | EndCommandBuffer(); |
| 8360 | } |
| 8361 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8362 | TEST_F(VkLayerTest, FillBufferAlignment) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8363 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8364 | "dstOffset, is not a multiple of 4"); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8365 | |
| 8366 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8367 | |
| 8368 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 8369 | vk_testing::Buffer buffer; |
| 8370 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 8371 | |
| 8372 | BeginCommandBuffer(); |
| 8373 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8374 | m_commandBuffer->FillBuffer(buffer.handle(), 1, 4, 0x11111111); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8375 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8376 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8377 | // Introduce failure by using size that is not multiple of 4 |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8378 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8379 | "size, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8380 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8381 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 6, 0x11111111); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8382 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8383 | m_errorMonitor->VerifyFound(); |
| 8384 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8385 | EndCommandBuffer(); |
| 8386 | } |
| 8387 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 8388 | #endif // DEVICE_LIMITS_TESTS |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 8389 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8390 | #if IMAGE_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8391 | TEST_F(VkLayerTest, InvalidImageView) { |
| 8392 | VkResult err; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8393 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8394 | m_errorMonitor->SetDesiredFailureMsg( |
| 8395 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8396 | "vkCreateImageView called with baseMipLevel 10 "); |
| 8397 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8398 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8399 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8400 | // Create an image and try to create a view with bad baseMipLevel |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8401 | VkImage image; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8402 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8403 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8404 | const int32_t tex_width = 32; |
| 8405 | const int32_t tex_height = 32; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8406 | |
| 8407 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8408 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8409 | image_create_info.pNext = NULL; |
| 8410 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8411 | image_create_info.format = tex_format; |
| 8412 | image_create_info.extent.width = tex_width; |
| 8413 | image_create_info.extent.height = tex_height; |
| 8414 | image_create_info.extent.depth = 1; |
| 8415 | image_create_info.mipLevels = 1; |
| 8416 | image_create_info.arrayLayers = 1; |
| 8417 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8418 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 8419 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 8420 | image_create_info.flags = 0; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8421 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8422 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8423 | ASSERT_VK_SUCCESS(err); |
| 8424 | |
| 8425 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8426 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8427 | image_view_create_info.image = image; |
| 8428 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 8429 | image_view_create_info.format = tex_format; |
| 8430 | image_view_create_info.subresourceRange.layerCount = 1; |
| 8431 | image_view_create_info.subresourceRange.baseMipLevel = 10; // cause an error |
| 8432 | image_view_create_info.subresourceRange.levelCount = 1; |
| 8433 | image_view_create_info.subresourceRange.aspectMask = |
| 8434 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8435 | |
| 8436 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8437 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 8438 | &view); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8439 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8440 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8441 | } |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8442 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8443 | TEST_F(VkLayerTest, InvalidImageViewAspect) { |
| 8444 | VkResult err; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 8445 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8446 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8447 | "vkCreateImageView: Color image " |
| 8448 | "formats must have ONLY the " |
| 8449 | "VK_IMAGE_ASPECT_COLOR_BIT set"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8450 | |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 8451 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 8452 | |
| 8453 | // Create an image and try to create a view with an invalid aspectMask |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8454 | VkImage image; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 8455 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8456 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8457 | const int32_t tex_width = 32; |
| 8458 | const int32_t tex_height = 32; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 8459 | |
| 8460 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8461 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8462 | image_create_info.pNext = NULL; |
| 8463 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8464 | image_create_info.format = tex_format; |
| 8465 | image_create_info.extent.width = tex_width; |
| 8466 | image_create_info.extent.height = tex_height; |
| 8467 | image_create_info.extent.depth = 1; |
| 8468 | image_create_info.mipLevels = 1; |
| 8469 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8470 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 8471 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 8472 | image_create_info.flags = 0; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 8473 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8474 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 8475 | ASSERT_VK_SUCCESS(err); |
| 8476 | |
| 8477 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8478 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8479 | image_view_create_info.image = image; |
| 8480 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 8481 | image_view_create_info.format = tex_format; |
| 8482 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 8483 | image_view_create_info.subresourceRange.levelCount = 1; |
| 8484 | // Cause an error by setting an invalid image aspect |
| 8485 | image_view_create_info.subresourceRange.aspectMask = |
| 8486 | VK_IMAGE_ASPECT_METADATA_BIT; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 8487 | |
| 8488 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8489 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 8490 | &view); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 8491 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8492 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 8493 | } |
| 8494 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 8495 | TEST_F(VkLayerTest, CopyImageLayerCountMismatch) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8496 | VkResult err; |
| 8497 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8498 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8499 | m_errorMonitor->SetDesiredFailureMsg( |
| 8500 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 8501 | "vkCmdCopyImage: number of layers in source and destination subresources for pRegions"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8502 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8503 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8504 | |
| 8505 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8506 | VkImage srcImage; |
| 8507 | VkImage dstImage; |
| 8508 | VkDeviceMemory srcMem; |
| 8509 | VkDeviceMemory destMem; |
| 8510 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8511 | |
| 8512 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8513 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8514 | image_create_info.pNext = NULL; |
| 8515 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8516 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8517 | image_create_info.extent.width = 32; |
| 8518 | image_create_info.extent.height = 32; |
| 8519 | image_create_info.extent.depth = 1; |
| 8520 | image_create_info.mipLevels = 1; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 8521 | image_create_info.arrayLayers = 4; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8522 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8523 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 8524 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 8525 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8526 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8527 | err = |
| 8528 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8529 | ASSERT_VK_SUCCESS(err); |
| 8530 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8531 | err = |
| 8532 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8533 | ASSERT_VK_SUCCESS(err); |
| 8534 | |
| 8535 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8536 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8537 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 8538 | memAlloc.pNext = NULL; |
| 8539 | memAlloc.allocationSize = 0; |
| 8540 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8541 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 8542 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8543 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8544 | pass = |
| 8545 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 8546 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8547 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8548 | ASSERT_VK_SUCCESS(err); |
| 8549 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8550 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8551 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8552 | pass = |
| 8553 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8554 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8555 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8556 | ASSERT_VK_SUCCESS(err); |
| 8557 | |
| 8558 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 8559 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8560 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8561 | ASSERT_VK_SUCCESS(err); |
| 8562 | |
| 8563 | BeginCommandBuffer(); |
| 8564 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8565 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8566 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 8567 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 8568 | copyRegion.srcSubresource.layerCount = 1; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8569 | copyRegion.srcOffset.x = 0; |
| 8570 | copyRegion.srcOffset.y = 0; |
| 8571 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8572 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8573 | copyRegion.dstSubresource.mipLevel = 0; |
| 8574 | copyRegion.dstSubresource.baseArrayLayer = 0; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 8575 | // Introduce failure by forcing the dst layerCount to differ from src |
| 8576 | copyRegion.dstSubresource.layerCount = 3; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8577 | copyRegion.dstOffset.x = 0; |
| 8578 | copyRegion.dstOffset.y = 0; |
| 8579 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8580 | copyRegion.extent.width = 1; |
| 8581 | copyRegion.extent.height = 1; |
| 8582 | copyRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8583 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 8584 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8585 | EndCommandBuffer(); |
| 8586 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8587 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8588 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8589 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8590 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8591 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 8592 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8593 | } |
| 8594 | |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 8595 | TEST_F(VkLayerTest, ImageLayerUnsupportedFormat) { |
| 8596 | |
| 8597 | TEST_DESCRIPTION("Creating images with unsuported formats "); |
| 8598 | |
| 8599 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8600 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8601 | VkImageObj image(m_device); |
| 8602 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 8603 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 8604 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 8605 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 8606 | ASSERT_TRUE(image.initialized()); |
| 8607 | |
| 8608 | VkFormat unsupported = VK_FORMAT_UNDEFINED; |
| 8609 | for (int f = VK_FORMAT_BEGIN_RANGE; f <= VK_FORMAT_END_RANGE; f++) { |
| 8610 | VkFormat format = static_cast<VkFormat>(f); |
| 8611 | VkFormatProperties fProps = m_device->format_properties(format); |
| 8612 | if (format != VK_FORMAT_UNDEFINED && fProps.linearTilingFeatures == 0 && |
| 8613 | fProps.optimalTilingFeatures == 0) { |
| 8614 | unsupported = format; |
| 8615 | break; |
| 8616 | } |
| 8617 | } |
| 8618 | if (unsupported != VK_FORMAT_UNDEFINED) { |
| 8619 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8620 | "vkCreateImage parameter, " |
| 8621 | "VkFormat pCreateInfo->format, " |
| 8622 | "contains unsupported format"); |
| 8623 | // Create image with unsupported format - Expect FORMAT_UNSUPPORTED |
| 8624 | VkImageCreateInfo image_create_info; |
| 8625 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8626 | image_create_info.pNext = NULL; |
| 8627 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8628 | image_create_info.format = unsupported; |
| 8629 | image_create_info.extent.width = 32; |
| 8630 | image_create_info.extent.height = 32; |
| 8631 | image_create_info.extent.depth = 1; |
| 8632 | image_create_info.mipLevels = 1; |
| 8633 | image_create_info.arrayLayers = 1; |
| 8634 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8635 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 8636 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 8637 | image_create_info.flags = 0; |
| 8638 | |
| 8639 | VkImage localImage; |
| 8640 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &localImage); |
| 8641 | m_errorMonitor->VerifyFound(); |
| 8642 | |
| 8643 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8644 | "vkCreateRenderPass parameter, " |
| 8645 | "VkFormat in " |
| 8646 | "pCreateInfo->pAttachments"); |
| 8647 | // Create renderpass with unsupported format - Expect FORMAT_UNSUPPORTED |
| 8648 | VkAttachmentDescription att; |
| 8649 | att.format = unsupported; |
| 8650 | att.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8651 | att.loadOp = VK_ATTACHMENT_LOAD_OP_LOAD; |
| 8652 | att.storeOp = VK_ATTACHMENT_STORE_OP_STORE; |
| 8653 | att.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; |
| 8654 | att.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; |
| 8655 | att.initialLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 8656 | att.finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 8657 | |
| 8658 | VkRenderPassCreateInfo rp_info = {}; |
| 8659 | VkRenderPass rp; |
| 8660 | rp_info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; |
| 8661 | rp_info.attachmentCount = 1; |
| 8662 | rp_info.pAttachments = &att; |
| 8663 | rp_info.subpassCount = 0; |
| 8664 | rp_info.pSubpasses = NULL; |
| 8665 | vkCreateRenderPass(m_device->handle(), &rp_info, NULL, &rp); |
| 8666 | m_errorMonitor->VerifyFound(); |
| 8667 | } |
| 8668 | } |
| 8669 | |
| 8670 | TEST_F(VkLayerTest, ImageLayerViewTests) { |
| 8671 | VkResult ret; |
| 8672 | TEST_DESCRIPTION("Passing bad parameters to CreateImageView"); |
| 8673 | |
| 8674 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8675 | |
| 8676 | VkImageObj image(m_device); |
| 8677 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 8678 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 8679 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 8680 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 8681 | ASSERT_TRUE(image.initialized()); |
| 8682 | |
| 8683 | VkImageView imgView; |
| 8684 | VkImageViewCreateInfo imgViewInfo = {}; |
| 8685 | imgViewInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 8686 | imgViewInfo.image = image.handle(); |
| 8687 | imgViewInfo.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 8688 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8689 | imgViewInfo.subresourceRange.layerCount = 1; |
| 8690 | imgViewInfo.subresourceRange.baseMipLevel = 0; |
| 8691 | imgViewInfo.subresourceRange.levelCount = 1; |
| 8692 | imgViewInfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8693 | |
| 8694 | m_errorMonitor->SetDesiredFailureMsg( |
| 8695 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8696 | "vkCreateImageView called with baseMipLevel"); |
| 8697 | // View can't have baseMipLevel >= image's mipLevels - Expect |
| 8698 | // VIEW_CREATE_ERROR |
| 8699 | imgViewInfo.subresourceRange.baseMipLevel = 1; |
| 8700 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 8701 | m_errorMonitor->VerifyFound(); |
| 8702 | imgViewInfo.subresourceRange.baseMipLevel = 0; |
| 8703 | |
| 8704 | m_errorMonitor->SetDesiredFailureMsg( |
| 8705 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8706 | "vkCreateImageView called with baseArrayLayer"); |
| 8707 | // View can't have baseArrayLayer >= image's arraySize - Expect |
| 8708 | // VIEW_CREATE_ERROR |
| 8709 | imgViewInfo.subresourceRange.baseArrayLayer = 1; |
| 8710 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 8711 | m_errorMonitor->VerifyFound(); |
| 8712 | imgViewInfo.subresourceRange.baseArrayLayer = 0; |
| 8713 | |
| 8714 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8715 | "vkCreateImageView called with 0 in " |
| 8716 | "pCreateInfo->subresourceRange." |
| 8717 | "levelCount"); |
| 8718 | // View's levelCount can't be 0 - Expect VIEW_CREATE_ERROR |
| 8719 | imgViewInfo.subresourceRange.levelCount = 0; |
| 8720 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 8721 | m_errorMonitor->VerifyFound(); |
| 8722 | imgViewInfo.subresourceRange.levelCount = 1; |
| 8723 | |
| 8724 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8725 | "vkCreateImageView called with 0 in " |
| 8726 | "pCreateInfo->subresourceRange." |
| 8727 | "layerCount"); |
| 8728 | // View's layerCount can't be 0 - Expect VIEW_CREATE_ERROR |
| 8729 | imgViewInfo.subresourceRange.layerCount = 0; |
| 8730 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 8731 | m_errorMonitor->VerifyFound(); |
| 8732 | imgViewInfo.subresourceRange.layerCount = 1; |
| 8733 | |
| 8734 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8735 | "but both must be color formats"); |
| 8736 | // Can't use depth format for view into color image - Expect INVALID_FORMAT |
| 8737 | imgViewInfo.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 8738 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 8739 | m_errorMonitor->VerifyFound(); |
| 8740 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8741 | |
| 8742 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8743 | "Formats MUST be IDENTICAL unless " |
| 8744 | "VK_IMAGE_CREATE_MUTABLE_FORMAT BIT " |
| 8745 | "was set on image creation."); |
| 8746 | // Same compatibility class but no MUTABLE_FORMAT bit - Expect |
| 8747 | // VIEW_CREATE_ERROR |
| 8748 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UINT; |
| 8749 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 8750 | m_errorMonitor->VerifyFound(); |
| 8751 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8752 | |
| 8753 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8754 | "can support ImageViews with " |
| 8755 | "differing formats but they must be " |
| 8756 | "in the same compatibility class."); |
| 8757 | // Have MUTABLE_FORMAT bit but not in same compatibility class - Expect |
| 8758 | // VIEW_CREATE_ERROR |
| 8759 | VkImageCreateInfo mutImgInfo = image.create_info(); |
| 8760 | VkImage mutImage; |
| 8761 | mutImgInfo.format = VK_FORMAT_R8_UINT; |
| 8762 | assert( |
| 8763 | m_device->format_properties(VK_FORMAT_R8_UINT).optimalTilingFeatures & |
| 8764 | VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT); |
| 8765 | mutImgInfo.flags = VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT; |
| 8766 | mutImgInfo.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 8767 | ret = vkCreateImage(m_device->handle(), &mutImgInfo, NULL, &mutImage); |
| 8768 | ASSERT_VK_SUCCESS(ret); |
| 8769 | imgViewInfo.image = mutImage; |
| 8770 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 8771 | m_errorMonitor->VerifyFound(); |
| 8772 | imgViewInfo.image = image.handle(); |
| 8773 | vkDestroyImage(m_device->handle(), mutImage, NULL); |
| 8774 | } |
| 8775 | |
| 8776 | TEST_F(VkLayerTest, MiscImageLayerTests) { |
| 8777 | |
| 8778 | TEST_DESCRIPTION("Image layer tests that don't belong elsewhare"); |
| 8779 | |
| 8780 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8781 | |
| 8782 | VkImageObj image(m_device); |
| 8783 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 8784 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 8785 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 8786 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 8787 | ASSERT_TRUE(image.initialized()); |
| 8788 | |
| 8789 | m_errorMonitor->SetDesiredFailureMsg( |
| 8790 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8791 | "number of layers in image subresource is zero"); |
| 8792 | vk_testing::Buffer buffer; |
| 8793 | VkMemoryPropertyFlags reqs = 0; |
| 8794 | buffer.init_as_src(*m_device, 128 * 128 * 4, reqs); |
| 8795 | VkBufferImageCopy region = {}; |
| 8796 | region.bufferRowLength = 128; |
| 8797 | region.bufferImageHeight = 128; |
| 8798 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8799 | // layerCount can't be 0 - Expect MISMATCHED_IMAGE_ASPECT |
| 8800 | region.imageSubresource.layerCount = 0; |
| 8801 | region.imageExtent.height = 4; |
| 8802 | region.imageExtent.width = 4; |
| 8803 | region.imageExtent.depth = 1; |
| 8804 | m_commandBuffer->BeginCommandBuffer(); |
| 8805 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 8806 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 8807 | 1, ®ion); |
| 8808 | m_errorMonitor->VerifyFound(); |
| 8809 | region.imageSubresource.layerCount = 1; |
| 8810 | |
| 8811 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8812 | "aspectMasks for each region must " |
| 8813 | "specify only COLOR or DEPTH or " |
| 8814 | "STENCIL"); |
| 8815 | // Expect MISMATCHED_IMAGE_ASPECT |
| 8816 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_METADATA_BIT; |
| 8817 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 8818 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 8819 | 1, ®ion); |
| 8820 | m_errorMonitor->VerifyFound(); |
| 8821 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8822 | |
| 8823 | m_errorMonitor->SetDesiredFailureMsg( |
| 8824 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8825 | "If the format of srcImage is a depth, stencil, depth stencil or " |
| 8826 | "integer-based format then filter must be VK_FILTER_NEAREST"); |
| 8827 | // Expect INVALID_FILTER |
| 8828 | VkImageObj intImage1(m_device); |
| 8829 | intImage1.init(128, 128, VK_FORMAT_R8_UINT, |
| 8830 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, |
| 8831 | 0); |
| 8832 | VkImageObj intImage2(m_device); |
| 8833 | intImage2.init(128, 128, VK_FORMAT_R8_UINT, |
| 8834 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, |
| 8835 | 0); |
| 8836 | VkImageBlit blitRegion = {}; |
| 8837 | blitRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8838 | blitRegion.srcSubresource.baseArrayLayer = 0; |
| 8839 | blitRegion.srcSubresource.layerCount = 1; |
| 8840 | blitRegion.srcSubresource.mipLevel = 0; |
| 8841 | blitRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8842 | blitRegion.dstSubresource.baseArrayLayer = 0; |
| 8843 | blitRegion.dstSubresource.layerCount = 1; |
| 8844 | blitRegion.dstSubresource.mipLevel = 0; |
| 8845 | |
| 8846 | vkCmdBlitImage(m_commandBuffer->GetBufferHandle(), intImage1.handle(), |
| 8847 | intImage1.layout(), intImage2.handle(), intImage2.layout(), |
| 8848 | 16, &blitRegion, VK_FILTER_LINEAR); |
| 8849 | m_errorMonitor->VerifyFound(); |
| 8850 | |
| 8851 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8852 | "called with 0 in ppMemoryBarriers"); |
| 8853 | VkImageMemoryBarrier img_barrier; |
| 8854 | img_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; |
| 8855 | img_barrier.pNext = NULL; |
| 8856 | img_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 8857 | img_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 8858 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 8859 | img_barrier.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 8860 | img_barrier.image = image.handle(); |
| 8861 | img_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 8862 | img_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 8863 | img_barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8864 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 8865 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 8866 | // layerCount should not be 0 - Expect INVALID_IMAGE_RESOURCE |
| 8867 | img_barrier.subresourceRange.layerCount = 0; |
| 8868 | img_barrier.subresourceRange.levelCount = 1; |
| 8869 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 8870 | VK_PIPELINE_STAGE_HOST_BIT, |
| 8871 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 8872 | nullptr, 1, &img_barrier); |
| 8873 | m_errorMonitor->VerifyFound(); |
| 8874 | img_barrier.subresourceRange.layerCount = 1; |
| 8875 | } |
| 8876 | |
| 8877 | TEST_F(VkLayerTest, ImageFormatLimits) { |
| 8878 | |
| 8879 | TEST_DESCRIPTION("Exceed the limits of image format "); |
| 8880 | |
| 8881 | m_errorMonitor->SetDesiredFailureMsg( |
| 8882 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8883 | "CreateImage extents exceed allowable limits for format"); |
| 8884 | VkImageCreateInfo image_create_info = {}; |
| 8885 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8886 | image_create_info.pNext = NULL; |
| 8887 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8888 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8889 | image_create_info.extent.width = 32; |
| 8890 | image_create_info.extent.height = 32; |
| 8891 | image_create_info.extent.depth = 1; |
| 8892 | image_create_info.mipLevels = 1; |
| 8893 | image_create_info.arrayLayers = 1; |
| 8894 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8895 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 8896 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 8897 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 8898 | image_create_info.flags = 0; |
| 8899 | |
| 8900 | VkImage nullImg; |
| 8901 | VkImageFormatProperties imgFmtProps; |
| 8902 | vkGetPhysicalDeviceImageFormatProperties( |
| 8903 | gpu(), image_create_info.format, image_create_info.imageType, |
| 8904 | image_create_info.tiling, image_create_info.usage, |
| 8905 | image_create_info.flags, &imgFmtProps); |
| 8906 | image_create_info.extent.depth = imgFmtProps.maxExtent.depth + 1; |
| 8907 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 8908 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 8909 | m_errorMonitor->VerifyFound(); |
| 8910 | image_create_info.extent.depth = 1; |
| 8911 | |
| 8912 | m_errorMonitor->SetDesiredFailureMsg( |
| 8913 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8914 | "exceeds allowable maximum supported by format of"); |
| 8915 | image_create_info.mipLevels = imgFmtProps.maxMipLevels + 1; |
| 8916 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 8917 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 8918 | m_errorMonitor->VerifyFound(); |
| 8919 | image_create_info.mipLevels = 1; |
| 8920 | |
| 8921 | m_errorMonitor->SetDesiredFailureMsg( |
| 8922 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8923 | "exceeds allowable maximum supported by format of"); |
| 8924 | image_create_info.arrayLayers = imgFmtProps.maxArrayLayers + 1; |
| 8925 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 8926 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 8927 | m_errorMonitor->VerifyFound(); |
| 8928 | image_create_info.arrayLayers = 1; |
| 8929 | |
| 8930 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8931 | "is not supported by format"); |
| 8932 | int samples = imgFmtProps.sampleCounts >> 1; |
| 8933 | image_create_info.samples = (VkSampleCountFlagBits)samples; |
| 8934 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 8935 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 8936 | m_errorMonitor->VerifyFound(); |
| 8937 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8938 | |
| 8939 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8940 | "pCreateInfo->initialLayout, must be " |
| 8941 | "VK_IMAGE_LAYOUT_UNDEFINED or " |
| 8942 | "VK_IMAGE_LAYOUT_PREINITIALIZED"); |
| 8943 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 8944 | // Expect INVALID_LAYOUT |
| 8945 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 8946 | m_errorMonitor->VerifyFound(); |
| 8947 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 8948 | } |
| 8949 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8950 | TEST_F(VkLayerTest, CopyImageFormatSizeMismatch) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 8951 | VkResult err; |
| 8952 | bool pass; |
| 8953 | |
| 8954 | // Create color images with different format sizes and try to copy between them |
| 8955 | m_errorMonitor->SetDesiredFailureMsg( |
| 8956 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8957 | "vkCmdCopyImage called with unmatched source and dest image format sizes"); |
| 8958 | |
| 8959 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8960 | |
| 8961 | // Create two images of different types and try to copy between them |
| 8962 | VkImage srcImage; |
| 8963 | VkImage dstImage; |
| 8964 | VkDeviceMemory srcMem; |
| 8965 | VkDeviceMemory destMem; |
| 8966 | VkMemoryRequirements memReqs; |
| 8967 | |
| 8968 | VkImageCreateInfo image_create_info = {}; |
| 8969 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8970 | image_create_info.pNext = NULL; |
| 8971 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8972 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8973 | image_create_info.extent.width = 32; |
| 8974 | image_create_info.extent.height = 32; |
| 8975 | image_create_info.extent.depth = 1; |
| 8976 | image_create_info.mipLevels = 1; |
| 8977 | image_create_info.arrayLayers = 1; |
| 8978 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8979 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 8980 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 8981 | image_create_info.flags = 0; |
| 8982 | |
| 8983 | err = |
| 8984 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
| 8985 | ASSERT_VK_SUCCESS(err); |
| 8986 | |
| 8987 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 8988 | // Introduce failure by creating second image with a different-sized format. |
| 8989 | image_create_info.format = VK_FORMAT_R5G5B5A1_UNORM_PACK16; |
| 8990 | |
| 8991 | err = |
| 8992 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
| 8993 | ASSERT_VK_SUCCESS(err); |
| 8994 | |
| 8995 | // Allocate memory |
| 8996 | VkMemoryAllocateInfo memAlloc = {}; |
| 8997 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 8998 | memAlloc.pNext = NULL; |
| 8999 | memAlloc.allocationSize = 0; |
| 9000 | memAlloc.memoryTypeIndex = 0; |
| 9001 | |
| 9002 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
| 9003 | memAlloc.allocationSize = memReqs.size; |
| 9004 | pass = |
| 9005 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 9006 | ASSERT_TRUE(pass); |
| 9007 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
| 9008 | ASSERT_VK_SUCCESS(err); |
| 9009 | |
| 9010 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
| 9011 | memAlloc.allocationSize = memReqs.size; |
| 9012 | pass = |
| 9013 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 9014 | ASSERT_TRUE(pass); |
| 9015 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
| 9016 | ASSERT_VK_SUCCESS(err); |
| 9017 | |
| 9018 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 9019 | ASSERT_VK_SUCCESS(err); |
| 9020 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
| 9021 | ASSERT_VK_SUCCESS(err); |
| 9022 | |
| 9023 | BeginCommandBuffer(); |
| 9024 | VkImageCopy copyRegion; |
| 9025 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 9026 | copyRegion.srcSubresource.mipLevel = 0; |
| 9027 | copyRegion.srcSubresource.baseArrayLayer = 0; |
| 9028 | copyRegion.srcSubresource.layerCount = 0; |
| 9029 | copyRegion.srcOffset.x = 0; |
| 9030 | copyRegion.srcOffset.y = 0; |
| 9031 | copyRegion.srcOffset.z = 0; |
| 9032 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 9033 | copyRegion.dstSubresource.mipLevel = 0; |
| 9034 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 9035 | copyRegion.dstSubresource.layerCount = 0; |
| 9036 | copyRegion.dstOffset.x = 0; |
| 9037 | copyRegion.dstOffset.y = 0; |
| 9038 | copyRegion.dstOffset.z = 0; |
| 9039 | copyRegion.extent.width = 1; |
| 9040 | copyRegion.extent.height = 1; |
| 9041 | copyRegion.extent.depth = 1; |
| 9042 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 9043 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 9044 | EndCommandBuffer(); |
| 9045 | |
| 9046 | m_errorMonitor->VerifyFound(); |
| 9047 | |
| 9048 | vkDestroyImage(m_device->device(), srcImage, NULL); |
| 9049 | vkDestroyImage(m_device->device(), dstImage, NULL); |
| 9050 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 9051 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9052 | } |
| 9053 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9054 | TEST_F(VkLayerTest, CopyImageDepthStencilFormatMismatch) { |
| 9055 | VkResult err; |
| 9056 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9057 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 9058 | // 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] | 9059 | m_errorMonitor->SetDesiredFailureMsg( |
| 9060 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 9061 | "vkCmdCopyImage called with unmatched source and dest image depth"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9062 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9063 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9064 | |
| 9065 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9066 | VkImage srcImage; |
| 9067 | VkImage dstImage; |
| 9068 | VkDeviceMemory srcMem; |
| 9069 | VkDeviceMemory destMem; |
| 9070 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9071 | |
| 9072 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9073 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9074 | image_create_info.pNext = NULL; |
| 9075 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 9076 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 9077 | image_create_info.extent.width = 32; |
| 9078 | image_create_info.extent.height = 32; |
| 9079 | image_create_info.extent.depth = 1; |
| 9080 | image_create_info.mipLevels = 1; |
| 9081 | image_create_info.arrayLayers = 1; |
| 9082 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 9083 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 9084 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 9085 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9086 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9087 | err = |
| 9088 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9089 | ASSERT_VK_SUCCESS(err); |
| 9090 | |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 9091 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 9092 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 9093 | // Introduce failure by creating second image with a depth/stencil format |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9094 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 9095 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 9096 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9097 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9098 | err = |
| 9099 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9100 | ASSERT_VK_SUCCESS(err); |
| 9101 | |
| 9102 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9103 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9104 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 9105 | memAlloc.pNext = NULL; |
| 9106 | memAlloc.allocationSize = 0; |
| 9107 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9108 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 9109 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9110 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9111 | pass = |
| 9112 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 9113 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9114 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9115 | ASSERT_VK_SUCCESS(err); |
| 9116 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9117 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9118 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9119 | pass = |
| 9120 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 9121 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9122 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9123 | ASSERT_VK_SUCCESS(err); |
| 9124 | |
| 9125 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 9126 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9127 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9128 | ASSERT_VK_SUCCESS(err); |
| 9129 | |
| 9130 | BeginCommandBuffer(); |
| 9131 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 9132 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9133 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 9134 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9135 | copyRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9136 | copyRegion.srcOffset.x = 0; |
| 9137 | copyRegion.srcOffset.y = 0; |
| 9138 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 9139 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9140 | copyRegion.dstSubresource.mipLevel = 0; |
| 9141 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 9142 | copyRegion.dstSubresource.layerCount = 0; |
| 9143 | copyRegion.dstOffset.x = 0; |
| 9144 | copyRegion.dstOffset.y = 0; |
| 9145 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9146 | copyRegion.extent.width = 1; |
| 9147 | copyRegion.extent.height = 1; |
| 9148 | copyRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9149 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 9150 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9151 | EndCommandBuffer(); |
| 9152 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9153 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9154 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9155 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9156 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9157 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 9158 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9159 | } |
| 9160 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9161 | TEST_F(VkLayerTest, ResolveImageLowSampleCount) { |
| 9162 | VkResult err; |
| 9163 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9164 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9165 | m_errorMonitor->SetDesiredFailureMsg( |
| 9166 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9167 | "vkCmdResolveImage called with source sample count less than 2."); |
| 9168 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9169 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9170 | |
| 9171 | // 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] | 9172 | VkImage srcImage; |
| 9173 | VkImage dstImage; |
| 9174 | VkDeviceMemory srcMem; |
| 9175 | VkDeviceMemory destMem; |
| 9176 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9177 | |
| 9178 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9179 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9180 | image_create_info.pNext = NULL; |
| 9181 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 9182 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 9183 | image_create_info.extent.width = 32; |
| 9184 | image_create_info.extent.height = 1; |
| 9185 | image_create_info.extent.depth = 1; |
| 9186 | image_create_info.mipLevels = 1; |
| 9187 | image_create_info.arrayLayers = 1; |
| 9188 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 9189 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 9190 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 9191 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9192 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9193 | err = |
| 9194 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9195 | ASSERT_VK_SUCCESS(err); |
| 9196 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9197 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9198 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9199 | err = |
| 9200 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9201 | ASSERT_VK_SUCCESS(err); |
| 9202 | |
| 9203 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9204 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9205 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 9206 | memAlloc.pNext = NULL; |
| 9207 | memAlloc.allocationSize = 0; |
| 9208 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9209 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 9210 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9211 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9212 | pass = |
| 9213 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 9214 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9215 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9216 | ASSERT_VK_SUCCESS(err); |
| 9217 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9218 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9219 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9220 | pass = |
| 9221 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 9222 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9223 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9224 | ASSERT_VK_SUCCESS(err); |
| 9225 | |
| 9226 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 9227 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9228 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9229 | ASSERT_VK_SUCCESS(err); |
| 9230 | |
| 9231 | BeginCommandBuffer(); |
| 9232 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9233 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 9234 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9235 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 9236 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9237 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 9238 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9239 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9240 | resolveRegion.srcOffset.x = 0; |
| 9241 | resolveRegion.srcOffset.y = 0; |
| 9242 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 9243 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9244 | resolveRegion.dstSubresource.mipLevel = 0; |
| 9245 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 9246 | resolveRegion.dstSubresource.layerCount = 0; |
| 9247 | resolveRegion.dstOffset.x = 0; |
| 9248 | resolveRegion.dstOffset.y = 0; |
| 9249 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9250 | resolveRegion.extent.width = 1; |
| 9251 | resolveRegion.extent.height = 1; |
| 9252 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9253 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 9254 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9255 | EndCommandBuffer(); |
| 9256 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9257 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9258 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9259 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9260 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9261 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 9262 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9263 | } |
| 9264 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9265 | TEST_F(VkLayerTest, ResolveImageHighSampleCount) { |
| 9266 | VkResult err; |
| 9267 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9268 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9269 | m_errorMonitor->SetDesiredFailureMsg( |
| 9270 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9271 | "vkCmdResolveImage called with dest sample count greater than 1."); |
| 9272 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9273 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9274 | |
Chris Forbes | a753069 | 2016-05-08 12:35:39 +1200 | [diff] [blame] | 9275 | // 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] | 9276 | VkImage srcImage; |
| 9277 | VkImage dstImage; |
| 9278 | VkDeviceMemory srcMem; |
| 9279 | VkDeviceMemory destMem; |
| 9280 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9281 | |
| 9282 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9283 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9284 | image_create_info.pNext = NULL; |
| 9285 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 9286 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 9287 | image_create_info.extent.width = 32; |
| 9288 | image_create_info.extent.height = 1; |
| 9289 | image_create_info.extent.depth = 1; |
| 9290 | image_create_info.mipLevels = 1; |
| 9291 | image_create_info.arrayLayers = 1; |
Chris Forbes | a753069 | 2016-05-08 12:35:39 +1200 | [diff] [blame] | 9292 | image_create_info.samples = VK_SAMPLE_COUNT_4_BIT; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9293 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 9294 | // Note: Some implementations expect color attachment usage for any |
| 9295 | // multisample surface |
| 9296 | image_create_info.usage = |
| 9297 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 9298 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9299 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9300 | err = |
| 9301 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9302 | ASSERT_VK_SUCCESS(err); |
| 9303 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9304 | // Note: Some implementations expect color attachment usage for any |
| 9305 | // multisample surface |
| 9306 | image_create_info.usage = |
| 9307 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9308 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9309 | err = |
| 9310 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9311 | ASSERT_VK_SUCCESS(err); |
| 9312 | |
| 9313 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9314 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9315 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 9316 | memAlloc.pNext = NULL; |
| 9317 | memAlloc.allocationSize = 0; |
| 9318 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9319 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 9320 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9321 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9322 | pass = |
| 9323 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 9324 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9325 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9326 | ASSERT_VK_SUCCESS(err); |
| 9327 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9328 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9329 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9330 | pass = |
| 9331 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 9332 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9333 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9334 | ASSERT_VK_SUCCESS(err); |
| 9335 | |
| 9336 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 9337 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9338 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9339 | ASSERT_VK_SUCCESS(err); |
| 9340 | |
| 9341 | BeginCommandBuffer(); |
| 9342 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9343 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 9344 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9345 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 9346 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9347 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 9348 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9349 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9350 | resolveRegion.srcOffset.x = 0; |
| 9351 | resolveRegion.srcOffset.y = 0; |
| 9352 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 9353 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9354 | resolveRegion.dstSubresource.mipLevel = 0; |
| 9355 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 9356 | resolveRegion.dstSubresource.layerCount = 0; |
| 9357 | resolveRegion.dstOffset.x = 0; |
| 9358 | resolveRegion.dstOffset.y = 0; |
| 9359 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9360 | resolveRegion.extent.width = 1; |
| 9361 | resolveRegion.extent.height = 1; |
| 9362 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9363 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 9364 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9365 | EndCommandBuffer(); |
| 9366 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9367 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9368 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9369 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9370 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9371 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 9372 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9373 | } |
| 9374 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9375 | TEST_F(VkLayerTest, ResolveImageFormatMismatch) { |
| 9376 | VkResult err; |
| 9377 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9378 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9379 | m_errorMonitor->SetDesiredFailureMsg( |
| 9380 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9381 | "vkCmdResolveImage called with unmatched source and dest formats."); |
| 9382 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9383 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9384 | |
| 9385 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9386 | VkImage srcImage; |
| 9387 | VkImage dstImage; |
| 9388 | VkDeviceMemory srcMem; |
| 9389 | VkDeviceMemory destMem; |
| 9390 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9391 | |
| 9392 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9393 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9394 | image_create_info.pNext = NULL; |
| 9395 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 9396 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 9397 | image_create_info.extent.width = 32; |
| 9398 | image_create_info.extent.height = 1; |
| 9399 | image_create_info.extent.depth = 1; |
| 9400 | image_create_info.mipLevels = 1; |
| 9401 | image_create_info.arrayLayers = 1; |
| 9402 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 9403 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 9404 | // Note: Some implementations expect color attachment usage for any |
| 9405 | // multisample surface |
| 9406 | image_create_info.usage = |
| 9407 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 9408 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9409 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9410 | err = |
| 9411 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9412 | ASSERT_VK_SUCCESS(err); |
| 9413 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9414 | // Set format to something other than source image |
| 9415 | image_create_info.format = VK_FORMAT_R32_SFLOAT; |
| 9416 | // Note: Some implementations expect color attachment usage for any |
| 9417 | // multisample surface |
| 9418 | image_create_info.usage = |
| 9419 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 9420 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9421 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9422 | err = |
| 9423 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9424 | ASSERT_VK_SUCCESS(err); |
| 9425 | |
| 9426 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9427 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9428 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 9429 | memAlloc.pNext = NULL; |
| 9430 | memAlloc.allocationSize = 0; |
| 9431 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9432 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 9433 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9434 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9435 | pass = |
| 9436 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 9437 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9438 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9439 | ASSERT_VK_SUCCESS(err); |
| 9440 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9441 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9442 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9443 | pass = |
| 9444 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 9445 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9446 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9447 | ASSERT_VK_SUCCESS(err); |
| 9448 | |
| 9449 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 9450 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9451 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9452 | ASSERT_VK_SUCCESS(err); |
| 9453 | |
| 9454 | BeginCommandBuffer(); |
| 9455 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9456 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 9457 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9458 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 9459 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9460 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 9461 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9462 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9463 | resolveRegion.srcOffset.x = 0; |
| 9464 | resolveRegion.srcOffset.y = 0; |
| 9465 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 9466 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9467 | resolveRegion.dstSubresource.mipLevel = 0; |
| 9468 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 9469 | resolveRegion.dstSubresource.layerCount = 0; |
| 9470 | resolveRegion.dstOffset.x = 0; |
| 9471 | resolveRegion.dstOffset.y = 0; |
| 9472 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9473 | resolveRegion.extent.width = 1; |
| 9474 | resolveRegion.extent.height = 1; |
| 9475 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9476 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 9477 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9478 | EndCommandBuffer(); |
| 9479 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9480 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9481 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9482 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9483 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9484 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 9485 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9486 | } |
| 9487 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9488 | TEST_F(VkLayerTest, ResolveImageTypeMismatch) { |
| 9489 | VkResult err; |
| 9490 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9491 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9492 | m_errorMonitor->SetDesiredFailureMsg( |
| 9493 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9494 | "vkCmdResolveImage called with unmatched source and dest image types."); |
| 9495 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9496 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9497 | |
| 9498 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9499 | VkImage srcImage; |
| 9500 | VkImage dstImage; |
| 9501 | VkDeviceMemory srcMem; |
| 9502 | VkDeviceMemory destMem; |
| 9503 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9504 | |
| 9505 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9506 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9507 | image_create_info.pNext = NULL; |
| 9508 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 9509 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 9510 | image_create_info.extent.width = 32; |
| 9511 | image_create_info.extent.height = 1; |
| 9512 | image_create_info.extent.depth = 1; |
| 9513 | image_create_info.mipLevels = 1; |
| 9514 | image_create_info.arrayLayers = 1; |
| 9515 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 9516 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 9517 | // Note: Some implementations expect color attachment usage for any |
| 9518 | // multisample surface |
| 9519 | image_create_info.usage = |
| 9520 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 9521 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9522 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9523 | err = |
| 9524 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9525 | ASSERT_VK_SUCCESS(err); |
| 9526 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9527 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 9528 | // Note: Some implementations expect color attachment usage for any |
| 9529 | // multisample surface |
| 9530 | image_create_info.usage = |
| 9531 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 9532 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9533 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9534 | err = |
| 9535 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9536 | ASSERT_VK_SUCCESS(err); |
| 9537 | |
| 9538 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9539 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9540 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 9541 | memAlloc.pNext = NULL; |
| 9542 | memAlloc.allocationSize = 0; |
| 9543 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9544 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 9545 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9546 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9547 | pass = |
| 9548 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 9549 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9550 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9551 | ASSERT_VK_SUCCESS(err); |
| 9552 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9553 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9554 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9555 | pass = |
| 9556 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 9557 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9558 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9559 | ASSERT_VK_SUCCESS(err); |
| 9560 | |
| 9561 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 9562 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9563 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9564 | ASSERT_VK_SUCCESS(err); |
| 9565 | |
| 9566 | BeginCommandBuffer(); |
| 9567 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9568 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 9569 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9570 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 9571 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9572 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 9573 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9574 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9575 | resolveRegion.srcOffset.x = 0; |
| 9576 | resolveRegion.srcOffset.y = 0; |
| 9577 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 9578 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9579 | resolveRegion.dstSubresource.mipLevel = 0; |
| 9580 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 9581 | resolveRegion.dstSubresource.layerCount = 0; |
| 9582 | resolveRegion.dstOffset.x = 0; |
| 9583 | resolveRegion.dstOffset.y = 0; |
| 9584 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9585 | resolveRegion.extent.width = 1; |
| 9586 | resolveRegion.extent.height = 1; |
| 9587 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9588 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 9589 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9590 | EndCommandBuffer(); |
| 9591 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9592 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9593 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9594 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9595 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9596 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 9597 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9598 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9599 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9600 | TEST_F(VkLayerTest, DepthStencilImageViewWithColorAspectBitError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9601 | // 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] | 9602 | // to using a DS format, then cause it to hit error due to COLOR_BIT not |
| 9603 | // set in aspect |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9604 | // The image format check comes 2nd in validation so we trigger it first, |
| 9605 | // 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] | 9606 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9607 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9608 | m_errorMonitor->SetDesiredFailureMsg( |
| 9609 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9610 | "Combination depth/stencil image formats can have only the "); |
| 9611 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9612 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9613 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 9614 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9615 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 9616 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9617 | |
| 9618 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9619 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 9620 | ds_pool_ci.pNext = NULL; |
| 9621 | ds_pool_ci.maxSets = 1; |
| 9622 | ds_pool_ci.poolSizeCount = 1; |
| 9623 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9624 | |
| 9625 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9626 | err = |
| 9627 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9628 | ASSERT_VK_SUCCESS(err); |
| 9629 | |
| 9630 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9631 | dsl_binding.binding = 0; |
| 9632 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 9633 | dsl_binding.descriptorCount = 1; |
| 9634 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 9635 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9636 | |
| 9637 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9638 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 9639 | ds_layout_ci.pNext = NULL; |
| 9640 | ds_layout_ci.bindingCount = 1; |
| 9641 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9642 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9643 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 9644 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9645 | ASSERT_VK_SUCCESS(err); |
| 9646 | |
| 9647 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9648 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 9649 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 9650 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9651 | alloc_info.descriptorPool = ds_pool; |
| 9652 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9653 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 9654 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9655 | ASSERT_VK_SUCCESS(err); |
| 9656 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9657 | VkImage image_bad; |
| 9658 | VkImage image_good; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9659 | // One bad format and one good format for Color attachment |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9660 | const VkFormat tex_format_bad = VK_FORMAT_D32_SFLOAT_S8_UINT; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9661 | const VkFormat tex_format_good = VK_FORMAT_B8G8R8A8_UNORM; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9662 | const int32_t tex_width = 32; |
| 9663 | const int32_t tex_height = 32; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9664 | |
| 9665 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9666 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9667 | image_create_info.pNext = NULL; |
| 9668 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 9669 | image_create_info.format = tex_format_bad; |
| 9670 | image_create_info.extent.width = tex_width; |
| 9671 | image_create_info.extent.height = tex_height; |
| 9672 | image_create_info.extent.depth = 1; |
| 9673 | image_create_info.mipLevels = 1; |
| 9674 | image_create_info.arrayLayers = 1; |
| 9675 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 9676 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 9677 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT | |
| 9678 | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 9679 | image_create_info.flags = 0; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9680 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9681 | err = |
| 9682 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image_bad); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9683 | ASSERT_VK_SUCCESS(err); |
| 9684 | image_create_info.format = tex_format_good; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9685 | image_create_info.usage = |
| 9686 | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 9687 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, |
| 9688 | &image_good); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9689 | ASSERT_VK_SUCCESS(err); |
| 9690 | |
| 9691 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9692 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9693 | image_view_create_info.image = image_bad; |
| 9694 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 9695 | image_view_create_info.format = tex_format_bad; |
| 9696 | image_view_create_info.subresourceRange.baseArrayLayer = 0; |
| 9697 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 9698 | image_view_create_info.subresourceRange.layerCount = 1; |
| 9699 | image_view_create_info.subresourceRange.levelCount = 1; |
| 9700 | image_view_create_info.subresourceRange.aspectMask = |
| 9701 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9702 | |
| 9703 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9704 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 9705 | &view); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9706 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9707 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9708 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9709 | vkDestroyImage(m_device->device(), image_bad, NULL); |
| 9710 | vkDestroyImage(m_device->device(), image_good, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9711 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 9712 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9713 | } |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 9714 | #endif // IMAGE_TESTS |
| 9715 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 9716 | int main(int argc, char **argv) { |
| 9717 | int result; |
| 9718 | |
Cody Northrop | 8e54a40 | 2016-03-08 22:25:52 -0700 | [diff] [blame] | 9719 | #ifdef ANDROID |
| 9720 | int vulkanSupport = InitVulkan(); |
| 9721 | if (vulkanSupport == 0) |
| 9722 | return 1; |
| 9723 | #endif |
| 9724 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 9725 | ::testing::InitGoogleTest(&argc, argv); |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 9726 | VkTestFramework::InitArgs(&argc, argv); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 9727 | |
| 9728 | ::testing::AddGlobalTestEnvironment(new TestEnvironment); |
| 9729 | |
| 9730 | result = RUN_ALL_TESTS(); |
| 9731 | |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 9732 | VkTestFramework::Finish(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 9733 | return result; |
| 9734 | } |