Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015-2016 The Khronos Group Inc. |
| 3 | * Copyright (c) 2015-2016 Valve Corporation |
| 4 | * Copyright (c) 2015-2016 LunarG, Inc. |
Michael Lentine | 0a369f6 | 2016-02-03 16:51:46 -0600 | [diff] [blame] | 5 | * Copyright (c) 2015-2016 Google, Inc. |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6 | * |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 7 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | * you may not use this file except in compliance with the License. |
| 9 | * You may obtain a copy of the License at |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10 | * |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 11 | * http://www.apache.org/licenses/LICENSE-2.0 |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12 | * |
| 13 | * Author: Chia-I Wu <olvaffe@gmail.com> |
| 14 | * Author: Chris Forbes <chrisf@ijw.co.nz> |
| 15 | * Author: Courtney Goeltzenleuchter <courtney@LunarG.com> |
| 16 | * Author: Mark Lobodzinski <mark@lunarg.com> |
| 17 | * Author: Mike Stroyan <mike@LunarG.com> |
| 18 | * Author: Tobin Ehlis <tobine@google.com> |
| 19 | * Author: Tony Barbour <tony@LunarG.com> |
| 20 | */ |
Tony Barbour | 65c48b3 | 2015-11-17 10:02:56 -0700 | [diff] [blame] | 21 | |
Cody Northrop | 8e54a40 | 2016-03-08 22:25:52 -0700 | [diff] [blame] | 22 | #ifdef ANDROID |
| 23 | #include "vulkan_wrapper.h" |
| 24 | #else |
David Pinedo | 9316d3b | 2015-11-06 12:54:48 -0700 | [diff] [blame] | 25 | #include <vulkan/vulkan.h> |
Cody Northrop | 8e54a40 | 2016-03-08 22:25:52 -0700 | [diff] [blame] | 26 | #endif |
Courtney Goeltzenleuchter | 58f3eff | 2015-10-07 13:28:58 -0600 | [diff] [blame] | 27 | #include "test_common.h" |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 28 | #include "vkrenderframework.h" |
Tobin Ehlis | a0cb02e | 2015-07-03 10:15:26 -0600 | [diff] [blame] | 29 | #include "vk_layer_config.h" |
Jon Ashburn | 7fa7e22 | 2016-02-02 12:08:10 -0700 | [diff] [blame] | 30 | #include "icd-spv.h" |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 31 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 32 | #define GLM_FORCE_RADIANS |
| 33 | #include "glm/glm.hpp" |
| 34 | #include <glm/gtc/matrix_transform.hpp> |
| 35 | |
Dustin Graves | ffa90fa | 2016-05-06 11:20:38 -0600 | [diff] [blame] | 36 | #define PARAMETER_VALIDATION_TESTS 1 |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 37 | #define MEM_TRACKER_TESTS 1 |
| 38 | #define OBJ_TRACKER_TESTS 1 |
| 39 | #define DRAW_STATE_TESTS 1 |
| 40 | #define THREADING_TESTS 1 |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 41 | #define SHADER_CHECKER_TESTS 1 |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 42 | #define DEVICE_LIMITS_TESTS 1 |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 43 | #define IMAGE_TESTS 1 |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 44 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 45 | //-------------------------------------------------------------------------------------- |
| 46 | // Mesh and VertexFormat Data |
| 47 | //-------------------------------------------------------------------------------------- |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 48 | struct Vertex { |
| 49 | float posX, posY, posZ, posW; // Position data |
| 50 | float r, g, b, a; // Color |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 51 | }; |
| 52 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 53 | #define XYZ1(_x_, _y_, _z_) (_x_), (_y_), (_z_), 1.f |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 54 | |
| 55 | typedef enum _BsoFailSelect { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 56 | BsoFailNone = 0x00000000, |
| 57 | BsoFailLineWidth = 0x00000001, |
| 58 | BsoFailDepthBias = 0x00000002, |
| 59 | BsoFailViewport = 0x00000004, |
| 60 | BsoFailScissor = 0x00000008, |
| 61 | BsoFailBlend = 0x00000010, |
| 62 | BsoFailDepthBounds = 0x00000020, |
| 63 | BsoFailStencilReadMask = 0x00000040, |
| 64 | BsoFailStencilWriteMask = 0x00000080, |
| 65 | BsoFailStencilReference = 0x00000100, |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 66 | } BsoFailSelect; |
| 67 | |
| 68 | struct vktriangle_vs_uniform { |
| 69 | // Must start with MVP |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 70 | float mvp[4][4]; |
| 71 | float position[3][4]; |
| 72 | float color[3][4]; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 73 | }; |
| 74 | |
Mark Lobodzinski | 75a97e6 | 2015-06-02 09:41:30 -0500 | [diff] [blame] | 75 | static const char bindStateVertShaderText[] = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 76 | "#version 450\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 77 | "vec2 vertices[3];\n" |
| 78 | "out gl_PerVertex {\n" |
| 79 | " vec4 gl_Position;\n" |
| 80 | "};\n" |
| 81 | "void main() {\n" |
| 82 | " vertices[0] = vec2(-1.0, -1.0);\n" |
| 83 | " vertices[1] = vec2( 1.0, -1.0);\n" |
| 84 | " vertices[2] = vec2( 0.0, 1.0);\n" |
| 85 | " gl_Position = vec4(vertices[gl_VertexIndex % 3], 0.0, 1.0);\n" |
| 86 | "}\n"; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 87 | |
Mark Lobodzinski | 75a97e6 | 2015-06-02 09:41:30 -0500 | [diff] [blame] | 88 | static const char bindStateFragShaderText[] = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 89 | "#version 450\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 90 | "\n" |
| 91 | "layout(location = 0) out vec4 uFragColor;\n" |
| 92 | "void main(){\n" |
| 93 | " uFragColor = vec4(0,1,0,1);\n" |
| 94 | "}\n"; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 95 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 96 | static VKAPI_ATTR VkBool32 VKAPI_CALL |
| 97 | myDbgFunc(VkFlags msgFlags, VkDebugReportObjectTypeEXT objType, |
| 98 | uint64_t srcObject, size_t location, int32_t msgCode, |
| 99 | const char *pLayerPrefix, const char *pMsg, void *pUserData); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 100 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 101 | // ******************************************************** |
| 102 | // ErrorMonitor Usage: |
| 103 | // |
| 104 | // Call SetDesiredFailureMsg with a string to be compared against all |
| 105 | // encountered log messages. Passing NULL will match all log messages. |
| 106 | // logMsg will return true for skipCall only if msg is matched or NULL. |
| 107 | // |
| 108 | // Call DesiredMsgFound to determine if the desired failure message |
| 109 | // was encountered. |
| 110 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 111 | class ErrorMonitor { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 112 | public: |
| 113 | ErrorMonitor() { |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 114 | test_platform_thread_create_mutex(&m_mutex); |
| 115 | test_platform_thread_lock_mutex(&m_mutex); |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 116 | m_msgFlags = VK_DEBUG_REPORT_INFORMATION_BIT_EXT; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 117 | m_bailout = NULL; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 118 | test_platform_thread_unlock_mutex(&m_mutex); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 119 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 120 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 121 | ~ErrorMonitor() { test_platform_thread_delete_mutex(&m_mutex); } |
| 122 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 123 | void SetDesiredFailureMsg(VkFlags msgFlags, const char *msgString) { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 124 | // also discard all collected messages to this point |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 125 | test_platform_thread_lock_mutex(&m_mutex); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 126 | m_failureMsg.clear(); |
| 127 | m_otherMsgs.clear(); |
| 128 | m_desiredMsg = msgString; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 129 | m_msgFound = VK_FALSE; |
| 130 | m_msgFlags = msgFlags; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 131 | test_platform_thread_unlock_mutex(&m_mutex); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 132 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 133 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 134 | VkBool32 CheckForDesiredMsg(VkFlags msgFlags, const char *msgString) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 135 | VkBool32 result = VK_FALSE; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 136 | test_platform_thread_lock_mutex(&m_mutex); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 137 | if (m_bailout != NULL) { |
| 138 | *m_bailout = true; |
| 139 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 140 | string errorString(msgString); |
| 141 | if (msgFlags & m_msgFlags) { |
| 142 | if (errorString.find(m_desiredMsg) != string::npos) { |
Chris Forbes | c7b8ad7 | 2016-04-04 18:50:38 +1200 | [diff] [blame] | 143 | if (m_msgFound) { /* if multiple matches, don't lose all but the last! */ |
| 144 | m_otherMsgs.push_back(m_failureMsg); |
| 145 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 146 | m_failureMsg = errorString; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 147 | m_msgFound = VK_TRUE; |
| 148 | result = VK_TRUE; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 149 | } else { |
| 150 | m_otherMsgs.push_back(errorString); |
| 151 | } |
| 152 | } |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 153 | test_platform_thread_unlock_mutex(&m_mutex); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 154 | return result; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 155 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 156 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 157 | vector<string> GetOtherFailureMsgs(void) { return m_otherMsgs; } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 158 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 159 | string GetFailureMsg(void) { return m_failureMsg; } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 160 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 161 | VkBool32 DesiredMsgFound(void) { return m_msgFound; } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 162 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 163 | void SetBailout(bool *bailout) { m_bailout = bailout; } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 164 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 165 | void DumpFailureMsgs(void) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 166 | vector<string> otherMsgs = GetOtherFailureMsgs(); |
| 167 | cout << "Other error messages logged for this test were:" << endl; |
| 168 | for (auto iter = otherMsgs.begin(); iter != otherMsgs.end(); iter++) { |
| 169 | cout << " " << *iter << endl; |
| 170 | } |
| 171 | } |
| 172 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 173 | /* helpers */ |
| 174 | |
| 175 | void ExpectSuccess() { |
| 176 | // match anything |
| 177 | SetDesiredFailureMsg(~0u, ""); |
| 178 | } |
| 179 | |
| 180 | void VerifyFound() { |
| 181 | // Not seeing the desired message is a failure. /Before/ throwing, dump |
| 182 | // any other messages. |
| 183 | if (!DesiredMsgFound()) { |
| 184 | DumpFailureMsgs(); |
| 185 | FAIL() << "Did not receive expected error '" << m_desiredMsg << "'"; |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | void VerifyNotFound() { |
| 190 | // ExpectSuccess() configured us to match anything. Any error is a |
| 191 | // failure. |
| 192 | if (DesiredMsgFound()) { |
| 193 | DumpFailureMsgs(); |
| 194 | FAIL() << "Expected to succeed but got error: " << GetFailureMsg(); |
| 195 | } |
| 196 | } |
| 197 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 198 | private: |
| 199 | VkFlags m_msgFlags; |
| 200 | string m_desiredMsg; |
| 201 | string m_failureMsg; |
| 202 | vector<string> m_otherMsgs; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 203 | test_platform_thread_mutex m_mutex; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 204 | bool *m_bailout; |
| 205 | VkBool32 m_msgFound; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 206 | }; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 207 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 208 | static VKAPI_ATTR VkBool32 VKAPI_CALL |
| 209 | myDbgFunc(VkFlags msgFlags, VkDebugReportObjectTypeEXT objType, |
| 210 | uint64_t srcObject, size_t location, int32_t msgCode, |
| 211 | const char *pLayerPrefix, const char *pMsg, void *pUserData) { |
| 212 | if (msgFlags & |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 213 | (VK_DEBUG_REPORT_WARNING_BIT_EXT | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 214 | VK_DEBUG_REPORT_ERROR_BIT_EXT)) { |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 215 | ErrorMonitor *errMonitor = (ErrorMonitor *)pUserData; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 216 | return errMonitor->CheckForDesiredMsg(msgFlags, pMsg); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 217 | } |
Courtney Goeltzenleuchter | 0664083 | 2015-09-04 13:52:24 -0600 | [diff] [blame] | 218 | return false; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 219 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 220 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 221 | class VkLayerTest : public VkRenderFramework { |
| 222 | public: |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 223 | VkResult BeginCommandBuffer(VkCommandBufferObj &commandBuffer); |
| 224 | VkResult EndCommandBuffer(VkCommandBufferObj &commandBuffer); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 225 | void VKTriangleTest(const char *vertShaderText, const char *fragShaderText, |
| 226 | BsoFailSelect failMask); |
| 227 | void GenericDrawPreparation(VkCommandBufferObj *commandBuffer, |
| 228 | VkPipelineObj &pipelineobj, |
| 229 | VkDescriptorSetObj &descriptorSet, |
| 230 | BsoFailSelect failMask); |
| 231 | void GenericDrawPreparation(VkPipelineObj &pipelineobj, |
| 232 | VkDescriptorSetObj &descriptorSet, |
| 233 | BsoFailSelect failMask) { |
| 234 | GenericDrawPreparation(m_commandBuffer, pipelineobj, descriptorSet, |
| 235 | failMask); |
| 236 | } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 237 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 238 | /* Convenience functions that use built-in command buffer */ |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 239 | VkResult BeginCommandBuffer() { |
| 240 | return BeginCommandBuffer(*m_commandBuffer); |
| 241 | } |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 242 | VkResult EndCommandBuffer() { return EndCommandBuffer(*m_commandBuffer); } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 243 | void Draw(uint32_t vertexCount, uint32_t instanceCount, |
| 244 | uint32_t firstVertex, uint32_t firstInstance) { |
| 245 | m_commandBuffer->Draw(vertexCount, instanceCount, firstVertex, |
| 246 | firstInstance); |
| 247 | } |
| 248 | void DrawIndexed(uint32_t indexCount, uint32_t instanceCount, |
| 249 | uint32_t firstIndex, int32_t vertexOffset, |
| 250 | uint32_t firstInstance) { |
| 251 | m_commandBuffer->DrawIndexed(indexCount, instanceCount, firstIndex, |
| 252 | vertexOffset, firstInstance); |
| 253 | } |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 254 | void QueueCommandBuffer() { m_commandBuffer->QueueCommandBuffer(); } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 255 | void QueueCommandBuffer(const VkFence &fence) { |
| 256 | m_commandBuffer->QueueCommandBuffer(fence); |
| 257 | } |
| 258 | void BindVertexBuffer(VkConstantBufferObj *vertexBuffer, |
| 259 | VkDeviceSize offset, uint32_t binding) { |
| 260 | m_commandBuffer->BindVertexBuffer(vertexBuffer, offset, binding); |
| 261 | } |
| 262 | void BindIndexBuffer(VkIndexBufferObj *indexBuffer, VkDeviceSize offset) { |
| 263 | m_commandBuffer->BindIndexBuffer(indexBuffer, offset); |
| 264 | } |
| 265 | |
| 266 | protected: |
| 267 | ErrorMonitor *m_errorMonitor; |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 268 | bool m_enableWSI; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 269 | |
| 270 | virtual void SetUp() { |
Courtney Goeltzenleuchter | cd69eee | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 271 | std::vector<const char *> instance_layer_names; |
| 272 | std::vector<const char *> device_layer_names; |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 273 | std::vector<const char *> instance_extension_names; |
| 274 | std::vector<const char *> device_extension_names; |
Tony Barbour | 3fdff9e | 2015-04-23 12:55:36 -0600 | [diff] [blame] | 275 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 276 | instance_extension_names.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME); |
Courtney Goeltzenleuchter | c2b06fe | 2015-06-16 15:59:11 -0600 | [diff] [blame] | 277 | /* |
| 278 | * Since CreateDbgMsgCallback is an instance level extension call |
| 279 | * any extension / layer that utilizes that feature also needs |
| 280 | * to be enabled at create instance time. |
| 281 | */ |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 282 | // Use Threading layer first to protect others from |
| 283 | // ThreadCommandBufferCollision test |
Courtney Goeltzenleuchter | 7688532 | 2016-02-06 17:11:22 -0700 | [diff] [blame] | 284 | instance_layer_names.push_back("VK_LAYER_GOOGLE_threading"); |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 285 | instance_layer_names.push_back("VK_LAYER_LUNARG_parameter_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 286 | instance_layer_names.push_back("VK_LAYER_LUNARG_object_tracker"); |
Tobin Ehlis | c96f806 | 2016-03-09 16:12:48 -0700 | [diff] [blame] | 287 | instance_layer_names.push_back("VK_LAYER_LUNARG_core_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 288 | instance_layer_names.push_back("VK_LAYER_LUNARG_device_limits"); |
| 289 | instance_layer_names.push_back("VK_LAYER_LUNARG_image"); |
Ian Elliott | e48a138 | 2016-04-28 14:22:58 -0600 | [diff] [blame] | 290 | instance_layer_names.push_back("VK_LAYER_LUNARG_swapchain"); |
Dustin Graves | eaa78cd | 2016-01-26 16:30:22 -0700 | [diff] [blame] | 291 | instance_layer_names.push_back("VK_LAYER_GOOGLE_unique_objects"); |
Courtney Goeltzenleuchter | d971b61 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 292 | |
Courtney Goeltzenleuchter | 7688532 | 2016-02-06 17:11:22 -0700 | [diff] [blame] | 293 | device_layer_names.push_back("VK_LAYER_GOOGLE_threading"); |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 294 | device_layer_names.push_back("VK_LAYER_LUNARG_parameter_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 295 | device_layer_names.push_back("VK_LAYER_LUNARG_object_tracker"); |
Tobin Ehlis | c96f806 | 2016-03-09 16:12:48 -0700 | [diff] [blame] | 296 | device_layer_names.push_back("VK_LAYER_LUNARG_core_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 297 | device_layer_names.push_back("VK_LAYER_LUNARG_device_limits"); |
| 298 | device_layer_names.push_back("VK_LAYER_LUNARG_image"); |
Ian Elliott | e48a138 | 2016-04-28 14:22:58 -0600 | [diff] [blame] | 299 | device_layer_names.push_back("VK_LAYER_LUNARG_swapchain"); |
Dustin Graves | eaa78cd | 2016-01-26 16:30:22 -0700 | [diff] [blame] | 300 | device_layer_names.push_back("VK_LAYER_GOOGLE_unique_objects"); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 301 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 302 | if (m_enableWSI) { |
| 303 | instance_extension_names.push_back(VK_KHR_SURFACE_EXTENSION_NAME); |
| 304 | device_extension_names.push_back(VK_KHR_SWAPCHAIN_EXTENSION_NAME); |
| 305 | #ifdef NEED_TO_TEST_THIS_ON_PLATFORM |
| 306 | #if defined(VK_USE_PLATFORM_ANDROID_KHR) |
| 307 | instance_extension_names.push_back(VK_KHR_ANDROID_SURFACE_EXTENSION_NAME); |
| 308 | #endif // VK_USE_PLATFORM_ANDROID_KHR |
| 309 | #if defined(VK_USE_PLATFORM_MIR_KHR) |
| 310 | instance_extension_names.push_back(VK_KHR_MIR_SURFACE_EXTENSION_NAME); |
| 311 | #endif // VK_USE_PLATFORM_MIR_KHR |
| 312 | #if defined(VK_USE_PLATFORM_WAYLAND_KHR) |
| 313 | instance_extension_names.push_back(VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME); |
| 314 | #endif // VK_USE_PLATFORM_WAYLAND_KHR |
| 315 | #if defined(VK_USE_PLATFORM_WIN32_KHR) |
| 316 | instance_extension_names.push_back(VK_KHR_WIN32_SURFACE_EXTENSION_NAME); |
| 317 | #endif // VK_USE_PLATFORM_WIN32_KHR |
| 318 | #endif // NEED_TO_TEST_THIS_ON_PLATFORM |
| 319 | #if defined(VK_USE_PLATFORM_XCB_KHR) |
| 320 | instance_extension_names.push_back(VK_KHR_XCB_SURFACE_EXTENSION_NAME); |
| 321 | #elif defined(VK_USE_PLATFORM_XLIB_KHR) |
| 322 | instance_extension_names.push_back(VK_KHR_XLIB_SURFACE_EXTENSION_NAME); |
| 323 | #endif // VK_USE_PLATFORM_XLIB_KHR |
| 324 | } |
| 325 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 326 | this->app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 327 | this->app_info.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 328 | this->app_info.pApplicationName = "layer_tests"; |
| 329 | this->app_info.applicationVersion = 1; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 330 | this->app_info.pEngineName = "unittest"; |
| 331 | this->app_info.engineVersion = 1; |
Jon Ashburn | c5012ff | 2016-03-22 13:57:46 -0600 | [diff] [blame] | 332 | this->app_info.apiVersion = VK_API_VERSION_1_0; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 333 | |
Tony Barbour | 15524c3 | 2015-04-29 17:34:29 -0600 | [diff] [blame] | 334 | m_errorMonitor = new ErrorMonitor; |
Courtney Goeltzenleuchter | cd69eee | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 335 | InitFramework(instance_layer_names, device_layer_names, |
| 336 | instance_extension_names, device_extension_names, |
| 337 | myDbgFunc, m_errorMonitor); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 338 | } |
| 339 | |
| 340 | virtual void TearDown() { |
| 341 | // Clean up resources before we reset |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 342 | ShutdownFramework(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 343 | delete m_errorMonitor; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 344 | } |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 345 | |
| 346 | VkLayerTest() { |
| 347 | m_enableWSI = false; |
| 348 | } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 349 | }; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 350 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 351 | VkResult VkLayerTest::BeginCommandBuffer(VkCommandBufferObj &commandBuffer) { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 352 | VkResult result; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 353 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 354 | result = commandBuffer.BeginCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 355 | |
| 356 | /* |
| 357 | * For render test all drawing happens in a single render pass |
| 358 | * on a single command buffer. |
| 359 | */ |
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 360 | if (VK_SUCCESS == result && renderPass()) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 361 | commandBuffer.BeginRenderPass(renderPassBeginInfo()); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 362 | } |
| 363 | |
| 364 | return result; |
| 365 | } |
| 366 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 367 | VkResult VkLayerTest::EndCommandBuffer(VkCommandBufferObj &commandBuffer) { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 368 | VkResult result; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 369 | |
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 370 | if (renderPass()) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 371 | commandBuffer.EndRenderPass(); |
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 372 | } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 373 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 374 | result = commandBuffer.EndCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 375 | |
| 376 | return result; |
| 377 | } |
| 378 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 379 | void VkLayerTest::VKTriangleTest(const char *vertShaderText, |
| 380 | const char *fragShaderText, |
| 381 | BsoFailSelect failMask) { |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 382 | // Create identity matrix |
| 383 | int i; |
| 384 | struct vktriangle_vs_uniform data; |
| 385 | |
| 386 | glm::mat4 Projection = glm::mat4(1.0f); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 387 | glm::mat4 View = glm::mat4(1.0f); |
| 388 | glm::mat4 Model = glm::mat4(1.0f); |
| 389 | glm::mat4 MVP = Projection * View * Model; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 390 | const int matrixSize = sizeof(MVP); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 391 | const int bufSize = sizeof(vktriangle_vs_uniform) / sizeof(float); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 392 | |
| 393 | memcpy(&data.mvp, &MVP[0][0], matrixSize); |
| 394 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 395 | static const Vertex tri_data[] = { |
| 396 | {XYZ1(-1, -1, 0), XYZ1(1.f, 0.f, 0.f)}, |
| 397 | {XYZ1(1, -1, 0), XYZ1(0.f, 1.f, 0.f)}, |
| 398 | {XYZ1(0, 1, 0), XYZ1(0.f, 0.f, 1.f)}, |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 399 | }; |
| 400 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 401 | for (i = 0; i < 3; i++) { |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 402 | data.position[i][0] = tri_data[i].posX; |
| 403 | data.position[i][1] = tri_data[i].posY; |
| 404 | data.position[i][2] = tri_data[i].posZ; |
| 405 | data.position[i][3] = tri_data[i].posW; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 406 | data.color[i][0] = tri_data[i].r; |
| 407 | data.color[i][1] = tri_data[i].g; |
| 408 | data.color[i][2] = tri_data[i].b; |
| 409 | data.color[i][3] = tri_data[i].a; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 410 | } |
| 411 | |
| 412 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 413 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 414 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 415 | VkConstantBufferObj constantBuffer(m_device, bufSize * 2, sizeof(float), |
| 416 | (const void *)&data); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 417 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 418 | VkShaderObj vs(m_device, vertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 419 | VkShaderObj ps(m_device, fragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, |
| 420 | this); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 421 | |
| 422 | VkPipelineObj pipelineobj(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 423 | pipelineobj.AddColorAttachment(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 424 | pipelineobj.AddShader(&vs); |
| 425 | pipelineobj.AddShader(&ps); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 426 | if (failMask & BsoFailLineWidth) { |
| 427 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_LINE_WIDTH); |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 428 | VkPipelineInputAssemblyStateCreateInfo ia_state = {}; |
| 429 | ia_state.sType = |
| 430 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 431 | ia_state.topology = VK_PRIMITIVE_TOPOLOGY_LINE_LIST; |
| 432 | pipelineobj.SetInputAssembly(&ia_state); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 433 | } |
| 434 | if (failMask & BsoFailDepthBias) { |
| 435 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_DEPTH_BIAS); |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 436 | VkPipelineRasterizationStateCreateInfo rs_state = {}; |
| 437 | rs_state.sType = |
| 438 | VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 439 | rs_state.depthBiasEnable = VK_TRUE; |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 440 | rs_state.lineWidth = 1.0f; |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 441 | pipelineobj.SetRasterization(&rs_state); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 442 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 443 | // Viewport and scissors must stay in synch or other errors will occur than |
| 444 | // the ones we want |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 445 | if (failMask & BsoFailViewport) { |
| 446 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_VIEWPORT); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 447 | m_viewports.clear(); |
| 448 | m_scissors.clear(); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 449 | } |
| 450 | if (failMask & BsoFailScissor) { |
| 451 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_SCISSOR); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 452 | m_scissors.clear(); |
| 453 | m_viewports.clear(); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 454 | } |
| 455 | if (failMask & BsoFailBlend) { |
| 456 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_BLEND_CONSTANTS); |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 457 | VkPipelineColorBlendAttachmentState att_state = {}; |
| 458 | att_state.dstAlphaBlendFactor = VK_BLEND_FACTOR_CONSTANT_COLOR; |
| 459 | att_state.blendEnable = VK_TRUE; |
| 460 | pipelineobj.AddColorAttachment(0, &att_state); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 461 | } |
| 462 | if (failMask & BsoFailDepthBounds) { |
| 463 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_DEPTH_BOUNDS); |
| 464 | } |
| 465 | if (failMask & BsoFailStencilReadMask) { |
| 466 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK); |
| 467 | } |
| 468 | if (failMask & BsoFailStencilWriteMask) { |
| 469 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_WRITE_MASK); |
| 470 | } |
| 471 | if (failMask & BsoFailStencilReference) { |
| 472 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_REFERENCE); |
| 473 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 474 | |
| 475 | VkDescriptorSetObj descriptorSet(m_device); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 476 | descriptorSet.AppendBuffer(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, |
| 477 | constantBuffer); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 478 | |
| 479 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 480 | ASSERT_VK_SUCCESS(BeginCommandBuffer()); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 481 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 482 | GenericDrawPreparation(pipelineobj, descriptorSet, failMask); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 483 | |
| 484 | // render triangle |
Courtney Goeltzenleuchter | 08c2637 | 2015-09-23 12:31:50 -0600 | [diff] [blame] | 485 | Draw(3, 1, 0, 0); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 486 | |
| 487 | // finalize recording of the command buffer |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 488 | EndCommandBuffer(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 489 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 490 | QueueCommandBuffer(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 491 | } |
| 492 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 493 | void VkLayerTest::GenericDrawPreparation(VkCommandBufferObj *commandBuffer, |
| 494 | VkPipelineObj &pipelineobj, |
| 495 | VkDescriptorSetObj &descriptorSet, |
| 496 | BsoFailSelect failMask) { |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 497 | if (m_depthStencil->Initialized()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 498 | commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 499 | m_stencil_clear_color, m_depthStencil); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 500 | } else { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 501 | commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 502 | m_stencil_clear_color, NULL); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 503 | } |
| 504 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 505 | commandBuffer->PrepareAttachments(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 506 | // Make sure depthWriteEnable is set so that Depth fail test will work |
| 507 | // correctly |
| 508 | // Make sure stencilTestEnable is set so that Stencil fail test will work |
| 509 | // correctly |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 510 | VkStencilOpState stencil = {}; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 511 | stencil.failOp = VK_STENCIL_OP_KEEP; |
| 512 | stencil.passOp = VK_STENCIL_OP_KEEP; |
| 513 | stencil.depthFailOp = VK_STENCIL_OP_KEEP; |
| 514 | stencil.compareOp = VK_COMPARE_OP_NEVER; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 515 | |
| 516 | VkPipelineDepthStencilStateCreateInfo ds_ci = {}; |
| 517 | ds_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO; |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 518 | ds_ci.pNext = NULL; |
| 519 | ds_ci.depthTestEnable = VK_FALSE; |
| 520 | ds_ci.depthWriteEnable = VK_TRUE; |
| 521 | ds_ci.depthCompareOp = VK_COMPARE_OP_NEVER; |
| 522 | ds_ci.depthBoundsTestEnable = VK_FALSE; |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 523 | if (failMask & BsoFailDepthBounds) { |
| 524 | ds_ci.depthBoundsTestEnable = VK_TRUE; |
Tobin Ehlis | 21c8835 | 2016-05-26 06:15:45 -0600 | [diff] [blame] | 525 | ds_ci.maxDepthBounds = 0.0f; |
| 526 | ds_ci.minDepthBounds = 0.0f; |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 527 | } |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 528 | ds_ci.stencilTestEnable = VK_TRUE; |
| 529 | ds_ci.front = stencil; |
| 530 | ds_ci.back = stencil; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 531 | |
Tobin Ehlis | 4bf96d1 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 532 | pipelineobj.SetDepthStencil(&ds_ci); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 533 | pipelineobj.SetViewport(m_viewports); |
| 534 | pipelineobj.SetScissor(m_scissors); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 535 | descriptorSet.CreateVKDescriptorSet(commandBuffer); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 536 | VkResult err = pipelineobj.CreateVKPipeline( |
| 537 | descriptorSet.GetPipelineLayout(), renderPass()); |
Cody Northrop | 29a08f2 | 2015-08-27 10:20:35 -0600 | [diff] [blame] | 538 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 539 | commandBuffer->BindPipeline(pipelineobj); |
| 540 | commandBuffer->BindDescriptorSet(descriptorSet); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 541 | } |
| 542 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 543 | class VkWsiEnabledLayerTest : public VkLayerTest { |
| 544 | public: |
| 545 | protected: |
| 546 | VkWsiEnabledLayerTest() { |
| 547 | m_enableWSI = true; |
| 548 | } |
| 549 | }; |
| 550 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 551 | // ******************************************************************************************************************** |
| 552 | // ******************************************************************************************************************** |
| 553 | // ******************************************************************************************************************** |
| 554 | // ******************************************************************************************************************** |
Dustin Graves | ffa90fa | 2016-05-06 11:20:38 -0600 | [diff] [blame] | 555 | #if PARAMETER_VALIDATION_TESTS |
| 556 | TEST_F(VkLayerTest, RequiredParameter) { |
| 557 | TEST_DESCRIPTION("Specify VK_NULL_HANDLE, NULL, and 0 for required handle, " |
| 558 | "pointer, array, and array count parameters"); |
| 559 | |
| 560 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 561 | |
| 562 | m_errorMonitor->SetDesiredFailureMsg( |
| 563 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 564 | "required parameter pFeatures specified as NULL"); |
| 565 | // Specify NULL for a pointer to a handle |
| 566 | // Expected to trigger an error with |
| 567 | // parameter_validation::validate_required_pointer |
| 568 | vkGetPhysicalDeviceFeatures(gpu(), NULL); |
| 569 | m_errorMonitor->VerifyFound(); |
| 570 | |
| 571 | m_errorMonitor->SetDesiredFailureMsg( |
| 572 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Dustin Graves | a4bb8c1 | 2016-05-16 17:22:51 -0600 | [diff] [blame] | 573 | "required parameter pQueueFamilyPropertyCount specified as NULL"); |
Dustin Graves | ffa90fa | 2016-05-06 11:20:38 -0600 | [diff] [blame] | 574 | // Specify NULL for pointer to array count |
| 575 | // Expected to trigger an error with parameter_validation::validate_array |
Dustin Graves | a4bb8c1 | 2016-05-16 17:22:51 -0600 | [diff] [blame] | 576 | vkGetPhysicalDeviceQueueFamilyProperties(gpu(), NULL, NULL); |
Dustin Graves | ffa90fa | 2016-05-06 11:20:38 -0600 | [diff] [blame] | 577 | m_errorMonitor->VerifyFound(); |
| 578 | |
| 579 | m_errorMonitor->SetDesiredFailureMsg( |
| 580 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 581 | "parameter viewportCount must be greater than 0"); |
| 582 | // Specify 0 for a required array count |
| 583 | // Expected to trigger an error with parameter_validation::validate_array |
| 584 | VkViewport view_port = {}; |
| 585 | m_commandBuffer->SetViewport(0, 0, &view_port); |
| 586 | m_errorMonitor->VerifyFound(); |
| 587 | |
| 588 | m_errorMonitor->SetDesiredFailureMsg( |
| 589 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 590 | "required parameter pViewports specified as NULL"); |
| 591 | // Specify NULL for a required array |
| 592 | // Expected to trigger an error with parameter_validation::validate_array |
| 593 | m_commandBuffer->SetViewport(0, 1, NULL); |
| 594 | m_errorMonitor->VerifyFound(); |
| 595 | |
| 596 | m_errorMonitor->SetDesiredFailureMsg( |
| 597 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 598 | "required parameter memory specified as VK_NULL_HANDLE"); |
| 599 | // Specify VK_NULL_HANDLE for a required handle |
| 600 | // Expected to trigger an error with |
| 601 | // parameter_validation::validate_required_handle |
| 602 | vkUnmapMemory(device(), VK_NULL_HANDLE); |
| 603 | m_errorMonitor->VerifyFound(); |
| 604 | |
| 605 | m_errorMonitor->SetDesiredFailureMsg( |
| 606 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 607 | "required parameter pFences[0] specified as VK_NULL_HANDLE"); |
| 608 | // Specify VK_NULL_HANDLE for a required handle array entry |
| 609 | // Expected to trigger an error with |
| 610 | // parameter_validation::validate_required_handle_array |
| 611 | VkFence fence = VK_NULL_HANDLE; |
| 612 | vkResetFences(device(), 1, &fence); |
| 613 | m_errorMonitor->VerifyFound(); |
| 614 | |
| 615 | m_errorMonitor->SetDesiredFailureMsg( |
| 616 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 617 | "required parameter pAllocateInfo specified as NULL"); |
| 618 | // Specify NULL for a required struct pointer |
| 619 | // Expected to trigger an error with |
| 620 | // parameter_validation::validate_struct_type |
| 621 | VkDeviceMemory memory = VK_NULL_HANDLE; |
| 622 | vkAllocateMemory(device(), NULL, NULL, &memory); |
| 623 | m_errorMonitor->VerifyFound(); |
| 624 | |
| 625 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 626 | "value of faceMask must not be 0"); |
| 627 | // Specify 0 for a required VkFlags parameter |
| 628 | // Expected to trigger an error with parameter_validation::validate_flags |
| 629 | m_commandBuffer->SetStencilReference(0, 0); |
| 630 | m_errorMonitor->VerifyFound(); |
| 631 | |
| 632 | m_errorMonitor->SetDesiredFailureMsg( |
| 633 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 634 | "value of pSubmits[i].pWaitDstStageMask[0] must not be 0"); |
| 635 | // Specify 0 for a required VkFlags array entry |
| 636 | // Expected to trigger an error with |
| 637 | // parameter_validation::validate_flags_array |
| 638 | VkSemaphore semaphore = VK_NULL_HANDLE; |
| 639 | VkPipelineStageFlags stageFlags = 0; |
| 640 | VkSubmitInfo submitInfo = {}; |
| 641 | submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 642 | submitInfo.waitSemaphoreCount = 1; |
| 643 | submitInfo.pWaitSemaphores = &semaphore; |
| 644 | submitInfo.pWaitDstStageMask = &stageFlags; |
| 645 | vkQueueSubmit(m_device->m_queue, 1, &submitInfo, VK_NULL_HANDLE); |
| 646 | m_errorMonitor->VerifyFound(); |
| 647 | } |
Dustin Graves | c99cf5a | 2016-05-09 14:40:29 -0600 | [diff] [blame] | 648 | |
Dustin Graves | fce74c0 | 2016-05-10 11:42:58 -0600 | [diff] [blame] | 649 | TEST_F(VkLayerTest, ReservedParameter) { |
| 650 | TEST_DESCRIPTION("Specify a non-zero value for a reserved parameter"); |
| 651 | |
| 652 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 653 | |
| 654 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 655 | " must be 0"); |
| 656 | // Specify 0 for a reserved VkFlags parameter |
| 657 | // Expected to trigger an error with |
| 658 | // parameter_validation::validate_reserved_flags |
| 659 | VkEvent event_handle = VK_NULL_HANDLE; |
| 660 | VkEventCreateInfo event_info = {}; |
| 661 | event_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 662 | event_info.flags = 1; |
| 663 | vkCreateEvent(device(), &event_info, NULL, &event_handle); |
| 664 | m_errorMonitor->VerifyFound(); |
| 665 | } |
| 666 | |
Dustin Graves | c99cf5a | 2016-05-09 14:40:29 -0600 | [diff] [blame] | 667 | TEST_F(VkLayerTest, InvalidStructSType) { |
| 668 | TEST_DESCRIPTION("Specify an invalid VkStructureType for a Vulkan " |
| 669 | "structure's sType field"); |
| 670 | |
| 671 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 672 | |
| 673 | m_errorMonitor->SetDesiredFailureMsg( |
| 674 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 675 | "parameter pAllocateInfo->sType must be"); |
| 676 | // Zero struct memory, effectively setting sType to |
| 677 | // VK_STRUCTURE_TYPE_APPLICATION_INFO |
| 678 | // Expected to trigger an error with |
| 679 | // parameter_validation::validate_struct_type |
| 680 | VkMemoryAllocateInfo alloc_info = {}; |
| 681 | VkDeviceMemory memory = VK_NULL_HANDLE; |
| 682 | vkAllocateMemory(device(), &alloc_info, NULL, &memory); |
| 683 | m_errorMonitor->VerifyFound(); |
| 684 | |
| 685 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 686 | "parameter pSubmits[0].sType must be"); |
| 687 | // Zero struct memory, effectively setting sType to |
| 688 | // VK_STRUCTURE_TYPE_APPLICATION_INFO |
| 689 | // Expected to trigger an error with |
| 690 | // parameter_validation::validate_struct_type_array |
| 691 | VkSubmitInfo submit_info = {}; |
| 692 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 693 | m_errorMonitor->VerifyFound(); |
| 694 | } |
| 695 | |
| 696 | TEST_F(VkLayerTest, InvalidStructPNext) { |
| 697 | TEST_DESCRIPTION( |
| 698 | "Specify an invalid value for a Vulkan structure's pNext field"); |
| 699 | |
| 700 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 701 | |
| 702 | m_errorMonitor->SetDesiredFailureMsg( |
| 703 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 704 | "value of pAllocateInfo->pNext must be NULL"); |
| 705 | // Set VkMemoryAllocateInfo::pNext to a non-NULL value, when pNext must be |
| 706 | // NULL |
| 707 | // Expected to trigger an error with |
| 708 | // parameter_validation::validate_struct_pnext |
| 709 | VkDeviceMemory memory = VK_NULL_HANDLE; |
| 710 | // Zero-initialization will provide the correct sType |
| 711 | VkApplicationInfo app_info = {}; |
Dustin Graves | 47b6cba | 2016-05-10 17:34:38 -0600 | [diff] [blame] | 712 | VkMemoryAllocateInfo memory_alloc_info = {}; |
| 713 | memory_alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 714 | memory_alloc_info.pNext = &app_info; |
| 715 | vkAllocateMemory(device(), &memory_alloc_info, NULL, &memory); |
Dustin Graves | c99cf5a | 2016-05-09 14:40:29 -0600 | [diff] [blame] | 716 | m_errorMonitor->VerifyFound(); |
| 717 | |
Dustin Graves | 47b6cba | 2016-05-10 17:34:38 -0600 | [diff] [blame] | 718 | m_errorMonitor->SetDesiredFailureMsg( |
| 719 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 720 | " chain includes a structure with unexpected VkStructureType "); |
| 721 | // Set VkGraphicsPipelineCreateInfo::VkPipelineRasterizationStateCreateInfo::pNext to an invalid structure, when pNext is allowed to be a non-NULL value |
| 722 | // Expected to trigger an error with |
| 723 | // parameter_validation::validate_struct_pnext |
| 724 | VkDescriptorPoolSize ds_type_count = {}; |
| 725 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 726 | ds_type_count.descriptorCount = 1; |
| 727 | |
| 728 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 729 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 730 | ds_pool_ci.pNext = NULL; |
| 731 | ds_pool_ci.maxSets = 1; |
| 732 | ds_pool_ci.poolSizeCount = 1; |
| 733 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 734 | |
| 735 | VkDescriptorPool ds_pool; |
| 736 | VkResult err = |
| 737 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 738 | ASSERT_VK_SUCCESS(err); |
| 739 | |
| 740 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 741 | dsl_binding.binding = 0; |
| 742 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 743 | dsl_binding.descriptorCount = 1; |
| 744 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 745 | dsl_binding.pImmutableSamplers = NULL; |
| 746 | |
| 747 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 748 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 749 | ds_layout_ci.pNext = NULL; |
| 750 | ds_layout_ci.bindingCount = 1; |
| 751 | ds_layout_ci.pBindings = &dsl_binding; |
| 752 | |
| 753 | VkDescriptorSetLayout ds_layout; |
| 754 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 755 | &ds_layout); |
| 756 | ASSERT_VK_SUCCESS(err); |
| 757 | |
| 758 | VkDescriptorSet descriptorSet; |
| 759 | VkDescriptorSetAllocateInfo ds_alloc_info = {}; |
| 760 | ds_alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 761 | ds_alloc_info.descriptorSetCount = 1; |
| 762 | ds_alloc_info.descriptorPool = ds_pool; |
| 763 | ds_alloc_info.pSetLayouts = &ds_layout; |
| 764 | err = vkAllocateDescriptorSets(m_device->device(), &ds_alloc_info, |
| 765 | &descriptorSet); |
| 766 | ASSERT_VK_SUCCESS(err); |
| 767 | |
| 768 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 769 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 770 | pipeline_layout_ci.setLayoutCount = 1; |
| 771 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 772 | |
| 773 | VkPipelineLayout pipeline_layout; |
| 774 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 775 | &pipeline_layout); |
| 776 | ASSERT_VK_SUCCESS(err); |
| 777 | |
| 778 | VkViewport vp = {}; // Just need dummy vp to point to |
| 779 | VkRect2D sc = {}; // dummy scissor to point to |
| 780 | |
| 781 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 782 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 783 | vp_state_ci.scissorCount = 1; |
| 784 | vp_state_ci.pScissors = ≻ |
| 785 | vp_state_ci.viewportCount = 1; |
| 786 | vp_state_ci.pViewports = &vp; |
| 787 | |
| 788 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 789 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 790 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 791 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 792 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 793 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 794 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 795 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 796 | |
| 797 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 798 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 799 | gp_ci.pViewportState = &vp_state_ci; |
| 800 | gp_ci.pRasterizationState = &rs_state_ci; |
| 801 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 802 | gp_ci.layout = pipeline_layout; |
| 803 | gp_ci.renderPass = renderPass(); |
| 804 | |
| 805 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 806 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 807 | pc_ci.initialDataSize = 0; |
| 808 | pc_ci.pInitialData = 0; |
| 809 | |
| 810 | VkPipeline pipeline; |
| 811 | VkPipelineCache pipelineCache; |
| 812 | |
| 813 | err = |
| 814 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 815 | ASSERT_VK_SUCCESS(err); |
| 816 | |
| 817 | // Set VkPipelineRasterizationStateCreateInfo::pNext to an invalid value |
| 818 | VkApplicationInfo invalid_pnext_struct = {}; |
| 819 | rs_state_ci.pNext = &invalid_pnext_struct; |
| 820 | |
| 821 | vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 822 | &gp_ci, NULL, &pipeline); |
| 823 | m_errorMonitor->VerifyFound(); |
Dustin Graves | c99cf5a | 2016-05-09 14:40:29 -0600 | [diff] [blame] | 824 | } |
Dustin Graves | 5d33d53 | 2016-05-09 16:21:12 -0600 | [diff] [blame] | 825 | |
| 826 | TEST_F(VkLayerTest, UnrecognizedValue) { |
| 827 | TEST_DESCRIPTION( |
| 828 | "Specify unrecognized Vulkan enumeration, flags, and VkBool32 values"); |
| 829 | |
| 830 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 831 | |
| 832 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 833 | "does not fall within the begin..end " |
| 834 | "range of the core VkFormat " |
| 835 | "enumeration tokens"); |
| 836 | // Specify an invalid VkFormat value |
| 837 | // Expected to trigger an error with |
| 838 | // parameter_validation::validate_ranged_enum |
| 839 | VkFormatProperties format_properties; |
| 840 | vkGetPhysicalDeviceFormatProperties(gpu(), static_cast<VkFormat>(8000), |
| 841 | &format_properties); |
| 842 | m_errorMonitor->VerifyFound(); |
| 843 | |
| 844 | m_errorMonitor->SetDesiredFailureMsg( |
| 845 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 846 | "contains flag bits that are not recognized members of"); |
| 847 | // Specify an invalid VkFlags bitmask value |
| 848 | // Expected to trigger an error with parameter_validation::validate_flags |
| 849 | VkImageFormatProperties image_format_properties; |
| 850 | vkGetPhysicalDeviceImageFormatProperties( |
| 851 | gpu(), VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_TYPE_2D, |
| 852 | VK_IMAGE_TILING_OPTIMAL, static_cast<VkImageUsageFlags>(1 << 25), 0, |
| 853 | &image_format_properties); |
| 854 | m_errorMonitor->VerifyFound(); |
| 855 | |
| 856 | m_errorMonitor->SetDesiredFailureMsg( |
| 857 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 858 | "contains flag bits that are not recognized members of"); |
| 859 | // Specify an invalid VkFlags array entry |
| 860 | // Expected to trigger an error with |
| 861 | // parameter_validation::validate_flags_array |
| 862 | VkSemaphore semaphore = VK_NULL_HANDLE; |
| 863 | VkPipelineStageFlags stage_flags = |
| 864 | static_cast<VkPipelineStageFlags>(1 << 25); |
| 865 | VkSubmitInfo submit_info = {}; |
| 866 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 867 | submit_info.waitSemaphoreCount = 1; |
| 868 | submit_info.pWaitSemaphores = &semaphore; |
| 869 | submit_info.pWaitDstStageMask = &stage_flags; |
| 870 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 871 | m_errorMonitor->VerifyFound(); |
| 872 | |
| 873 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, |
| 874 | "is neither VK_TRUE nor VK_FALSE"); |
| 875 | // Specify an invalid VkBool32 value |
| 876 | // Expected to trigger a warning with |
| 877 | // parameter_validation::validate_bool32 |
| 878 | VkSampler sampler = VK_NULL_HANDLE; |
| 879 | VkSamplerCreateInfo sampler_info = {}; |
| 880 | sampler_info.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 881 | sampler_info.pNext = NULL; |
| 882 | sampler_info.magFilter = VK_FILTER_NEAREST; |
| 883 | sampler_info.minFilter = VK_FILTER_NEAREST; |
| 884 | sampler_info.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 885 | sampler_info.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 886 | sampler_info.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 887 | sampler_info.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 888 | sampler_info.mipLodBias = 1.0; |
| 889 | sampler_info.maxAnisotropy = 1; |
| 890 | sampler_info.compareEnable = VK_FALSE; |
| 891 | sampler_info.compareOp = VK_COMPARE_OP_NEVER; |
| 892 | sampler_info.minLod = 1.0; |
| 893 | sampler_info.maxLod = 1.0; |
| 894 | sampler_info.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 895 | sampler_info.unnormalizedCoordinates = VK_FALSE; |
| 896 | // Not VK_TRUE or VK_FALSE |
| 897 | sampler_info.anisotropyEnable = 3; |
| 898 | vkCreateSampler(m_device->device(), &sampler_info, NULL, &sampler); |
| 899 | m_errorMonitor->VerifyFound(); |
| 900 | } |
Dustin Graves | fce74c0 | 2016-05-10 11:42:58 -0600 | [diff] [blame] | 901 | |
| 902 | TEST_F(VkLayerTest, FailedReturnValue) { |
| 903 | TEST_DESCRIPTION("Check for a message describing a VkResult failure code"); |
| 904 | |
| 905 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 906 | |
Dustin Graves | 13c1e2b | 2016-05-16 15:31:02 -0600 | [diff] [blame] | 907 | // Find an unsupported image format |
| 908 | VkFormat unsupported = VK_FORMAT_UNDEFINED; |
| 909 | for (int f = VK_FORMAT_BEGIN_RANGE; f <= VK_FORMAT_END_RANGE; f++) { |
| 910 | VkFormat format = static_cast<VkFormat>(f); |
| 911 | VkFormatProperties fProps = m_device->format_properties(format); |
| 912 | if (format != VK_FORMAT_UNDEFINED && fProps.linearTilingFeatures == 0 && |
| 913 | fProps.optimalTilingFeatures == 0) { |
| 914 | unsupported = format; |
| 915 | break; |
| 916 | } |
| 917 | } |
| 918 | |
| 919 | if (unsupported != VK_FORMAT_UNDEFINED) { |
| 920 | m_errorMonitor->SetDesiredFailureMsg( |
| 921 | VK_DEBUG_REPORT_WARNING_BIT_EXT, |
| 922 | "the requested format is not supported on this device"); |
| 923 | // Specify an unsupported VkFormat value to generate a |
| 924 | // VK_ERROR_FORMAT_NOT_SUPPORTED return code |
| 925 | // Expected to trigger a warning from |
| 926 | // parameter_validation::validate_result |
| 927 | VkImageFormatProperties image_format_properties; |
| 928 | VkResult err = vkGetPhysicalDeviceImageFormatProperties( |
| 929 | gpu(), unsupported, VK_IMAGE_TYPE_2D, VK_IMAGE_TILING_OPTIMAL, |
| 930 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, 0, &image_format_properties); |
| 931 | ASSERT_TRUE(err == VK_ERROR_FORMAT_NOT_SUPPORTED); |
| 932 | m_errorMonitor->VerifyFound(); |
| 933 | } |
Dustin Graves | fce74c0 | 2016-05-10 11:42:58 -0600 | [diff] [blame] | 934 | } |
Dustin Graves | ffa90fa | 2016-05-06 11:20:38 -0600 | [diff] [blame] | 935 | #endif // PARAMETER_VALIDATION_TESTS |
| 936 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 937 | #if MEM_TRACKER_TESTS |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 938 | #if 0 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 939 | TEST_F(VkLayerTest, CallResetCommandBufferBeforeCompletion) |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 940 | { |
| 941 | vk_testing::Fence testFence; |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 942 | VkFenceCreateInfo fenceInfo = {}; |
| 943 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 944 | fenceInfo.pNext = NULL; |
| 945 | fenceInfo.flags = 0; |
| 946 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 947 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "Resetting CB"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 948 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 949 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tony Barbour | c1eb1a5 | 2015-07-20 13:00:10 -0600 | [diff] [blame] | 950 | |
| 951 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 952 | vk_testing::Buffer buffer; |
| 953 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 954 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 955 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 956 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 4, 0x11111111); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 957 | EndCommandBuffer(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 958 | |
| 959 | testFence.init(*m_device, fenceInfo); |
| 960 | |
| 961 | // Bypass framework since it does the waits automatically |
| 962 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 963 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 964 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 965 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 966 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 967 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 968 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 969 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 970 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 971 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 972 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 973 | |
| 974 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 975 | ASSERT_VK_SUCCESS( err ); |
| 976 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 977 | // Introduce failure by calling begin again before checking fence |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 978 | vkResetCommandBuffer(m_commandBuffer->handle(), 0); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 979 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 980 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 981 | } |
| 982 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 983 | TEST_F(VkLayerTest, CallBeginCommandBufferBeforeCompletion) |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 984 | { |
| 985 | vk_testing::Fence testFence; |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 986 | VkFenceCreateInfo fenceInfo = {}; |
| 987 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 988 | fenceInfo.pNext = NULL; |
| 989 | fenceInfo.flags = 0; |
| 990 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 991 | 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] | 992 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 993 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 994 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 995 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 996 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 997 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 998 | 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] | 999 | EndCommandBuffer(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1000 | |
| 1001 | testFence.init(*m_device, fenceInfo); |
| 1002 | |
| 1003 | // Bypass framework since it does the waits automatically |
| 1004 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1005 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 1006 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1007 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1008 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1009 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 1010 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1011 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1012 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1013 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1014 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 1015 | |
| 1016 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1017 | ASSERT_VK_SUCCESS( err ); |
| 1018 | |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 1019 | VkCommandBufferInheritanceInfo hinfo = {}; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1020 | VkCommandBufferBeginInfo info = {}; |
| 1021 | info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
| 1022 | info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1023 | info.renderPass = VK_NULL_HANDLE; |
| 1024 | info.subpass = 0; |
| 1025 | info.framebuffer = VK_NULL_HANDLE; |
Chia-I Wu | b8d47ae | 2015-11-11 10:18:12 +0800 | [diff] [blame] | 1026 | info.occlusionQueryEnable = VK_FALSE; |
| 1027 | info.queryFlags = 0; |
| 1028 | info.pipelineStatistics = 0; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1029 | |
| 1030 | // Introduce failure by calling BCB again before checking fence |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1031 | vkBeginCommandBuffer(m_commandBuffer->handle(), &info); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1032 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1033 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1034 | } |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1035 | #endif |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1036 | |
Mark Lobodzinski | 152fe25 | 2016-05-03 16:49:15 -0600 | [diff] [blame] | 1037 | // This is a positive test. No failures are expected. |
| 1038 | TEST_F(VkLayerTest, TestAliasedMemoryTracking) { |
| 1039 | VkResult err; |
| 1040 | bool pass; |
| 1041 | |
| 1042 | TEST_DESCRIPTION("Create a buffer, allocate memory, bind memory, destroy " |
| 1043 | "the buffer, create an image, and bind the same memory to " |
| 1044 | "it"); |
| 1045 | |
| 1046 | m_errorMonitor->ExpectSuccess(); |
| 1047 | |
| 1048 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1049 | |
| 1050 | VkBuffer buffer; |
| 1051 | VkImage image; |
| 1052 | VkDeviceMemory mem; |
| 1053 | VkMemoryRequirements mem_reqs; |
| 1054 | |
| 1055 | VkBufferCreateInfo buf_info = {}; |
| 1056 | buf_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 1057 | buf_info.pNext = NULL; |
| 1058 | buf_info.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 1059 | buf_info.size = 256; |
| 1060 | buf_info.queueFamilyIndexCount = 0; |
| 1061 | buf_info.pQueueFamilyIndices = NULL; |
| 1062 | buf_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 1063 | buf_info.flags = 0; |
| 1064 | err = vkCreateBuffer(m_device->device(), &buf_info, NULL, &buffer); |
| 1065 | ASSERT_VK_SUCCESS(err); |
| 1066 | |
| 1067 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &mem_reqs); |
| 1068 | |
| 1069 | VkMemoryAllocateInfo alloc_info = {}; |
| 1070 | alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1071 | alloc_info.pNext = NULL; |
| 1072 | alloc_info.memoryTypeIndex = 0; |
| 1073 | |
| 1074 | // Ensure memory is big enough for both bindings |
| 1075 | alloc_info.allocationSize = 0x10000; |
| 1076 | |
| 1077 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &alloc_info, |
| 1078 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 1079 | if (!pass) { |
| 1080 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 1081 | return; |
| 1082 | } |
| 1083 | |
| 1084 | err = vkAllocateMemory(m_device->device(), &alloc_info, NULL, &mem); |
| 1085 | ASSERT_VK_SUCCESS(err); |
| 1086 | |
| 1087 | uint8_t *pData; |
| 1088 | err = vkMapMemory(m_device->device(), mem, 0, mem_reqs.size, 0, |
| 1089 | (void **)&pData); |
| 1090 | ASSERT_VK_SUCCESS(err); |
| 1091 | |
Mark Lobodzinski | 2abefa9 | 2016-05-05 11:45:57 -0600 | [diff] [blame] | 1092 | memset(pData, 0xCADECADE, static_cast<size_t>(mem_reqs.size)); |
Mark Lobodzinski | 152fe25 | 2016-05-03 16:49:15 -0600 | [diff] [blame] | 1093 | |
| 1094 | vkUnmapMemory(m_device->device(), mem); |
| 1095 | |
| 1096 | err = vkBindBufferMemory(m_device->device(), buffer, mem, 0); |
| 1097 | ASSERT_VK_SUCCESS(err); |
| 1098 | |
| 1099 | // NOW, destroy the buffer. Obviously, the resource no longer occupies this |
| 1100 | // memory. In fact, it was never used by the GPU. |
| 1101 | // Just be be sure, wait for idle. |
| 1102 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 1103 | vkDeviceWaitIdle(m_device->device()); |
| 1104 | |
| 1105 | VkImageCreateInfo image_create_info = {}; |
| 1106 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1107 | image_create_info.pNext = NULL; |
| 1108 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1109 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 1110 | image_create_info.extent.width = 64; |
| 1111 | image_create_info.extent.height = 64; |
| 1112 | image_create_info.extent.depth = 1; |
| 1113 | image_create_info.mipLevels = 1; |
| 1114 | image_create_info.arrayLayers = 1; |
| 1115 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1116 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1117 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_PREINITIALIZED; |
| 1118 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 1119 | image_create_info.queueFamilyIndexCount = 0; |
| 1120 | image_create_info.pQueueFamilyIndices = NULL; |
| 1121 | image_create_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 1122 | image_create_info.flags = 0; |
| 1123 | |
| 1124 | VkMemoryAllocateInfo mem_alloc = {}; |
| 1125 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1126 | mem_alloc.pNext = NULL; |
| 1127 | mem_alloc.allocationSize = 0; |
| 1128 | mem_alloc.memoryTypeIndex = 0; |
| 1129 | |
| 1130 | /* Create a mappable image. It will be the texture if linear images are ok |
| 1131 | * to be textures or it will be the staging image if they are not. |
| 1132 | */ |
| 1133 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 1134 | ASSERT_VK_SUCCESS(err); |
| 1135 | |
| 1136 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
| 1137 | |
| 1138 | mem_alloc.allocationSize = mem_reqs.size; |
| 1139 | |
| 1140 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, |
| 1141 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 1142 | if (!pass) { |
| 1143 | vkDestroyImage(m_device->device(), image, NULL); |
| 1144 | return; |
| 1145 | } |
| 1146 | |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1147 | // VALIDATION FAILURE: |
Mark Lobodzinski | 152fe25 | 2016-05-03 16:49:15 -0600 | [diff] [blame] | 1148 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 1149 | ASSERT_VK_SUCCESS(err); |
| 1150 | |
| 1151 | m_errorMonitor->VerifyNotFound(); |
| 1152 | |
| 1153 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 1154 | vkDestroyImage(m_device->device(), image, NULL); |
| 1155 | } |
| 1156 | |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1157 | TEST_F(VkLayerTest, InvalidMemoryAliasing) { |
| 1158 | TEST_DESCRIPTION("Create a buffer and image, allocate memory, and bind the " |
| 1159 | "buffer and image to memory such that they will alias."); |
| 1160 | VkResult err; |
| 1161 | bool pass; |
| 1162 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1163 | |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1164 | VkBuffer buffer, buffer2; |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1165 | VkImage image; |
| 1166 | VkDeviceMemory mem; // buffer will be bound first |
| 1167 | VkDeviceMemory mem_img; // image bound first |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1168 | VkMemoryRequirements buff_mem_reqs, img_mem_reqs; |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1169 | |
| 1170 | VkBufferCreateInfo buf_info = {}; |
| 1171 | buf_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 1172 | buf_info.pNext = NULL; |
| 1173 | buf_info.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 1174 | buf_info.size = 256; |
| 1175 | buf_info.queueFamilyIndexCount = 0; |
| 1176 | buf_info.pQueueFamilyIndices = NULL; |
| 1177 | buf_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 1178 | buf_info.flags = 0; |
| 1179 | err = vkCreateBuffer(m_device->device(), &buf_info, NULL, &buffer); |
| 1180 | ASSERT_VK_SUCCESS(err); |
| 1181 | |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1182 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &buff_mem_reqs); |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1183 | |
| 1184 | VkImageCreateInfo image_create_info = {}; |
| 1185 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1186 | image_create_info.pNext = NULL; |
| 1187 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1188 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 1189 | image_create_info.extent.width = 64; |
| 1190 | image_create_info.extent.height = 64; |
| 1191 | image_create_info.extent.depth = 1; |
| 1192 | image_create_info.mipLevels = 1; |
| 1193 | image_create_info.arrayLayers = 1; |
| 1194 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1195 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1196 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_PREINITIALIZED; |
| 1197 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 1198 | image_create_info.queueFamilyIndexCount = 0; |
| 1199 | image_create_info.pQueueFamilyIndices = NULL; |
| 1200 | image_create_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 1201 | image_create_info.flags = 0; |
| 1202 | |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1203 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 1204 | ASSERT_VK_SUCCESS(err); |
| 1205 | |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1206 | vkGetImageMemoryRequirements(m_device->device(), image, &img_mem_reqs); |
| 1207 | |
| 1208 | VkMemoryAllocateInfo alloc_info = {}; |
| 1209 | alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1210 | alloc_info.pNext = NULL; |
| 1211 | alloc_info.memoryTypeIndex = 0; |
| 1212 | // Ensure memory is big enough for both bindings |
| 1213 | alloc_info.allocationSize = buff_mem_reqs.size + img_mem_reqs.size; |
| 1214 | pass = m_device->phy().set_memory_type( |
| 1215 | buff_mem_reqs.memoryTypeBits | img_mem_reqs.memoryTypeBits, &alloc_info, |
| 1216 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1217 | if (!pass) { |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1218 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1219 | vkDestroyImage(m_device->device(), image, NULL); |
| 1220 | return; |
| 1221 | } |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1222 | err = vkAllocateMemory(m_device->device(), &alloc_info, NULL, &mem); |
| 1223 | ASSERT_VK_SUCCESS(err); |
| 1224 | err = vkBindBufferMemory(m_device->device(), buffer, mem, 0); |
| 1225 | ASSERT_VK_SUCCESS(err); |
| 1226 | |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1227 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1228 | " is aliased with buffer 0x"); |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1229 | // VALIDATION FAILURE due to image mapping overlapping buffer mapping |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1230 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 1231 | m_errorMonitor->VerifyFound(); |
| 1232 | |
| 1233 | // Now correctly bind image to second mem allocation before incorrectly |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1234 | // aliasing buffer2 |
| 1235 | err = vkCreateBuffer(m_device->device(), &buf_info, NULL, &buffer2); |
| 1236 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1237 | err = vkAllocateMemory(m_device->device(), &alloc_info, NULL, &mem_img); |
| 1238 | ASSERT_VK_SUCCESS(err); |
| 1239 | err = vkBindImageMemory(m_device->device(), image, mem_img, 0); |
| 1240 | ASSERT_VK_SUCCESS(err); |
| 1241 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1242 | " is aliased with image 0x"); |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1243 | err = vkBindBufferMemory(m_device->device(), buffer2, mem_img, 0); |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1244 | m_errorMonitor->VerifyFound(); |
| 1245 | |
| 1246 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1247 | vkDestroyBuffer(m_device->device(), buffer2, NULL); |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1248 | vkDestroyImage(m_device->device(), image, NULL); |
| 1249 | vkFreeMemory(m_device->device(), mem, NULL); |
| 1250 | vkFreeMemory(m_device->device(), mem_img, NULL); |
| 1251 | } |
| 1252 | |
Tobin Ehlis | 3537252 | 2016-05-12 08:32:31 -0600 | [diff] [blame] | 1253 | TEST_F(VkLayerTest, InvalidMemoryMapping) { |
| 1254 | TEST_DESCRIPTION("Attempt to map memory in a number of incorrect ways"); |
| 1255 | VkResult err; |
| 1256 | bool pass; |
| 1257 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1258 | |
| 1259 | VkBuffer buffer; |
| 1260 | VkDeviceMemory mem; |
| 1261 | VkMemoryRequirements mem_reqs; |
| 1262 | |
| 1263 | VkBufferCreateInfo buf_info = {}; |
| 1264 | buf_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 1265 | buf_info.pNext = NULL; |
| 1266 | buf_info.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 1267 | buf_info.size = 256; |
| 1268 | buf_info.queueFamilyIndexCount = 0; |
| 1269 | buf_info.pQueueFamilyIndices = NULL; |
| 1270 | buf_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 1271 | buf_info.flags = 0; |
| 1272 | err = vkCreateBuffer(m_device->device(), &buf_info, NULL, &buffer); |
| 1273 | ASSERT_VK_SUCCESS(err); |
| 1274 | |
| 1275 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &mem_reqs); |
| 1276 | VkMemoryAllocateInfo alloc_info = {}; |
| 1277 | alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1278 | alloc_info.pNext = NULL; |
| 1279 | alloc_info.memoryTypeIndex = 0; |
| 1280 | |
| 1281 | // Ensure memory is big enough for both bindings |
| 1282 | static const VkDeviceSize allocation_size = 0x10000; |
| 1283 | alloc_info.allocationSize = allocation_size; |
| 1284 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &alloc_info, |
| 1285 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 1286 | if (!pass) { |
| 1287 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 1288 | return; |
| 1289 | } |
| 1290 | err = vkAllocateMemory(m_device->device(), &alloc_info, NULL, &mem); |
| 1291 | ASSERT_VK_SUCCESS(err); |
| 1292 | |
| 1293 | uint8_t *pData; |
| 1294 | // Attempt to map memory size 0 is invalid |
| 1295 | m_errorMonitor->SetDesiredFailureMsg( |
| 1296 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1297 | "VkMapMemory: Attempting to map memory range of size zero"); |
| 1298 | err = vkMapMemory(m_device->device(), mem, 0, 0, 0, (void **)&pData); |
| 1299 | m_errorMonitor->VerifyFound(); |
| 1300 | // Map memory twice |
| 1301 | err = vkMapMemory(m_device->device(), mem, 0, mem_reqs.size, 0, |
| 1302 | (void **)&pData); |
| 1303 | ASSERT_VK_SUCCESS(err); |
| 1304 | m_errorMonitor->SetDesiredFailureMsg( |
| 1305 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1306 | "VkMapMemory: Attempting to map memory on an already-mapped object "); |
| 1307 | err = vkMapMemory(m_device->device(), mem, 0, mem_reqs.size, 0, |
| 1308 | (void **)&pData); |
| 1309 | m_errorMonitor->VerifyFound(); |
| 1310 | |
| 1311 | // Unmap the memory to avoid re-map error |
| 1312 | vkUnmapMemory(m_device->device(), mem); |
| 1313 | // overstep allocation with VK_WHOLE_SIZE |
| 1314 | m_errorMonitor->SetDesiredFailureMsg( |
| 1315 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1316 | " with size of VK_WHOLE_SIZE oversteps total array size 0x"); |
| 1317 | err = vkMapMemory(m_device->device(), mem, allocation_size + 1, |
| 1318 | VK_WHOLE_SIZE, 0, (void **)&pData); |
| 1319 | m_errorMonitor->VerifyFound(); |
| 1320 | // overstep allocation w/o VK_WHOLE_SIZE |
| 1321 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1322 | " oversteps total array size 0x"); |
| 1323 | err = vkMapMemory(m_device->device(), mem, 1, allocation_size, 0, |
| 1324 | (void **)&pData); |
| 1325 | m_errorMonitor->VerifyFound(); |
| 1326 | // Now error due to unmapping memory that's not mapped |
| 1327 | m_errorMonitor->SetDesiredFailureMsg( |
| 1328 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1329 | "Unmapping Memory without memory being mapped: "); |
| 1330 | vkUnmapMemory(m_device->device(), mem); |
| 1331 | m_errorMonitor->VerifyFound(); |
| 1332 | // Now map memory and cause errors due to flushing invalid ranges |
| 1333 | err = vkMapMemory(m_device->device(), mem, 16, VK_WHOLE_SIZE, 0, |
| 1334 | (void **)&pData); |
| 1335 | ASSERT_VK_SUCCESS(err); |
| 1336 | VkMappedMemoryRange mmr = {}; |
| 1337 | mmr.memory = mem; |
| 1338 | mmr.offset = 15; // Error b/c offset less than offset of mapped mem |
| 1339 | m_errorMonitor->SetDesiredFailureMsg( |
| 1340 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1341 | ") is less than Memory Object's offset ("); |
| 1342 | vkFlushMappedMemoryRanges(m_device->device(), 1, &mmr); |
| 1343 | m_errorMonitor->VerifyFound(); |
| 1344 | // Now flush range that oversteps mapped range |
| 1345 | vkUnmapMemory(m_device->device(), mem); |
| 1346 | err = vkMapMemory(m_device->device(), mem, 0, 256, 0, (void **)&pData); |
| 1347 | ASSERT_VK_SUCCESS(err); |
| 1348 | mmr.offset = 16; |
| 1349 | mmr.size = 256; // flushing bounds (272) exceed mapped bounds (256) |
| 1350 | m_errorMonitor->SetDesiredFailureMsg( |
| 1351 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1352 | ") exceeds the Memory Object's upper-bound ("); |
| 1353 | vkFlushMappedMemoryRanges(m_device->device(), 1, &mmr); |
| 1354 | m_errorMonitor->VerifyFound(); |
| 1355 | |
| 1356 | pass = |
| 1357 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &alloc_info, |
| 1358 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, |
| 1359 | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT); |
| 1360 | if (!pass) { |
| 1361 | vkFreeMemory(m_device->device(), mem, NULL); |
| 1362 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 1363 | return; |
| 1364 | } |
| 1365 | // TODO : If we can get HOST_VISIBLE w/o HOST_COHERENT we can test cases of |
| 1366 | // MEMTRACK_INVALID_MAP in validateAndCopyNoncoherentMemoryToDriver() |
| 1367 | |
| 1368 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 1369 | vkFreeMemory(m_device->device(), mem, NULL); |
| 1370 | } |
| 1371 | |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1372 | TEST_F(VkLayerTest, EnableWsiBeforeUse) { |
| 1373 | VkResult err; |
| 1374 | bool pass; |
| 1375 | |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1376 | // FIXME: After we turn on this code for non-Linux platforms, uncomment the |
| 1377 | // following declaration (which is temporarily being moved below): |
| 1378 | // VkSurfaceKHR surface = VK_NULL_HANDLE; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1379 | VkSwapchainKHR swapchain = VK_NULL_HANDLE; |
| 1380 | VkSwapchainCreateInfoKHR swapchain_create_info = {}; |
| 1381 | uint32_t swapchain_image_count = 0; |
| 1382 | // VkImage swapchain_images[1] = {VK_NULL_HANDLE}; |
| 1383 | uint32_t image_index = 0; |
| 1384 | // VkPresentInfoKHR present_info = {}; |
| 1385 | |
| 1386 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1387 | |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1388 | #ifdef NEED_TO_TEST_THIS_ON_PLATFORM |
| 1389 | #if defined(VK_USE_PLATFORM_ANDROID_KHR) |
| 1390 | // Use the functions from the VK_KHR_android_surface extension without |
| 1391 | // enabling that extension: |
| 1392 | |
| 1393 | // Create a surface: |
| 1394 | VkAndroidSurfaceCreateInfoKHR android_create_info = {}; |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1395 | m_errorMonitor->SetDesiredFailureMsg( |
| 1396 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1397 | "extension was not enabled for this"); |
| 1398 | err = vkCreateAndroidSurfaceKHR(instance(), &android_create_info, NULL, |
| 1399 | &surface); |
| 1400 | pass = (err != VK_SUCCESS); |
| 1401 | ASSERT_TRUE(pass); |
| 1402 | m_errorMonitor->VerifyFound(); |
| 1403 | #endif // VK_USE_PLATFORM_ANDROID_KHR |
| 1404 | |
| 1405 | |
| 1406 | #if defined(VK_USE_PLATFORM_MIR_KHR) |
| 1407 | // Use the functions from the VK_KHR_mir_surface extension without enabling |
| 1408 | // that extension: |
| 1409 | |
| 1410 | // Create a surface: |
| 1411 | VkMirSurfaceCreateInfoKHR mir_create_info = {}; |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1412 | m_errorMonitor->SetDesiredFailureMsg( |
| 1413 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1414 | "extension was not enabled for this"); |
| 1415 | err = vkCreateMirSurfaceKHR(instance(), &mir_create_info, NULL, &surface); |
| 1416 | pass = (err != VK_SUCCESS); |
| 1417 | ASSERT_TRUE(pass); |
| 1418 | m_errorMonitor->VerifyFound(); |
| 1419 | |
| 1420 | // Tell whether an mir_connection supports presentation: |
| 1421 | MirConnection *mir_connection = NULL; |
| 1422 | m_errorMonitor->SetDesiredFailureMsg( |
| 1423 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1424 | "extension was not enabled for this"); |
| 1425 | vkGetPhysicalDeviceMirPresentationSupportKHR(gpu(), 0, mir_connection, |
| 1426 | visual_id); |
| 1427 | m_errorMonitor->VerifyFound(); |
| 1428 | #endif // VK_USE_PLATFORM_MIR_KHR |
| 1429 | |
| 1430 | |
| 1431 | #if defined(VK_USE_PLATFORM_WAYLAND_KHR) |
| 1432 | // Use the functions from the VK_KHR_wayland_surface extension without |
| 1433 | // enabling that extension: |
| 1434 | |
| 1435 | // Create a surface: |
| 1436 | VkWaylandSurfaceCreateInfoKHR wayland_create_info = {}; |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1437 | m_errorMonitor->SetDesiredFailureMsg( |
| 1438 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1439 | "extension was not enabled for this"); |
| 1440 | err = vkCreateWaylandSurfaceKHR(instance(), &wayland_create_info, NULL, |
| 1441 | &surface); |
| 1442 | pass = (err != VK_SUCCESS); |
| 1443 | ASSERT_TRUE(pass); |
| 1444 | m_errorMonitor->VerifyFound(); |
| 1445 | |
| 1446 | // Tell whether an wayland_display supports presentation: |
| 1447 | struct wl_display wayland_display = {}; |
| 1448 | m_errorMonitor->SetDesiredFailureMsg( |
| 1449 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1450 | "extension was not enabled for this"); |
| 1451 | vkGetPhysicalDeviceWaylandPresentationSupportKHR(gpu(), 0, |
| 1452 | &wayland_display); |
| 1453 | m_errorMonitor->VerifyFound(); |
| 1454 | #endif // VK_USE_PLATFORM_WAYLAND_KHR |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1455 | #endif // NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1456 | |
| 1457 | |
| 1458 | #if defined(VK_USE_PLATFORM_WIN32_KHR) |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1459 | // FIXME: REMOVE THIS HERE, AND UNCOMMENT ABOVE, WHEN THIS TEST HAS BEEN PORTED |
| 1460 | // TO NON-LINUX PLATFORMS: |
| 1461 | VkSurfaceKHR surface = VK_NULL_HANDLE; |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1462 | // Use the functions from the VK_KHR_win32_surface extension without |
| 1463 | // enabling that extension: |
| 1464 | |
| 1465 | // Create a surface: |
| 1466 | VkWin32SurfaceCreateInfoKHR win32_create_info = {}; |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1467 | m_errorMonitor->SetDesiredFailureMsg( |
| 1468 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1469 | "extension was not enabled for this"); |
| 1470 | err = vkCreateWin32SurfaceKHR(instance(), &win32_create_info, NULL, |
| 1471 | &surface); |
| 1472 | pass = (err != VK_SUCCESS); |
| 1473 | ASSERT_TRUE(pass); |
| 1474 | m_errorMonitor->VerifyFound(); |
| 1475 | |
| 1476 | // Tell whether win32 supports presentation: |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1477 | m_errorMonitor->SetDesiredFailureMsg( |
| 1478 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1479 | "extension was not enabled for this"); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1480 | vkGetPhysicalDeviceWin32PresentationSupportKHR(gpu(), 0); |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1481 | m_errorMonitor->VerifyFound(); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1482 | // Set this (for now, until all platforms are supported and tested): |
| 1483 | #define NEED_TO_TEST_THIS_ON_PLATFORM |
| 1484 | #endif // VK_USE_PLATFORM_WIN32_KHR |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1485 | |
| 1486 | |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1487 | #if defined(VK_USE_PLATFORM_XCB_KHR) |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1488 | // FIXME: REMOVE THIS HERE, AND UNCOMMENT ABOVE, WHEN THIS TEST HAS BEEN PORTED |
| 1489 | // TO NON-LINUX PLATFORMS: |
| 1490 | VkSurfaceKHR surface = VK_NULL_HANDLE; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1491 | // Use the functions from the VK_KHR_xcb_surface extension without enabling |
| 1492 | // that extension: |
| 1493 | |
| 1494 | // Create a surface: |
| 1495 | VkXcbSurfaceCreateInfoKHR xcb_create_info = {}; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1496 | m_errorMonitor->SetDesiredFailureMsg( |
| 1497 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1498 | "extension was not enabled for this"); |
| 1499 | err = vkCreateXcbSurfaceKHR(instance(), &xcb_create_info, NULL, &surface); |
| 1500 | pass = (err != VK_SUCCESS); |
| 1501 | ASSERT_TRUE(pass); |
| 1502 | m_errorMonitor->VerifyFound(); |
| 1503 | |
| 1504 | // Tell whether an xcb_visualid_t supports presentation: |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1505 | xcb_connection_t *xcb_connection = NULL; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1506 | xcb_visualid_t visual_id = 0; |
| 1507 | m_errorMonitor->SetDesiredFailureMsg( |
| 1508 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1509 | "extension was not enabled for this"); |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1510 | vkGetPhysicalDeviceXcbPresentationSupportKHR(gpu(), 0, xcb_connection, |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1511 | visual_id); |
| 1512 | m_errorMonitor->VerifyFound(); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1513 | // Set this (for now, until all platforms are supported and tested): |
| 1514 | #define NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1515 | #endif // VK_USE_PLATFORM_XCB_KHR |
| 1516 | |
| 1517 | |
Ian Elliott | 1263081 | 2016-04-29 14:35:43 -0600 | [diff] [blame] | 1518 | #if defined(VK_USE_PLATFORM_XLIB_KHR) |
| 1519 | // Use the functions from the VK_KHR_xlib_surface extension without enabling |
| 1520 | // that extension: |
| 1521 | |
| 1522 | // Create a surface: |
| 1523 | VkXlibSurfaceCreateInfoKHR xlib_create_info = {}; |
Ian Elliott | 1263081 | 2016-04-29 14:35:43 -0600 | [diff] [blame] | 1524 | m_errorMonitor->SetDesiredFailureMsg( |
| 1525 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1526 | "extension was not enabled for this"); |
| 1527 | err = vkCreateXlibSurfaceKHR(instance(), &xlib_create_info, NULL, &surface); |
| 1528 | pass = (err != VK_SUCCESS); |
| 1529 | ASSERT_TRUE(pass); |
| 1530 | m_errorMonitor->VerifyFound(); |
| 1531 | |
| 1532 | // Tell whether an Xlib VisualID supports presentation: |
| 1533 | Display *dpy = NULL; |
| 1534 | VisualID visual = 0; |
| 1535 | m_errorMonitor->SetDesiredFailureMsg( |
| 1536 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1537 | "extension was not enabled for this"); |
| 1538 | vkGetPhysicalDeviceXlibPresentationSupportKHR(gpu(), 0, dpy, visual); |
| 1539 | m_errorMonitor->VerifyFound(); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1540 | // Set this (for now, until all platforms are supported and tested): |
| 1541 | #define NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1263081 | 2016-04-29 14:35:43 -0600 | [diff] [blame] | 1542 | #endif // VK_USE_PLATFORM_XLIB_KHR |
| 1543 | |
| 1544 | |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1545 | // Use the functions from the VK_KHR_surface extension without enabling |
| 1546 | // that extension: |
| 1547 | |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1548 | #ifdef NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1549 | // Destroy a surface: |
| 1550 | m_errorMonitor->SetDesiredFailureMsg( |
| 1551 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1552 | "extension was not enabled for this"); |
| 1553 | vkDestroySurfaceKHR(instance(), surface, NULL); |
| 1554 | m_errorMonitor->VerifyFound(); |
| 1555 | |
| 1556 | // Check if surface supports presentation: |
| 1557 | VkBool32 supported = false; |
| 1558 | m_errorMonitor->SetDesiredFailureMsg( |
| 1559 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1560 | "extension was not enabled for this"); |
| 1561 | err = vkGetPhysicalDeviceSurfaceSupportKHR(gpu(), 0, surface, &supported); |
| 1562 | pass = (err != VK_SUCCESS); |
| 1563 | ASSERT_TRUE(pass); |
| 1564 | m_errorMonitor->VerifyFound(); |
| 1565 | |
| 1566 | // Check surface capabilities: |
| 1567 | VkSurfaceCapabilitiesKHR capabilities = {}; |
| 1568 | m_errorMonitor->SetDesiredFailureMsg( |
| 1569 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1570 | "extension was not enabled for this"); |
| 1571 | err = vkGetPhysicalDeviceSurfaceCapabilitiesKHR(gpu(), surface, |
| 1572 | &capabilities); |
| 1573 | pass = (err != VK_SUCCESS); |
| 1574 | ASSERT_TRUE(pass); |
| 1575 | m_errorMonitor->VerifyFound(); |
| 1576 | |
| 1577 | // Check surface formats: |
| 1578 | uint32_t format_count = 0; |
| 1579 | VkSurfaceFormatKHR *formats = NULL; |
| 1580 | m_errorMonitor->SetDesiredFailureMsg( |
| 1581 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1582 | "extension was not enabled for this"); |
| 1583 | err = vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, |
| 1584 | &format_count, formats); |
| 1585 | pass = (err != VK_SUCCESS); |
| 1586 | ASSERT_TRUE(pass); |
| 1587 | m_errorMonitor->VerifyFound(); |
| 1588 | |
| 1589 | // Check surface present modes: |
| 1590 | uint32_t present_mode_count = 0; |
| 1591 | VkSurfaceFormatKHR *present_modes = NULL; |
| 1592 | m_errorMonitor->SetDesiredFailureMsg( |
| 1593 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1594 | "extension was not enabled for this"); |
| 1595 | err = vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, |
| 1596 | &present_mode_count, present_modes); |
| 1597 | pass = (err != VK_SUCCESS); |
| 1598 | ASSERT_TRUE(pass); |
| 1599 | m_errorMonitor->VerifyFound(); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1600 | #endif // NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1601 | |
| 1602 | |
| 1603 | // Use the functions from the VK_KHR_swapchain extension without enabling |
| 1604 | // that extension: |
| 1605 | |
| 1606 | // Create a swapchain: |
| 1607 | m_errorMonitor->SetDesiredFailureMsg( |
| 1608 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1609 | "extension was not enabled for this"); |
| 1610 | swapchain_create_info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR; |
| 1611 | swapchain_create_info.pNext = NULL; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1612 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, |
| 1613 | NULL, &swapchain); |
| 1614 | pass = (err != VK_SUCCESS); |
| 1615 | ASSERT_TRUE(pass); |
| 1616 | m_errorMonitor->VerifyFound(); |
| 1617 | |
| 1618 | // Get the images from the swapchain: |
| 1619 | m_errorMonitor->SetDesiredFailureMsg( |
| 1620 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1621 | "extension was not enabled for this"); |
| 1622 | err = vkGetSwapchainImagesKHR(m_device->device(), swapchain, |
| 1623 | &swapchain_image_count, NULL); |
| 1624 | pass = (err != VK_SUCCESS); |
| 1625 | ASSERT_TRUE(pass); |
| 1626 | m_errorMonitor->VerifyFound(); |
| 1627 | |
| 1628 | // Try to acquire an image: |
| 1629 | m_errorMonitor->SetDesiredFailureMsg( |
| 1630 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1631 | "extension was not enabled for this"); |
| 1632 | err = vkAcquireNextImageKHR(m_device->device(), swapchain, 0, |
| 1633 | VK_NULL_HANDLE, VK_NULL_HANDLE, &image_index); |
| 1634 | pass = (err != VK_SUCCESS); |
| 1635 | ASSERT_TRUE(pass); |
| 1636 | m_errorMonitor->VerifyFound(); |
| 1637 | |
| 1638 | // Try to present an image: |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1639 | // |
| 1640 | // NOTE: Currently can't test this because a real swapchain is needed (as |
| 1641 | // opposed to the fake one we created) in order for the layer to lookup the |
| 1642 | // VkDevice used to enable the extension: |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1643 | |
| 1644 | // Destroy the swapchain: |
| 1645 | m_errorMonitor->SetDesiredFailureMsg( |
| 1646 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1647 | "extension was not enabled for this"); |
| 1648 | vkDestroySwapchainKHR(m_device->device(), swapchain, NULL); |
| 1649 | m_errorMonitor->VerifyFound(); |
| 1650 | } |
| 1651 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1652 | TEST_F(VkWsiEnabledLayerTest, TestEnabledWsi) { |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1653 | |
Dustin Graves | 6c6d898 | 2016-05-17 10:09:21 -0600 | [diff] [blame] | 1654 | #if defined(VK_USE_PLATFORM_XCB_KHR) |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1655 | VkSurfaceKHR surface = VK_NULL_HANDLE; |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1656 | |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1657 | VkResult err; |
| 1658 | bool pass; |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1659 | VkSwapchainKHR swapchain = VK_NULL_HANDLE; |
| 1660 | VkSwapchainCreateInfoKHR swapchain_create_info = {}; |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1661 | // uint32_t swapchain_image_count = 0; |
| 1662 | // VkImage swapchain_images[1] = {VK_NULL_HANDLE}; |
| 1663 | // uint32_t image_index = 0; |
| 1664 | // VkPresentInfoKHR present_info = {}; |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1665 | |
| 1666 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1667 | |
| 1668 | // Use the create function from one of the VK_KHR_*_surface extension in |
| 1669 | // order to create a surface, testing all known errors in the process, |
| 1670 | // before successfully creating a surface: |
| 1671 | // First, try to create a surface without a VkXcbSurfaceCreateInfoKHR: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1672 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1673 | "called with NULL pointer"); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1674 | err = vkCreateXcbSurfaceKHR(instance(), NULL, NULL, &surface); |
| 1675 | pass = (err != VK_SUCCESS); |
| 1676 | ASSERT_TRUE(pass); |
| 1677 | m_errorMonitor->VerifyFound(); |
| 1678 | |
| 1679 | // Next, try to create a surface with the wrong |
| 1680 | // VkXcbSurfaceCreateInfoKHR::sType: |
| 1681 | VkXcbSurfaceCreateInfoKHR xcb_create_info = {}; |
| 1682 | xcb_create_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1683 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1684 | "called with the wrong value for"); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1685 | err = vkCreateXcbSurfaceKHR(instance(), &xcb_create_info, NULL, &surface); |
| 1686 | pass = (err != VK_SUCCESS); |
| 1687 | ASSERT_TRUE(pass); |
| 1688 | m_errorMonitor->VerifyFound(); |
| 1689 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1690 | // Create a native window, and then correctly create a surface: |
| 1691 | xcb_connection_t *connection; |
| 1692 | xcb_screen_t *screen; |
| 1693 | xcb_window_t xcb_window; |
| 1694 | xcb_intern_atom_reply_t *atom_wm_delete_window; |
| 1695 | |
| 1696 | const xcb_setup_t *setup; |
| 1697 | xcb_screen_iterator_t iter; |
| 1698 | int scr; |
| 1699 | uint32_t value_mask, value_list[32]; |
| 1700 | int width = 1; |
| 1701 | int height = 1; |
| 1702 | |
| 1703 | connection = xcb_connect(NULL, &scr); |
| 1704 | ASSERT_TRUE(connection != NULL); |
| 1705 | setup = xcb_get_setup(connection); |
| 1706 | iter = xcb_setup_roots_iterator(setup); |
| 1707 | while (scr-- > 0) |
| 1708 | xcb_screen_next(&iter); |
| 1709 | screen = iter.data; |
| 1710 | |
| 1711 | xcb_window = xcb_generate_id(connection); |
| 1712 | |
| 1713 | value_mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK; |
| 1714 | value_list[0] = screen->black_pixel; |
| 1715 | value_list[1] = XCB_EVENT_MASK_KEY_RELEASE | XCB_EVENT_MASK_EXPOSURE | |
| 1716 | XCB_EVENT_MASK_STRUCTURE_NOTIFY; |
| 1717 | |
| 1718 | xcb_create_window(connection, XCB_COPY_FROM_PARENT, xcb_window, |
| 1719 | screen->root, 0, 0, width, height, 0, |
| 1720 | XCB_WINDOW_CLASS_INPUT_OUTPUT, screen->root_visual, |
| 1721 | value_mask, value_list); |
| 1722 | |
| 1723 | /* Magic code that will send notification when window is destroyed */ |
| 1724 | xcb_intern_atom_cookie_t cookie = |
| 1725 | xcb_intern_atom(connection, 1, 12, "WM_PROTOCOLS"); |
| 1726 | xcb_intern_atom_reply_t *reply = |
| 1727 | xcb_intern_atom_reply(connection, cookie, 0); |
| 1728 | |
| 1729 | xcb_intern_atom_cookie_t cookie2 = |
| 1730 | xcb_intern_atom(connection, 0, 16, "WM_DELETE_WINDOW"); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1731 | atom_wm_delete_window = xcb_intern_atom_reply(connection, cookie2, 0); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1732 | xcb_change_property(connection, XCB_PROP_MODE_REPLACE, xcb_window, |
| 1733 | (*reply).atom, 4, 32, 1, |
| 1734 | &(*atom_wm_delete_window).atom); |
| 1735 | free(reply); |
| 1736 | |
| 1737 | xcb_map_window(connection, xcb_window); |
| 1738 | |
| 1739 | // Force the x/y coordinates to 100,100 results are identical in consecutive |
| 1740 | // runs |
| 1741 | const uint32_t coords[] = {100, 100}; |
| 1742 | xcb_configure_window(connection, xcb_window, |
| 1743 | XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, coords); |
| 1744 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1745 | // Finally, try to correctly create a surface: |
| 1746 | xcb_create_info.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR; |
| 1747 | xcb_create_info.pNext = NULL; |
| 1748 | xcb_create_info.flags = 0; |
| 1749 | xcb_create_info.connection = connection; |
| 1750 | xcb_create_info.window = xcb_window; |
| 1751 | err = vkCreateXcbSurfaceKHR(instance(), &xcb_create_info, NULL, &surface); |
| 1752 | pass = (err == VK_SUCCESS); |
| 1753 | ASSERT_TRUE(pass); |
| 1754 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1755 | // Check if surface supports presentation: |
| 1756 | |
| 1757 | // 1st, do so without having queried the queue families: |
| 1758 | VkBool32 supported = false; |
| 1759 | // TODO: Get the following error to come out: |
| 1760 | m_errorMonitor->SetDesiredFailureMsg( |
| 1761 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1762 | "called before calling the vkGetPhysicalDeviceQueueFamilyProperties " |
| 1763 | "function"); |
| 1764 | err = vkGetPhysicalDeviceSurfaceSupportKHR(gpu(), 0, surface, &supported); |
| 1765 | pass = (err != VK_SUCCESS); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1766 | // ASSERT_TRUE(pass); |
| 1767 | // m_errorMonitor->VerifyFound(); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1768 | |
| 1769 | // Next, query a queue family index that's too large: |
| 1770 | m_errorMonitor->SetDesiredFailureMsg( |
| 1771 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1772 | "called with a queueFamilyIndex that is too large"); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1773 | err = vkGetPhysicalDeviceSurfaceSupportKHR(gpu(), 100000, surface, |
| 1774 | &supported); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1775 | pass = (err != VK_SUCCESS); |
| 1776 | ASSERT_TRUE(pass); |
| 1777 | m_errorMonitor->VerifyFound(); |
| 1778 | |
| 1779 | // Finally, do so correctly: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1780 | // FIXME: THIS ISN'T CORRECT--MUST QUERY UNTIL WE FIND A QUEUE FAMILY THAT'S |
| 1781 | // SUPPORTED |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1782 | err = vkGetPhysicalDeviceSurfaceSupportKHR(gpu(), 0, surface, &supported); |
| 1783 | pass = (err == VK_SUCCESS); |
| 1784 | ASSERT_TRUE(pass); |
| 1785 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1786 | // Before proceeding, try to create a swapchain without having called |
| 1787 | // vkGetPhysicalDeviceSurfaceCapabilitiesKHR(): |
| 1788 | swapchain_create_info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR; |
| 1789 | swapchain_create_info.pNext = NULL; |
| 1790 | swapchain_create_info.flags = 0; |
| 1791 | m_errorMonitor->SetDesiredFailureMsg( |
| 1792 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1793 | "called before calling vkGetPhysicalDeviceSurfaceCapabilitiesKHR()."); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1794 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, |
| 1795 | &swapchain); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1796 | pass = (err != VK_SUCCESS); |
| 1797 | ASSERT_TRUE(pass); |
| 1798 | m_errorMonitor->VerifyFound(); |
| 1799 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1800 | // Get the surface capabilities: |
| 1801 | VkSurfaceCapabilitiesKHR surface_capabilities; |
| 1802 | |
| 1803 | // Do so correctly (only error logged by this entrypoint is if the |
| 1804 | // extension isn't enabled): |
| 1805 | err = vkGetPhysicalDeviceSurfaceCapabilitiesKHR(gpu(), surface, |
| 1806 | &surface_capabilities); |
| 1807 | pass = (err == VK_SUCCESS); |
| 1808 | ASSERT_TRUE(pass); |
| 1809 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1810 | // Get the surface formats: |
| 1811 | uint32_t surface_format_count; |
| 1812 | |
| 1813 | // First, try without a pointer to surface_format_count: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1814 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1815 | "called with NULL pointer"); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1816 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, NULL, NULL); |
| 1817 | pass = (err == VK_SUCCESS); |
| 1818 | ASSERT_TRUE(pass); |
| 1819 | m_errorMonitor->VerifyFound(); |
| 1820 | |
| 1821 | // Next, call with a non-NULL pSurfaceFormats, even though we haven't |
| 1822 | // correctly done a 1st try (to get the count): |
| 1823 | m_errorMonitor->SetDesiredFailureMsg( |
| 1824 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1825 | "but no prior positive value has been seen for"); |
| 1826 | surface_format_count = 0; |
| 1827 | vkGetPhysicalDeviceSurfaceFormatsKHR( |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1828 | gpu(), surface, &surface_format_count, |
| 1829 | (VkSurfaceFormatKHR *)&surface_format_count); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1830 | pass = (err == VK_SUCCESS); |
| 1831 | ASSERT_TRUE(pass); |
| 1832 | m_errorMonitor->VerifyFound(); |
| 1833 | |
| 1834 | // Next, correctly do a 1st try (with a NULL pointer to surface_formats): |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1835 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, &surface_format_count, |
| 1836 | NULL); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1837 | pass = (err == VK_SUCCESS); |
| 1838 | ASSERT_TRUE(pass); |
| 1839 | |
| 1840 | // Allocate memory for the correct number of VkSurfaceFormatKHR's: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1841 | VkSurfaceFormatKHR *surface_formats = (VkSurfaceFormatKHR *)malloc( |
| 1842 | surface_format_count * sizeof(VkSurfaceFormatKHR)); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1843 | |
| 1844 | // Next, do a 2nd try with surface_format_count being set too high: |
| 1845 | surface_format_count += 5; |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1846 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1847 | "that is greater than the value"); |
| 1848 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, &surface_format_count, |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1849 | surface_formats); |
| 1850 | pass = (err == VK_SUCCESS); |
| 1851 | ASSERT_TRUE(pass); |
| 1852 | m_errorMonitor->VerifyFound(); |
| 1853 | |
| 1854 | // Finally, do a correct 1st and 2nd try: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1855 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, &surface_format_count, |
| 1856 | NULL); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1857 | pass = (err == VK_SUCCESS); |
| 1858 | ASSERT_TRUE(pass); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1859 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, &surface_format_count, |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1860 | surface_formats); |
| 1861 | pass = (err == VK_SUCCESS); |
| 1862 | ASSERT_TRUE(pass); |
| 1863 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1864 | // Get the surface present modes: |
| 1865 | uint32_t surface_present_mode_count; |
| 1866 | |
| 1867 | // First, try without a pointer to surface_format_count: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1868 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1869 | "called with NULL pointer"); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1870 | vkGetPhysicalDeviceSurfacePresentModesKHR(gpu(), surface, NULL, NULL); |
| 1871 | pass = (err == VK_SUCCESS); |
| 1872 | ASSERT_TRUE(pass); |
| 1873 | m_errorMonitor->VerifyFound(); |
| 1874 | |
| 1875 | // Next, call with a non-NULL VkPresentModeKHR, even though we haven't |
| 1876 | // correctly done a 1st try (to get the count): |
| 1877 | m_errorMonitor->SetDesiredFailureMsg( |
| 1878 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1879 | "but no prior positive value has been seen for"); |
| 1880 | surface_present_mode_count = 0; |
| 1881 | vkGetPhysicalDeviceSurfacePresentModesKHR( |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1882 | gpu(), surface, &surface_present_mode_count, |
| 1883 | (VkPresentModeKHR *)&surface_present_mode_count); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1884 | pass = (err == VK_SUCCESS); |
| 1885 | ASSERT_TRUE(pass); |
| 1886 | m_errorMonitor->VerifyFound(); |
| 1887 | |
| 1888 | // Next, correctly do a 1st try (with a NULL pointer to surface_formats): |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1889 | vkGetPhysicalDeviceSurfacePresentModesKHR( |
| 1890 | gpu(), surface, &surface_present_mode_count, NULL); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1891 | pass = (err == VK_SUCCESS); |
| 1892 | ASSERT_TRUE(pass); |
| 1893 | |
| 1894 | // Allocate memory for the correct number of VkSurfaceFormatKHR's: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1895 | VkPresentModeKHR *surface_present_modes = (VkPresentModeKHR *)malloc( |
| 1896 | surface_present_mode_count * sizeof(VkPresentModeKHR)); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1897 | |
| 1898 | // Next, do a 2nd try with surface_format_count being set too high: |
| 1899 | surface_present_mode_count += 5; |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1900 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1901 | "that is greater than the value"); |
| 1902 | vkGetPhysicalDeviceSurfacePresentModesKHR( |
| 1903 | gpu(), surface, &surface_present_mode_count, surface_present_modes); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1904 | pass = (err == VK_SUCCESS); |
| 1905 | ASSERT_TRUE(pass); |
| 1906 | m_errorMonitor->VerifyFound(); |
| 1907 | |
| 1908 | // Finally, do a correct 1st and 2nd try: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1909 | vkGetPhysicalDeviceSurfacePresentModesKHR( |
| 1910 | gpu(), surface, &surface_present_mode_count, NULL); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1911 | pass = (err == VK_SUCCESS); |
| 1912 | ASSERT_TRUE(pass); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1913 | vkGetPhysicalDeviceSurfacePresentModesKHR( |
| 1914 | gpu(), surface, &surface_present_mode_count, surface_present_modes); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1915 | pass = (err == VK_SUCCESS); |
| 1916 | ASSERT_TRUE(pass); |
| 1917 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1918 | // Create a swapchain: |
| 1919 | |
| 1920 | // First, try without a pointer to swapchain_create_info: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1921 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1922 | "called with NULL pointer"); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1923 | err = vkCreateSwapchainKHR(m_device->device(), NULL, NULL, &swapchain); |
| 1924 | pass = (err != VK_SUCCESS); |
| 1925 | ASSERT_TRUE(pass); |
| 1926 | m_errorMonitor->VerifyFound(); |
| 1927 | |
| 1928 | // Next, call with a non-NULL swapchain_create_info, that has the wrong |
| 1929 | // sType: |
| 1930 | swapchain_create_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1931 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1932 | "called with the wrong value for"); |
| 1933 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, |
| 1934 | &swapchain); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1935 | pass = (err != VK_SUCCESS); |
| 1936 | ASSERT_TRUE(pass); |
| 1937 | m_errorMonitor->VerifyFound(); |
| 1938 | |
| 1939 | // Next, call with a NULL swapchain pointer: |
| 1940 | swapchain_create_info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR; |
| 1941 | swapchain_create_info.pNext = NULL; |
| 1942 | swapchain_create_info.flags = 0; |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1943 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1944 | "called with NULL pointer"); |
| 1945 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, |
| 1946 | NULL); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1947 | pass = (err != VK_SUCCESS); |
| 1948 | ASSERT_TRUE(pass); |
| 1949 | m_errorMonitor->VerifyFound(); |
| 1950 | |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1951 | // TODO: Enhance swapchain layer so that |
| 1952 | // swapchain_create_info.queueFamilyIndexCount is checked against something? |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1953 | |
| 1954 | // Next, call with a queue family index that's too large: |
| 1955 | uint32_t queueFamilyIndex[2] = {100000, 0}; |
| 1956 | swapchain_create_info.imageSharingMode = VK_SHARING_MODE_CONCURRENT; |
| 1957 | swapchain_create_info.queueFamilyIndexCount = 2; |
| 1958 | swapchain_create_info.pQueueFamilyIndices = queueFamilyIndex; |
| 1959 | m_errorMonitor->SetDesiredFailureMsg( |
| 1960 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1961 | "called with a queueFamilyIndex that is too large"); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1962 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, |
| 1963 | &swapchain); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1964 | pass = (err != VK_SUCCESS); |
| 1965 | ASSERT_TRUE(pass); |
| 1966 | m_errorMonitor->VerifyFound(); |
| 1967 | |
| 1968 | // Next, call a queueFamilyIndexCount that's too small for CONCURRENT: |
| 1969 | swapchain_create_info.imageSharingMode = VK_SHARING_MODE_CONCURRENT; |
| 1970 | swapchain_create_info.queueFamilyIndexCount = 1; |
| 1971 | m_errorMonitor->SetDesiredFailureMsg( |
| 1972 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1973 | "but with a bad value(s) for pCreateInfo->queueFamilyIndexCount or " |
| 1974 | "pCreateInfo->pQueueFamilyIndices)."); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1975 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, |
| 1976 | &swapchain); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1977 | pass = (err != VK_SUCCESS); |
| 1978 | ASSERT_TRUE(pass); |
| 1979 | m_errorMonitor->VerifyFound(); |
| 1980 | |
| 1981 | // Next, call with an invalid imageSharingMode: |
| 1982 | swapchain_create_info.imageSharingMode = VK_SHARING_MODE_MAX_ENUM; |
| 1983 | swapchain_create_info.queueFamilyIndexCount = 1; |
| 1984 | m_errorMonitor->SetDesiredFailureMsg( |
| 1985 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1986 | "called with a non-supported pCreateInfo->imageSharingMode (i.e."); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1987 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, |
| 1988 | &swapchain); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1989 | pass = (err != VK_SUCCESS); |
| 1990 | ASSERT_TRUE(pass); |
| 1991 | m_errorMonitor->VerifyFound(); |
| 1992 | // Fix for the future: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1993 | // FIXME: THIS ISN'T CORRECT--MUST QUERY UNTIL WE FIND A QUEUE FAMILY THAT'S |
| 1994 | // SUPPORTED |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1995 | swapchain_create_info.queueFamilyIndexCount = 0; |
| 1996 | queueFamilyIndex[0] = 0; |
| 1997 | swapchain_create_info.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 1998 | |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1999 | // TODO: CONTINUE TESTING VALIDATION OF vkCreateSwapchainKHR() ... |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2000 | // Get the images from a swapchain: |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2001 | // Acquire an image from a swapchain: |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2002 | // Present an image to a swapchain: |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2003 | // Destroy the swapchain: |
| 2004 | |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2005 | // TODOs: |
| 2006 | // |
| 2007 | // - Try destroying the device without first destroying the swapchain |
| 2008 | // |
| 2009 | // - Try destroying the device without first destroying the surface |
| 2010 | // |
| 2011 | // - Try destroying the surface without first destroying the swapchain |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2012 | |
| 2013 | // Destroy the surface: |
| 2014 | vkDestroySurfaceKHR(instance(), surface, NULL); |
| 2015 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2016 | // Tear down the window: |
| 2017 | xcb_destroy_window(connection, xcb_window); |
| 2018 | xcb_disconnect(connection); |
| 2019 | |
| 2020 | #else // VK_USE_PLATFORM_XCB_KHR |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2021 | return; |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2022 | #endif // VK_USE_PLATFORM_XCB_KHR |
| 2023 | } |
| 2024 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2025 | TEST_F(VkLayerTest, MapMemWithoutHostVisibleBit) { |
| 2026 | VkResult err; |
| 2027 | bool pass; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2028 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2029 | m_errorMonitor->SetDesiredFailureMsg( |
| 2030 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2031 | "Mapping Memory without VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT"); |
| 2032 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2033 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2034 | |
| 2035 | // 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] | 2036 | VkImage image; |
| 2037 | VkDeviceMemory mem; |
| 2038 | VkMemoryRequirements mem_reqs; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2039 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2040 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2041 | const int32_t tex_width = 32; |
| 2042 | const int32_t tex_height = 32; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2043 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2044 | VkImageCreateInfo image_create_info = {}; |
| 2045 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2046 | image_create_info.pNext = NULL; |
| 2047 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2048 | image_create_info.format = tex_format; |
| 2049 | image_create_info.extent.width = tex_width; |
| 2050 | image_create_info.extent.height = tex_height; |
| 2051 | image_create_info.extent.depth = 1; |
| 2052 | image_create_info.mipLevels = 1; |
| 2053 | image_create_info.arrayLayers = 1; |
| 2054 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 2055 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 2056 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 2057 | image_create_info.flags = 0; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2058 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2059 | VkMemoryAllocateInfo mem_alloc = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2060 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2061 | mem_alloc.pNext = NULL; |
| 2062 | mem_alloc.allocationSize = 0; |
| 2063 | // Introduce failure, do NOT set memProps to |
| 2064 | // VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
| 2065 | mem_alloc.memoryTypeIndex = 1; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2066 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2067 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2068 | ASSERT_VK_SUCCESS(err); |
| 2069 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2070 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2071 | |
Mark Lobodzinski | 2306535 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 2072 | mem_alloc.allocationSize = mem_reqs.size; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2073 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2074 | pass = |
| 2075 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0, |
| 2076 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 2077 | if (!pass) { // If we can't find any unmappable memory this test doesn't |
| 2078 | // make sense |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2079 | vkDestroyImage(m_device->device(), image, NULL); |
Tony Barbour | 02fdc7d | 2015-08-04 16:13:01 -0600 | [diff] [blame] | 2080 | return; |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2081 | } |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 2082 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2083 | // allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2084 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2085 | ASSERT_VK_SUCCESS(err); |
| 2086 | |
| 2087 | // Try to bind free memory that has been freed |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 2088 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2089 | ASSERT_VK_SUCCESS(err); |
| 2090 | |
| 2091 | // Map memory as if to initialize the image |
| 2092 | void *mappedAddress = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2093 | err = vkMapMemory(m_device->device(), mem, 0, VK_WHOLE_SIZE, 0, |
| 2094 | &mappedAddress); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2095 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2096 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2097 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2098 | vkDestroyImage(m_device->device(), image, NULL); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2099 | } |
| 2100 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2101 | TEST_F(VkLayerTest, RebindMemory) { |
| 2102 | VkResult err; |
| 2103 | bool pass; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2104 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2105 | m_errorMonitor->SetDesiredFailureMsg( |
| 2106 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2107 | "which has already been bound to mem object"); |
| 2108 | |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2109 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2110 | |
| 2111 | // 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] | 2112 | VkImage image; |
| 2113 | VkDeviceMemory mem1; |
| 2114 | VkDeviceMemory mem2; |
| 2115 | VkMemoryRequirements mem_reqs; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2116 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2117 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2118 | const int32_t tex_width = 32; |
| 2119 | const int32_t tex_height = 32; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2120 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2121 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2122 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 2123 | image_create_info.pNext = NULL; |
| 2124 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2125 | image_create_info.format = tex_format; |
| 2126 | image_create_info.extent.width = tex_width; |
| 2127 | image_create_info.extent.height = tex_height; |
| 2128 | image_create_info.extent.depth = 1; |
| 2129 | image_create_info.mipLevels = 1; |
| 2130 | image_create_info.arrayLayers = 1; |
| 2131 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 2132 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 2133 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 2134 | image_create_info.flags = 0; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2135 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2136 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2137 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 2138 | mem_alloc.pNext = NULL; |
| 2139 | mem_alloc.allocationSize = 0; |
| 2140 | mem_alloc.memoryTypeIndex = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2141 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2142 | // Introduce failure, do NOT set memProps to |
| 2143 | // VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2144 | mem_alloc.memoryTypeIndex = 1; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2145 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2146 | ASSERT_VK_SUCCESS(err); |
| 2147 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2148 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2149 | |
| 2150 | mem_alloc.allocationSize = mem_reqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2151 | pass = |
| 2152 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 2153 | ASSERT_TRUE(pass); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2154 | |
| 2155 | // allocate 2 memory objects |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2156 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem1); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2157 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2158 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem2); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2159 | ASSERT_VK_SUCCESS(err); |
| 2160 | |
| 2161 | // Bind first memory object to Image object |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 2162 | err = vkBindImageMemory(m_device->device(), image, mem1, 0); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2163 | ASSERT_VK_SUCCESS(err); |
| 2164 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2165 | // Introduce validation failure, try to bind a different memory object to |
| 2166 | // the same image object |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 2167 | err = vkBindImageMemory(m_device->device(), image, mem2, 0); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2168 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2169 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2170 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2171 | vkDestroyImage(m_device->device(), image, NULL); |
| 2172 | vkFreeMemory(m_device->device(), mem1, NULL); |
| 2173 | vkFreeMemory(m_device->device(), mem2, NULL); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2174 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2175 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2176 | TEST_F(VkLayerTest, SubmitSignaledFence) { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2177 | vk_testing::Fence testFence; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2178 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2179 | m_errorMonitor->SetDesiredFailureMsg( |
| 2180 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "submitted in SIGNALED state. Fences " |
| 2181 | "must be reset before being submitted"); |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2182 | |
| 2183 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2184 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2185 | fenceInfo.pNext = NULL; |
| 2186 | fenceInfo.flags = VK_FENCE_CREATE_SIGNALED_BIT; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2187 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2188 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2189 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 2190 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2191 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 2192 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2193 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 2194 | m_stencil_clear_color, NULL); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 2195 | EndCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2196 | |
| 2197 | testFence.init(*m_device, fenceInfo); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2198 | |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2199 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 2200 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2201 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2202 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2203 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 2204 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2205 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2206 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2207 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2208 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 2209 | |
| 2210 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2211 | vkQueueWaitIdle(m_device->m_queue); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2212 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2213 | m_errorMonitor->VerifyFound(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2214 | } |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 2215 | // This is a positive test. We used to expect error in this case but spec now |
| 2216 | // allows it |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2217 | TEST_F(VkLayerTest, ResetUnsignaledFence) { |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 2218 | m_errorMonitor->ExpectSuccess(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2219 | vk_testing::Fence testFence; |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2220 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2221 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2222 | fenceInfo.pNext = NULL; |
| 2223 | |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2224 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2225 | testFence.init(*m_device, fenceInfo); |
Chia-I Wu | d9e8e82 | 2015-07-03 11:45:55 +0800 | [diff] [blame] | 2226 | VkFence fences[1] = {testFence.handle()}; |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 2227 | VkResult result = vkResetFences(m_device->device(), 1, fences); |
| 2228 | ASSERT_VK_SUCCESS(result); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2229 | |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 2230 | m_errorMonitor->VerifyNotFound(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2231 | } |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2232 | |
| 2233 | TEST_F(VkLayerTest, InvalidUsageBits) |
| 2234 | { |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2235 | TEST_DESCRIPTION( |
Karl Schultz | b5bc11e | 2016-05-04 08:36:08 -0600 | [diff] [blame] | 2236 | "Specify wrong usage for image then create conflicting view of image " |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2237 | "Initialize buffer with wrong usage then perform copy expecting errors " |
| 2238 | "from both the image and the buffer (2 calls)"); |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2239 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2240 | "Invalid usage flag for image "); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2241 | |
| 2242 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2243 | VkImageObj image(m_device); |
| 2244 | // Initialize image with USAGE_INPUT_ATTACHMENT |
Tobin Ehlis | 8b313c0 | 2016-05-25 15:01:52 -0600 | [diff] [blame] | 2245 | image.init(128, 128, VK_FORMAT_D24_UNORM_S8_UINT, |
Karl Schultz | b5bc11e | 2016-05-04 08:36:08 -0600 | [diff] [blame] | 2246 | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
| 2247 | ASSERT_TRUE(image.initialized()); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2248 | |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2249 | VkImageView dsv; |
| 2250 | VkImageViewCreateInfo dsvci = {}; |
| 2251 | dsvci.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 2252 | dsvci.image = image.handle(); |
| 2253 | dsvci.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 2254 | dsvci.format = VK_FORMAT_D32_SFLOAT_S8_UINT; |
| 2255 | dsvci.subresourceRange.layerCount = 1; |
| 2256 | dsvci.subresourceRange.baseMipLevel = 0; |
| 2257 | dsvci.subresourceRange.levelCount = 1; |
| 2258 | dsvci.subresourceRange.aspectMask = |
| 2259 | VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2260 | |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2261 | // Create a view with depth / stencil aspect for image with different usage |
| 2262 | vkCreateImageView(m_device->device(), &dsvci, NULL, &dsv); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2263 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2264 | m_errorMonitor->VerifyFound(); |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2265 | |
| 2266 | // Initialize buffer with TRANSFER_DST usage |
| 2267 | vk_testing::Buffer buffer; |
| 2268 | VkMemoryPropertyFlags reqs = 0; |
| 2269 | buffer.init_as_dst(*m_device, 128 * 128, reqs); |
| 2270 | VkBufferImageCopy region = {}; |
| 2271 | region.bufferRowLength = 128; |
| 2272 | region.bufferImageHeight = 128; |
| 2273 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 2274 | region.imageSubresource.layerCount = 1; |
| 2275 | region.imageExtent.height = 16; |
| 2276 | region.imageExtent.width = 16; |
| 2277 | region.imageExtent.depth = 1; |
| 2278 | |
| 2279 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2280 | "Invalid usage flag for buffer "); |
| 2281 | // Buffer usage not set to TRANSFER_SRC and image usage not set to |
| 2282 | // TRANSFER_DST |
| 2283 | BeginCommandBuffer(); |
| 2284 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 2285 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 2286 | 1, ®ion); |
| 2287 | m_errorMonitor->VerifyFound(); |
| 2288 | |
| 2289 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2290 | "Invalid usage flag for image "); |
| 2291 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 2292 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 2293 | 1, ®ion); |
| 2294 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2295 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 2296 | #endif // MEM_TRACKER_TESTS |
| 2297 | |
Tobin Ehlis | 4bf96d1 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 2298 | #if OBJ_TRACKER_TESTS |
Mark Lobodzinski | fc5cc66 | 2016-05-02 17:17:41 -0600 | [diff] [blame] | 2299 | |
| 2300 | TEST_F(VkLayerTest, LeakAnObject) { |
| 2301 | VkResult err; |
| 2302 | |
| 2303 | TEST_DESCRIPTION( |
| 2304 | "Create a fence and destroy its device without first destroying the fence."); |
| 2305 | |
| 2306 | // Note that we have to create a new device since destroying the |
| 2307 | // framework's device causes Teardown() to fail and just calling Teardown |
| 2308 | // will destroy the errorMonitor. |
| 2309 | |
| 2310 | m_errorMonitor->SetDesiredFailureMsg( |
| 2311 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2312 | "OBJ ERROR : VK_DEBUG_REPORT_OBJECT_TYPE_FENCE_EXT object"); |
| 2313 | |
| 2314 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2315 | |
| 2316 | const std::vector<VkQueueFamilyProperties> queue_props = |
| 2317 | m_device->queue_props; |
| 2318 | std::vector<VkDeviceQueueCreateInfo> queue_info; |
| 2319 | queue_info.reserve(queue_props.size()); |
| 2320 | std::vector<std::vector<float>> queue_priorities; |
| 2321 | for (uint32_t i = 0; i < (uint32_t)queue_props.size(); i++) { |
| 2322 | VkDeviceQueueCreateInfo qi = {}; |
| 2323 | qi.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO; |
| 2324 | qi.pNext = NULL; |
| 2325 | qi.queueFamilyIndex = i; |
| 2326 | qi.queueCount = queue_props[i].queueCount; |
| 2327 | queue_priorities.emplace_back(qi.queueCount, 0.0f); |
| 2328 | qi.pQueuePriorities = queue_priorities[i].data(); |
| 2329 | queue_info.push_back(qi); |
| 2330 | } |
| 2331 | |
| 2332 | std::vector<const char *> device_layer_names; |
| 2333 | std::vector<const char *> device_extension_names; |
| 2334 | device_layer_names.push_back("VK_LAYER_GOOGLE_threading"); |
| 2335 | device_layer_names.push_back("VK_LAYER_LUNARG_parameter_validation"); |
| 2336 | device_layer_names.push_back("VK_LAYER_LUNARG_object_tracker"); |
| 2337 | device_layer_names.push_back("VK_LAYER_LUNARG_core_validation"); |
| 2338 | device_layer_names.push_back("VK_LAYER_LUNARG_device_limits"); |
| 2339 | device_layer_names.push_back("VK_LAYER_LUNARG_image"); |
| 2340 | device_layer_names.push_back("VK_LAYER_GOOGLE_unique_objects"); |
| 2341 | |
| 2342 | // The sacrificial device object |
| 2343 | VkDevice testDevice; |
| 2344 | VkDeviceCreateInfo device_create_info = {}; |
| 2345 | auto features = m_device->phy().features(); |
| 2346 | device_create_info.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO; |
| 2347 | device_create_info.pNext = NULL; |
| 2348 | device_create_info.queueCreateInfoCount = queue_info.size(); |
| 2349 | device_create_info.pQueueCreateInfos = queue_info.data(); |
| 2350 | device_create_info.enabledLayerCount = device_layer_names.size(); |
| 2351 | device_create_info.ppEnabledLayerNames = device_layer_names.data(); |
| 2352 | device_create_info.pEnabledFeatures = &features; |
| 2353 | err = vkCreateDevice(gpu(), &device_create_info, NULL, &testDevice); |
| 2354 | ASSERT_VK_SUCCESS(err); |
| 2355 | |
| 2356 | VkFence fence; |
| 2357 | VkFenceCreateInfo fence_create_info = {}; |
| 2358 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2359 | fence_create_info.pNext = NULL; |
| 2360 | fence_create_info.flags = 0; |
| 2361 | err = vkCreateFence(testDevice, &fence_create_info, NULL, &fence); |
| 2362 | ASSERT_VK_SUCCESS(err); |
| 2363 | |
| 2364 | // Induce failure by not calling vkDestroyFence |
| 2365 | vkDestroyDevice(testDevice, NULL); |
| 2366 | m_errorMonitor->VerifyFound(); |
| 2367 | } |
| 2368 | |
| 2369 | TEST_F(VkLayerTest, InvalidCommandPoolConsistency) { |
| 2370 | |
| 2371 | TEST_DESCRIPTION("Allocate command buffers from one command pool and " |
| 2372 | "attempt to delete them from another."); |
| 2373 | |
| 2374 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2375 | "FreeCommandBuffers is attempting to free Command Buffer"); |
| 2376 | |
| 2377 | VkCommandPool command_pool_one; |
| 2378 | VkCommandPool command_pool_two; |
| 2379 | |
| 2380 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2381 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2382 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2383 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2384 | |
| 2385 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2386 | &command_pool_one); |
| 2387 | |
| 2388 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2389 | &command_pool_two); |
| 2390 | |
| 2391 | VkCommandBuffer command_buffer[9]; |
| 2392 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2393 | command_buffer_allocate_info.sType = |
| 2394 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2395 | command_buffer_allocate_info.commandPool = command_pool_one; |
| 2396 | command_buffer_allocate_info.commandBufferCount = 9; |
| 2397 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2398 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2399 | command_buffer); |
| 2400 | |
| 2401 | vkFreeCommandBuffers(m_device->device(), command_pool_two, 4, |
| 2402 | &command_buffer[3]); |
| 2403 | |
| 2404 | m_errorMonitor->VerifyFound(); |
| 2405 | |
| 2406 | vkDestroyCommandPool(m_device->device(), command_pool_one, NULL); |
| 2407 | vkDestroyCommandPool(m_device->device(), command_pool_two, NULL); |
| 2408 | } |
| 2409 | |
| 2410 | TEST_F(VkLayerTest, InvalidDescriptorPoolConsistency) { |
| 2411 | VkResult err; |
| 2412 | |
| 2413 | TEST_DESCRIPTION("Allocate descriptor sets from one DS pool and " |
| 2414 | "attempt to delete them from another."); |
| 2415 | |
| 2416 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2417 | "FreeDescriptorSets is attempting to free descriptorSet"); |
| 2418 | |
| 2419 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2420 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2421 | |
| 2422 | VkDescriptorPoolSize ds_type_count = {}; |
| 2423 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 2424 | ds_type_count.descriptorCount = 1; |
| 2425 | |
| 2426 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2427 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2428 | ds_pool_ci.pNext = NULL; |
| 2429 | ds_pool_ci.flags = 0; |
| 2430 | ds_pool_ci.maxSets = 1; |
| 2431 | ds_pool_ci.poolSizeCount = 1; |
| 2432 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 2433 | |
| 2434 | VkDescriptorPool ds_pool_one; |
| 2435 | err = |
| 2436 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool_one); |
| 2437 | ASSERT_VK_SUCCESS(err); |
| 2438 | |
| 2439 | // Create a second descriptor pool |
| 2440 | VkDescriptorPool ds_pool_two; |
| 2441 | err = |
| 2442 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool_two); |
| 2443 | ASSERT_VK_SUCCESS(err); |
| 2444 | |
| 2445 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 2446 | dsl_binding.binding = 0; |
| 2447 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 2448 | dsl_binding.descriptorCount = 1; |
| 2449 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2450 | dsl_binding.pImmutableSamplers = NULL; |
| 2451 | |
| 2452 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2453 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2454 | ds_layout_ci.pNext = NULL; |
| 2455 | ds_layout_ci.bindingCount = 1; |
| 2456 | ds_layout_ci.pBindings = &dsl_binding; |
| 2457 | |
| 2458 | VkDescriptorSetLayout ds_layout; |
| 2459 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2460 | &ds_layout); |
| 2461 | ASSERT_VK_SUCCESS(err); |
| 2462 | |
| 2463 | VkDescriptorSet descriptorSet; |
| 2464 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 2465 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 2466 | alloc_info.descriptorSetCount = 1; |
| 2467 | alloc_info.descriptorPool = ds_pool_one; |
| 2468 | alloc_info.pSetLayouts = &ds_layout; |
| 2469 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 2470 | &descriptorSet); |
| 2471 | ASSERT_VK_SUCCESS(err); |
| 2472 | |
| 2473 | err = vkFreeDescriptorSets(m_device->device(), ds_pool_two, 1, &descriptorSet); |
| 2474 | |
| 2475 | m_errorMonitor->VerifyFound(); |
| 2476 | |
| 2477 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2478 | vkDestroyDescriptorPool(m_device->device(), ds_pool_one, NULL); |
| 2479 | vkDestroyDescriptorPool(m_device->device(), ds_pool_two, NULL); |
| 2480 | } |
| 2481 | |
| 2482 | TEST_F(VkLayerTest, CreateUnknownObject) { |
| 2483 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2484 | "Invalid VkImage Object "); |
| 2485 | |
| 2486 | TEST_DESCRIPTION( |
| 2487 | "Pass an invalid image object handle into a Vulkan API call."); |
| 2488 | |
| 2489 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2490 | |
| 2491 | // Pass bogus handle into GetImageMemoryRequirements |
| 2492 | VkMemoryRequirements mem_reqs; |
| 2493 | uint64_t fakeImageHandle = 0xCADECADE; |
| 2494 | VkImage fauxImage = reinterpret_cast<VkImage &>(fakeImageHandle); |
| 2495 | |
| 2496 | vkGetImageMemoryRequirements(m_device->device(), fauxImage, &mem_reqs); |
| 2497 | |
| 2498 | m_errorMonitor->VerifyFound(); |
| 2499 | } |
| 2500 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2501 | TEST_F(VkLayerTest, PipelineNotBound) { |
| 2502 | VkResult err; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2503 | |
Mark Lobodzinski | fc5cc66 | 2016-05-02 17:17:41 -0600 | [diff] [blame] | 2504 | TEST_DESCRIPTION( |
| 2505 | "Pass in an invalid pipeline object handle into a Vulkan API call."); |
| 2506 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2507 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2508 | "Invalid VkPipeline Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2509 | |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2510 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2511 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2512 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2513 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2514 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2515 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2516 | |
| 2517 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2518 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2519 | ds_pool_ci.pNext = NULL; |
| 2520 | ds_pool_ci.maxSets = 1; |
| 2521 | ds_pool_ci.poolSizeCount = 1; |
| 2522 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2523 | |
| 2524 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2525 | err = |
| 2526 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2527 | ASSERT_VK_SUCCESS(err); |
| 2528 | |
| 2529 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2530 | dsl_binding.binding = 0; |
| 2531 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2532 | dsl_binding.descriptorCount = 1; |
| 2533 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2534 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2535 | |
| 2536 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2537 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2538 | ds_layout_ci.pNext = NULL; |
| 2539 | ds_layout_ci.bindingCount = 1; |
| 2540 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2541 | |
| 2542 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2543 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2544 | &ds_layout); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2545 | ASSERT_VK_SUCCESS(err); |
| 2546 | |
| 2547 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2548 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2549 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2550 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2551 | alloc_info.descriptorPool = ds_pool; |
| 2552 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2553 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 2554 | &descriptorSet); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2555 | ASSERT_VK_SUCCESS(err); |
| 2556 | |
| 2557 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2558 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 2559 | pipeline_layout_ci.pNext = NULL; |
| 2560 | pipeline_layout_ci.setLayoutCount = 1; |
| 2561 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2562 | |
| 2563 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2564 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2565 | &pipeline_layout); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2566 | ASSERT_VK_SUCCESS(err); |
| 2567 | |
Mark Young | ad77905 | 2016-01-06 14:26:04 -0700 | [diff] [blame] | 2568 | VkPipeline badPipeline = (VkPipeline)((size_t)0xbaadb1be); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2569 | |
| 2570 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2571 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 2572 | VK_PIPELINE_BIND_POINT_GRAPHICS, badPipeline); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2573 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2574 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2575 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2576 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2577 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2578 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2579 | } |
| 2580 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2581 | TEST_F(VkLayerTest, BindInvalidMemory) { |
| 2582 | VkResult err; |
| 2583 | bool pass; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2584 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2585 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2586 | "Invalid VkDeviceMemory Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2587 | |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2588 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2589 | |
| 2590 | // 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] | 2591 | VkImage image; |
| 2592 | VkDeviceMemory mem; |
| 2593 | VkMemoryRequirements mem_reqs; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2594 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2595 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2596 | const int32_t tex_width = 32; |
| 2597 | const int32_t tex_height = 32; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2598 | |
| 2599 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2600 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 2601 | image_create_info.pNext = NULL; |
| 2602 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2603 | image_create_info.format = tex_format; |
| 2604 | image_create_info.extent.width = tex_width; |
| 2605 | image_create_info.extent.height = tex_height; |
| 2606 | image_create_info.extent.depth = 1; |
| 2607 | image_create_info.mipLevels = 1; |
| 2608 | image_create_info.arrayLayers = 1; |
| 2609 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 2610 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 2611 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 2612 | image_create_info.flags = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2613 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2614 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2615 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 2616 | mem_alloc.pNext = NULL; |
| 2617 | mem_alloc.allocationSize = 0; |
| 2618 | mem_alloc.memoryTypeIndex = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2619 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2620 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2621 | ASSERT_VK_SUCCESS(err); |
| 2622 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2623 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2624 | |
| 2625 | mem_alloc.allocationSize = mem_reqs.size; |
| 2626 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2627 | pass = |
| 2628 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 2629 | ASSERT_TRUE(pass); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2630 | |
| 2631 | // allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2632 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2633 | ASSERT_VK_SUCCESS(err); |
| 2634 | |
| 2635 | // Introduce validation failure, free memory before binding |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2636 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2637 | |
| 2638 | // Try to bind free memory that has been freed |
| 2639 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 2640 | // This may very well return an error. |
| 2641 | (void)err; |
| 2642 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2643 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2644 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2645 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2646 | } |
| 2647 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2648 | TEST_F(VkLayerTest, BindMemoryToDestroyedObject) { |
| 2649 | VkResult err; |
| 2650 | bool pass; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2651 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2652 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2653 | "Invalid VkImage Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2654 | |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2655 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2656 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2657 | // Create an image object, allocate memory, destroy the object and then try |
| 2658 | // to bind it |
| 2659 | VkImage image; |
| 2660 | VkDeviceMemory mem; |
| 2661 | VkMemoryRequirements mem_reqs; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2662 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2663 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2664 | const int32_t tex_width = 32; |
| 2665 | const int32_t tex_height = 32; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2666 | |
| 2667 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2668 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 2669 | image_create_info.pNext = NULL; |
| 2670 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2671 | image_create_info.format = tex_format; |
| 2672 | image_create_info.extent.width = tex_width; |
| 2673 | image_create_info.extent.height = tex_height; |
| 2674 | image_create_info.extent.depth = 1; |
| 2675 | image_create_info.mipLevels = 1; |
| 2676 | image_create_info.arrayLayers = 1; |
| 2677 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 2678 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 2679 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 2680 | image_create_info.flags = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2681 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2682 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2683 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 2684 | mem_alloc.pNext = NULL; |
| 2685 | mem_alloc.allocationSize = 0; |
| 2686 | mem_alloc.memoryTypeIndex = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2687 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2688 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2689 | ASSERT_VK_SUCCESS(err); |
| 2690 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2691 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2692 | |
| 2693 | mem_alloc.allocationSize = mem_reqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2694 | pass = |
| 2695 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 2696 | ASSERT_TRUE(pass); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2697 | |
| 2698 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2699 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2700 | ASSERT_VK_SUCCESS(err); |
| 2701 | |
| 2702 | // Introduce validation failure, destroy Image object before binding |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2703 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2704 | ASSERT_VK_SUCCESS(err); |
| 2705 | |
| 2706 | // Now Try to bind memory to this destroyed object |
| 2707 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 2708 | // This may very well return an error. |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2709 | (void)err; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2710 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2711 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2712 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2713 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2714 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 2715 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 2716 | #endif // OBJ_TRACKER_TESTS |
| 2717 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 2718 | #if DRAW_STATE_TESTS |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 2719 | |
| 2720 | // This is a positive test. No errors should be generated. |
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 2721 | TEST_F(VkLayerTest, WaitEventThenSet) { |
| 2722 | TEST_DESCRIPTION( |
| 2723 | "Wait on a event then set it after the wait has been submitted."); |
| 2724 | |
| 2725 | if ((m_device->queue_props.empty()) || |
| 2726 | (m_device->queue_props[0].queueCount < 2)) |
| 2727 | return; |
| 2728 | |
| 2729 | m_errorMonitor->ExpectSuccess(); |
| 2730 | |
| 2731 | VkEvent event; |
| 2732 | VkEventCreateInfo event_create_info{}; |
| 2733 | event_create_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 2734 | vkCreateEvent(m_device->device(), &event_create_info, nullptr, &event); |
| 2735 | |
| 2736 | VkCommandPool command_pool; |
| 2737 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2738 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2739 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2740 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2741 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2742 | &command_pool); |
| 2743 | |
| 2744 | VkCommandBuffer command_buffer; |
| 2745 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2746 | command_buffer_allocate_info.sType = |
| 2747 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2748 | command_buffer_allocate_info.commandPool = command_pool; |
| 2749 | command_buffer_allocate_info.commandBufferCount = 1; |
| 2750 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2751 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2752 | &command_buffer); |
| 2753 | |
| 2754 | VkQueue queue = VK_NULL_HANDLE; |
| 2755 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 2756 | 1, &queue); |
| 2757 | |
| 2758 | { |
| 2759 | VkCommandBufferBeginInfo begin_info{}; |
| 2760 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2761 | vkBeginCommandBuffer(command_buffer, &begin_info); |
| 2762 | |
| 2763 | vkCmdWaitEvents(command_buffer, 1, &event, VK_PIPELINE_STAGE_HOST_BIT, |
| 2764 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, nullptr, 0, |
| 2765 | nullptr, 0, nullptr); |
| 2766 | vkCmdResetEvent(command_buffer, event, |
| 2767 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); |
| 2768 | vkEndCommandBuffer(command_buffer); |
| 2769 | } |
| 2770 | { |
| 2771 | VkSubmitInfo submit_info{}; |
| 2772 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2773 | submit_info.commandBufferCount = 1; |
| 2774 | submit_info.pCommandBuffers = &command_buffer; |
| 2775 | submit_info.signalSemaphoreCount = 0; |
| 2776 | submit_info.pSignalSemaphores = nullptr; |
| 2777 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2778 | } |
| 2779 | { vkSetEvent(m_device->device(), event); } |
| 2780 | |
| 2781 | vkQueueWaitIdle(queue); |
| 2782 | |
| 2783 | vkDestroyEvent(m_device->device(), event, nullptr); |
| 2784 | vkFreeCommandBuffers(m_device->device(), command_pool, 1, &command_buffer); |
| 2785 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2786 | |
| 2787 | m_errorMonitor->VerifyNotFound(); |
| 2788 | } |
Michael Lentine | 5627e69 | 2016-05-20 17:45:02 -0500 | [diff] [blame] | 2789 | // This is a positive test. No errors should be generated. |
| 2790 | TEST_F(VkLayerTest, QueryAndCopyMultipleCommandBuffers) { |
| 2791 | TEST_DESCRIPTION( |
| 2792 | "Issue a query and copy from it on a second command buffer."); |
| 2793 | |
| 2794 | if ((m_device->queue_props.empty()) || |
| 2795 | (m_device->queue_props[0].queueCount < 2)) |
| 2796 | return; |
| 2797 | |
| 2798 | m_errorMonitor->ExpectSuccess(); |
| 2799 | |
| 2800 | VkQueryPool query_pool; |
| 2801 | VkQueryPoolCreateInfo query_pool_create_info{}; |
| 2802 | query_pool_create_info.sType = VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO; |
| 2803 | query_pool_create_info.queryType = VK_QUERY_TYPE_TIMESTAMP; |
| 2804 | query_pool_create_info.queryCount = 1; |
| 2805 | vkCreateQueryPool(m_device->device(), &query_pool_create_info, nullptr, |
| 2806 | &query_pool); |
| 2807 | |
| 2808 | VkCommandPool command_pool; |
| 2809 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2810 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2811 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2812 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2813 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2814 | &command_pool); |
| 2815 | |
| 2816 | VkCommandBuffer command_buffer[2]; |
| 2817 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2818 | command_buffer_allocate_info.sType = |
| 2819 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2820 | command_buffer_allocate_info.commandPool = command_pool; |
| 2821 | command_buffer_allocate_info.commandBufferCount = 2; |
| 2822 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2823 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2824 | command_buffer); |
| 2825 | |
| 2826 | VkQueue queue = VK_NULL_HANDLE; |
| 2827 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 2828 | 1, &queue); |
| 2829 | |
| 2830 | uint32_t qfi = 0; |
| 2831 | VkBufferCreateInfo buff_create_info = {}; |
| 2832 | buff_create_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 2833 | buff_create_info.size = 1024; |
| 2834 | buff_create_info.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT; |
| 2835 | buff_create_info.queueFamilyIndexCount = 1; |
| 2836 | buff_create_info.pQueueFamilyIndices = &qfi; |
| 2837 | |
| 2838 | VkResult err; |
| 2839 | VkBuffer buffer; |
| 2840 | err = vkCreateBuffer(m_device->device(), &buff_create_info, NULL, &buffer); |
| 2841 | ASSERT_VK_SUCCESS(err); |
| 2842 | VkMemoryAllocateInfo mem_alloc = {}; |
| 2843 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 2844 | mem_alloc.pNext = NULL; |
| 2845 | mem_alloc.allocationSize = 1024; |
| 2846 | mem_alloc.memoryTypeIndex = 0; |
| 2847 | |
| 2848 | VkMemoryRequirements memReqs; |
| 2849 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &memReqs); |
| 2850 | bool pass = |
| 2851 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &mem_alloc, 0); |
| 2852 | if (!pass) { |
| 2853 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 2854 | return; |
| 2855 | } |
| 2856 | |
| 2857 | VkDeviceMemory mem; |
| 2858 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
| 2859 | ASSERT_VK_SUCCESS(err); |
| 2860 | err = vkBindBufferMemory(m_device->device(), buffer, mem, 0); |
| 2861 | ASSERT_VK_SUCCESS(err); |
| 2862 | |
| 2863 | { |
| 2864 | VkCommandBufferBeginInfo begin_info{}; |
| 2865 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2866 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2867 | |
| 2868 | vkCmdResetQueryPool(command_buffer[0], query_pool, 0, 1); |
| 2869 | vkCmdWriteTimestamp(command_buffer[0], |
| 2870 | VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT, query_pool, 0); |
| 2871 | |
| 2872 | vkEndCommandBuffer(command_buffer[0]); |
| 2873 | |
| 2874 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 2875 | |
| 2876 | vkCmdCopyQueryPoolResults(command_buffer[1], query_pool, 0, 1, buffer, |
| 2877 | 0, 0, 0); |
| 2878 | |
| 2879 | vkEndCommandBuffer(command_buffer[1]); |
| 2880 | } |
| 2881 | { |
| 2882 | VkSubmitInfo submit_info{}; |
| 2883 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2884 | submit_info.commandBufferCount = 2; |
| 2885 | submit_info.pCommandBuffers = command_buffer; |
| 2886 | submit_info.signalSemaphoreCount = 0; |
| 2887 | submit_info.pSignalSemaphores = nullptr; |
| 2888 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2889 | } |
| 2890 | |
| 2891 | vkQueueWaitIdle(queue); |
| 2892 | |
| 2893 | vkDestroyQueryPool(m_device->device(), query_pool, nullptr); |
| 2894 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, command_buffer); |
| 2895 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2896 | |
| 2897 | m_errorMonitor->VerifyNotFound(); |
| 2898 | } |
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 2899 | |
| 2900 | TEST_F(VkLayerTest, ResetEventThenSet) { |
| 2901 | TEST_DESCRIPTION( |
| 2902 | "Reset an event then set it after the reset has been submitted."); |
| 2903 | |
| 2904 | if ((m_device->queue_props.empty()) || |
| 2905 | (m_device->queue_props[0].queueCount < 2)) |
| 2906 | return; |
| 2907 | |
| 2908 | m_errorMonitor->ExpectSuccess(); |
| 2909 | |
| 2910 | VkEvent event; |
| 2911 | VkEventCreateInfo event_create_info{}; |
| 2912 | event_create_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 2913 | vkCreateEvent(m_device->device(), &event_create_info, nullptr, &event); |
| 2914 | |
| 2915 | VkCommandPool command_pool; |
| 2916 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2917 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2918 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2919 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2920 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2921 | &command_pool); |
| 2922 | |
| 2923 | VkCommandBuffer command_buffer; |
| 2924 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2925 | command_buffer_allocate_info.sType = |
| 2926 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2927 | command_buffer_allocate_info.commandPool = command_pool; |
| 2928 | command_buffer_allocate_info.commandBufferCount = 1; |
| 2929 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2930 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2931 | &command_buffer); |
| 2932 | |
| 2933 | VkQueue queue = VK_NULL_HANDLE; |
| 2934 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 2935 | 1, &queue); |
| 2936 | |
| 2937 | { |
| 2938 | VkCommandBufferBeginInfo begin_info{}; |
| 2939 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2940 | vkBeginCommandBuffer(command_buffer, &begin_info); |
| 2941 | |
| 2942 | vkCmdResetEvent(command_buffer, event, |
| 2943 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); |
| 2944 | vkCmdWaitEvents(command_buffer, 1, &event, |
| 2945 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2946 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, nullptr, 0, |
| 2947 | nullptr, 0, nullptr); |
| 2948 | vkEndCommandBuffer(command_buffer); |
| 2949 | } |
| 2950 | { |
| 2951 | VkSubmitInfo submit_info{}; |
| 2952 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2953 | submit_info.commandBufferCount = 1; |
| 2954 | submit_info.pCommandBuffers = &command_buffer; |
| 2955 | submit_info.signalSemaphoreCount = 0; |
| 2956 | submit_info.pSignalSemaphores = nullptr; |
| 2957 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2958 | } |
| 2959 | { |
| 2960 | m_errorMonitor->SetDesiredFailureMsg( |
| 2961 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Cannot call vkSetEvent() on event " |
| 2962 | "0x1 that is already in use by a " |
| 2963 | "command buffer."); |
| 2964 | vkSetEvent(m_device->device(), event); |
| 2965 | m_errorMonitor->VerifyFound(); |
| 2966 | } |
| 2967 | |
| 2968 | vkQueueWaitIdle(queue); |
| 2969 | |
| 2970 | vkDestroyEvent(m_device->device(), event, nullptr); |
| 2971 | vkFreeCommandBuffers(m_device->device(), command_pool, 1, &command_buffer); |
| 2972 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2973 | } |
| 2974 | |
| 2975 | // This is a positive test. No errors should be generated. |
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 2976 | TEST_F(VkLayerTest, TwoFencesThreeFrames) { |
| 2977 | TEST_DESCRIPTION("Two command buffers with two separate fences are each " |
| 2978 | "run through a Submit & WaitForFences cycle 3 times. This " |
| 2979 | "previously revealed a bug so running this positive test " |
| 2980 | "to prevent a regression."); |
| 2981 | m_errorMonitor->ExpectSuccess(); |
| 2982 | |
| 2983 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2984 | VkQueue queue = VK_NULL_HANDLE; |
| 2985 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 2986 | 0, &queue); |
| 2987 | |
| 2988 | static const uint32_t NUM_OBJECTS = 2; |
| 2989 | static const uint32_t NUM_FRAMES = 3; |
| 2990 | VkCommandBuffer cmd_buffers[NUM_OBJECTS] = {}; |
| 2991 | VkFence fences[NUM_OBJECTS] = {}; |
| 2992 | |
| 2993 | VkCommandPool cmd_pool; |
| 2994 | VkCommandPoolCreateInfo cmd_pool_ci = {}; |
| 2995 | cmd_pool_ci.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2996 | cmd_pool_ci.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2997 | cmd_pool_ci.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2998 | VkResult err = vkCreateCommandPool(m_device->device(), &cmd_pool_ci, |
| 2999 | nullptr, &cmd_pool); |
| 3000 | ASSERT_VK_SUCCESS(err); |
| 3001 | |
| 3002 | VkCommandBufferAllocateInfo cmd_buf_info = {}; |
| 3003 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3004 | cmd_buf_info.commandPool = cmd_pool; |
| 3005 | cmd_buf_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3006 | cmd_buf_info.commandBufferCount = 1; |
| 3007 | |
| 3008 | VkFenceCreateInfo fence_ci = {}; |
| 3009 | fence_ci.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3010 | fence_ci.pNext = nullptr; |
| 3011 | fence_ci.flags = 0; |
| 3012 | |
| 3013 | for (uint32_t i = 0; i < NUM_OBJECTS; ++i) { |
| 3014 | err = vkAllocateCommandBuffers(m_device->device(), &cmd_buf_info, |
| 3015 | &cmd_buffers[i]); |
| 3016 | ASSERT_VK_SUCCESS(err); |
| 3017 | err = vkCreateFence(m_device->device(), &fence_ci, nullptr, &fences[i]); |
| 3018 | ASSERT_VK_SUCCESS(err); |
| 3019 | } |
| 3020 | |
| 3021 | for (uint32_t frame = 0; frame < NUM_FRAMES; ++frame) { |
Tobin Ehlis | f902516 | 2016-05-26 06:55:21 -0600 | [diff] [blame] | 3022 | for (uint32_t obj = 0; obj < NUM_OBJECTS; ++obj) { |
| 3023 | // Create empty cmd buffer |
| 3024 | VkCommandBufferBeginInfo cmdBufBeginDesc = {}; |
| 3025 | cmdBufBeginDesc.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 3026 | |
Tobin Ehlis | f902516 | 2016-05-26 06:55:21 -0600 | [diff] [blame] | 3027 | err = vkBeginCommandBuffer(cmd_buffers[obj], &cmdBufBeginDesc); |
| 3028 | ASSERT_VK_SUCCESS(err); |
| 3029 | err = vkEndCommandBuffer(cmd_buffers[obj]); |
| 3030 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 3031 | |
Tobin Ehlis | f902516 | 2016-05-26 06:55:21 -0600 | [diff] [blame] | 3032 | VkSubmitInfo submit_info = {}; |
| 3033 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3034 | submit_info.commandBufferCount = 1; |
| 3035 | submit_info.pCommandBuffers = &cmd_buffers[obj]; |
| 3036 | // Submit cmd buffer and wait for fence |
| 3037 | err = vkQueueSubmit(queue, 1, &submit_info, fences[obj]); |
| 3038 | ASSERT_VK_SUCCESS(err); |
| 3039 | err = vkWaitForFences(m_device->device(), 1, &fences[obj], VK_TRUE, |
| 3040 | UINT64_MAX); |
| 3041 | ASSERT_VK_SUCCESS(err); |
| 3042 | err = vkResetFences(m_device->device(), 1, &fences[obj]); |
| 3043 | ASSERT_VK_SUCCESS(err); |
| 3044 | } |
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 3045 | } |
| 3046 | m_errorMonitor->VerifyNotFound(); |
| 3047 | } |
| 3048 | // This is a positive test. No errors should be generated. |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3049 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceQWI) { |
| 3050 | |
| 3051 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 3052 | "submitted on separate queues followed by a QueueWaitIdle."); |
| 3053 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 3054 | if ((m_device->queue_props.empty()) || |
| 3055 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 3056 | return; |
| 3057 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3058 | m_errorMonitor->ExpectSuccess(); |
| 3059 | |
| 3060 | VkSemaphore semaphore; |
| 3061 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 3062 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 3063 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 3064 | &semaphore); |
| 3065 | |
| 3066 | VkCommandPool command_pool; |
| 3067 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3068 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3069 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3070 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3071 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3072 | &command_pool); |
| 3073 | |
| 3074 | VkCommandBuffer command_buffer[2]; |
| 3075 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3076 | command_buffer_allocate_info.sType = |
| 3077 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3078 | command_buffer_allocate_info.commandPool = command_pool; |
| 3079 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3080 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3081 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3082 | command_buffer); |
| 3083 | |
| 3084 | VkQueue queue = VK_NULL_HANDLE; |
| 3085 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 3086 | 1, &queue); |
| 3087 | |
| 3088 | { |
| 3089 | VkCommandBufferBeginInfo begin_info{}; |
| 3090 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3091 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3092 | |
| 3093 | vkCmdPipelineBarrier(command_buffer[0], |
| 3094 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3095 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3096 | 0, nullptr, 0, nullptr); |
| 3097 | |
| 3098 | VkViewport viewport{}; |
| 3099 | viewport.maxDepth = 1.0f; |
| 3100 | viewport.minDepth = 0.0f; |
| 3101 | viewport.width = 512; |
| 3102 | viewport.height = 512; |
| 3103 | viewport.x = 0; |
| 3104 | viewport.y = 0; |
| 3105 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3106 | vkEndCommandBuffer(command_buffer[0]); |
| 3107 | } |
| 3108 | { |
| 3109 | VkCommandBufferBeginInfo begin_info{}; |
| 3110 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3111 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3112 | |
| 3113 | VkViewport viewport{}; |
| 3114 | viewport.maxDepth = 1.0f; |
| 3115 | viewport.minDepth = 0.0f; |
| 3116 | viewport.width = 512; |
| 3117 | viewport.height = 512; |
| 3118 | viewport.x = 0; |
| 3119 | viewport.y = 0; |
| 3120 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3121 | vkEndCommandBuffer(command_buffer[1]); |
| 3122 | } |
| 3123 | { |
| 3124 | VkSubmitInfo submit_info{}; |
| 3125 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3126 | submit_info.commandBufferCount = 1; |
| 3127 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3128 | submit_info.signalSemaphoreCount = 1; |
| 3129 | submit_info.pSignalSemaphores = &semaphore; |
| 3130 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3131 | } |
| 3132 | { |
| 3133 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3134 | VkSubmitInfo submit_info{}; |
| 3135 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3136 | submit_info.commandBufferCount = 1; |
| 3137 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3138 | submit_info.waitSemaphoreCount = 1; |
| 3139 | submit_info.pWaitSemaphores = &semaphore; |
| 3140 | submit_info.pWaitDstStageMask = flags; |
| 3141 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3142 | } |
| 3143 | |
| 3144 | vkQueueWaitIdle(m_device->m_queue); |
| 3145 | |
| 3146 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 3147 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3148 | &command_buffer[0]); |
| 3149 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3150 | |
| 3151 | m_errorMonitor->VerifyNotFound(); |
| 3152 | } |
| 3153 | |
| 3154 | // This is a positive test. No errors should be generated. |
| 3155 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceQWIFence) { |
| 3156 | |
| 3157 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 3158 | "submitted on separate queues, the second having a fence" |
| 3159 | "followed by a QueueWaitIdle."); |
| 3160 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 3161 | if ((m_device->queue_props.empty()) || |
| 3162 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 3163 | return; |
| 3164 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3165 | m_errorMonitor->ExpectSuccess(); |
| 3166 | |
| 3167 | VkFence fence; |
| 3168 | VkFenceCreateInfo fence_create_info{}; |
| 3169 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3170 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3171 | |
| 3172 | VkSemaphore semaphore; |
| 3173 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 3174 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 3175 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 3176 | &semaphore); |
| 3177 | |
| 3178 | VkCommandPool command_pool; |
| 3179 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3180 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3181 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3182 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3183 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3184 | &command_pool); |
| 3185 | |
| 3186 | VkCommandBuffer command_buffer[2]; |
| 3187 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3188 | command_buffer_allocate_info.sType = |
| 3189 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3190 | command_buffer_allocate_info.commandPool = command_pool; |
| 3191 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3192 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3193 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3194 | command_buffer); |
| 3195 | |
| 3196 | VkQueue queue = VK_NULL_HANDLE; |
| 3197 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 3198 | 1, &queue); |
| 3199 | |
| 3200 | { |
| 3201 | VkCommandBufferBeginInfo begin_info{}; |
| 3202 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3203 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3204 | |
| 3205 | vkCmdPipelineBarrier(command_buffer[0], |
| 3206 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3207 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3208 | 0, nullptr, 0, nullptr); |
| 3209 | |
| 3210 | VkViewport viewport{}; |
| 3211 | viewport.maxDepth = 1.0f; |
| 3212 | viewport.minDepth = 0.0f; |
| 3213 | viewport.width = 512; |
| 3214 | viewport.height = 512; |
| 3215 | viewport.x = 0; |
| 3216 | viewport.y = 0; |
| 3217 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3218 | vkEndCommandBuffer(command_buffer[0]); |
| 3219 | } |
| 3220 | { |
| 3221 | VkCommandBufferBeginInfo begin_info{}; |
| 3222 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3223 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3224 | |
| 3225 | VkViewport viewport{}; |
| 3226 | viewport.maxDepth = 1.0f; |
| 3227 | viewport.minDepth = 0.0f; |
| 3228 | viewport.width = 512; |
| 3229 | viewport.height = 512; |
| 3230 | viewport.x = 0; |
| 3231 | viewport.y = 0; |
| 3232 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3233 | vkEndCommandBuffer(command_buffer[1]); |
| 3234 | } |
| 3235 | { |
| 3236 | VkSubmitInfo submit_info{}; |
| 3237 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3238 | submit_info.commandBufferCount = 1; |
| 3239 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3240 | submit_info.signalSemaphoreCount = 1; |
| 3241 | submit_info.pSignalSemaphores = &semaphore; |
| 3242 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3243 | } |
| 3244 | { |
| 3245 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3246 | VkSubmitInfo submit_info{}; |
| 3247 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3248 | submit_info.commandBufferCount = 1; |
| 3249 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3250 | submit_info.waitSemaphoreCount = 1; |
| 3251 | submit_info.pWaitSemaphores = &semaphore; |
| 3252 | submit_info.pWaitDstStageMask = flags; |
| 3253 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 3254 | } |
| 3255 | |
| 3256 | vkQueueWaitIdle(m_device->m_queue); |
| 3257 | |
| 3258 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3259 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 3260 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3261 | &command_buffer[0]); |
| 3262 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3263 | |
| 3264 | m_errorMonitor->VerifyNotFound(); |
| 3265 | } |
| 3266 | |
| 3267 | // This is a positive test. No errors should be generated. |
| 3268 | TEST_F(VkLayerTest, |
| 3269 | TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceTwoWFF) { |
| 3270 | |
| 3271 | TEST_DESCRIPTION( |
| 3272 | "Two command buffers, each in a separate QueueSubmit call " |
| 3273 | "submitted on separate queues, the second having a fence" |
| 3274 | "followed by two consecutive WaitForFences calls on the same fence."); |
| 3275 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 3276 | if ((m_device->queue_props.empty()) || |
| 3277 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 3278 | return; |
| 3279 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3280 | m_errorMonitor->ExpectSuccess(); |
| 3281 | |
| 3282 | VkFence fence; |
| 3283 | VkFenceCreateInfo fence_create_info{}; |
| 3284 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3285 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3286 | |
| 3287 | VkSemaphore semaphore; |
| 3288 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 3289 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 3290 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 3291 | &semaphore); |
| 3292 | |
| 3293 | VkCommandPool command_pool; |
| 3294 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3295 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3296 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3297 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3298 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3299 | &command_pool); |
| 3300 | |
| 3301 | VkCommandBuffer command_buffer[2]; |
| 3302 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3303 | command_buffer_allocate_info.sType = |
| 3304 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3305 | command_buffer_allocate_info.commandPool = command_pool; |
| 3306 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3307 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3308 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3309 | command_buffer); |
| 3310 | |
| 3311 | VkQueue queue = VK_NULL_HANDLE; |
| 3312 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 3313 | 1, &queue); |
| 3314 | |
| 3315 | { |
| 3316 | VkCommandBufferBeginInfo begin_info{}; |
| 3317 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3318 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3319 | |
| 3320 | vkCmdPipelineBarrier(command_buffer[0], |
| 3321 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3322 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3323 | 0, nullptr, 0, nullptr); |
| 3324 | |
| 3325 | VkViewport viewport{}; |
| 3326 | viewport.maxDepth = 1.0f; |
| 3327 | viewport.minDepth = 0.0f; |
| 3328 | viewport.width = 512; |
| 3329 | viewport.height = 512; |
| 3330 | viewport.x = 0; |
| 3331 | viewport.y = 0; |
| 3332 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3333 | vkEndCommandBuffer(command_buffer[0]); |
| 3334 | } |
| 3335 | { |
| 3336 | VkCommandBufferBeginInfo begin_info{}; |
| 3337 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3338 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3339 | |
| 3340 | VkViewport viewport{}; |
| 3341 | viewport.maxDepth = 1.0f; |
| 3342 | viewport.minDepth = 0.0f; |
| 3343 | viewport.width = 512; |
| 3344 | viewport.height = 512; |
| 3345 | viewport.x = 0; |
| 3346 | viewport.y = 0; |
| 3347 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3348 | vkEndCommandBuffer(command_buffer[1]); |
| 3349 | } |
| 3350 | { |
| 3351 | VkSubmitInfo submit_info{}; |
| 3352 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3353 | submit_info.commandBufferCount = 1; |
| 3354 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3355 | submit_info.signalSemaphoreCount = 1; |
| 3356 | submit_info.pSignalSemaphores = &semaphore; |
| 3357 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3358 | } |
| 3359 | { |
| 3360 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3361 | VkSubmitInfo submit_info{}; |
| 3362 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3363 | submit_info.commandBufferCount = 1; |
| 3364 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3365 | submit_info.waitSemaphoreCount = 1; |
| 3366 | submit_info.pWaitSemaphores = &semaphore; |
| 3367 | submit_info.pWaitDstStageMask = flags; |
| 3368 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 3369 | } |
| 3370 | |
| 3371 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3372 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3373 | |
| 3374 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3375 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 3376 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3377 | &command_buffer[0]); |
| 3378 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3379 | |
| 3380 | m_errorMonitor->VerifyNotFound(); |
| 3381 | } |
| 3382 | |
| 3383 | // This is a positive test. No errors should be generated. |
| 3384 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFence) { |
| 3385 | |
| 3386 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 3387 | "submitted on separate queues, the second having a fence, " |
| 3388 | "followed by a WaitForFences call."); |
| 3389 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 3390 | if ((m_device->queue_props.empty()) || |
| 3391 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 3392 | return; |
| 3393 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3394 | m_errorMonitor->ExpectSuccess(); |
| 3395 | |
| 3396 | VkFence fence; |
| 3397 | VkFenceCreateInfo fence_create_info{}; |
| 3398 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3399 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3400 | |
| 3401 | VkSemaphore semaphore; |
| 3402 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 3403 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 3404 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 3405 | &semaphore); |
| 3406 | |
| 3407 | VkCommandPool command_pool; |
| 3408 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3409 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3410 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3411 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3412 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3413 | &command_pool); |
| 3414 | |
| 3415 | VkCommandBuffer command_buffer[2]; |
| 3416 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3417 | command_buffer_allocate_info.sType = |
| 3418 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3419 | command_buffer_allocate_info.commandPool = command_pool; |
| 3420 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3421 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3422 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3423 | command_buffer); |
| 3424 | |
| 3425 | VkQueue queue = VK_NULL_HANDLE; |
| 3426 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 3427 | 1, &queue); |
| 3428 | |
| 3429 | |
| 3430 | { |
| 3431 | VkCommandBufferBeginInfo begin_info{}; |
| 3432 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3433 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3434 | |
| 3435 | vkCmdPipelineBarrier(command_buffer[0], |
| 3436 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3437 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3438 | 0, nullptr, 0, nullptr); |
| 3439 | |
| 3440 | VkViewport viewport{}; |
| 3441 | viewport.maxDepth = 1.0f; |
| 3442 | viewport.minDepth = 0.0f; |
| 3443 | viewport.width = 512; |
| 3444 | viewport.height = 512; |
| 3445 | viewport.x = 0; |
| 3446 | viewport.y = 0; |
| 3447 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3448 | vkEndCommandBuffer(command_buffer[0]); |
| 3449 | } |
| 3450 | { |
| 3451 | VkCommandBufferBeginInfo begin_info{}; |
| 3452 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3453 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3454 | |
| 3455 | VkViewport viewport{}; |
| 3456 | viewport.maxDepth = 1.0f; |
| 3457 | viewport.minDepth = 0.0f; |
| 3458 | viewport.width = 512; |
| 3459 | viewport.height = 512; |
| 3460 | viewport.x = 0; |
| 3461 | viewport.y = 0; |
| 3462 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3463 | vkEndCommandBuffer(command_buffer[1]); |
| 3464 | } |
| 3465 | { |
| 3466 | VkSubmitInfo submit_info{}; |
| 3467 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3468 | submit_info.commandBufferCount = 1; |
| 3469 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3470 | submit_info.signalSemaphoreCount = 1; |
| 3471 | submit_info.pSignalSemaphores = &semaphore; |
| 3472 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3473 | } |
| 3474 | { |
| 3475 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3476 | VkSubmitInfo submit_info{}; |
| 3477 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3478 | submit_info.commandBufferCount = 1; |
| 3479 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3480 | submit_info.waitSemaphoreCount = 1; |
| 3481 | submit_info.pWaitSemaphores = &semaphore; |
| 3482 | submit_info.pWaitDstStageMask = flags; |
| 3483 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 3484 | } |
| 3485 | |
| 3486 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3487 | |
| 3488 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3489 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 3490 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3491 | &command_buffer[0]); |
| 3492 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3493 | |
| 3494 | m_errorMonitor->VerifyNotFound(); |
| 3495 | } |
| 3496 | |
| 3497 | // This is a positive test. No errors should be generated. |
| 3498 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueWithSemaphoreAndOneFence) { |
| 3499 | |
| 3500 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 3501 | "on the same queue, sharing a signal/wait semaphore, the " |
| 3502 | "second having a fence, " |
| 3503 | "followed by a WaitForFences call."); |
| 3504 | |
| 3505 | m_errorMonitor->ExpectSuccess(); |
| 3506 | |
| 3507 | VkFence fence; |
| 3508 | VkFenceCreateInfo fence_create_info{}; |
| 3509 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3510 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3511 | |
| 3512 | VkSemaphore semaphore; |
| 3513 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 3514 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 3515 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 3516 | &semaphore); |
| 3517 | |
| 3518 | VkCommandPool command_pool; |
| 3519 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3520 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3521 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3522 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3523 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3524 | &command_pool); |
| 3525 | |
| 3526 | VkCommandBuffer command_buffer[2]; |
| 3527 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3528 | command_buffer_allocate_info.sType = |
| 3529 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3530 | command_buffer_allocate_info.commandPool = command_pool; |
| 3531 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3532 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3533 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3534 | command_buffer); |
| 3535 | |
| 3536 | { |
| 3537 | VkCommandBufferBeginInfo begin_info{}; |
| 3538 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3539 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3540 | |
| 3541 | vkCmdPipelineBarrier(command_buffer[0], |
| 3542 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3543 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3544 | 0, nullptr, 0, nullptr); |
| 3545 | |
| 3546 | VkViewport viewport{}; |
| 3547 | viewport.maxDepth = 1.0f; |
| 3548 | viewport.minDepth = 0.0f; |
| 3549 | viewport.width = 512; |
| 3550 | viewport.height = 512; |
| 3551 | viewport.x = 0; |
| 3552 | viewport.y = 0; |
| 3553 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3554 | vkEndCommandBuffer(command_buffer[0]); |
| 3555 | } |
| 3556 | { |
| 3557 | VkCommandBufferBeginInfo begin_info{}; |
| 3558 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3559 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3560 | |
| 3561 | VkViewport viewport{}; |
| 3562 | viewport.maxDepth = 1.0f; |
| 3563 | viewport.minDepth = 0.0f; |
| 3564 | viewport.width = 512; |
| 3565 | viewport.height = 512; |
| 3566 | viewport.x = 0; |
| 3567 | viewport.y = 0; |
| 3568 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3569 | vkEndCommandBuffer(command_buffer[1]); |
| 3570 | } |
| 3571 | { |
| 3572 | VkSubmitInfo submit_info{}; |
| 3573 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3574 | submit_info.commandBufferCount = 1; |
| 3575 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3576 | submit_info.signalSemaphoreCount = 1; |
| 3577 | submit_info.pSignalSemaphores = &semaphore; |
| 3578 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3579 | } |
| 3580 | { |
| 3581 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3582 | VkSubmitInfo submit_info{}; |
| 3583 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3584 | submit_info.commandBufferCount = 1; |
| 3585 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3586 | submit_info.waitSemaphoreCount = 1; |
| 3587 | submit_info.pWaitSemaphores = &semaphore; |
| 3588 | submit_info.pWaitDstStageMask = flags; |
| 3589 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 3590 | } |
| 3591 | |
| 3592 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3593 | |
| 3594 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3595 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 3596 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3597 | &command_buffer[0]); |
| 3598 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3599 | |
| 3600 | m_errorMonitor->VerifyNotFound(); |
| 3601 | } |
| 3602 | |
| 3603 | // This is a positive test. No errors should be generated. |
| 3604 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueNullQueueSubmitWithFence) { |
| 3605 | |
| 3606 | TEST_DESCRIPTION( |
| 3607 | "Two command buffers, each in a separate QueueSubmit call " |
| 3608 | "on the same queue, no fences, followed by a third QueueSubmit with NO " |
| 3609 | "SubmitInfos but with a fence, followed by a WaitForFences call."); |
| 3610 | |
| 3611 | m_errorMonitor->ExpectSuccess(); |
| 3612 | |
| 3613 | VkFence fence; |
| 3614 | VkFenceCreateInfo fence_create_info{}; |
| 3615 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3616 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3617 | |
| 3618 | VkCommandPool command_pool; |
| 3619 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3620 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3621 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3622 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3623 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3624 | &command_pool); |
| 3625 | |
| 3626 | VkCommandBuffer command_buffer[2]; |
| 3627 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3628 | command_buffer_allocate_info.sType = |
| 3629 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3630 | command_buffer_allocate_info.commandPool = command_pool; |
| 3631 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3632 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3633 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3634 | command_buffer); |
| 3635 | |
| 3636 | { |
| 3637 | VkCommandBufferBeginInfo begin_info{}; |
| 3638 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3639 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3640 | |
| 3641 | vkCmdPipelineBarrier(command_buffer[0], |
| 3642 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3643 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3644 | 0, nullptr, 0, nullptr); |
| 3645 | |
| 3646 | VkViewport viewport{}; |
| 3647 | viewport.maxDepth = 1.0f; |
| 3648 | viewport.minDepth = 0.0f; |
| 3649 | viewport.width = 512; |
| 3650 | viewport.height = 512; |
| 3651 | viewport.x = 0; |
| 3652 | viewport.y = 0; |
| 3653 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3654 | vkEndCommandBuffer(command_buffer[0]); |
| 3655 | } |
| 3656 | { |
| 3657 | VkCommandBufferBeginInfo begin_info{}; |
| 3658 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3659 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3660 | |
| 3661 | VkViewport viewport{}; |
| 3662 | viewport.maxDepth = 1.0f; |
| 3663 | viewport.minDepth = 0.0f; |
| 3664 | viewport.width = 512; |
| 3665 | viewport.height = 512; |
| 3666 | viewport.x = 0; |
| 3667 | viewport.y = 0; |
| 3668 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3669 | vkEndCommandBuffer(command_buffer[1]); |
| 3670 | } |
| 3671 | { |
| 3672 | VkSubmitInfo submit_info{}; |
| 3673 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3674 | submit_info.commandBufferCount = 1; |
| 3675 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3676 | submit_info.signalSemaphoreCount = 0; |
| 3677 | submit_info.pSignalSemaphores = VK_NULL_HANDLE; |
| 3678 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3679 | } |
| 3680 | { |
| 3681 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3682 | VkSubmitInfo submit_info{}; |
| 3683 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3684 | submit_info.commandBufferCount = 1; |
| 3685 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3686 | submit_info.waitSemaphoreCount = 0; |
| 3687 | submit_info.pWaitSemaphores = VK_NULL_HANDLE; |
| 3688 | submit_info.pWaitDstStageMask = flags; |
| 3689 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3690 | } |
| 3691 | |
| 3692 | vkQueueSubmit(m_device->m_queue, 0, NULL, fence); |
| 3693 | |
| 3694 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3695 | |
| 3696 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3697 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3698 | &command_buffer[0]); |
| 3699 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3700 | |
| 3701 | m_errorMonitor->VerifyNotFound(); |
| 3702 | } |
| 3703 | |
| 3704 | // This is a positive test. No errors should be generated. |
| 3705 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueOneFence) { |
| 3706 | |
| 3707 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 3708 | "on the same queue, the second having a fence, followed " |
| 3709 | "by a WaitForFences call."); |
| 3710 | |
| 3711 | m_errorMonitor->ExpectSuccess(); |
| 3712 | |
| 3713 | VkFence fence; |
| 3714 | VkFenceCreateInfo fence_create_info{}; |
| 3715 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3716 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3717 | |
| 3718 | VkCommandPool command_pool; |
| 3719 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3720 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3721 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3722 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3723 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3724 | &command_pool); |
| 3725 | |
| 3726 | VkCommandBuffer command_buffer[2]; |
| 3727 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3728 | command_buffer_allocate_info.sType = |
| 3729 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3730 | command_buffer_allocate_info.commandPool = command_pool; |
| 3731 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3732 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3733 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3734 | command_buffer); |
| 3735 | |
| 3736 | { |
| 3737 | VkCommandBufferBeginInfo begin_info{}; |
| 3738 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3739 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3740 | |
| 3741 | vkCmdPipelineBarrier(command_buffer[0], |
| 3742 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3743 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3744 | 0, nullptr, 0, nullptr); |
| 3745 | |
| 3746 | VkViewport viewport{}; |
| 3747 | viewport.maxDepth = 1.0f; |
| 3748 | viewport.minDepth = 0.0f; |
| 3749 | viewport.width = 512; |
| 3750 | viewport.height = 512; |
| 3751 | viewport.x = 0; |
| 3752 | viewport.y = 0; |
| 3753 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3754 | vkEndCommandBuffer(command_buffer[0]); |
| 3755 | } |
| 3756 | { |
| 3757 | VkCommandBufferBeginInfo begin_info{}; |
| 3758 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3759 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3760 | |
| 3761 | VkViewport viewport{}; |
| 3762 | viewport.maxDepth = 1.0f; |
| 3763 | viewport.minDepth = 0.0f; |
| 3764 | viewport.width = 512; |
| 3765 | viewport.height = 512; |
| 3766 | viewport.x = 0; |
| 3767 | viewport.y = 0; |
| 3768 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3769 | vkEndCommandBuffer(command_buffer[1]); |
| 3770 | } |
| 3771 | { |
| 3772 | VkSubmitInfo submit_info{}; |
| 3773 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3774 | submit_info.commandBufferCount = 1; |
| 3775 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3776 | submit_info.signalSemaphoreCount = 0; |
| 3777 | submit_info.pSignalSemaphores = VK_NULL_HANDLE; |
| 3778 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3779 | } |
| 3780 | { |
| 3781 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3782 | VkSubmitInfo submit_info{}; |
| 3783 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3784 | submit_info.commandBufferCount = 1; |
| 3785 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3786 | submit_info.waitSemaphoreCount = 0; |
| 3787 | submit_info.pWaitSemaphores = VK_NULL_HANDLE; |
| 3788 | submit_info.pWaitDstStageMask = flags; |
| 3789 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 3790 | } |
| 3791 | |
| 3792 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3793 | |
| 3794 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3795 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3796 | &command_buffer[0]); |
| 3797 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3798 | |
| 3799 | m_errorMonitor->VerifyNotFound(); |
| 3800 | } |
| 3801 | |
| 3802 | // This is a positive test. No errors should be generated. |
| 3803 | TEST_F(VkLayerTest, TwoSubmitInfosWithSemaphoreOneQueueSubmitsOneFence) { |
| 3804 | |
| 3805 | TEST_DESCRIPTION( |
| 3806 | "Two command buffers each in a separate SubmitInfo sent in a single " |
| 3807 | "QueueSubmit call followed by a WaitForFences call."); |
| 3808 | |
| 3809 | m_errorMonitor->ExpectSuccess(); |
| 3810 | |
| 3811 | VkFence fence; |
| 3812 | VkFenceCreateInfo fence_create_info{}; |
| 3813 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3814 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3815 | |
| 3816 | VkSemaphore semaphore; |
| 3817 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 3818 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 3819 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 3820 | &semaphore); |
| 3821 | |
| 3822 | VkCommandPool command_pool; |
| 3823 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3824 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3825 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3826 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3827 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3828 | &command_pool); |
| 3829 | |
| 3830 | VkCommandBuffer command_buffer[2]; |
| 3831 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3832 | command_buffer_allocate_info.sType = |
| 3833 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3834 | command_buffer_allocate_info.commandPool = command_pool; |
| 3835 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3836 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3837 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3838 | command_buffer); |
| 3839 | |
| 3840 | { |
| 3841 | VkCommandBufferBeginInfo begin_info{}; |
| 3842 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3843 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3844 | |
| 3845 | vkCmdPipelineBarrier(command_buffer[0], |
| 3846 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3847 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3848 | 0, nullptr, 0, nullptr); |
| 3849 | |
| 3850 | VkViewport viewport{}; |
| 3851 | viewport.maxDepth = 1.0f; |
| 3852 | viewport.minDepth = 0.0f; |
| 3853 | viewport.width = 512; |
| 3854 | viewport.height = 512; |
| 3855 | viewport.x = 0; |
| 3856 | viewport.y = 0; |
| 3857 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3858 | vkEndCommandBuffer(command_buffer[0]); |
| 3859 | } |
| 3860 | { |
| 3861 | VkCommandBufferBeginInfo begin_info{}; |
| 3862 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3863 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3864 | |
| 3865 | VkViewport viewport{}; |
| 3866 | viewport.maxDepth = 1.0f; |
| 3867 | viewport.minDepth = 0.0f; |
| 3868 | viewport.width = 512; |
| 3869 | viewport.height = 512; |
| 3870 | viewport.x = 0; |
| 3871 | viewport.y = 0; |
| 3872 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3873 | vkEndCommandBuffer(command_buffer[1]); |
| 3874 | } |
| 3875 | { |
| 3876 | VkSubmitInfo submit_info[2]; |
| 3877 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3878 | |
| 3879 | submit_info[0].sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3880 | submit_info[0].pNext = NULL; |
| 3881 | submit_info[0].commandBufferCount = 1; |
| 3882 | submit_info[0].pCommandBuffers = &command_buffer[0]; |
| 3883 | submit_info[0].signalSemaphoreCount = 1; |
| 3884 | submit_info[0].pSignalSemaphores = &semaphore; |
| 3885 | submit_info[0].waitSemaphoreCount = 0; |
| 3886 | submit_info[0].pWaitSemaphores = NULL; |
| 3887 | submit_info[0].pWaitDstStageMask = 0; |
| 3888 | |
| 3889 | submit_info[1].sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3890 | submit_info[1].pNext = NULL; |
| 3891 | submit_info[1].commandBufferCount = 1; |
| 3892 | submit_info[1].pCommandBuffers = &command_buffer[1]; |
| 3893 | submit_info[1].waitSemaphoreCount = 1; |
| 3894 | submit_info[1].pWaitSemaphores = &semaphore; |
| 3895 | submit_info[1].pWaitDstStageMask = flags; |
| 3896 | submit_info[1].signalSemaphoreCount = 0; |
| 3897 | submit_info[1].pSignalSemaphores = NULL; |
| 3898 | vkQueueSubmit(m_device->m_queue, 2, &submit_info[0], fence); |
| 3899 | } |
| 3900 | |
| 3901 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3902 | |
| 3903 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3904 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3905 | &command_buffer[0]); |
| 3906 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3907 | |
| 3908 | m_errorMonitor->VerifyNotFound(); |
| 3909 | } |
| 3910 | |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 3911 | TEST_F(VkLayerTest, DynamicDepthBiasNotBound) { |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 3912 | TEST_DESCRIPTION( |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 3913 | "Run a simple draw calls to validate failure when Depth Bias dynamic " |
| 3914 | "state is required but not correctly bound."); |
| 3915 | |
| 3916 | // Dynamic depth bias |
| 3917 | m_errorMonitor->SetDesiredFailureMsg( |
| 3918 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3919 | "Dynamic depth bias state not set for this command buffer"); |
| 3920 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 3921 | BsoFailDepthBias); |
| 3922 | m_errorMonitor->VerifyFound(); |
| 3923 | } |
| 3924 | |
| 3925 | TEST_F(VkLayerTest, DynamicLineWidthNotBound) { |
| 3926 | TEST_DESCRIPTION( |
| 3927 | "Run a simple draw calls to validate failure when Line Width dynamic " |
| 3928 | "state is required but not correctly bound."); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 3929 | |
| 3930 | // Dynamic line width |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3931 | m_errorMonitor->SetDesiredFailureMsg( |
| 3932 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3933 | "Dynamic line width state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3934 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 3935 | BsoFailLineWidth); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3936 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 3937 | } |
| 3938 | |
| 3939 | TEST_F(VkLayerTest, DynamicViewportNotBound) { |
| 3940 | TEST_DESCRIPTION( |
| 3941 | "Run a simple draw calls to validate failure when Viewport dynamic " |
| 3942 | "state is required but not correctly bound."); |
| 3943 | |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 3944 | // Dynamic viewport state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3945 | m_errorMonitor->SetDesiredFailureMsg( |
| 3946 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3947 | "Dynamic viewport state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3948 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 3949 | BsoFailViewport); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3950 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 3951 | } |
| 3952 | |
| 3953 | TEST_F(VkLayerTest, DynamicScissorNotBound) { |
| 3954 | TEST_DESCRIPTION( |
| 3955 | "Run a simple draw calls to validate failure when Scissor dynamic " |
| 3956 | "state is required but not correctly bound."); |
| 3957 | |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 3958 | // Dynamic scissor state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3959 | m_errorMonitor->SetDesiredFailureMsg( |
| 3960 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3961 | "Dynamic scissor state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3962 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 3963 | BsoFailScissor); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3964 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 3965 | } |
| 3966 | |
Tobin Ehlis | 21c8835 | 2016-05-26 06:15:45 -0600 | [diff] [blame] | 3967 | TEST_F(VkLayerTest, DynamiBlendConstantsNotBound) { |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 3968 | TEST_DESCRIPTION( |
Tobin Ehlis | 21c8835 | 2016-05-26 06:15:45 -0600 | [diff] [blame] | 3969 | "Run a simple draw calls to validate failure when Blend Constants " |
| 3970 | "dynamic state is required but not correctly bound."); |
| 3971 | // Dynamic blend constant state |
| 3972 | m_errorMonitor->SetDesiredFailureMsg( |
| 3973 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3974 | "Dynamic blend constants state not set for this command buffer"); |
| 3975 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 3976 | BsoFailBlend); |
| 3977 | m_errorMonitor->VerifyFound(); |
| 3978 | } |
| 3979 | |
| 3980 | TEST_F(VkLayerTest, DynamicDepthBoundsNotBound) { |
| 3981 | TEST_DESCRIPTION( |
| 3982 | "Run a simple draw calls to validate failure when Depth Bounds dynamic " |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 3983 | "state is required but not correctly bound."); |
Tobin Ehlis | 21c8835 | 2016-05-26 06:15:45 -0600 | [diff] [blame] | 3984 | if (!m_device->phy().features().depthBounds) { |
| 3985 | printf("Device does not support depthBounds test; skipped.\n"); |
| 3986 | return; |
| 3987 | } |
| 3988 | // Dynamic depth bounds |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3989 | m_errorMonitor->SetDesiredFailureMsg( |
| 3990 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3991 | "Dynamic depth bounds state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3992 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 3993 | BsoFailDepthBounds); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3994 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 3995 | } |
| 3996 | |
| 3997 | TEST_F(VkLayerTest, DynamicStencilReadNotBound) { |
| 3998 | TEST_DESCRIPTION( |
| 3999 | "Run a simple draw calls to validate failure when Stencil Read dynamic " |
| 4000 | "state is required but not correctly bound."); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 4001 | // Dynamic stencil read mask |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4002 | m_errorMonitor->SetDesiredFailureMsg( |
| 4003 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4004 | "Dynamic stencil read mask state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4005 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 4006 | BsoFailStencilReadMask); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4007 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 4008 | } |
| 4009 | |
| 4010 | TEST_F(VkLayerTest, DynamicStencilWriteNotBound) { |
| 4011 | TEST_DESCRIPTION( |
| 4012 | "Run a simple draw calls to validate failure when Stencil Write dynamic" |
| 4013 | " state is required but not correctly bound."); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 4014 | // Dynamic stencil write mask |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4015 | m_errorMonitor->SetDesiredFailureMsg( |
| 4016 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4017 | "Dynamic stencil write mask state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4018 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 4019 | BsoFailStencilWriteMask); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4020 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 4021 | } |
| 4022 | |
| 4023 | TEST_F(VkLayerTest, DynamicStencilRefNotBound) { |
| 4024 | TEST_DESCRIPTION( |
| 4025 | "Run a simple draw calls to validate failure when Stencil Ref dynamic " |
| 4026 | "state is required but not correctly bound."); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 4027 | // Dynamic stencil reference |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4028 | m_errorMonitor->SetDesiredFailureMsg( |
| 4029 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4030 | "Dynamic stencil reference state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4031 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 4032 | BsoFailStencilReference); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4033 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 4034 | } |
| 4035 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4036 | TEST_F(VkLayerTest, CommandBufferTwoSubmits) { |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4037 | vk_testing::Fence testFence; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4038 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4039 | m_errorMonitor->SetDesiredFailureMsg( |
| 4040 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4041 | "was begun w/ VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set, but has " |
| 4042 | "been submitted"); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4043 | |
| 4044 | VkFenceCreateInfo fenceInfo = {}; |
| 4045 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 4046 | fenceInfo.pNext = NULL; |
| 4047 | fenceInfo.flags = 0; |
| 4048 | |
| 4049 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4050 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 4051 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4052 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4053 | // We luck out b/c by default the framework creates CB w/ the |
| 4054 | // VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4055 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4056 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 4057 | m_stencil_clear_color, NULL); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4058 | EndCommandBuffer(); |
| 4059 | |
| 4060 | testFence.init(*m_device, fenceInfo); |
| 4061 | |
| 4062 | // Bypass framework since it does the waits automatically |
| 4063 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 4064 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 4065 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 4066 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4067 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 4068 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 4069 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4070 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4071 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4072 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 4073 | submit_info.pSignalSemaphores = NULL; |
| 4074 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4075 | err = vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
| 4076 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4077 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4078 | // Cause validation error by re-submitting cmd buffer that should only be |
| 4079 | // submitted once |
| 4080 | err = vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4081 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4082 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4083 | } |
| 4084 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4085 | TEST_F(VkLayerTest, AllocDescriptorFromEmptyPool) { |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4086 | // Initiate Draw w/o a PSO bound |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4087 | VkResult err; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4088 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4089 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4090 | "Unable to allocate 1 descriptors of " |
| 4091 | "type " |
| 4092 | "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4093 | |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4094 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4095 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4096 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4097 | // Create Pool w/ 1 Sampler descriptor, but try to alloc Uniform Buffer |
| 4098 | // descriptor from it |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4099 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4100 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 4101 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4102 | |
| 4103 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4104 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4105 | ds_pool_ci.pNext = NULL; |
| 4106 | ds_pool_ci.flags = 0; |
| 4107 | ds_pool_ci.maxSets = 1; |
| 4108 | ds_pool_ci.poolSizeCount = 1; |
| 4109 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4110 | |
| 4111 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4112 | err = |
| 4113 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4114 | ASSERT_VK_SUCCESS(err); |
| 4115 | |
| 4116 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4117 | dsl_binding.binding = 0; |
| 4118 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4119 | dsl_binding.descriptorCount = 1; |
| 4120 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4121 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4122 | |
| 4123 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4124 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4125 | ds_layout_ci.pNext = NULL; |
| 4126 | ds_layout_ci.bindingCount = 1; |
| 4127 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4128 | |
| 4129 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4130 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4131 | &ds_layout); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4132 | ASSERT_VK_SUCCESS(err); |
| 4133 | |
| 4134 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4135 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4136 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4137 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4138 | alloc_info.descriptorPool = ds_pool; |
| 4139 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4140 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4141 | &descriptorSet); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4142 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4143 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4144 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4145 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4146 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4147 | } |
| 4148 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4149 | TEST_F(VkLayerTest, FreeDescriptorFromOneShotPool) { |
| 4150 | VkResult err; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4151 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4152 | m_errorMonitor->SetDesiredFailureMsg( |
| 4153 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4154 | "It is invalid to call vkFreeDescriptorSets() with a pool created " |
| 4155 | "without setting VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4156 | |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4157 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4158 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4159 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4160 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4161 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4162 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4163 | |
| 4164 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4165 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4166 | ds_pool_ci.pNext = NULL; |
| 4167 | ds_pool_ci.maxSets = 1; |
| 4168 | ds_pool_ci.poolSizeCount = 1; |
| 4169 | ds_pool_ci.flags = 0; |
| 4170 | // Not specifying VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT means |
| 4171 | // app can only call vkResetDescriptorPool on this pool.; |
| 4172 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4173 | |
| 4174 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4175 | err = |
| 4176 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4177 | ASSERT_VK_SUCCESS(err); |
| 4178 | |
| 4179 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4180 | dsl_binding.binding = 0; |
| 4181 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4182 | dsl_binding.descriptorCount = 1; |
| 4183 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4184 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4185 | |
| 4186 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4187 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4188 | ds_layout_ci.pNext = NULL; |
| 4189 | ds_layout_ci.bindingCount = 1; |
| 4190 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4191 | |
| 4192 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4193 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4194 | &ds_layout); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4195 | ASSERT_VK_SUCCESS(err); |
| 4196 | |
| 4197 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4198 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4199 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4200 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4201 | alloc_info.descriptorPool = ds_pool; |
| 4202 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4203 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4204 | &descriptorSet); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4205 | ASSERT_VK_SUCCESS(err); |
| 4206 | |
| 4207 | err = vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptorSet); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4208 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4209 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4210 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4211 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4212 | } |
| 4213 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4214 | TEST_F(VkLayerTest, InvalidDescriptorPool) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4215 | // Attempt to clear Descriptor Pool with bad object. |
| 4216 | // ObjectTracker should catch this. |
| 4217 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4218 | "Invalid VkDescriptorPool Object 0xbaad6001"); |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 4219 | uint64_t fake_pool_handle = 0xbaad6001; |
| 4220 | VkDescriptorPool bad_pool = reinterpret_cast<VkDescriptorPool &>(fake_pool_handle); |
| 4221 | vkResetDescriptorPool(device(), bad_pool, 0); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4222 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4223 | } |
| 4224 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4225 | TEST_F(VkLayerTest, InvalidDescriptorSet) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4226 | // Attempt to bind an invalid Descriptor Set to a valid Command Buffer |
| 4227 | // ObjectTracker should catch this. |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4228 | // Create a valid cmd buffer |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4229 | // call vkCmdBindDescriptorSets w/ false Descriptor Set |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 4230 | |
| 4231 | uint64_t fake_set_handle = 0xbaad6001; |
| 4232 | VkDescriptorSet bad_set = reinterpret_cast<VkDescriptorSet &>(fake_set_handle); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4233 | VkResult err; |
| 4234 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4235 | "Invalid VkDescriptorSet Object 0xbaad6001"); |
| 4236 | |
| 4237 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4238 | |
| 4239 | VkDescriptorSetLayoutBinding layout_bindings[1] = {}; |
| 4240 | layout_bindings[0].binding = 0; |
| 4241 | layout_bindings[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4242 | layout_bindings[0].descriptorCount = 1; |
| 4243 | layout_bindings[0].stageFlags = VK_SHADER_STAGE_VERTEX_BIT; |
| 4244 | layout_bindings[0].pImmutableSamplers = NULL; |
| 4245 | |
| 4246 | VkDescriptorSetLayout descriptor_set_layout; |
| 4247 | VkDescriptorSetLayoutCreateInfo dslci = {}; |
| 4248 | dslci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4249 | dslci.pNext = NULL; |
| 4250 | dslci.bindingCount = 1; |
| 4251 | dslci.pBindings = layout_bindings; |
| 4252 | err = vkCreateDescriptorSetLayout(device(), &dslci, NULL, &descriptor_set_layout); |
Karl Schultz | 5cb2111 | 2016-04-21 17:17:40 -0600 | [diff] [blame] | 4253 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4254 | |
| 4255 | VkPipelineLayout pipeline_layout; |
| 4256 | VkPipelineLayoutCreateInfo plci = {}; |
| 4257 | plci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4258 | plci.pNext = NULL; |
| 4259 | plci.setLayoutCount = 1; |
| 4260 | plci.pSetLayouts = &descriptor_set_layout; |
| 4261 | err = vkCreatePipelineLayout(device(), &plci, NULL, &pipeline_layout); |
Karl Schultz | 5cb2111 | 2016-04-21 17:17:40 -0600 | [diff] [blame] | 4262 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4263 | |
| 4264 | BeginCommandBuffer(); |
| 4265 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 4266 | pipeline_layout, 0, 1, &bad_set, 0, NULL); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4267 | m_errorMonitor->VerifyFound(); |
| 4268 | EndCommandBuffer(); |
| 4269 | vkDestroyPipelineLayout(device(), pipeline_layout, NULL); |
| 4270 | vkDestroyDescriptorSetLayout(device(), descriptor_set_layout, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4271 | } |
| 4272 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4273 | TEST_F(VkLayerTest, InvalidDescriptorSetLayout) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4274 | // Attempt to create a Pipeline Layout with an invalid Descriptor Set Layout. |
| 4275 | // ObjectTracker should catch this. |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 4276 | uint64_t fake_layout_handle = 0xbaad6001; |
| 4277 | VkDescriptorSetLayout bad_layout = reinterpret_cast<VkDescriptorSetLayout &>(fake_layout_handle); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4278 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4279 | "Invalid VkDescriptorSetLayout Object 0xbaad6001"); |
| 4280 | |
| 4281 | VkPipelineLayout pipeline_layout; |
| 4282 | VkPipelineLayoutCreateInfo plci = {}; |
| 4283 | plci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4284 | plci.pNext = NULL; |
| 4285 | plci.setLayoutCount = 1; |
| 4286 | plci.pSetLayouts = &bad_layout; |
| 4287 | vkCreatePipelineLayout(device(), &plci, NULL, &pipeline_layout); |
| 4288 | |
| 4289 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4290 | } |
| 4291 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4292 | TEST_F(VkLayerTest, InvalidPipeline) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4293 | // Attempt to bind an invalid Pipeline to a valid Command Buffer |
| 4294 | // ObjectTracker should catch this. |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4295 | // Create a valid cmd buffer |
| 4296 | // call vkCmdBindPipeline w/ false Pipeline |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 4297 | uint64_t fake_pipeline_handle = 0xbaad6001; |
| 4298 | VkPipeline bad_pipeline = reinterpret_cast<VkPipeline &>(fake_pipeline_handle); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4299 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4300 | "Invalid VkPipeline Object 0xbaad6001"); |
| 4301 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4302 | BeginCommandBuffer(); |
| 4303 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4304 | VK_PIPELINE_BIND_POINT_GRAPHICS, bad_pipeline); |
| 4305 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b8b6b27 | 2016-05-02 13:26:06 -0600 | [diff] [blame] | 4306 | |
| 4307 | // Now issue a draw call with no pipeline bound |
| 4308 | m_errorMonitor->SetDesiredFailureMsg( |
| 4309 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4310 | "At Draw/Dispatch time no valid VkPipeline is bound!"); |
| 4311 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4312 | BeginCommandBuffer(); |
| 4313 | Draw(1, 0, 0, 0); |
| 4314 | m_errorMonitor->VerifyFound(); |
| 4315 | // Finally same check once more but with Dispatch/Compute |
| 4316 | m_errorMonitor->SetDesiredFailureMsg( |
| 4317 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4318 | "At Draw/Dispatch time no valid VkPipeline is bound!"); |
| 4319 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4320 | BeginCommandBuffer(); |
| 4321 | vkCmdDispatch(m_commandBuffer->GetBufferHandle(), 0, 0, 0); |
| 4322 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4323 | } |
| 4324 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4325 | TEST_F(VkLayerTest, DescriptorSetNotUpdated) { |
| 4326 | // Create and update CommandBuffer then call QueueSubmit w/o calling End on |
| 4327 | // CommandBuffer |
| 4328 | VkResult err; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4329 | |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 4330 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4331 | " bound but it was never updated. "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4332 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4333 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 4334 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 4335 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4336 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4337 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4338 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4339 | |
| 4340 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4341 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4342 | ds_pool_ci.pNext = NULL; |
| 4343 | ds_pool_ci.maxSets = 1; |
| 4344 | ds_pool_ci.poolSizeCount = 1; |
| 4345 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 4346 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4347 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4348 | err = |
| 4349 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4350 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4351 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4352 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4353 | dsl_binding.binding = 0; |
| 4354 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4355 | dsl_binding.descriptorCount = 1; |
| 4356 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4357 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4358 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4359 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4360 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4361 | ds_layout_ci.pNext = NULL; |
| 4362 | ds_layout_ci.bindingCount = 1; |
| 4363 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4364 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4365 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4366 | &ds_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4367 | ASSERT_VK_SUCCESS(err); |
| 4368 | |
| 4369 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4370 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4371 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4372 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4373 | alloc_info.descriptorPool = ds_pool; |
| 4374 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4375 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4376 | &descriptorSet); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4377 | ASSERT_VK_SUCCESS(err); |
| 4378 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4379 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4380 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4381 | pipeline_layout_ci.pNext = NULL; |
| 4382 | pipeline_layout_ci.setLayoutCount = 1; |
| 4383 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4384 | |
| 4385 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4386 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4387 | &pipeline_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4388 | ASSERT_VK_SUCCESS(err); |
| 4389 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4390 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4391 | VK_SHADER_STAGE_VERTEX_BIT, this); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4392 | // 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] | 4393 | // on more devices |
| 4394 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4395 | VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4396 | |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 4397 | VkPipelineObj pipe(m_device); |
| 4398 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 4399 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 4400 | pipe.AddColorAttachment(); |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 4401 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4402 | |
| 4403 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4404 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4405 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 4406 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 4407 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 4408 | 1, &descriptorSet, 0, NULL); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4409 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4410 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 4411 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4412 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4413 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4414 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4415 | } |
| 4416 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4417 | TEST_F(VkLayerTest, InvalidBufferViewObject) { |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4418 | // Create a single TEXEL_BUFFER descriptor and send it an invalid bufferView |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4419 | VkResult err; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4420 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4421 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4422 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Attempted write update to texel buffer " |
| 4423 | "descriptor with invalid buffer view"); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4424 | |
| 4425 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4426 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4427 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 4428 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4429 | |
| 4430 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4431 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4432 | ds_pool_ci.pNext = NULL; |
| 4433 | ds_pool_ci.maxSets = 1; |
| 4434 | ds_pool_ci.poolSizeCount = 1; |
| 4435 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4436 | |
| 4437 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4438 | err = |
| 4439 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4440 | ASSERT_VK_SUCCESS(err); |
| 4441 | |
| 4442 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4443 | dsl_binding.binding = 0; |
| 4444 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 4445 | dsl_binding.descriptorCount = 1; |
| 4446 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4447 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4448 | |
| 4449 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4450 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4451 | ds_layout_ci.pNext = NULL; |
| 4452 | ds_layout_ci.bindingCount = 1; |
| 4453 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4454 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4455 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4456 | &ds_layout); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4457 | ASSERT_VK_SUCCESS(err); |
| 4458 | |
| 4459 | VkDescriptorSet descriptorSet; |
| 4460 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4461 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4462 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4463 | alloc_info.descriptorPool = ds_pool; |
| 4464 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4465 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4466 | &descriptorSet); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4467 | ASSERT_VK_SUCCESS(err); |
| 4468 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4469 | VkBufferView view = |
| 4470 | (VkBufferView)((size_t)0xbaadbeef); // invalid bufferView object |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4471 | VkWriteDescriptorSet descriptor_write; |
| 4472 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 4473 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 4474 | descriptor_write.dstSet = descriptorSet; |
| 4475 | descriptor_write.dstBinding = 0; |
| 4476 | descriptor_write.descriptorCount = 1; |
| 4477 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 4478 | descriptor_write.pTexelBufferView = &view; |
| 4479 | |
| 4480 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 4481 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4482 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4483 | |
| 4484 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4485 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 4486 | } |
| 4487 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4488 | TEST_F(VkLayerTest, InvalidDynamicOffsetCases) { |
| 4489 | // Create a descriptorSet w/ dynamic descriptor and then hit 3 offset error |
| 4490 | // cases: |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4491 | // 1. No dynamicOffset supplied |
| 4492 | // 2. Too many dynamicOffsets supplied |
| 4493 | // 3. Dynamic offset oversteps buffer being updated |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4494 | VkResult err; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4495 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4496 | " requires 1 dynamicOffsets, but only " |
| 4497 | "0 dynamicOffsets are left in " |
| 4498 | "pDynamicOffsets "); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4499 | |
| 4500 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4501 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 4502 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4503 | |
| 4504 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4505 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 4506 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4507 | |
| 4508 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4509 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4510 | ds_pool_ci.pNext = NULL; |
| 4511 | ds_pool_ci.maxSets = 1; |
| 4512 | ds_pool_ci.poolSizeCount = 1; |
| 4513 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4514 | |
| 4515 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4516 | err = |
| 4517 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4518 | ASSERT_VK_SUCCESS(err); |
| 4519 | |
| 4520 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4521 | dsl_binding.binding = 0; |
| 4522 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 4523 | dsl_binding.descriptorCount = 1; |
| 4524 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4525 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4526 | |
| 4527 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4528 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4529 | ds_layout_ci.pNext = NULL; |
| 4530 | ds_layout_ci.bindingCount = 1; |
| 4531 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4532 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4533 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4534 | &ds_layout); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4535 | ASSERT_VK_SUCCESS(err); |
| 4536 | |
| 4537 | VkDescriptorSet descriptorSet; |
| 4538 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4539 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4540 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4541 | alloc_info.descriptorPool = ds_pool; |
| 4542 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4543 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4544 | &descriptorSet); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4545 | ASSERT_VK_SUCCESS(err); |
| 4546 | |
| 4547 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4548 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4549 | pipeline_layout_ci.pNext = NULL; |
| 4550 | pipeline_layout_ci.setLayoutCount = 1; |
| 4551 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4552 | |
| 4553 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4554 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4555 | &pipeline_layout); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4556 | ASSERT_VK_SUCCESS(err); |
| 4557 | |
| 4558 | // Create a buffer to update the descriptor with |
| 4559 | uint32_t qfi = 0; |
| 4560 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4561 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 4562 | buffCI.size = 1024; |
| 4563 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 4564 | buffCI.queueFamilyIndexCount = 1; |
| 4565 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4566 | |
| 4567 | VkBuffer dyub; |
| 4568 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 4569 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4570 | // Allocate memory and bind to buffer so we can make it to the appropriate |
| 4571 | // error |
| 4572 | VkMemoryAllocateInfo mem_alloc = {}; |
| 4573 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 4574 | mem_alloc.pNext = NULL; |
| 4575 | mem_alloc.allocationSize = 1024; |
Chris Forbes | b6116cc | 2016-05-08 11:39:59 +1200 | [diff] [blame] | 4576 | mem_alloc.memoryTypeIndex = 0; |
| 4577 | |
| 4578 | VkMemoryRequirements memReqs; |
| 4579 | vkGetBufferMemoryRequirements(m_device->device(), dyub, &memReqs); |
| 4580 | bool pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &mem_alloc, |
| 4581 | 0); |
| 4582 | if (!pass) { |
| 4583 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
| 4584 | return; |
| 4585 | } |
| 4586 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4587 | VkDeviceMemory mem; |
| 4588 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
| 4589 | ASSERT_VK_SUCCESS(err); |
| 4590 | err = vkBindBufferMemory(m_device->device(), dyub, mem, 0); |
| 4591 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4592 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 4593 | VkDescriptorBufferInfo buffInfo = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4594 | buffInfo.buffer = dyub; |
| 4595 | buffInfo.offset = 0; |
| 4596 | buffInfo.range = 1024; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4597 | |
| 4598 | VkWriteDescriptorSet descriptor_write; |
| 4599 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 4600 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 4601 | descriptor_write.dstSet = descriptorSet; |
| 4602 | descriptor_write.dstBinding = 0; |
| 4603 | descriptor_write.descriptorCount = 1; |
| 4604 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 4605 | descriptor_write.pBufferInfo = &buffInfo; |
| 4606 | |
| 4607 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 4608 | |
| 4609 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4610 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 4611 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 4612 | 1, &descriptorSet, 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4613 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4614 | uint32_t pDynOff[2] = {512, 756}; |
| 4615 | // 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] | 4616 | m_errorMonitor->SetDesiredFailureMsg( |
| 4617 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4618 | "Attempting to bind 1 descriptorSets with 1 dynamic descriptors, but "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4619 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 4620 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 4621 | 1, &descriptorSet, 2, pDynOff); |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 4622 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4623 | // Finally cause error due to dynamicOffset being too big |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4624 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4625 | " dynamic offset 512 combined with " |
| 4626 | "offset 0 and range 1024 that " |
| 4627 | "oversteps the buffer size of 1024"); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4628 | // Create PSO to be used for draw-time errors below |
| 4629 | char const *vsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 4630 | "#version 450\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4631 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 4632 | "out gl_PerVertex { \n" |
| 4633 | " vec4 gl_Position;\n" |
| 4634 | "};\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4635 | "void main(){\n" |
| 4636 | " gl_Position = vec4(1);\n" |
| 4637 | "}\n"; |
| 4638 | char const *fsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 4639 | "#version 450\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4640 | "\n" |
| 4641 | "layout(location=0) out vec4 x;\n" |
| 4642 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 4643 | "void main(){\n" |
| 4644 | " x = vec4(bar.y);\n" |
| 4645 | "}\n"; |
| 4646 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4647 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 4648 | VkPipelineObj pipe(m_device); |
| 4649 | pipe.AddShader(&vs); |
| 4650 | pipe.AddShader(&fs); |
| 4651 | pipe.AddColorAttachment(); |
| 4652 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 4653 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4654 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4655 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 4656 | // This update should succeed, but offset size of 512 will overstep buffer |
| 4657 | // /w range 1024 & size 1024 |
| 4658 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 4659 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 4660 | 1, &descriptorSet, 1, pDynOff); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4661 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4662 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4663 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4664 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
Tobin Ehlis | 512098e | 2016-05-05 09:06:12 -0600 | [diff] [blame] | 4665 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4666 | |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4667 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4668 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 4669 | } |
| 4670 | |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4671 | TEST_F(VkLayerTest, InvalidPushConstants) { |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4672 | VkResult err; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4673 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4674 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 4675 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4676 | |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4677 | VkPipelineLayout pipeline_layout; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4678 | VkPushConstantRange pc_range = {}; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4679 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 4680 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4681 | pipeline_layout_ci.pushConstantRangeCount = 1; |
| 4682 | pipeline_layout_ci.pPushConstantRanges = &pc_range; |
| 4683 | |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4684 | // |
| 4685 | // Check for invalid push constant ranges in pipeline layouts. |
| 4686 | // |
| 4687 | struct PipelineLayoutTestCase { |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4688 | VkPushConstantRange const range; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4689 | char const *msg; |
| 4690 | }; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4691 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4692 | const uint32_t too_big = m_device->props.limits.maxPushConstantsSize + 0x4; |
| 4693 | const std::array<PipelineLayoutTestCase, 10> range_tests = {{ |
| 4694 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 0}, |
| 4695 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 4696 | "size 0."}, |
| 4697 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 1}, |
| 4698 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 4699 | "size 1."}, |
| 4700 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 1}, |
| 4701 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 4702 | "size 1."}, |
| 4703 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 0}, |
| 4704 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 4705 | "size 0."}, |
| 4706 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 4}, |
| 4707 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 4708 | "offset 1. Offset must"}, |
| 4709 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, too_big}, |
| 4710 | "vkCreatePipelineLayout() call has push constants index 0 " |
| 4711 | "with offset "}, |
| 4712 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, too_big}, |
| 4713 | "vkCreatePipelineLayout() call has push constants " |
| 4714 | "index 0 with offset "}, |
| 4715 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, 0}, |
| 4716 | "vkCreatePipelineLayout() call has push constants index 0 " |
| 4717 | "with offset "}, |
| 4718 | {{VK_SHADER_STAGE_VERTEX_BIT, 0xFFFFFFF0, 0x00000020}, |
| 4719 | "vkCreatePipelineLayout() call has push " |
| 4720 | "constants index 0 with offset "}, |
| 4721 | {{VK_SHADER_STAGE_VERTEX_BIT, 0x00000020, 0xFFFFFFF0}, |
| 4722 | "vkCreatePipelineLayout() call has push " |
| 4723 | "constants index 0 with offset "}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4724 | }}; |
| 4725 | |
| 4726 | // Check for invalid offset and size |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4727 | for (const auto &iter : range_tests) { |
| 4728 | pc_range = iter.range; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4729 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4730 | iter.msg); |
| 4731 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, |
| 4732 | NULL, &pipeline_layout); |
| 4733 | m_errorMonitor->VerifyFound(); |
| 4734 | if (VK_SUCCESS == err) { |
| 4735 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4736 | } |
| 4737 | } |
| 4738 | |
| 4739 | // Check for invalid stage flag |
| 4740 | pc_range.offset = 0; |
| 4741 | pc_range.size = 16; |
| 4742 | pc_range.stageFlags = 0; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4743 | m_errorMonitor->SetDesiredFailureMsg( |
| 4744 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4745 | "vkCreatePipelineLayout() call has no stageFlags set."); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4746 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4747 | &pipeline_layout); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4748 | m_errorMonitor->VerifyFound(); |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4749 | if (VK_SUCCESS == err) { |
| 4750 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4751 | } |
| 4752 | |
| 4753 | // Check for overlapping ranges |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4754 | const uint32_t ranges_per_test = 5; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4755 | struct OverlappingRangeTestCase { |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4756 | VkPushConstantRange const ranges[ranges_per_test]; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4757 | char const *msg; |
| 4758 | }; |
| 4759 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4760 | const std::array<OverlappingRangeTestCase, 5> overlapping_range_tests = { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4761 | {{{{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4762 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4763 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4764 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4765 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, |
| 4766 | "vkCreatePipelineLayout() call has push constants with overlapping " |
| 4767 | "ranges: 0:[0, 4), 1:[0, 4)"}, |
| 4768 | { |
| 4769 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4770 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, |
| 4771 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, |
| 4772 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 8}, |
| 4773 | {VK_SHADER_STAGE_VERTEX_BIT, 16, 4}}, |
| 4774 | "vkCreatePipelineLayout() call has push constants with " |
| 4775 | "overlapping " |
| 4776 | "ranges: 3:[12, 20), 4:[16, 20)", |
| 4777 | }, |
| 4778 | { |
| 4779 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, |
| 4780 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 8}, |
| 4781 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, |
| 4782 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, |
| 4783 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, |
| 4784 | "vkCreatePipelineLayout() call has push constants with " |
| 4785 | "overlapping " |
| 4786 | "ranges: 0:[16, 20), 1:[12, 20)", |
| 4787 | }, |
| 4788 | { |
| 4789 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, |
| 4790 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, |
| 4791 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, |
| 4792 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 8}, |
| 4793 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, |
| 4794 | "vkCreatePipelineLayout() call has push constants with " |
| 4795 | "overlapping " |
| 4796 | "ranges: 0:[16, 20), 3:[12, 20)", |
| 4797 | }, |
| 4798 | { |
| 4799 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, |
| 4800 | {VK_SHADER_STAGE_VERTEX_BIT, 32, 4}, |
| 4801 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 96}, |
| 4802 | {VK_SHADER_STAGE_VERTEX_BIT, 40, 8}, |
| 4803 | {VK_SHADER_STAGE_VERTEX_BIT, 52, 4}}, |
| 4804 | "vkCreatePipelineLayout() call has push constants with " |
| 4805 | "overlapping " |
| 4806 | "ranges: 0:[16, 20), 2:[4, 100)", |
| 4807 | }}}; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4808 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4809 | for (const auto &iter : overlapping_range_tests) { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4810 | pipeline_layout_ci.pPushConstantRanges = iter.ranges; |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4811 | pipeline_layout_ci.pushConstantRangeCount = ranges_per_test; |
| 4812 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4813 | iter.msg); |
| 4814 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, |
| 4815 | NULL, &pipeline_layout); |
| 4816 | m_errorMonitor->VerifyFound(); |
| 4817 | if (VK_SUCCESS == err) { |
| 4818 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4819 | } |
| 4820 | } |
| 4821 | |
| 4822 | // Run some positive tests to make sure overlap checking in the layer is OK |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4823 | const std::array<OverlappingRangeTestCase, 2> overlapping_range_tests_pos = |
| 4824 | {{{{{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4825 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, |
| 4826 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, |
| 4827 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 4}, |
| 4828 | {VK_SHADER_STAGE_VERTEX_BIT, 16, 4}}, |
| 4829 | ""}, |
| 4830 | {{{VK_SHADER_STAGE_VERTEX_BIT, 92, 24}, |
| 4831 | {VK_SHADER_STAGE_VERTEX_BIT, 80, 4}, |
| 4832 | {VK_SHADER_STAGE_VERTEX_BIT, 64, 8}, |
| 4833 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 16}, |
| 4834 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, |
| 4835 | ""}}}; |
| 4836 | for (const auto &iter : overlapping_range_tests_pos) { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4837 | pipeline_layout_ci.pPushConstantRanges = iter.ranges; |
| 4838 | m_errorMonitor->ExpectSuccess(); |
| 4839 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, |
| 4840 | NULL, &pipeline_layout); |
| 4841 | m_errorMonitor->VerifyNotFound(); |
| 4842 | if (VK_SUCCESS == err) { |
| 4843 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4844 | } |
| 4845 | } |
| 4846 | |
| 4847 | // |
| 4848 | // CmdPushConstants tests |
| 4849 | // |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4850 | const uint8_t dummy_values[100] = {}; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4851 | |
| 4852 | // Check for invalid offset and size and if range is within layout range(s) |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4853 | const std::array<PipelineLayoutTestCase, 16> cmd_range_tests = {{ |
| 4854 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 0}, |
| 4855 | "vkCmdPushConstants() call has push constants with size 0. Size " |
| 4856 | "must be greater than zero and a multiple of 4."}, |
| 4857 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 1}, |
| 4858 | "vkCmdPushConstants() call has push constants with size 1. Size " |
| 4859 | "must be greater than zero and a multiple of 4."}, |
| 4860 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 1}, |
| 4861 | "vkCmdPushConstants() call has push constants with size 1. Size " |
| 4862 | "must be greater than zero and a multiple of 4."}, |
| 4863 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 0}, |
| 4864 | "vkCmdPushConstants() call has push constants with offset 1. " |
| 4865 | "Offset must be a multiple of 4."}, |
| 4866 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 4}, |
| 4867 | "vkCmdPushConstants() call has push constants with offset 1. " |
| 4868 | "Offset must be a multiple of 4."}, |
| 4869 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 20}, |
| 4870 | "vkCmdPushConstants() Push constant range [0, 20) with stageFlags = " |
| 4871 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4872 | {{VK_SHADER_STAGE_VERTEX_BIT, 60, 8}, |
| 4873 | "vkCmdPushConstants() Push constant range [60, 68) with stageFlags = " |
| 4874 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4875 | {{VK_SHADER_STAGE_VERTEX_BIT, 76, 8}, |
| 4876 | "vkCmdPushConstants() Push constant range [76, 84) with stageFlags = " |
| 4877 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4878 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 80}, |
| 4879 | "vkCmdPushConstants() Push constant range [0, 80) with stageFlags = " |
| 4880 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4881 | {{VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, 0, 4}, |
| 4882 | "vkCmdPushConstants() stageFlags = 0x2 do not match the stageFlags in " |
| 4883 | "any of the ranges in pipeline layout"}, |
| 4884 | {{VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, |
| 4885 | 0, 16}, |
| 4886 | "vkCmdPushConstants() stageFlags = 0x3 do not match the stageFlags in " |
| 4887 | "any of the ranges in pipeline layout"}, |
| 4888 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, too_big}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4889 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4890 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, too_big}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4891 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4892 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, 0}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4893 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4894 | {{VK_SHADER_STAGE_VERTEX_BIT, 0xFFFFFFF0, 0x00000020}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4895 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4896 | {{VK_SHADER_STAGE_VERTEX_BIT, 0x00000020, 0xFFFFFFF0}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4897 | "vkCmdPushConstants() call has push constants with offset "}, |
| 4898 | }}; |
| 4899 | |
| 4900 | // Two ranges for testing robustness |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4901 | const VkPushConstantRange pc_range2[] = { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4902 | {VK_SHADER_STAGE_VERTEX_BIT, 64, 16}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4903 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4904 | }; |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4905 | pipeline_layout_ci.pushConstantRangeCount = |
| 4906 | sizeof(pc_range2) / sizeof(VkPushConstantRange); |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4907 | pipeline_layout_ci.pPushConstantRanges = pc_range2; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4908 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4909 | &pipeline_layout); |
| 4910 | ASSERT_VK_SUCCESS(err); |
| 4911 | BeginCommandBuffer(); |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4912 | for (const auto &iter : cmd_range_tests) { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4913 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4914 | iter.msg); |
| 4915 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4916 | iter.range.stageFlags, iter.range.offset, |
| 4917 | iter.range.size, dummy_values); |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4918 | m_errorMonitor->VerifyFound(); |
| 4919 | } |
| 4920 | |
| 4921 | // Check for invalid stage flag |
| 4922 | m_errorMonitor->SetDesiredFailureMsg( |
| 4923 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4924 | "vkCmdPushConstants() call has no stageFlags set."); |
| 4925 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, 0, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4926 | 0, 16, dummy_values); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4927 | m_errorMonitor->VerifyFound(); |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4928 | EndCommandBuffer(); |
| 4929 | vkResetCommandBuffer(m_commandBuffer->GetBufferHandle(), 0); |
| 4930 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4931 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4932 | // overlapping range tests with cmd |
| 4933 | const std::array<PipelineLayoutTestCase, 3> cmd_overlap_tests = {{ |
| 4934 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 20}, |
| 4935 | "vkCmdPushConstants() Push constant range [0, 20) with stageFlags = " |
| 4936 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4937 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, |
| 4938 | "vkCmdPushConstants() Push constant range [16, 20) with stageFlags = " |
| 4939 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4940 | {{VK_SHADER_STAGE_VERTEX_BIT, 40, 16}, |
| 4941 | "vkCmdPushConstants() Push constant range [40, 56) with stageFlags = " |
| 4942 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4943 | }}; |
| 4944 | const VkPushConstantRange pc_range3[] = { |
| 4945 | {VK_SHADER_STAGE_VERTEX_BIT, 20, 16}, |
| 4946 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, |
| 4947 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4948 | {VK_SHADER_STAGE_VERTEX_BIT, 44, 8}, |
| 4949 | {VK_SHADER_STAGE_VERTEX_BIT, 80, 12}, |
| 4950 | {VK_SHADER_STAGE_VERTEX_BIT, 36, 8}, |
| 4951 | {VK_SHADER_STAGE_VERTEX_BIT, 56, 28}, |
| 4952 | }; |
| 4953 | pipeline_layout_ci.pushConstantRangeCount = |
| 4954 | sizeof(pc_range3) / sizeof(VkPushConstantRange); |
| 4955 | pipeline_layout_ci.pPushConstantRanges = pc_range3; |
| 4956 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4957 | &pipeline_layout); |
| 4958 | ASSERT_VK_SUCCESS(err); |
| 4959 | BeginCommandBuffer(); |
| 4960 | for (const auto &iter : cmd_overlap_tests) { |
| 4961 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4962 | iter.msg); |
| 4963 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, |
| 4964 | iter.range.stageFlags, iter.range.offset, |
| 4965 | iter.range.size, dummy_values); |
| 4966 | m_errorMonitor->VerifyFound(); |
| 4967 | } |
| 4968 | EndCommandBuffer(); |
| 4969 | vkResetCommandBuffer(m_commandBuffer->GetBufferHandle(), 0); |
| 4970 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4971 | |
| 4972 | // positive overlapping range tests with cmd |
| 4973 | const std::array<PipelineLayoutTestCase, 4> cmd_overlap_tests_pos = {{ |
| 4974 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, ""}, |
| 4975 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, ""}, |
| 4976 | {{VK_SHADER_STAGE_VERTEX_BIT, 20, 12}, ""}, |
| 4977 | {{VK_SHADER_STAGE_VERTEX_BIT, 56, 36}, ""}, |
| 4978 | }}; |
| 4979 | const VkPushConstantRange pc_range4[] = { |
| 4980 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 64}, |
| 4981 | {VK_SHADER_STAGE_VERTEX_BIT, 20, 16}, |
| 4982 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, |
| 4983 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4984 | {VK_SHADER_STAGE_VERTEX_BIT, 44, 8}, |
| 4985 | {VK_SHADER_STAGE_VERTEX_BIT, 80, 12}, |
| 4986 | {VK_SHADER_STAGE_VERTEX_BIT, 36, 8}, |
| 4987 | {VK_SHADER_STAGE_VERTEX_BIT, 56, 28}, |
| 4988 | }; |
| 4989 | pipeline_layout_ci.pushConstantRangeCount = |
| 4990 | sizeof(pc_range4) / sizeof(VkPushConstantRange); |
| 4991 | pipeline_layout_ci.pPushConstantRanges = pc_range4; |
| 4992 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4993 | &pipeline_layout); |
| 4994 | ASSERT_VK_SUCCESS(err); |
| 4995 | BeginCommandBuffer(); |
| 4996 | for (const auto &iter : cmd_overlap_tests_pos) { |
| 4997 | m_errorMonitor->ExpectSuccess(); |
| 4998 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, |
| 4999 | iter.range.stageFlags, iter.range.offset, |
| 5000 | iter.range.size, dummy_values); |
| 5001 | m_errorMonitor->VerifyNotFound(); |
| 5002 | } |
| 5003 | EndCommandBuffer(); |
| 5004 | vkResetCommandBuffer(m_commandBuffer->GetBufferHandle(), 0); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 5005 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5006 | } |
| 5007 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5008 | TEST_F(VkLayerTest, DescriptorSetCompatibility) { |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5009 | // Test various desriptorSet errors with bad binding combinations |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5010 | VkResult err; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5011 | |
| 5012 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5013 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 5014 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5015 | |
| 5016 | static const uint32_t NUM_DESCRIPTOR_TYPES = 5; |
| 5017 | VkDescriptorPoolSize ds_type_count[NUM_DESCRIPTOR_TYPES] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5018 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5019 | ds_type_count[0].descriptorCount = 10; |
| 5020 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 5021 | ds_type_count[1].descriptorCount = 2; |
| 5022 | ds_type_count[2].type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 5023 | ds_type_count[2].descriptorCount = 2; |
| 5024 | ds_type_count[3].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 5025 | ds_type_count[3].descriptorCount = 5; |
| 5026 | // TODO : LunarG ILO driver currently asserts in desc.c w/ INPUT_ATTACHMENT |
| 5027 | // type |
| 5028 | // ds_type_count[4].type = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; |
| 5029 | ds_type_count[4].type = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
| 5030 | ds_type_count[4].descriptorCount = 2; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5031 | |
| 5032 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5033 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5034 | ds_pool_ci.pNext = NULL; |
| 5035 | ds_pool_ci.maxSets = 5; |
| 5036 | ds_pool_ci.poolSizeCount = NUM_DESCRIPTOR_TYPES; |
| 5037 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5038 | |
| 5039 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5040 | err = |
| 5041 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5042 | ASSERT_VK_SUCCESS(err); |
| 5043 | |
| 5044 | static const uint32_t MAX_DS_TYPES_IN_LAYOUT = 2; |
| 5045 | VkDescriptorSetLayoutBinding dsl_binding[MAX_DS_TYPES_IN_LAYOUT] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5046 | dsl_binding[0].binding = 0; |
| 5047 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5048 | dsl_binding[0].descriptorCount = 5; |
| 5049 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 5050 | dsl_binding[0].pImmutableSamplers = NULL; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5051 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5052 | // Create layout identical to set0 layout but w/ different stageFlags |
| 5053 | VkDescriptorSetLayoutBinding dsl_fs_stage_only = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5054 | dsl_fs_stage_only.binding = 0; |
| 5055 | dsl_fs_stage_only.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5056 | dsl_fs_stage_only.descriptorCount = 5; |
| 5057 | dsl_fs_stage_only.stageFlags = |
| 5058 | VK_SHADER_STAGE_FRAGMENT_BIT; // Different stageFlags to cause error at |
| 5059 | // bind time |
| 5060 | dsl_fs_stage_only.pImmutableSamplers = NULL; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5061 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5062 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5063 | ds_layout_ci.pNext = NULL; |
| 5064 | ds_layout_ci.bindingCount = 1; |
| 5065 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5066 | static const uint32_t NUM_LAYOUTS = 4; |
| 5067 | VkDescriptorSetLayout ds_layout[NUM_LAYOUTS] = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5068 | VkDescriptorSetLayout ds_layout_fs_only = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5069 | // Create 4 unique layouts for full pipelineLayout, and 1 special fs-only |
| 5070 | // layout for error case |
| 5071 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5072 | &ds_layout[0]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5073 | ASSERT_VK_SUCCESS(err); |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 5074 | ds_layout_ci.pBindings = &dsl_fs_stage_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5075 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5076 | &ds_layout_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5077 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5078 | dsl_binding[0].binding = 0; |
| 5079 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5080 | dsl_binding[0].descriptorCount = 2; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 5081 | dsl_binding[1].binding = 1; |
| 5082 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 5083 | dsl_binding[1].descriptorCount = 2; |
| 5084 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 5085 | dsl_binding[1].pImmutableSamplers = NULL; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 5086 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5087 | ds_layout_ci.bindingCount = 2; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5088 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5089 | &ds_layout[1]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5090 | ASSERT_VK_SUCCESS(err); |
| 5091 | dsl_binding[0].binding = 0; |
| 5092 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5093 | dsl_binding[0].descriptorCount = 5; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5094 | ds_layout_ci.bindingCount = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5095 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5096 | &ds_layout[2]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5097 | ASSERT_VK_SUCCESS(err); |
| 5098 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5099 | dsl_binding[0].descriptorCount = 2; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5100 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5101 | &ds_layout[3]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5102 | ASSERT_VK_SUCCESS(err); |
| 5103 | |
| 5104 | static const uint32_t NUM_SETS = 4; |
| 5105 | VkDescriptorSet descriptorSet[NUM_SETS] = {}; |
| 5106 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5107 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5108 | alloc_info.descriptorSetCount = NUM_LAYOUTS; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5109 | alloc_info.descriptorPool = ds_pool; |
| 5110 | alloc_info.pSetLayouts = ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5111 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5112 | descriptorSet); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5113 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5114 | VkDescriptorSet ds0_fs_only = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5115 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5116 | alloc_info.pSetLayouts = &ds_layout_fs_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5117 | err = |
| 5118 | vkAllocateDescriptorSets(m_device->device(), &alloc_info, &ds0_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5119 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5120 | |
| 5121 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5122 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5123 | pipeline_layout_ci.pNext = NULL; |
| 5124 | pipeline_layout_ci.setLayoutCount = NUM_LAYOUTS; |
| 5125 | pipeline_layout_ci.pSetLayouts = ds_layout; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5126 | |
| 5127 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5128 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5129 | &pipeline_layout); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5130 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5131 | // Create pipelineLayout with only one setLayout |
| 5132 | pipeline_layout_ci.setLayoutCount = 1; |
| 5133 | VkPipelineLayout single_pipe_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5134 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5135 | &single_pipe_layout); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5136 | ASSERT_VK_SUCCESS(err); |
| 5137 | // Create pipelineLayout with 2 descriptor setLayout at index 0 |
| 5138 | pipeline_layout_ci.pSetLayouts = &ds_layout[3]; |
| 5139 | VkPipelineLayout pipe_layout_one_desc; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5140 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5141 | &pipe_layout_one_desc); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5142 | ASSERT_VK_SUCCESS(err); |
| 5143 | // Create pipelineLayout with 5 SAMPLER descriptor setLayout at index 0 |
| 5144 | pipeline_layout_ci.pSetLayouts = &ds_layout[2]; |
| 5145 | VkPipelineLayout pipe_layout_five_samp; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5146 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5147 | &pipe_layout_five_samp); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5148 | ASSERT_VK_SUCCESS(err); |
| 5149 | // Create pipelineLayout with UB type, but stageFlags for FS only |
| 5150 | pipeline_layout_ci.pSetLayouts = &ds_layout_fs_only; |
| 5151 | VkPipelineLayout pipe_layout_fs_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5152 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5153 | &pipe_layout_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5154 | ASSERT_VK_SUCCESS(err); |
| 5155 | // Create pipelineLayout w/ incompatible set0 layout, but set1 is fine |
| 5156 | VkDescriptorSetLayout pl_bad_s0[2] = {}; |
| 5157 | pl_bad_s0[0] = ds_layout_fs_only; |
| 5158 | pl_bad_s0[1] = ds_layout[1]; |
| 5159 | pipeline_layout_ci.setLayoutCount = 2; |
| 5160 | pipeline_layout_ci.pSetLayouts = pl_bad_s0; |
| 5161 | VkPipelineLayout pipe_layout_bad_set0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5162 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5163 | &pipe_layout_bad_set0); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5164 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5165 | |
| 5166 | // Create a buffer to update the descriptor with |
| 5167 | uint32_t qfi = 0; |
| 5168 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5169 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 5170 | buffCI.size = 1024; |
| 5171 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 5172 | buffCI.queueFamilyIndexCount = 1; |
| 5173 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5174 | |
| 5175 | VkBuffer dyub; |
| 5176 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 5177 | ASSERT_VK_SUCCESS(err); |
| 5178 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 5179 | static const uint32_t NUM_BUFFS = 5; |
| 5180 | VkDescriptorBufferInfo buffInfo[NUM_BUFFS] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5181 | for (uint32_t i = 0; i < NUM_BUFFS; ++i) { |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5182 | buffInfo[i].buffer = dyub; |
| 5183 | buffInfo[i].offset = 0; |
| 5184 | buffInfo[i].range = 1024; |
| 5185 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5186 | VkImage image; |
| 5187 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5188 | const int32_t tex_width = 32; |
| 5189 | const int32_t tex_height = 32; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5190 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5191 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5192 | image_create_info.pNext = NULL; |
| 5193 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5194 | image_create_info.format = tex_format; |
| 5195 | image_create_info.extent.width = tex_width; |
| 5196 | image_create_info.extent.height = tex_height; |
| 5197 | image_create_info.extent.depth = 1; |
| 5198 | image_create_info.mipLevels = 1; |
| 5199 | image_create_info.arrayLayers = 1; |
| 5200 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 5201 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 5202 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 5203 | image_create_info.flags = 0; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5204 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 5205 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5206 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5207 | VkMemoryRequirements memReqs; |
| 5208 | VkDeviceMemory imageMem; |
| 5209 | bool pass; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 5210 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5211 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 5212 | memAlloc.pNext = NULL; |
| 5213 | memAlloc.allocationSize = 0; |
| 5214 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 5215 | vkGetImageMemoryRequirements(m_device->device(), image, &memReqs); |
| 5216 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5217 | pass = |
| 5218 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 5219 | ASSERT_TRUE(pass); |
| 5220 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &imageMem); |
| 5221 | ASSERT_VK_SUCCESS(err); |
| 5222 | err = vkBindImageMemory(m_device->device(), image, imageMem, 0); |
| 5223 | ASSERT_VK_SUCCESS(err); |
| 5224 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5225 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5226 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 5227 | image_view_create_info.image = image; |
| 5228 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 5229 | image_view_create_info.format = tex_format; |
| 5230 | image_view_create_info.subresourceRange.layerCount = 1; |
| 5231 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 5232 | image_view_create_info.subresourceRange.levelCount = 1; |
| 5233 | image_view_create_info.subresourceRange.aspectMask = |
| 5234 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5235 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5236 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5237 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 5238 | &view); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5239 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 5240 | VkDescriptorImageInfo imageInfo[4] = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5241 | imageInfo[0].imageView = view; |
| 5242 | imageInfo[0].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 5243 | imageInfo[1].imageView = view; |
| 5244 | imageInfo[1].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 5245 | imageInfo[2].imageView = view; |
| 5246 | imageInfo[2].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 5247 | imageInfo[3].imageView = view; |
| 5248 | imageInfo[3].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5249 | |
| 5250 | static const uint32_t NUM_SET_UPDATES = 3; |
| 5251 | VkWriteDescriptorSet descriptor_write[NUM_SET_UPDATES] = {}; |
| 5252 | descriptor_write[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 5253 | descriptor_write[0].dstSet = descriptorSet[0]; |
| 5254 | descriptor_write[0].dstBinding = 0; |
| 5255 | descriptor_write[0].descriptorCount = 5; |
| 5256 | descriptor_write[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5257 | descriptor_write[0].pBufferInfo = buffInfo; |
| 5258 | descriptor_write[1].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 5259 | descriptor_write[1].dstSet = descriptorSet[1]; |
| 5260 | descriptor_write[1].dstBinding = 0; |
| 5261 | descriptor_write[1].descriptorCount = 2; |
| 5262 | descriptor_write[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 5263 | descriptor_write[1].pImageInfo = imageInfo; |
| 5264 | descriptor_write[2].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 5265 | descriptor_write[2].dstSet = descriptorSet[1]; |
| 5266 | descriptor_write[2].dstBinding = 1; |
| 5267 | descriptor_write[2].descriptorCount = 2; |
| 5268 | descriptor_write[2].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 5269 | descriptor_write[2].pImageInfo = &imageInfo[2]; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5270 | |
| 5271 | vkUpdateDescriptorSets(m_device->device(), 3, descriptor_write, 0, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5272 | |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5273 | // Create PSO to be used for draw-time errors below |
| 5274 | char const *vsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 5275 | "#version 450\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5276 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5277 | "out gl_PerVertex {\n" |
| 5278 | " vec4 gl_Position;\n" |
| 5279 | "};\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5280 | "void main(){\n" |
| 5281 | " gl_Position = vec4(1);\n" |
| 5282 | "}\n"; |
| 5283 | char const *fsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 5284 | "#version 450\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5285 | "\n" |
| 5286 | "layout(location=0) out vec4 x;\n" |
| 5287 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 5288 | "void main(){\n" |
| 5289 | " x = vec4(bar.y);\n" |
| 5290 | "}\n"; |
| 5291 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5292 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5293 | VkPipelineObj pipe(m_device); |
| 5294 | pipe.AddShader(&vs); |
| 5295 | pipe.AddShader(&fs); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5296 | pipe.AddColorAttachment(); |
| 5297 | pipe.CreateVKPipeline(pipe_layout_fs_only, renderPass()); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5298 | |
| 5299 | BeginCommandBuffer(); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5300 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5301 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 5302 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 5303 | // NOTE : I believe LunarG ilo driver has bug (LX#189) that requires binding |
| 5304 | // of PSO |
| 5305 | // here before binding DSs. Otherwise we assert in cmd_copy_dset_data() of |
| 5306 | // cmd_pipeline.c |
| 5307 | // due to the fact that cmd_alloc_dset_data() has not been called in |
| 5308 | // cmd_bind_graphics_pipeline() |
| 5309 | // TODO : Want to cause various binding incompatibility issues here to test |
| 5310 | // DrawState |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5311 | // First cause various verify_layout_compatibility() fails |
| 5312 | // Second disturb early and late sets and verify INFO msgs |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5313 | // verify_set_layout_compatibility fail cases: |
| 5314 | // 1. invalid VkPipelineLayout (layout) passed into vkCmdBindDescriptorSets |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5315 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5316 | " due to: invalid VkPipelineLayout "); |
| 5317 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5318 | VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5319 | (VkPipelineLayout)((size_t)0xbaadb1be), 0, 1, |
| 5320 | &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5321 | m_errorMonitor->VerifyFound(); |
| 5322 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5323 | // 2. layoutIndex exceeds # of layouts in layout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5324 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5325 | " attempting to bind set to index 1"); |
| 5326 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5327 | VK_PIPELINE_BIND_POINT_GRAPHICS, single_pipe_layout, |
| 5328 | 0, 2, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5329 | m_errorMonitor->VerifyFound(); |
| 5330 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5331 | vkDestroyPipelineLayout(m_device->device(), single_pipe_layout, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5332 | // 3. Pipeline setLayout[0] has 2 descriptors, but set being bound has 5 |
| 5333 | // descriptors |
| 5334 | m_errorMonitor->SetDesiredFailureMsg( |
| 5335 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 5336 | " has 2 descriptors, but DescriptorSetLayout "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5337 | vkCmdBindDescriptorSets( |
| 5338 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5339 | pipe_layout_one_desc, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5340 | m_errorMonitor->VerifyFound(); |
| 5341 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5342 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_one_desc, NULL); |
| 5343 | // 4. same # of descriptors but mismatch in type |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5344 | m_errorMonitor->SetDesiredFailureMsg( |
| 5345 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 5346 | " is type 'VK_DESCRIPTOR_TYPE_SAMPLER' but binding "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5347 | vkCmdBindDescriptorSets( |
| 5348 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5349 | pipe_layout_five_samp, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5350 | m_errorMonitor->VerifyFound(); |
| 5351 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5352 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_five_samp, NULL); |
| 5353 | // 5. same # of descriptors but mismatch in stageFlags |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5354 | m_errorMonitor->SetDesiredFailureMsg( |
| 5355 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 5356 | " has stageFlags 16 but binding 0 for DescriptorSetLayout "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5357 | vkCmdBindDescriptorSets( |
| 5358 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5359 | pipe_layout_fs_only, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5360 | m_errorMonitor->VerifyFound(); |
| 5361 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5362 | // Cause INFO messages due to disturbing previously bound Sets |
| 5363 | // First bind sets 0 & 1 |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5364 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5365 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 5366 | 2, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5367 | // 1. Disturb bound set0 by re-binding set1 w/ updated pipelineLayout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5368 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 5369 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5370 | " previously bound as set #0 was disturbed "); |
| 5371 | vkCmdBindDescriptorSets( |
| 5372 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5373 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5374 | m_errorMonitor->VerifyFound(); |
| 5375 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5376 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5377 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 5378 | 2, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5379 | // 2. Disturb set after last bound set |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 5380 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5381 | " newly bound as set #0 so set #1 and " |
| 5382 | "any subsequent sets were disturbed "); |
| 5383 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5384 | VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5385 | pipe_layout_fs_only, 0, 1, &ds0_fs_only, 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5386 | m_errorMonitor->VerifyFound(); |
| 5387 | |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5388 | // Cause draw-time errors due to PSO incompatibilities |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5389 | // 1. Error due to not binding required set (we actually use same code as |
| 5390 | // above to disturb set0) |
| 5391 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5392 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 5393 | 2, &descriptorSet[0], 0, NULL); |
| 5394 | vkCmdBindDescriptorSets( |
| 5395 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5396 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
| 5397 | m_errorMonitor->SetDesiredFailureMsg( |
| 5398 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5399 | " uses set #0 but that set is not bound."); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5400 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5401 | m_errorMonitor->VerifyFound(); |
| 5402 | |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 5403 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_bad_set0, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5404 | // 2. Error due to bound set not being compatible with PSO's |
| 5405 | // VkPipelineLayout (diff stageFlags in this case) |
| 5406 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5407 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 5408 | 2, &descriptorSet[0], 0, NULL); |
| 5409 | m_errorMonitor->SetDesiredFailureMsg( |
| 5410 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5411 | " bound as set #0 is not compatible with "); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5412 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5413 | m_errorMonitor->VerifyFound(); |
| 5414 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5415 | // Remaining clean-up |
| 5416 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_fs_only, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5417 | for (uint32_t i = 0; i < NUM_LAYOUTS; ++i) { |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5418 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout[i], NULL); |
| 5419 | } |
| 5420 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout_fs_only, NULL); |
Tobin Ehlis | 9bfd449 | 2016-05-05 15:09:11 -0600 | [diff] [blame] | 5421 | vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &ds0_fs_only); |
| 5422 | vkFreeDescriptorSets(m_device->device(), ds_pool, NUM_SETS, descriptorSet); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5423 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5424 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5425 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 5426 | } |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5427 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5428 | TEST_F(VkLayerTest, NoBeginCommandBuffer) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5429 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5430 | m_errorMonitor->SetDesiredFailureMsg( |
| 5431 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5432 | "You must call vkBeginCommandBuffer() before this call to "); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5433 | |
| 5434 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5435 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5436 | // Call EndCommandBuffer() w/o calling BeginCommandBuffer() |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5437 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5438 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5439 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5440 | } |
| 5441 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5442 | TEST_F(VkLayerTest, SecondaryCommandBufferNullRenderpass) { |
| 5443 | VkResult err; |
| 5444 | VkCommandBuffer draw_cmd; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5445 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5446 | m_errorMonitor->SetDesiredFailureMsg( |
| 5447 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 61b36f3 | 2015-12-16 08:19:42 -0700 | [diff] [blame] | 5448 | " must specify a valid renderpass parameter."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5449 | |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 5450 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 5451 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5452 | VkCommandBufferAllocateInfo cmd = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5453 | cmd.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 5454 | cmd.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5455 | cmd.commandPool = m_commandPool; |
| 5456 | cmd.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5457 | cmd.commandBufferCount = 1; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 5458 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5459 | err = vkAllocateCommandBuffers(m_device->device(), &cmd, &draw_cmd); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5460 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 5461 | |
| 5462 | // Force the failure by not setting the Renderpass and Framebuffer fields |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5463 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5464 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5465 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 5466 | cmd_buf_info.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5467 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT | |
| 5468 | VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5469 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 5470 | |
| 5471 | // The error should be caught by validation of the BeginCommandBuffer call |
| 5472 | vkBeginCommandBuffer(draw_cmd, &cmd_buf_info); |
| 5473 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5474 | m_errorMonitor->VerifyFound(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5475 | vkFreeCommandBuffers(m_device->device(), m_commandPool, 1, &draw_cmd); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 5476 | } |
| 5477 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5478 | TEST_F(VkLayerTest, CommandBufferResetErrors) { |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5479 | // Cause error due to Begin while recording CB |
| 5480 | // Then cause 2 errors for attempting to reset CB w/o having |
| 5481 | // VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT set for the pool from |
| 5482 | // which CBs were allocated. Note that this bit is off by default. |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5483 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5484 | "Cannot call Begin on CB"); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5485 | |
| 5486 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5487 | |
| 5488 | // Calls AllocateCommandBuffers |
| 5489 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
| 5490 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5491 | // Force the failure by setting the Renderpass and Framebuffer fields with |
| 5492 | // (fake) data |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5493 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5494 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5495 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 5496 | cmd_buf_info.pNext = NULL; |
| 5497 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5498 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5499 | |
| 5500 | // Begin CB to transition to recording state |
| 5501 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
| 5502 | // Can't re-begin. This should trigger error |
| 5503 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5504 | m_errorMonitor->VerifyFound(); |
| 5505 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5506 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5507 | "Attempt to reset command buffer "); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5508 | VkCommandBufferResetFlags flags = 0; // Don't care about flags for this test |
| 5509 | // Reset attempt will trigger error due to incorrect CommandPool state |
| 5510 | vkResetCommandBuffer(commandBuffer.GetBufferHandle(), flags); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5511 | m_errorMonitor->VerifyFound(); |
| 5512 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5513 | m_errorMonitor->SetDesiredFailureMsg( |
| 5514 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5515 | " attempts to implicitly reset cmdBuffer created from "); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5516 | // Transition CB to RECORDED state |
| 5517 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
| 5518 | // Now attempting to Begin will implicitly reset, which triggers error |
| 5519 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5520 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5521 | } |
| 5522 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5523 | TEST_F(VkLayerTest, InvalidPipelineCreateState) { |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5524 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5525 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5526 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5527 | m_errorMonitor->SetDesiredFailureMsg( |
| 5528 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5529 | "Invalid Pipeline CreateInfo State: Vtx Shader required"); |
| 5530 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5531 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 5532 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 5533 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5534 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5535 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5536 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5537 | |
| 5538 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5539 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5540 | ds_pool_ci.pNext = NULL; |
| 5541 | ds_pool_ci.maxSets = 1; |
| 5542 | ds_pool_ci.poolSizeCount = 1; |
| 5543 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 5544 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5545 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5546 | err = |
| 5547 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5548 | ASSERT_VK_SUCCESS(err); |
| 5549 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5550 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5551 | dsl_binding.binding = 0; |
| 5552 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5553 | dsl_binding.descriptorCount = 1; |
| 5554 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5555 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5556 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5557 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5558 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5559 | ds_layout_ci.pNext = NULL; |
| 5560 | ds_layout_ci.bindingCount = 1; |
| 5561 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5562 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5563 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5564 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5565 | &ds_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5566 | ASSERT_VK_SUCCESS(err); |
| 5567 | |
| 5568 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5569 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5570 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5571 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5572 | alloc_info.descriptorPool = ds_pool; |
| 5573 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5574 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5575 | &descriptorSet); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5576 | ASSERT_VK_SUCCESS(err); |
| 5577 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5578 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5579 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5580 | pipeline_layout_ci.setLayoutCount = 1; |
| 5581 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5582 | |
| 5583 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5584 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5585 | &pipeline_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5586 | ASSERT_VK_SUCCESS(err); |
| 5587 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5588 | VkViewport vp = {}; // Just need dummy vp to point to |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5589 | VkRect2D sc = {}; // dummy scissor to point to |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5590 | |
| 5591 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5592 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 5593 | vp_state_ci.scissorCount = 1; |
| 5594 | vp_state_ci.pScissors = ≻ |
| 5595 | vp_state_ci.viewportCount = 1; |
| 5596 | vp_state_ci.pViewports = &vp; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5597 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 5598 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 5599 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 5600 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 5601 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 5602 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 5603 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 5604 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 5605 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 5606 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5607 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5608 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 5609 | gp_ci.pViewportState = &vp_state_ci; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 5610 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5611 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 5612 | gp_ci.layout = pipeline_layout; |
| 5613 | gp_ci.renderPass = renderPass(); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5614 | |
| 5615 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5616 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 5617 | pc_ci.initialDataSize = 0; |
| 5618 | pc_ci.pInitialData = 0; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5619 | |
| 5620 | VkPipeline pipeline; |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 5621 | VkPipelineCache pipelineCache; |
| 5622 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5623 | err = |
| 5624 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 5625 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5626 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 5627 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 5628 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5629 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5630 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5631 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 5632 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5633 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5634 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5635 | } |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5636 | /*// TODO : This test should be good, but needs Tess support in compiler to run |
| 5637 | TEST_F(VkLayerTest, InvalidPatchControlPoints) |
| 5638 | { |
| 5639 | // Attempt to Create Gfx Pipeline w/o a VS |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5640 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5641 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5642 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5643 | "Invalid Pipeline CreateInfo State: VK_PRIMITIVE_TOPOLOGY_PATCH |
| 5644 | primitive "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5645 | |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5646 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5647 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5648 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5649 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5650 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5651 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5652 | |
| 5653 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 5654 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5655 | ds_pool_ci.pNext = NULL; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5656 | ds_pool_ci.poolSizeCount = 1; |
| 5657 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5658 | |
| 5659 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5660 | err = vkCreateDescriptorPool(m_device->device(), |
| 5661 | 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] | 5662 | ASSERT_VK_SUCCESS(err); |
| 5663 | |
| 5664 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5665 | dsl_binding.binding = 0; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5666 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 5667 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5668 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5669 | dsl_binding.pImmutableSamplers = NULL; |
| 5670 | |
| 5671 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5672 | ds_layout_ci.sType = |
| 5673 | VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5674 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5675 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 5676 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5677 | |
| 5678 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5679 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5680 | &ds_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5681 | ASSERT_VK_SUCCESS(err); |
| 5682 | |
| 5683 | VkDescriptorSet descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5684 | err = vkAllocateDescriptorSets(m_device->device(), ds_pool, |
| 5685 | VK_DESCRIPTOR_SET_USAGE_NON_FREE, 1, &ds_layout, &descriptorSet); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5686 | ASSERT_VK_SUCCESS(err); |
| 5687 | |
| 5688 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5689 | pipeline_layout_ci.sType = |
| 5690 | VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5691 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5692 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5693 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 5694 | |
| 5695 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5696 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5697 | &pipeline_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5698 | ASSERT_VK_SUCCESS(err); |
| 5699 | |
| 5700 | VkPipelineShaderStageCreateInfo shaderStages[3]; |
| 5701 | memset(&shaderStages, 0, 3 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 5702 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5703 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, |
| 5704 | this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5705 | // 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] | 5706 | VkShaderObj |
| 5707 | tc(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, |
| 5708 | this); |
| 5709 | VkShaderObj |
| 5710 | te(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, |
| 5711 | this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5712 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5713 | shaderStages[0].sType = |
| 5714 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5715 | shaderStages[0].stage = VK_SHADER_STAGE_VERTEX_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5716 | shaderStages[0].shader = vs.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5717 | shaderStages[1].sType = |
| 5718 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5719 | shaderStages[1].stage = VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5720 | shaderStages[1].shader = tc.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5721 | shaderStages[2].sType = |
| 5722 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5723 | shaderStages[2].stage = VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5724 | shaderStages[2].shader = te.handle(); |
| 5725 | |
| 5726 | VkPipelineInputAssemblyStateCreateInfo iaCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5727 | iaCI.sType = |
| 5728 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
Chia-I Wu | 515eb8f | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5729 | iaCI.topology = VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5730 | |
| 5731 | VkPipelineTessellationStateCreateInfo tsCI = {}; |
| 5732 | tsCI.sType = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO; |
| 5733 | tsCI.patchControlPoints = 0; // This will cause an error |
| 5734 | |
| 5735 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 5736 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 5737 | gp_ci.pNext = NULL; |
| 5738 | gp_ci.stageCount = 3; |
| 5739 | gp_ci.pStages = shaderStages; |
| 5740 | gp_ci.pVertexInputState = NULL; |
| 5741 | gp_ci.pInputAssemblyState = &iaCI; |
| 5742 | gp_ci.pTessellationState = &tsCI; |
| 5743 | gp_ci.pViewportState = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5744 | gp_ci.pRasterizationState = NULL; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5745 | gp_ci.pMultisampleState = NULL; |
| 5746 | gp_ci.pDepthStencilState = NULL; |
| 5747 | gp_ci.pColorBlendState = NULL; |
| 5748 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 5749 | gp_ci.layout = pipeline_layout; |
| 5750 | gp_ci.renderPass = renderPass(); |
| 5751 | |
| 5752 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 5753 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 5754 | pc_ci.pNext = NULL; |
| 5755 | pc_ci.initialSize = 0; |
| 5756 | pc_ci.initialData = 0; |
| 5757 | pc_ci.maxSize = 0; |
| 5758 | |
| 5759 | VkPipeline pipeline; |
| 5760 | VkPipelineCache pipelineCache; |
| 5761 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5762 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, |
| 5763 | &pipelineCache); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5764 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5765 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 5766 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5767 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5768 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5769 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5770 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 5771 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5772 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5773 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5774 | } |
| 5775 | */ |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5776 | // Set scissor and viewport counts to different numbers |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5777 | TEST_F(VkLayerTest, PSOViewportScissorCountMismatch) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5778 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5779 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5780 | m_errorMonitor->SetDesiredFailureMsg( |
| 5781 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5782 | "Gfx Pipeline viewport count (1) must match scissor count (0)."); |
| 5783 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5784 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5785 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5786 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5787 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5788 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5789 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5790 | |
| 5791 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5792 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5793 | ds_pool_ci.maxSets = 1; |
| 5794 | ds_pool_ci.poolSizeCount = 1; |
| 5795 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5796 | |
| 5797 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5798 | err = |
| 5799 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5800 | ASSERT_VK_SUCCESS(err); |
| 5801 | |
| 5802 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5803 | dsl_binding.binding = 0; |
| 5804 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5805 | dsl_binding.descriptorCount = 1; |
| 5806 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5807 | |
| 5808 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5809 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5810 | ds_layout_ci.bindingCount = 1; |
| 5811 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5812 | |
| 5813 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5814 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5815 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5816 | ASSERT_VK_SUCCESS(err); |
| 5817 | |
| 5818 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5819 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5820 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5821 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5822 | alloc_info.descriptorPool = ds_pool; |
| 5823 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5824 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5825 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5826 | ASSERT_VK_SUCCESS(err); |
| 5827 | |
| 5828 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5829 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5830 | pipeline_layout_ci.setLayoutCount = 1; |
| 5831 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5832 | |
| 5833 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5834 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5835 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5836 | ASSERT_VK_SUCCESS(err); |
| 5837 | |
| 5838 | VkViewport vp = {}; // Just need dummy vp to point to |
| 5839 | |
| 5840 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5841 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 5842 | vp_state_ci.scissorCount = 0; |
| 5843 | vp_state_ci.viewportCount = 1; // Count mismatch should cause error |
| 5844 | vp_state_ci.pViewports = &vp; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5845 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 5846 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 5847 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 5848 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 5849 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 5850 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 5851 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 5852 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 5853 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 5854 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 5855 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5856 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5857 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5858 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 5859 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5860 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 5861 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 5862 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5863 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5864 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 5865 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5866 | |
| 5867 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5868 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 5869 | gp_ci.stageCount = 2; |
| 5870 | gp_ci.pStages = shaderStages; |
| 5871 | gp_ci.pViewportState = &vp_state_ci; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 5872 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5873 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 5874 | gp_ci.layout = pipeline_layout; |
| 5875 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5876 | |
| 5877 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5878 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5879 | |
| 5880 | VkPipeline pipeline; |
| 5881 | VkPipelineCache pipelineCache; |
| 5882 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5883 | err = |
| 5884 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5885 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5886 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 5887 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5888 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5889 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5890 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5891 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 5892 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5893 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5894 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5895 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5896 | // Don't set viewport state in PSO. This is an error b/c we always need this |
| 5897 | // state |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 5898 | // 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] | 5899 | TEST_F(VkLayerTest, PSOViewportStateNotSet) { |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5900 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5901 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5902 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5903 | m_errorMonitor->SetDesiredFailureMsg( |
| 5904 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5905 | "Gfx Pipeline pViewportState is null. Even if "); |
| 5906 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5907 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5908 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5909 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5910 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5911 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5912 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5913 | |
| 5914 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5915 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5916 | ds_pool_ci.maxSets = 1; |
| 5917 | ds_pool_ci.poolSizeCount = 1; |
| 5918 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5919 | |
| 5920 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5921 | err = |
| 5922 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5923 | ASSERT_VK_SUCCESS(err); |
| 5924 | |
| 5925 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5926 | dsl_binding.binding = 0; |
| 5927 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5928 | dsl_binding.descriptorCount = 1; |
| 5929 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5930 | |
| 5931 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5932 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5933 | ds_layout_ci.bindingCount = 1; |
| 5934 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5935 | |
| 5936 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5937 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5938 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5939 | ASSERT_VK_SUCCESS(err); |
| 5940 | |
| 5941 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5942 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5943 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5944 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5945 | alloc_info.descriptorPool = ds_pool; |
| 5946 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5947 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5948 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5949 | ASSERT_VK_SUCCESS(err); |
| 5950 | |
| 5951 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5952 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5953 | pipeline_layout_ci.setLayoutCount = 1; |
| 5954 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5955 | |
| 5956 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5957 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5958 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5959 | ASSERT_VK_SUCCESS(err); |
| 5960 | |
| 5961 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 5962 | // Set scissor as dynamic to avoid second error |
| 5963 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5964 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 5965 | dyn_state_ci.dynamicStateCount = 1; |
| 5966 | dyn_state_ci.pDynamicStates = &sc_state; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5967 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 5968 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5969 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5970 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5971 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 5972 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5973 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 5974 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 5975 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5976 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5977 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 5978 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5979 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 5980 | |
| 5981 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 5982 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 5983 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 5984 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 5985 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 5986 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 5987 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 5988 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 5989 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5990 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5991 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 5992 | gp_ci.stageCount = 2; |
| 5993 | gp_ci.pStages = shaderStages; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 5994 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5995 | gp_ci.pViewportState = NULL; // Not setting VP state w/o dynamic vp state |
| 5996 | // should cause validation error |
| 5997 | gp_ci.pDynamicState = &dyn_state_ci; |
| 5998 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 5999 | gp_ci.layout = pipeline_layout; |
| 6000 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6001 | |
| 6002 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6003 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6004 | |
| 6005 | VkPipeline pipeline; |
| 6006 | VkPipelineCache pipelineCache; |
| 6007 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6008 | err = |
| 6009 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6010 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6011 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6012 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6013 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6014 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6015 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6016 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 6017 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6018 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6019 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6020 | } |
| 6021 | // Create PSO w/o non-zero viewportCount but no viewport data |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6022 | // Then run second test where dynamic scissor count doesn't match PSO scissor |
| 6023 | // count |
| 6024 | TEST_F(VkLayerTest, PSOViewportCountWithoutDataAndDynScissorMismatch) { |
| 6025 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6026 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6027 | m_errorMonitor->SetDesiredFailureMsg( |
| 6028 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6029 | "Gfx Pipeline viewportCount is 1, but pViewports is NULL. "); |
| 6030 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6031 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6032 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6033 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6034 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6035 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6036 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6037 | |
| 6038 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6039 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6040 | ds_pool_ci.maxSets = 1; |
| 6041 | ds_pool_ci.poolSizeCount = 1; |
| 6042 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -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 | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6047 | ASSERT_VK_SUCCESS(err); |
| 6048 | |
| 6049 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6050 | dsl_binding.binding = 0; |
| 6051 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6052 | dsl_binding.descriptorCount = 1; |
| 6053 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6054 | |
| 6055 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6056 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6057 | ds_layout_ci.bindingCount = 1; |
| 6058 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6059 | |
| 6060 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6061 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6062 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6063 | ASSERT_VK_SUCCESS(err); |
| 6064 | |
| 6065 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6066 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6067 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6068 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 6069 | alloc_info.descriptorPool = ds_pool; |
| 6070 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6071 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6072 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6073 | ASSERT_VK_SUCCESS(err); |
| 6074 | |
| 6075 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6076 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6077 | pipeline_layout_ci.setLayoutCount = 1; |
| 6078 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6079 | |
| 6080 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6081 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6082 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6083 | ASSERT_VK_SUCCESS(err); |
| 6084 | |
| 6085 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6086 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 6087 | vp_state_ci.viewportCount = 1; |
| 6088 | vp_state_ci.pViewports = NULL; // Null vp w/ count of 1 should cause error |
| 6089 | vp_state_ci.scissorCount = 1; |
| 6090 | vp_state_ci.pScissors = |
| 6091 | NULL; // Scissor is dynamic (below) so this won't cause error |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6092 | |
| 6093 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 6094 | // Set scissor as dynamic to avoid that error |
| 6095 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6096 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 6097 | dyn_state_ci.dynamicStateCount = 1; |
| 6098 | dyn_state_ci.pDynamicStates = &sc_state; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6099 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 6100 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6101 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6102 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6103 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6104 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6105 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6106 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6107 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6108 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 6109 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 6110 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6111 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 6112 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 6113 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 6114 | vi_ci.pNext = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6115 | vi_ci.vertexBindingDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 6116 | vi_ci.pVertexBindingDescriptions = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6117 | vi_ci.vertexAttributeDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 6118 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 6119 | |
| 6120 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 6121 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 6122 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 6123 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6124 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6125 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 6126 | rs_ci.pNext = nullptr; |
| 6127 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6128 | VkPipelineColorBlendAttachmentState att = {}; |
| 6129 | att.blendEnable = VK_FALSE; |
| 6130 | att.colorWriteMask = 0xf; |
| 6131 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 6132 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 6133 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 6134 | cb_ci.pNext = nullptr; |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6135 | cb_ci.attachmentCount = 1; |
| 6136 | cb_ci.pAttachments = &att; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 6137 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6138 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6139 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 6140 | gp_ci.stageCount = 2; |
| 6141 | gp_ci.pStages = shaderStages; |
| 6142 | gp_ci.pVertexInputState = &vi_ci; |
| 6143 | gp_ci.pInputAssemblyState = &ia_ci; |
| 6144 | gp_ci.pViewportState = &vp_state_ci; |
| 6145 | gp_ci.pRasterizationState = &rs_ci; |
| 6146 | gp_ci.pColorBlendState = &cb_ci; |
| 6147 | gp_ci.pDynamicState = &dyn_state_ci; |
| 6148 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 6149 | gp_ci.layout = pipeline_layout; |
| 6150 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6151 | |
| 6152 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6153 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6154 | |
| 6155 | VkPipeline pipeline; |
| 6156 | VkPipelineCache pipelineCache; |
| 6157 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6158 | err = |
| 6159 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6160 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6161 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6162 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6163 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6164 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6165 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6166 | // 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] | 6167 | // First need to successfully create the PSO from above by setting |
| 6168 | // pViewports |
| 6169 | m_errorMonitor->SetDesiredFailureMsg( |
| 6170 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6171 | "Dynamic scissorCount from vkCmdSetScissor() is 2, but PSO " |
| 6172 | "scissorCount is 1. These counts must match."); |
| 6173 | |
| 6174 | VkViewport vp = {}; // Just need dummy vp to point to |
| 6175 | vp_state_ci.pViewports = &vp; |
| 6176 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6177 | &gp_ci, NULL, &pipeline); |
| 6178 | ASSERT_VK_SUCCESS(err); |
| 6179 | BeginCommandBuffer(); |
| 6180 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 6181 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
| 6182 | VkRect2D scissors[2] = {}; // don't care about data |
| 6183 | // Count of 2 doesn't match PSO count of 1 |
| 6184 | vkCmdSetScissor(m_commandBuffer->GetBufferHandle(), 0, 2, scissors); |
| 6185 | Draw(1, 0, 0, 0); |
| 6186 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6187 | m_errorMonitor->VerifyFound(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6188 | |
| 6189 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 6190 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6191 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6192 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 6193 | } |
| 6194 | // Create PSO w/o non-zero scissorCount but no scissor data |
| 6195 | // Then run second test where dynamic viewportCount doesn't match PSO |
| 6196 | // viewportCount |
| 6197 | TEST_F(VkLayerTest, PSOScissorCountWithoutDataAndDynViewportMismatch) { |
| 6198 | VkResult err; |
| 6199 | |
| 6200 | m_errorMonitor->SetDesiredFailureMsg( |
| 6201 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6202 | "Gfx Pipeline scissorCount is 1, but pScissors is NULL. "); |
| 6203 | |
| 6204 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6205 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6206 | |
| 6207 | VkDescriptorPoolSize ds_type_count = {}; |
| 6208 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6209 | ds_type_count.descriptorCount = 1; |
| 6210 | |
| 6211 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 6212 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6213 | ds_pool_ci.maxSets = 1; |
| 6214 | ds_pool_ci.poolSizeCount = 1; |
| 6215 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 6216 | |
| 6217 | VkDescriptorPool ds_pool; |
| 6218 | err = |
| 6219 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 6220 | ASSERT_VK_SUCCESS(err); |
| 6221 | |
| 6222 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 6223 | dsl_binding.binding = 0; |
| 6224 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6225 | dsl_binding.descriptorCount = 1; |
| 6226 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6227 | |
| 6228 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 6229 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6230 | ds_layout_ci.bindingCount = 1; |
| 6231 | ds_layout_ci.pBindings = &dsl_binding; |
| 6232 | |
| 6233 | VkDescriptorSetLayout ds_layout; |
| 6234 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6235 | &ds_layout); |
| 6236 | ASSERT_VK_SUCCESS(err); |
| 6237 | |
| 6238 | VkDescriptorSet descriptorSet; |
| 6239 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 6240 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 6241 | alloc_info.descriptorSetCount = 1; |
| 6242 | alloc_info.descriptorPool = ds_pool; |
| 6243 | alloc_info.pSetLayouts = &ds_layout; |
| 6244 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6245 | &descriptorSet); |
| 6246 | ASSERT_VK_SUCCESS(err); |
| 6247 | |
| 6248 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 6249 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6250 | pipeline_layout_ci.setLayoutCount = 1; |
| 6251 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 6252 | |
| 6253 | VkPipelineLayout pipeline_layout; |
| 6254 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6255 | &pipeline_layout); |
| 6256 | ASSERT_VK_SUCCESS(err); |
| 6257 | |
| 6258 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 6259 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 6260 | vp_state_ci.scissorCount = 1; |
| 6261 | vp_state_ci.pScissors = |
| 6262 | NULL; // Null scissor w/ count of 1 should cause error |
| 6263 | vp_state_ci.viewportCount = 1; |
| 6264 | vp_state_ci.pViewports = |
| 6265 | NULL; // vp is dynamic (below) so this won't cause error |
| 6266 | |
| 6267 | VkDynamicState vp_state = VK_DYNAMIC_STATE_VIEWPORT; |
| 6268 | // Set scissor as dynamic to avoid that error |
| 6269 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 6270 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 6271 | dyn_state_ci.dynamicStateCount = 1; |
| 6272 | dyn_state_ci.pDynamicStates = &vp_state; |
| 6273 | |
| 6274 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 6275 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 6276 | |
| 6277 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6278 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6279 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6280 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6281 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6282 | // but add it to be able to run on more devices |
| 6283 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 6284 | shaderStages[1] = fs.GetStageCreateInfo(); |
| 6285 | |
| 6286 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 6287 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 6288 | vi_ci.pNext = nullptr; |
| 6289 | vi_ci.vertexBindingDescriptionCount = 0; |
| 6290 | vi_ci.pVertexBindingDescriptions = nullptr; |
| 6291 | vi_ci.vertexAttributeDescriptionCount = 0; |
| 6292 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 6293 | |
| 6294 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 6295 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 6296 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 6297 | |
| 6298 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
| 6299 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 6300 | rs_ci.pNext = nullptr; |
| 6301 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6302 | VkPipelineColorBlendAttachmentState att = {}; |
| 6303 | att.blendEnable = VK_FALSE; |
| 6304 | att.colorWriteMask = 0xf; |
| 6305 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6306 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 6307 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 6308 | cb_ci.pNext = nullptr; |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6309 | cb_ci.attachmentCount = 1; |
| 6310 | cb_ci.pAttachments = &att; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6311 | |
| 6312 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 6313 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 6314 | gp_ci.stageCount = 2; |
| 6315 | gp_ci.pStages = shaderStages; |
| 6316 | gp_ci.pVertexInputState = &vi_ci; |
| 6317 | gp_ci.pInputAssemblyState = &ia_ci; |
| 6318 | gp_ci.pViewportState = &vp_state_ci; |
| 6319 | gp_ci.pRasterizationState = &rs_ci; |
| 6320 | gp_ci.pColorBlendState = &cb_ci; |
| 6321 | gp_ci.pDynamicState = &dyn_state_ci; |
| 6322 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 6323 | gp_ci.layout = pipeline_layout; |
| 6324 | gp_ci.renderPass = renderPass(); |
| 6325 | |
| 6326 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 6327 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 6328 | |
| 6329 | VkPipeline pipeline; |
| 6330 | VkPipelineCache pipelineCache; |
| 6331 | |
| 6332 | err = |
| 6333 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 6334 | ASSERT_VK_SUCCESS(err); |
| 6335 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6336 | &gp_ci, NULL, &pipeline); |
| 6337 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6338 | m_errorMonitor->VerifyFound(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6339 | |
| 6340 | // Now hit second fail case where we set scissor w/ different count than PSO |
| 6341 | // First need to successfully create the PSO from above by setting |
| 6342 | // pViewports |
| 6343 | m_errorMonitor->SetDesiredFailureMsg( |
| 6344 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6345 | "Dynamic viewportCount from vkCmdSetViewport() is 2, but PSO " |
| 6346 | "viewportCount is 1. These counts must match."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6347 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6348 | VkRect2D sc = {}; // Just need dummy vp to point to |
| 6349 | vp_state_ci.pScissors = ≻ |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6350 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6351 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6352 | ASSERT_VK_SUCCESS(err); |
| 6353 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6354 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 6355 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6356 | VkViewport viewports[2] = {}; // don't care about data |
| 6357 | // Count of 2 doesn't match PSO count of 1 |
Jon Ashburn | 19d3bf1 | 2015-12-30 14:06:55 -0700 | [diff] [blame] | 6358 | vkCmdSetViewport(m_commandBuffer->GetBufferHandle(), 0, 2, viewports); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6359 | Draw(1, 0, 0, 0); |
| 6360 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6361 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6362 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6363 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 6364 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6365 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6366 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6367 | } |
| 6368 | |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6369 | TEST_F(VkLayerTest, PSOLineWidthInvalid) { |
| 6370 | VkResult err; |
| 6371 | |
| 6372 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 6373 | "Attempt to set lineWidth to -1"); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6374 | |
| 6375 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6376 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6377 | |
| 6378 | VkDescriptorPoolSize ds_type_count = {}; |
| 6379 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6380 | ds_type_count.descriptorCount = 1; |
| 6381 | |
| 6382 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 6383 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6384 | ds_pool_ci.maxSets = 1; |
| 6385 | ds_pool_ci.poolSizeCount = 1; |
| 6386 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 6387 | |
| 6388 | VkDescriptorPool ds_pool; |
| 6389 | err = |
| 6390 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 6391 | ASSERT_VK_SUCCESS(err); |
| 6392 | |
| 6393 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 6394 | dsl_binding.binding = 0; |
| 6395 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6396 | dsl_binding.descriptorCount = 1; |
| 6397 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6398 | |
| 6399 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 6400 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6401 | ds_layout_ci.bindingCount = 1; |
| 6402 | ds_layout_ci.pBindings = &dsl_binding; |
| 6403 | |
| 6404 | VkDescriptorSetLayout ds_layout; |
| 6405 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6406 | &ds_layout); |
| 6407 | ASSERT_VK_SUCCESS(err); |
| 6408 | |
| 6409 | VkDescriptorSet descriptorSet; |
| 6410 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 6411 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 6412 | alloc_info.descriptorSetCount = 1; |
| 6413 | alloc_info.descriptorPool = ds_pool; |
| 6414 | alloc_info.pSetLayouts = &ds_layout; |
| 6415 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6416 | &descriptorSet); |
| 6417 | ASSERT_VK_SUCCESS(err); |
| 6418 | |
| 6419 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 6420 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6421 | pipeline_layout_ci.setLayoutCount = 1; |
| 6422 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 6423 | |
| 6424 | VkPipelineLayout pipeline_layout; |
| 6425 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6426 | &pipeline_layout); |
| 6427 | ASSERT_VK_SUCCESS(err); |
| 6428 | |
| 6429 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 6430 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 6431 | vp_state_ci.scissorCount = 1; |
| 6432 | vp_state_ci.pScissors = NULL; |
| 6433 | vp_state_ci.viewportCount = 1; |
| 6434 | vp_state_ci.pViewports = NULL; |
| 6435 | |
| 6436 | VkDynamicState dynamic_states[3] = {VK_DYNAMIC_STATE_VIEWPORT, |
| 6437 | VK_DYNAMIC_STATE_SCISSOR, |
| 6438 | VK_DYNAMIC_STATE_LINE_WIDTH}; |
| 6439 | // Set scissor as dynamic to avoid that error |
| 6440 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 6441 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 6442 | dyn_state_ci.dynamicStateCount = 2; |
| 6443 | dyn_state_ci.pDynamicStates = dynamic_states; |
| 6444 | |
| 6445 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 6446 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 6447 | |
| 6448 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6449 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6450 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6451 | VK_SHADER_STAGE_FRAGMENT_BIT, |
| 6452 | this); // TODO - We shouldn't need a fragment shader |
| 6453 | // but add it to be able to run on more devices |
| 6454 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 6455 | shaderStages[1] = fs.GetStageCreateInfo(); |
| 6456 | |
| 6457 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 6458 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 6459 | vi_ci.pNext = nullptr; |
| 6460 | vi_ci.vertexBindingDescriptionCount = 0; |
| 6461 | vi_ci.pVertexBindingDescriptions = nullptr; |
| 6462 | vi_ci.vertexAttributeDescriptionCount = 0; |
| 6463 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 6464 | |
| 6465 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 6466 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 6467 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 6468 | |
| 6469 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
| 6470 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 6471 | rs_ci.pNext = nullptr; |
| 6472 | |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 6473 | // Check too low (line width of -1.0f). |
| 6474 | rs_ci.lineWidth = -1.0f; |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6475 | |
| 6476 | VkPipelineColorBlendAttachmentState att = {}; |
| 6477 | att.blendEnable = VK_FALSE; |
| 6478 | att.colorWriteMask = 0xf; |
| 6479 | |
| 6480 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 6481 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 6482 | cb_ci.pNext = nullptr; |
| 6483 | cb_ci.attachmentCount = 1; |
| 6484 | cb_ci.pAttachments = &att; |
| 6485 | |
| 6486 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 6487 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 6488 | gp_ci.stageCount = 2; |
| 6489 | gp_ci.pStages = shaderStages; |
| 6490 | gp_ci.pVertexInputState = &vi_ci; |
| 6491 | gp_ci.pInputAssemblyState = &ia_ci; |
| 6492 | gp_ci.pViewportState = &vp_state_ci; |
| 6493 | gp_ci.pRasterizationState = &rs_ci; |
| 6494 | gp_ci.pColorBlendState = &cb_ci; |
| 6495 | gp_ci.pDynamicState = &dyn_state_ci; |
| 6496 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 6497 | gp_ci.layout = pipeline_layout; |
| 6498 | gp_ci.renderPass = renderPass(); |
| 6499 | |
| 6500 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 6501 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 6502 | |
| 6503 | VkPipeline pipeline; |
| 6504 | VkPipelineCache pipelineCache; |
| 6505 | |
| 6506 | err = |
| 6507 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 6508 | ASSERT_VK_SUCCESS(err); |
| 6509 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6510 | &gp_ci, NULL, &pipeline); |
| 6511 | |
| 6512 | m_errorMonitor->VerifyFound(); |
| 6513 | |
| 6514 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6515 | "Attempt to set lineWidth to 65536"); |
| 6516 | |
| 6517 | // Check too high (line width of 65536.0f). |
| 6518 | rs_ci.lineWidth = 65536.0f; |
| 6519 | |
| 6520 | err = |
| 6521 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 6522 | ASSERT_VK_SUCCESS(err); |
| 6523 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6524 | &gp_ci, NULL, &pipeline); |
| 6525 | |
| 6526 | m_errorMonitor->VerifyFound(); |
| 6527 | |
| 6528 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 6529 | "Attempt to set lineWidth to -1"); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6530 | |
| 6531 | dyn_state_ci.dynamicStateCount = 3; |
| 6532 | |
| 6533 | rs_ci.lineWidth = 1.0f; |
| 6534 | |
| 6535 | err = |
| 6536 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 6537 | ASSERT_VK_SUCCESS(err); |
| 6538 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6539 | &gp_ci, NULL, &pipeline); |
| 6540 | BeginCommandBuffer(); |
| 6541 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 6542 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
| 6543 | |
| 6544 | // Check too low with dynamic setting. |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 6545 | vkCmdSetLineWidth(m_commandBuffer->GetBufferHandle(), -1.0f); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6546 | m_errorMonitor->VerifyFound(); |
| 6547 | |
| 6548 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6549 | "Attempt to set lineWidth to 65536"); |
| 6550 | |
| 6551 | // Check too high with dynamic setting. |
| 6552 | vkCmdSetLineWidth(m_commandBuffer->GetBufferHandle(), 65536.0f); |
| 6553 | m_errorMonitor->VerifyFound(); |
| 6554 | EndCommandBuffer(); |
| 6555 | |
| 6556 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 6557 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6558 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6559 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 6560 | } |
| 6561 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6562 | TEST_F(VkLayerTest, NullRenderPass) { |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 6563 | // Bind a NULL RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6564 | m_errorMonitor->SetDesiredFailureMsg( |
| 6565 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6566 | "You cannot use a NULL RenderPass object in vkCmdBeginRenderPass()"); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 6567 | |
| 6568 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6569 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 6570 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 6571 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6572 | // Don't care about RenderPass handle b/c error should be flagged before |
| 6573 | // that |
| 6574 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), NULL, |
| 6575 | VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 6576 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6577 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 6578 | } |
| 6579 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6580 | TEST_F(VkLayerTest, RenderPassWithinRenderPass) { |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6581 | // Bind a BeginRenderPass within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6582 | m_errorMonitor->SetDesiredFailureMsg( |
| 6583 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6584 | "It is invalid to issue this call inside an active render pass"); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6585 | |
| 6586 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6587 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6588 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 6589 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6590 | // Just create a dummy Renderpass that's non-NULL so we can get to the |
| 6591 | // proper error |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6592 | VkRenderPassBeginInfo rp_begin = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6593 | rp_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; |
| 6594 | rp_begin.pNext = NULL; |
| 6595 | rp_begin.renderPass = renderPass(); |
| 6596 | rp_begin.framebuffer = framebuffer(); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6597 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6598 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &rp_begin, |
| 6599 | VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6600 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6601 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 6602 | } |
| 6603 | |
Cody Northrop | 3bb4d96 | 2016-05-09 16:15:57 -0600 | [diff] [blame] | 6604 | TEST_F(VkLayerTest, EndCommandBufferWithinRenderPass) { |
| 6605 | |
| 6606 | TEST_DESCRIPTION("End a command buffer with an active render pass"); |
| 6607 | |
| 6608 | m_errorMonitor->SetDesiredFailureMsg( |
| 6609 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6610 | "It is invalid to issue this call inside an active render pass"); |
| 6611 | |
| 6612 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6613 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6614 | |
| 6615 | // The framework's BeginCommandBuffer calls CreateRenderPass |
| 6616 | BeginCommandBuffer(); |
| 6617 | |
| 6618 | // Call directly into vkEndCommandBuffer instead of the |
| 6619 | // the framework's EndCommandBuffer, which inserts a |
| 6620 | // vkEndRenderPass |
| 6621 | vkEndCommandBuffer(m_commandBuffer->GetBufferHandle()); |
| 6622 | |
| 6623 | m_errorMonitor->VerifyFound(); |
| 6624 | |
| 6625 | // TODO: Add test for VK_COMMAND_BUFFER_LEVEL_SECONDARY |
| 6626 | // TODO: Add test for VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT |
| 6627 | } |
| 6628 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6629 | TEST_F(VkLayerTest, FillBufferWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6630 | // Call CmdFillBuffer within an active renderpass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6631 | m_errorMonitor->SetDesiredFailureMsg( |
| 6632 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6633 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6634 | |
| 6635 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6636 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6637 | |
| 6638 | // Renderpass is started here |
| 6639 | BeginCommandBuffer(); |
| 6640 | |
| 6641 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6642 | vk_testing::Buffer dstBuffer; |
| 6643 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6644 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6645 | m_commandBuffer->FillBuffer(dstBuffer.handle(), 0, 4, 0x11111111); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6646 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6647 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6648 | } |
| 6649 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6650 | TEST_F(VkLayerTest, UpdateBufferWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6651 | // Call CmdUpdateBuffer within an active renderpass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6652 | m_errorMonitor->SetDesiredFailureMsg( |
| 6653 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6654 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6655 | |
| 6656 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6657 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6658 | |
| 6659 | // Renderpass is started here |
| 6660 | BeginCommandBuffer(); |
| 6661 | |
| 6662 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6663 | vk_testing::Buffer dstBuffer; |
| 6664 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6665 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6666 | VkDeviceSize dstOffset = 0; |
| 6667 | VkDeviceSize dataSize = 1024; |
| 6668 | const uint32_t *pData = NULL; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6669 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6670 | vkCmdUpdateBuffer(m_commandBuffer->GetBufferHandle(), dstBuffer.handle(), |
| 6671 | dstOffset, dataSize, pData); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6672 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6673 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6674 | } |
| 6675 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6676 | TEST_F(VkLayerTest, ClearColorImageWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6677 | // Call CmdClearColorImage within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6678 | m_errorMonitor->SetDesiredFailureMsg( |
| 6679 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6680 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6681 | |
| 6682 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6683 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6684 | |
| 6685 | // Renderpass is started here |
| 6686 | BeginCommandBuffer(); |
| 6687 | |
Michael Lentine | 0a369f6 | 2016-02-03 16:51:46 -0600 | [diff] [blame] | 6688 | VkClearColorValue clear_color; |
| 6689 | memset(clear_color.uint32, 0, sizeof(uint32_t) * 4); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6690 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 6691 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6692 | const int32_t tex_width = 32; |
| 6693 | const int32_t tex_height = 32; |
| 6694 | VkImageCreateInfo image_create_info = {}; |
| 6695 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6696 | image_create_info.pNext = NULL; |
| 6697 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6698 | image_create_info.format = tex_format; |
| 6699 | image_create_info.extent.width = tex_width; |
| 6700 | image_create_info.extent.height = tex_height; |
| 6701 | image_create_info.extent.depth = 1; |
| 6702 | image_create_info.mipLevels = 1; |
| 6703 | image_create_info.arrayLayers = 1; |
| 6704 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 6705 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 6706 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6707 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6708 | vk_testing::Image dstImage; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6709 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 6710 | reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6711 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6712 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
| 6713 | image_create_info, VK_IMAGE_ASPECT_COLOR_BIT); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6714 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6715 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), dstImage.handle(), |
| 6716 | VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1, &range); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6717 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6718 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6719 | } |
| 6720 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6721 | TEST_F(VkLayerTest, ClearDepthStencilImageWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6722 | // Call CmdClearDepthStencilImage within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6723 | m_errorMonitor->SetDesiredFailureMsg( |
| 6724 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6725 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6726 | |
| 6727 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6728 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6729 | |
| 6730 | // Renderpass is started here |
| 6731 | BeginCommandBuffer(); |
| 6732 | |
| 6733 | VkClearDepthStencilValue clear_value = {0}; |
Dustin Graves | a2e5c94 | 2016-02-11 18:28:06 -0700 | [diff] [blame] | 6734 | VkMemoryPropertyFlags reqs = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6735 | VkImageCreateInfo image_create_info = vk_testing::Image::create_info(); |
| 6736 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6737 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 6738 | image_create_info.extent.width = 64; |
| 6739 | image_create_info.extent.height = 64; |
| 6740 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 6741 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6742 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6743 | vk_testing::Image dstImage; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6744 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 6745 | reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6746 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6747 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
| 6748 | image_create_info, VK_IMAGE_ASPECT_DEPTH_BIT); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6749 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6750 | vkCmdClearDepthStencilImage( |
| 6751 | m_commandBuffer->GetBufferHandle(), dstImage.handle(), |
| 6752 | VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, &clear_value, 1, |
| 6753 | &range); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6754 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6755 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6756 | } |
| 6757 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6758 | TEST_F(VkLayerTest, ClearColorAttachmentsOutsideRenderPass) { |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 6759 | // Call CmdClearAttachmentss outside of an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6760 | VkResult err; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6761 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6762 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6763 | "vkCmdClearAttachments: This call " |
| 6764 | "must be issued inside an active " |
| 6765 | "render pass"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6766 | |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6767 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6768 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6769 | |
| 6770 | // Start no RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6771 | err = m_commandBuffer->BeginCommandBuffer(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6772 | ASSERT_VK_SUCCESS(err); |
| 6773 | |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 6774 | VkClearAttachment color_attachment; |
| 6775 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 6776 | color_attachment.clearValue.color.float32[0] = 0; |
| 6777 | color_attachment.clearValue.color.float32[1] = 0; |
| 6778 | color_attachment.clearValue.color.float32[2] = 0; |
| 6779 | color_attachment.clearValue.color.float32[3] = 0; |
| 6780 | color_attachment.colorAttachment = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6781 | VkClearRect clear_rect = {{{0, 0}, {32, 32}}}; |
| 6782 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
| 6783 | &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6784 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6785 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6786 | } |
| 6787 | |
Karl Schultz | 9e66a29 | 2016-04-21 15:57:51 -0600 | [diff] [blame] | 6788 | TEST_F(VkLayerTest, BufferMemoryBarrierNoBuffer) { |
| 6789 | // Try to add a buffer memory barrier with no buffer. |
| 6790 | m_errorMonitor->SetDesiredFailureMsg( |
| 6791 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6792 | "required parameter pBufferMemoryBarriers[i].buffer specified as VK_NULL_HANDLE"); |
| 6793 | |
| 6794 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6795 | BeginCommandBuffer(); |
| 6796 | |
| 6797 | VkBufferMemoryBarrier buf_barrier = {}; |
| 6798 | buf_barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; |
| 6799 | buf_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 6800 | buf_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 6801 | buf_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 6802 | buf_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 6803 | buf_barrier.buffer = VK_NULL_HANDLE; |
| 6804 | buf_barrier.offset = 0; |
| 6805 | buf_barrier.size = VK_WHOLE_SIZE; |
| 6806 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6807 | VK_PIPELINE_STAGE_HOST_BIT, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, |
| 6808 | 0, 0, nullptr, 1, &buf_barrier, 0, nullptr); |
| 6809 | |
| 6810 | m_errorMonitor->VerifyFound(); |
| 6811 | } |
| 6812 | |
Tony Barbour | 7fd5c0f | 2016-05-03 16:11:53 -0600 | [diff] [blame] | 6813 | TEST_F(VkLayerTest, InvalidBarriers) { |
| 6814 | TEST_DESCRIPTION("A variety of ways to get VK_INVALID_BARRIER "); |
| 6815 | |
| 6816 | m_errorMonitor->SetDesiredFailureMsg( |
| 6817 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Barriers cannot be set during subpass"); |
| 6818 | |
| 6819 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6820 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6821 | |
| 6822 | VkMemoryBarrier mem_barrier = {}; |
| 6823 | mem_barrier.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER; |
| 6824 | mem_barrier.pNext = NULL; |
| 6825 | mem_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 6826 | mem_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 6827 | BeginCommandBuffer(); |
| 6828 | // BeginCommandBuffer() starts a render pass |
| 6829 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6830 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6831 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 1, |
| 6832 | &mem_barrier, 0, nullptr, 0, nullptr); |
| 6833 | m_errorMonitor->VerifyFound(); |
| 6834 | |
| 6835 | m_errorMonitor->SetDesiredFailureMsg( |
| 6836 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6837 | "Image Layout cannot be transitioned to UNDEFINED"); |
| 6838 | VkImageObj image(m_device); |
| 6839 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 6840 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
| 6841 | ASSERT_TRUE(image.initialized()); |
| 6842 | VkImageMemoryBarrier img_barrier = {}; |
| 6843 | img_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; |
| 6844 | img_barrier.pNext = NULL; |
| 6845 | img_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 6846 | img_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 6847 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 6848 | // New layout can't be UNDEFINED |
| 6849 | img_barrier.newLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 6850 | img_barrier.image = image.handle(); |
| 6851 | img_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 6852 | img_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 6853 | img_barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 6854 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 6855 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 6856 | img_barrier.subresourceRange.layerCount = 1; |
| 6857 | img_barrier.subresourceRange.levelCount = 1; |
| 6858 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6859 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6860 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 6861 | nullptr, 1, &img_barrier); |
| 6862 | m_errorMonitor->VerifyFound(); |
| 6863 | img_barrier.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 6864 | |
| 6865 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6866 | "Subresource must have the sum of the " |
| 6867 | "baseArrayLayer"); |
| 6868 | // baseArrayLayer + layerCount must be <= image's arrayLayers |
| 6869 | img_barrier.subresourceRange.baseArrayLayer = 1; |
| 6870 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6871 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6872 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 6873 | nullptr, 1, &img_barrier); |
| 6874 | m_errorMonitor->VerifyFound(); |
| 6875 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 6876 | |
| 6877 | m_errorMonitor->SetDesiredFailureMsg( |
| 6878 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6879 | "Subresource must have the sum of the baseMipLevel"); |
| 6880 | // baseMipLevel + levelCount must be <= image's mipLevels |
| 6881 | img_barrier.subresourceRange.baseMipLevel = 1; |
| 6882 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6883 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6884 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 6885 | nullptr, 1, &img_barrier); |
| 6886 | m_errorMonitor->VerifyFound(); |
| 6887 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 6888 | |
| 6889 | m_errorMonitor->SetDesiredFailureMsg( |
| 6890 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6891 | "Buffer Barriers cannot be used during a render pass"); |
| 6892 | vk_testing::Buffer buffer; |
| 6893 | buffer.init(*m_device, 256); |
| 6894 | VkBufferMemoryBarrier buf_barrier = {}; |
| 6895 | buf_barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; |
| 6896 | buf_barrier.pNext = NULL; |
| 6897 | buf_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 6898 | buf_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 6899 | buf_barrier.buffer = buffer.handle(); |
| 6900 | buf_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 6901 | buf_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 6902 | buf_barrier.offset = 0; |
| 6903 | buf_barrier.size = VK_WHOLE_SIZE; |
| 6904 | // Can't send buffer barrier during a render pass |
| 6905 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6906 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6907 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 6908 | &buf_barrier, 0, nullptr); |
| 6909 | m_errorMonitor->VerifyFound(); |
| 6910 | vkCmdEndRenderPass(m_commandBuffer->GetBufferHandle()); |
| 6911 | |
| 6912 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6913 | "which is not less than total size"); |
| 6914 | buf_barrier.offset = 257; |
| 6915 | // Offset greater than total size |
| 6916 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6917 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6918 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 6919 | &buf_barrier, 0, nullptr); |
| 6920 | m_errorMonitor->VerifyFound(); |
| 6921 | buf_barrier.offset = 0; |
| 6922 | |
| 6923 | m_errorMonitor->SetDesiredFailureMsg( |
| 6924 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "whose sum is greater than total size"); |
| 6925 | buf_barrier.size = 257; |
| 6926 | // Size greater than total size |
| 6927 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6928 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6929 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 6930 | &buf_barrier, 0, nullptr); |
| 6931 | m_errorMonitor->VerifyFound(); |
| 6932 | buf_barrier.size = VK_WHOLE_SIZE; |
| 6933 | |
| 6934 | m_errorMonitor->SetDesiredFailureMsg( |
| 6935 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6936 | "Image is a depth and stencil format and thus must " |
| 6937 | "have both VK_IMAGE_ASPECT_DEPTH_BIT and " |
| 6938 | "VK_IMAGE_ASPECT_STENCIL_BIT set."); |
| 6939 | VkDepthStencilObj ds_image(m_device); |
| 6940 | ds_image.Init(m_device, 128, 128, VK_FORMAT_D24_UNORM_S8_UINT); |
| 6941 | ASSERT_TRUE(ds_image.initialized()); |
| 6942 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 6943 | img_barrier.newLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; |
| 6944 | img_barrier.image = ds_image.handle(); |
| 6945 | // Leave aspectMask at COLOR on purpose |
| 6946 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6947 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6948 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 6949 | nullptr, 1, &img_barrier); |
| 6950 | m_errorMonitor->VerifyFound(); |
| 6951 | } |
| 6952 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6953 | TEST_F(VkLayerTest, IdxBufferAlignmentError) { |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 6954 | // Bind a BeginRenderPass within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6955 | VkResult err; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 6956 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6957 | m_errorMonitor->SetDesiredFailureMsg( |
| 6958 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6959 | "vkCmdBindIndexBuffer() offset (0x7) does not fall on "); |
| 6960 | |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 6961 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6962 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 6963 | uint32_t qfi = 0; |
| 6964 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6965 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 6966 | buffCI.size = 1024; |
| 6967 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
| 6968 | buffCI.queueFamilyIndexCount = 1; |
| 6969 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 6970 | |
| 6971 | VkBuffer ib; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6972 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 6973 | ASSERT_VK_SUCCESS(err); |
| 6974 | |
| 6975 | BeginCommandBuffer(); |
| 6976 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6977 | // vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 6978 | // VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 6979 | // 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] | 6980 | vkCmdBindIndexBuffer(m_commandBuffer->GetBufferHandle(), ib, 7, |
| 6981 | VK_INDEX_TYPE_UINT16); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 6982 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6983 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 6984 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6985 | vkDestroyBuffer(m_device->device(), ib, NULL); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 6986 | } |
| 6987 | |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 6988 | TEST_F(VkLayerTest, InvalidQueueFamilyIndex) { |
| 6989 | // Create an out-of-range queueFamilyIndex |
| 6990 | m_errorMonitor->SetDesiredFailureMsg( |
| 6991 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Dustin Graves | de62853 | 2016-04-21 16:30:17 -0600 | [diff] [blame] | 6992 | "vkCreateBuffer: pCreateInfo->pQueueFamilyIndices[0] (777) must be one " |
| 6993 | "of the indices specified when the device was created, via the " |
| 6994 | "VkDeviceQueueCreateInfo structure."); |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 6995 | |
| 6996 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6997 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6998 | VkBufferCreateInfo buffCI = {}; |
| 6999 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 7000 | buffCI.size = 1024; |
| 7001 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
| 7002 | buffCI.queueFamilyIndexCount = 1; |
| 7003 | // Introduce failure by specifying invalid queue_family_index |
| 7004 | uint32_t qfi = 777; |
| 7005 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 7006 | buffCI.sharingMode = VK_SHARING_MODE_CONCURRENT; // qfi only matters in CONCURRENT mode |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 7007 | |
| 7008 | VkBuffer ib; |
| 7009 | vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
| 7010 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7011 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 7012 | } |
| 7013 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7014 | TEST_F(VkLayerTest, ExecuteCommandsPrimaryCB) { |
| 7015 | // Attempt vkCmdExecuteCommands w/ a primary cmd buffer (should only be |
| 7016 | // secondary) |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7017 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7018 | m_errorMonitor->SetDesiredFailureMsg( |
| 7019 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7020 | "vkCmdExecuteCommands() called w/ Primary Cmd Buffer "); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 7021 | |
| 7022 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7023 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 7024 | |
| 7025 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7026 | // ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7027 | VkCommandBuffer primCB = m_commandBuffer->GetBufferHandle(); |
| 7028 | vkCmdExecuteCommands(m_commandBuffer->GetBufferHandle(), 1, &primCB); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 7029 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7030 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 7031 | } |
| 7032 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7033 | TEST_F(VkLayerTest, DSTypeMismatch) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 7034 | // 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] | 7035 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7036 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7037 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7038 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7039 | " binding #0 with type VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER but update " |
| 7040 | "type is VK_DESCRIPTOR_TYPE_SAMPLER"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7041 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7042 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7043 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7044 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7045 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7046 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7047 | |
| 7048 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7049 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7050 | ds_pool_ci.pNext = NULL; |
| 7051 | ds_pool_ci.maxSets = 1; |
| 7052 | ds_pool_ci.poolSizeCount = 1; |
| 7053 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7054 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7055 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7056 | err = |
| 7057 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7058 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7059 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7060 | dsl_binding.binding = 0; |
| 7061 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7062 | dsl_binding.descriptorCount = 1; |
| 7063 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7064 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7065 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7066 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7067 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7068 | ds_layout_ci.pNext = NULL; |
| 7069 | ds_layout_ci.bindingCount = 1; |
| 7070 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7071 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7072 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7073 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7074 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7075 | ASSERT_VK_SUCCESS(err); |
| 7076 | |
| 7077 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7078 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7079 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7080 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 7081 | alloc_info.descriptorPool = ds_pool; |
| 7082 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7083 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7084 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7085 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7086 | |
Tobin Ehlis | 30db8f8 | 2016-05-05 08:19:48 -0600 | [diff] [blame] | 7087 | VkSamplerCreateInfo sampler_ci = {}; |
| 7088 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 7089 | sampler_ci.pNext = NULL; |
| 7090 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 7091 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 7092 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 7093 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7094 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7095 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7096 | sampler_ci.mipLodBias = 1.0; |
| 7097 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 7098 | sampler_ci.maxAnisotropy = 1; |
| 7099 | sampler_ci.compareEnable = VK_FALSE; |
| 7100 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 7101 | sampler_ci.minLod = 1.0; |
| 7102 | sampler_ci.maxLod = 1.0; |
| 7103 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 7104 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
| 7105 | VkSampler sampler; |
| 7106 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
| 7107 | ASSERT_VK_SUCCESS(err); |
| 7108 | |
| 7109 | VkDescriptorImageInfo info = {}; |
| 7110 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7111 | |
| 7112 | VkWriteDescriptorSet descriptor_write; |
| 7113 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 7114 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7115 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7116 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7117 | // This is a mismatched type for the layout which expects BUFFER |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7118 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 7119 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7120 | |
| 7121 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 7122 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7123 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7124 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7125 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 7126 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7127 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 7128 | } |
| 7129 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7130 | TEST_F(VkLayerTest, DSUpdateOutOfBounds) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 7131 | // For overlapping Update, have arrayIndex exceed that of layout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7132 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7133 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7134 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7135 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7136 | " binding #0 with 1 total descriptors but update of 1 descriptors " |
| 7137 | "starting at binding offset of 0 combined with update array element " |
| 7138 | "offset of 1 oversteps the size of this descriptor set."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7139 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7140 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7141 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7142 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7143 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7144 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7145 | |
| 7146 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7147 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7148 | ds_pool_ci.pNext = NULL; |
| 7149 | ds_pool_ci.maxSets = 1; |
| 7150 | ds_pool_ci.poolSizeCount = 1; |
| 7151 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7152 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7153 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7154 | err = |
| 7155 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7156 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7157 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7158 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7159 | dsl_binding.binding = 0; |
| 7160 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7161 | dsl_binding.descriptorCount = 1; |
| 7162 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7163 | dsl_binding.pImmutableSamplers = NULL; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7164 | |
| 7165 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7166 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7167 | ds_layout_ci.pNext = NULL; |
| 7168 | ds_layout_ci.bindingCount = 1; |
| 7169 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7170 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7171 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7172 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7173 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7174 | ASSERT_VK_SUCCESS(err); |
| 7175 | |
| 7176 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7177 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7178 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7179 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 7180 | alloc_info.descriptorPool = ds_pool; |
| 7181 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7182 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7183 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7184 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7185 | |
Tobin Ehlis | 30db8f8 | 2016-05-05 08:19:48 -0600 | [diff] [blame] | 7186 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 7187 | VkDescriptorBufferInfo buff_info = {}; |
| 7188 | buff_info.buffer = |
| 7189 | VkBuffer(0); // Don't care about buffer handle for this test |
| 7190 | buff_info.offset = 0; |
| 7191 | buff_info.range = 1024; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7192 | |
| 7193 | VkWriteDescriptorSet descriptor_write; |
| 7194 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 7195 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7196 | descriptor_write.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7197 | descriptor_write.dstArrayElement = |
| 7198 | 1; /* This index out of bounds for the update */ |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7199 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7200 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7201 | descriptor_write.pBufferInfo = &buff_info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7202 | |
| 7203 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 7204 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7205 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7206 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7207 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7208 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 7209 | } |
| 7210 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7211 | TEST_F(VkLayerTest, InvalidDSUpdateIndex) { |
| 7212 | // Create layout w/ count of 1 and attempt update to that layout w/ binding |
| 7213 | // index 2 |
| 7214 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7215 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7216 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7217 | " does not have binding 2."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7218 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7219 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7220 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7221 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7222 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7223 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7224 | |
| 7225 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7226 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7227 | ds_pool_ci.pNext = NULL; |
| 7228 | ds_pool_ci.maxSets = 1; |
| 7229 | ds_pool_ci.poolSizeCount = 1; |
| 7230 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 7231 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7232 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7233 | err = |
| 7234 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7235 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7236 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7237 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7238 | dsl_binding.binding = 0; |
| 7239 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7240 | dsl_binding.descriptorCount = 1; |
| 7241 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7242 | dsl_binding.pImmutableSamplers = NULL; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7243 | |
| 7244 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7245 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7246 | ds_layout_ci.pNext = NULL; |
| 7247 | ds_layout_ci.bindingCount = 1; |
| 7248 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7249 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7250 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7251 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7252 | ASSERT_VK_SUCCESS(err); |
| 7253 | |
| 7254 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7255 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7256 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7257 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 7258 | alloc_info.descriptorPool = ds_pool; |
| 7259 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7260 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7261 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7262 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7263 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7264 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7265 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 7266 | sampler_ci.pNext = NULL; |
| 7267 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 7268 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 7269 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 7270 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7271 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7272 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7273 | sampler_ci.mipLodBias = 1.0; |
| 7274 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 7275 | sampler_ci.maxAnisotropy = 1; |
| 7276 | sampler_ci.compareEnable = VK_FALSE; |
| 7277 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 7278 | sampler_ci.minLod = 1.0; |
| 7279 | sampler_ci.maxLod = 1.0; |
| 7280 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 7281 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7282 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7283 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7284 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7285 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7286 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 7287 | VkDescriptorImageInfo info = {}; |
| 7288 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7289 | |
| 7290 | VkWriteDescriptorSet descriptor_write; |
| 7291 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 7292 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7293 | descriptor_write.dstSet = descriptorSet; |
| 7294 | descriptor_write.dstBinding = 2; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7295 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7296 | // 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] | 7297 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 7298 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7299 | |
| 7300 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 7301 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7302 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7303 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7304 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 7305 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7306 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 7307 | } |
| 7308 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7309 | TEST_F(VkLayerTest, InvalidDSUpdateStruct) { |
| 7310 | // Call UpdateDS w/ struct type other than valid VK_STRUCTUR_TYPE_UPDATE_* |
| 7311 | // types |
| 7312 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7313 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7314 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 660bcdc | 2016-05-17 10:39:46 -0600 | [diff] [blame] | 7315 | ".sType must be VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7316 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7317 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 7318 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7319 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7320 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7321 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7322 | |
| 7323 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7324 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7325 | ds_pool_ci.pNext = NULL; |
| 7326 | ds_pool_ci.maxSets = 1; |
| 7327 | ds_pool_ci.poolSizeCount = 1; |
| 7328 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 7329 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7330 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7331 | err = |
| 7332 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7333 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7334 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7335 | dsl_binding.binding = 0; |
| 7336 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7337 | dsl_binding.descriptorCount = 1; |
| 7338 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7339 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7340 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7341 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7342 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7343 | ds_layout_ci.pNext = NULL; |
| 7344 | ds_layout_ci.bindingCount = 1; |
| 7345 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7346 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7347 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7348 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7349 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7350 | ASSERT_VK_SUCCESS(err); |
| 7351 | |
| 7352 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7353 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7354 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7355 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 7356 | alloc_info.descriptorPool = ds_pool; |
| 7357 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7358 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7359 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7360 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7361 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7362 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7363 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 7364 | sampler_ci.pNext = NULL; |
| 7365 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 7366 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 7367 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 7368 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7369 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7370 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7371 | sampler_ci.mipLodBias = 1.0; |
| 7372 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 7373 | sampler_ci.maxAnisotropy = 1; |
| 7374 | sampler_ci.compareEnable = VK_FALSE; |
| 7375 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 7376 | sampler_ci.minLod = 1.0; |
| 7377 | sampler_ci.maxLod = 1.0; |
| 7378 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 7379 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7380 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7381 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7382 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7383 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 7384 | VkDescriptorImageInfo info = {}; |
| 7385 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7386 | |
| 7387 | VkWriteDescriptorSet descriptor_write; |
| 7388 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7389 | descriptor_write.sType = |
| 7390 | (VkStructureType)0x99999999; /* Intentionally broken struct type */ |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7391 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7392 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7393 | // 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] | 7394 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 7395 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7396 | |
| 7397 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 7398 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7399 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7400 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7401 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 7402 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7403 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 7404 | } |
| 7405 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7406 | TEST_F(VkLayerTest, SampleDescriptorUpdateError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7407 | // Create a single Sampler descriptor and send it an invalid Sampler |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7408 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7409 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7410 | m_errorMonitor->SetDesiredFailureMsg( |
| 7411 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7412 | "Attempted write update to sampler descriptor with invalid sampler"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7413 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7414 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7415 | // TODO : Farm Descriptor setup code to helper function(s) to reduce copied |
| 7416 | // code |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7417 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7418 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 7419 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7420 | |
| 7421 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7422 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7423 | ds_pool_ci.pNext = NULL; |
| 7424 | ds_pool_ci.maxSets = 1; |
| 7425 | ds_pool_ci.poolSizeCount = 1; |
| 7426 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7427 | |
| 7428 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7429 | err = |
| 7430 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7431 | ASSERT_VK_SUCCESS(err); |
| 7432 | |
| 7433 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7434 | dsl_binding.binding = 0; |
| 7435 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 7436 | dsl_binding.descriptorCount = 1; |
| 7437 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7438 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7439 | |
| 7440 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7441 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7442 | ds_layout_ci.pNext = NULL; |
| 7443 | ds_layout_ci.bindingCount = 1; |
| 7444 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7445 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7446 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7447 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7448 | ASSERT_VK_SUCCESS(err); |
| 7449 | |
| 7450 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7451 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7452 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7453 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7454 | alloc_info.descriptorPool = ds_pool; |
| 7455 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7456 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7457 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7458 | ASSERT_VK_SUCCESS(err); |
| 7459 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7460 | VkSampler sampler = |
| 7461 | (VkSampler)((size_t)0xbaadbeef); // Sampler with invalid handle |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7462 | |
| 7463 | VkDescriptorImageInfo descriptor_info; |
| 7464 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 7465 | descriptor_info.sampler = sampler; |
| 7466 | |
| 7467 | VkWriteDescriptorSet descriptor_write; |
| 7468 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 7469 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7470 | descriptor_write.dstSet = descriptorSet; |
| 7471 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7472 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7473 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 7474 | descriptor_write.pImageInfo = &descriptor_info; |
| 7475 | |
| 7476 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 7477 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7478 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7479 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7480 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7481 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7482 | } |
| 7483 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7484 | TEST_F(VkLayerTest, ImageViewDescriptorUpdateError) { |
| 7485 | // Create a single combined Image/Sampler descriptor and send it an invalid |
| 7486 | // imageView |
| 7487 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7488 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7489 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7490 | "Attempted write update to combined " |
| 7491 | "image sampler descriptor failed due " |
Tobin Ehlis | 63c4b8a | 2016-05-09 10:29:34 -0600 | [diff] [blame] | 7492 | "to: Invalid VkImageView:"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7493 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7494 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7495 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7496 | ds_type_count.type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 7497 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7498 | |
| 7499 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7500 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7501 | ds_pool_ci.pNext = NULL; |
| 7502 | ds_pool_ci.maxSets = 1; |
| 7503 | ds_pool_ci.poolSizeCount = 1; |
| 7504 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7505 | |
| 7506 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7507 | err = |
| 7508 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7509 | ASSERT_VK_SUCCESS(err); |
| 7510 | |
| 7511 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7512 | dsl_binding.binding = 0; |
| 7513 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 7514 | dsl_binding.descriptorCount = 1; |
| 7515 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7516 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7517 | |
| 7518 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7519 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7520 | ds_layout_ci.pNext = NULL; |
| 7521 | ds_layout_ci.bindingCount = 1; |
| 7522 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7523 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7524 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7525 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7526 | ASSERT_VK_SUCCESS(err); |
| 7527 | |
| 7528 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7529 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7530 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7531 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7532 | alloc_info.descriptorPool = ds_pool; |
| 7533 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7534 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7535 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7536 | ASSERT_VK_SUCCESS(err); |
| 7537 | |
| 7538 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7539 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 7540 | sampler_ci.pNext = NULL; |
| 7541 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 7542 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 7543 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 7544 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7545 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7546 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7547 | sampler_ci.mipLodBias = 1.0; |
| 7548 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 7549 | sampler_ci.maxAnisotropy = 1; |
| 7550 | sampler_ci.compareEnable = VK_FALSE; |
| 7551 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 7552 | sampler_ci.minLod = 1.0; |
| 7553 | sampler_ci.maxLod = 1.0; |
| 7554 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 7555 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7556 | |
| 7557 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7558 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7559 | ASSERT_VK_SUCCESS(err); |
| 7560 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7561 | VkImageView view = |
| 7562 | (VkImageView)((size_t)0xbaadbeef); // invalid imageView object |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7563 | |
| 7564 | VkDescriptorImageInfo descriptor_info; |
| 7565 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 7566 | descriptor_info.sampler = sampler; |
| 7567 | descriptor_info.imageView = view; |
| 7568 | |
| 7569 | VkWriteDescriptorSet descriptor_write; |
| 7570 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 7571 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7572 | descriptor_write.dstSet = descriptorSet; |
| 7573 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7574 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7575 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 7576 | descriptor_write.pImageInfo = &descriptor_info; |
| 7577 | |
| 7578 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 7579 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7580 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7581 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7582 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 7583 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7584 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7585 | } |
| 7586 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7587 | TEST_F(VkLayerTest, CopyDescriptorUpdateErrors) { |
| 7588 | // Create DS w/ layout of 2 types, write update 1 and attempt to copy-update |
| 7589 | // into the other |
| 7590 | VkResult err; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7591 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7592 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7593 | " binding #1 with type " |
| 7594 | "VK_DESCRIPTOR_TYPE_SAMPLER. Types do " |
| 7595 | "not match."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7596 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7597 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7598 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7599 | VkDescriptorPoolSize ds_type_count[2] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7600 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7601 | ds_type_count[0].descriptorCount = 1; |
| 7602 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 7603 | ds_type_count[1].descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7604 | |
| 7605 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7606 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7607 | ds_pool_ci.pNext = NULL; |
| 7608 | ds_pool_ci.maxSets = 1; |
| 7609 | ds_pool_ci.poolSizeCount = 2; |
| 7610 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7611 | |
| 7612 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7613 | err = |
| 7614 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7615 | ASSERT_VK_SUCCESS(err); |
| 7616 | VkDescriptorSetLayoutBinding dsl_binding[2] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7617 | dsl_binding[0].binding = 0; |
| 7618 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7619 | dsl_binding[0].descriptorCount = 1; |
| 7620 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 7621 | dsl_binding[0].pImmutableSamplers = NULL; |
| 7622 | dsl_binding[1].binding = 1; |
| 7623 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 7624 | dsl_binding[1].descriptorCount = 1; |
| 7625 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 7626 | dsl_binding[1].pImmutableSamplers = NULL; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7627 | |
| 7628 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7629 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7630 | ds_layout_ci.pNext = NULL; |
| 7631 | ds_layout_ci.bindingCount = 2; |
| 7632 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7633 | |
| 7634 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7635 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7636 | &ds_layout); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7637 | ASSERT_VK_SUCCESS(err); |
| 7638 | |
| 7639 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7640 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7641 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7642 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7643 | alloc_info.descriptorPool = ds_pool; |
| 7644 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7645 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7646 | &descriptorSet); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7647 | ASSERT_VK_SUCCESS(err); |
| 7648 | |
| 7649 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7650 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 7651 | sampler_ci.pNext = NULL; |
| 7652 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 7653 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 7654 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 7655 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7656 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7657 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7658 | sampler_ci.mipLodBias = 1.0; |
| 7659 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 7660 | sampler_ci.maxAnisotropy = 1; |
| 7661 | sampler_ci.compareEnable = VK_FALSE; |
| 7662 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 7663 | sampler_ci.minLod = 1.0; |
| 7664 | sampler_ci.maxLod = 1.0; |
| 7665 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 7666 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7667 | |
| 7668 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7669 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7670 | ASSERT_VK_SUCCESS(err); |
| 7671 | |
| 7672 | VkDescriptorImageInfo info = {}; |
| 7673 | info.sampler = sampler; |
| 7674 | |
| 7675 | VkWriteDescriptorSet descriptor_write; |
| 7676 | memset(&descriptor_write, 0, sizeof(VkWriteDescriptorSet)); |
| 7677 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7678 | descriptor_write.dstSet = descriptorSet; |
| 7679 | descriptor_write.dstBinding = 1; // SAMPLER binding from layout above |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7680 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7681 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 7682 | descriptor_write.pImageInfo = &info; |
| 7683 | // This write update should succeed |
| 7684 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 7685 | // Now perform a copy update that fails due to type mismatch |
| 7686 | VkCopyDescriptorSet copy_ds_update; |
| 7687 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 7688 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 7689 | copy_ds_update.srcSet = descriptorSet; |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 7690 | copy_ds_update.srcBinding = 1; // Copy from SAMPLER binding |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7691 | copy_ds_update.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7692 | copy_ds_update.dstBinding = 0; // ERROR : copy to UNIFORM binding |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7693 | copy_ds_update.descriptorCount = 1; // copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7694 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 7695 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7696 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7697 | // 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] | 7698 | m_errorMonitor->SetDesiredFailureMsg( |
| 7699 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7700 | " does not have copy update src binding of 3."); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7701 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 7702 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 7703 | copy_ds_update.srcSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7704 | copy_ds_update.srcBinding = |
| 7705 | 3; // ERROR : Invalid binding for matching layout |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7706 | copy_ds_update.dstSet = descriptorSet; |
| 7707 | copy_ds_update.dstBinding = 0; |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 7708 | copy_ds_update.descriptorCount = 1; // Copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7709 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 7710 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7711 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7712 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7713 | // 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] | 7714 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7715 | VK_DEBUG_REPORT_ERROR_BIT_EXT, " binding#1 with offset index of 1 plus " |
| 7716 | "update array offset of 0 and update of " |
| 7717 | "5 descriptors oversteps total number " |
| 7718 | "of descriptors in set: 2."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7719 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7720 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 7721 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 7722 | copy_ds_update.srcSet = descriptorSet; |
| 7723 | copy_ds_update.srcBinding = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7724 | copy_ds_update.dstSet = descriptorSet; |
| 7725 | copy_ds_update.dstBinding = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7726 | copy_ds_update.descriptorCount = |
| 7727 | 5; // ERROR copy 5 descriptors (out of bounds for layout) |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7728 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 7729 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7730 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7731 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7732 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 7733 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7734 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7735 | } |
| 7736 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7737 | TEST_F(VkLayerTest, NumSamplesMismatch) { |
| 7738 | // Create CommandBuffer where MSAA samples doesn't match RenderPass |
| 7739 | // sampleCount |
| 7740 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7741 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7742 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7743 | "Num samples mismatch! "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7744 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7745 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7746 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7747 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7748 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7749 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7750 | |
| 7751 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7752 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7753 | ds_pool_ci.pNext = NULL; |
| 7754 | ds_pool_ci.maxSets = 1; |
| 7755 | ds_pool_ci.poolSizeCount = 1; |
| 7756 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 7757 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7758 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7759 | err = |
| 7760 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7761 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7762 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7763 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 7764 | dsl_binding.binding = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7765 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 7766 | dsl_binding.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7767 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7768 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7769 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7770 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 7771 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7772 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7773 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 7774 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7775 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7776 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7777 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7778 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7779 | ASSERT_VK_SUCCESS(err); |
| 7780 | |
| 7781 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7782 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7783 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7784 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 7785 | alloc_info.descriptorPool = ds_pool; |
| 7786 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7787 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7788 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7789 | ASSERT_VK_SUCCESS(err); |
| 7790 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7791 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7792 | pipe_ms_state_ci.sType = |
| 7793 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 7794 | pipe_ms_state_ci.pNext = NULL; |
| 7795 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
| 7796 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 7797 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 7798 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7799 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7800 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7801 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 7802 | pipeline_layout_ci.pNext = NULL; |
| 7803 | pipeline_layout_ci.setLayoutCount = 1; |
| 7804 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7805 | |
| 7806 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7807 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 7808 | &pipeline_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7809 | ASSERT_VK_SUCCESS(err); |
| 7810 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7811 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 7812 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7813 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 7814 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 7815 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7816 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 7817 | VkPipelineObj pipe(m_device); |
| 7818 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 7819 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 7820 | pipe.AddColorAttachment(); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 7821 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 7822 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7823 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 7824 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7825 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 7826 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7827 | |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 7828 | // Render triangle (the error should trigger on the attempt to draw). |
| 7829 | Draw(3, 1, 0, 0); |
| 7830 | |
| 7831 | // Finalize recording of the command buffer |
| 7832 | EndCommandBuffer(); |
| 7833 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7834 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7835 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7836 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 7837 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7838 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 7839 | } |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 7840 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 7841 | TEST_F(VkLayerTest, NumBlendAttachMismatch) { |
| 7842 | // Create Pipeline where the number of blend attachments doesn't match the |
| 7843 | // number of color attachments. In this case, we don't add any color |
| 7844 | // blend attachments even though we have a color attachment. |
| 7845 | VkResult err; |
| 7846 | |
| 7847 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 7848 | "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] | 7849 | |
| 7850 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7851 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7852 | VkDescriptorPoolSize ds_type_count = {}; |
| 7853 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7854 | ds_type_count.descriptorCount = 1; |
| 7855 | |
| 7856 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 7857 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7858 | ds_pool_ci.pNext = NULL; |
| 7859 | ds_pool_ci.maxSets = 1; |
| 7860 | ds_pool_ci.poolSizeCount = 1; |
| 7861 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 7862 | |
| 7863 | VkDescriptorPool ds_pool; |
| 7864 | err = |
| 7865 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 7866 | ASSERT_VK_SUCCESS(err); |
| 7867 | |
| 7868 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 7869 | dsl_binding.binding = 0; |
| 7870 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7871 | dsl_binding.descriptorCount = 1; |
| 7872 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7873 | dsl_binding.pImmutableSamplers = NULL; |
| 7874 | |
| 7875 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 7876 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7877 | ds_layout_ci.pNext = NULL; |
| 7878 | ds_layout_ci.bindingCount = 1; |
| 7879 | ds_layout_ci.pBindings = &dsl_binding; |
| 7880 | |
| 7881 | VkDescriptorSetLayout ds_layout; |
| 7882 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7883 | &ds_layout); |
| 7884 | ASSERT_VK_SUCCESS(err); |
| 7885 | |
| 7886 | VkDescriptorSet descriptorSet; |
| 7887 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 7888 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 7889 | alloc_info.descriptorSetCount = 1; |
| 7890 | alloc_info.descriptorPool = ds_pool; |
| 7891 | alloc_info.pSetLayouts = &ds_layout; |
| 7892 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7893 | &descriptorSet); |
| 7894 | ASSERT_VK_SUCCESS(err); |
| 7895 | |
| 7896 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 7897 | pipe_ms_state_ci.sType = |
| 7898 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 7899 | pipe_ms_state_ci.pNext = NULL; |
| 7900 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 7901 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 7902 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 7903 | pipe_ms_state_ci.pSampleMask = NULL; |
| 7904 | |
| 7905 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 7906 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 7907 | pipeline_layout_ci.pNext = NULL; |
| 7908 | pipeline_layout_ci.setLayoutCount = 1; |
| 7909 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 7910 | |
| 7911 | VkPipelineLayout pipeline_layout; |
| 7912 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 7913 | &pipeline_layout); |
| 7914 | ASSERT_VK_SUCCESS(err); |
| 7915 | |
| 7916 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 7917 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7918 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 7919 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 7920 | this); // We shouldn't need a fragment shader |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 7921 | // but add it to be able to run on more devices |
| 7922 | VkPipelineObj pipe(m_device); |
| 7923 | pipe.AddShader(&vs); |
| 7924 | pipe.AddShader(&fs); |
| 7925 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 7926 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 7927 | |
| 7928 | BeginCommandBuffer(); |
| 7929 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 7930 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 7931 | |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 7932 | // Render triangle (the error should trigger on the attempt to draw). |
| 7933 | Draw(3, 1, 0, 0); |
| 7934 | |
| 7935 | // Finalize recording of the command buffer |
| 7936 | EndCommandBuffer(); |
| 7937 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7938 | m_errorMonitor->VerifyFound(); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 7939 | |
| 7940 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 7941 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7942 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 7943 | } |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 7944 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7945 | TEST_F(VkLayerTest, ClearCmdNoDraw) { |
| 7946 | // Create CommandBuffer where we add ClearCmd for FB Color attachment prior |
| 7947 | // to issuing a Draw |
| 7948 | VkResult err; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7949 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7950 | m_errorMonitor->SetDesiredFailureMsg( |
Tony Barbour | 7e56d30 | 2016-03-02 15:12:01 -0700 | [diff] [blame] | 7951 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7952 | "vkCmdClearAttachments() issued on CB object "); |
| 7953 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7954 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7955 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7956 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7957 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7958 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7959 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7960 | |
| 7961 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7962 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7963 | ds_pool_ci.pNext = NULL; |
| 7964 | ds_pool_ci.maxSets = 1; |
| 7965 | ds_pool_ci.poolSizeCount = 1; |
| 7966 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7967 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7968 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7969 | err = |
| 7970 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7971 | ASSERT_VK_SUCCESS(err); |
| 7972 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7973 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7974 | dsl_binding.binding = 0; |
| 7975 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7976 | dsl_binding.descriptorCount = 1; |
| 7977 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7978 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7979 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7980 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7981 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7982 | ds_layout_ci.pNext = NULL; |
| 7983 | ds_layout_ci.bindingCount = 1; |
| 7984 | ds_layout_ci.pBindings = &dsl_binding; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 7985 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7986 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7987 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7988 | &ds_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7989 | ASSERT_VK_SUCCESS(err); |
| 7990 | |
| 7991 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7992 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7993 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7994 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 7995 | alloc_info.descriptorPool = ds_pool; |
| 7996 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7997 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7998 | &descriptorSet); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7999 | ASSERT_VK_SUCCESS(err); |
| 8000 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8001 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8002 | pipe_ms_state_ci.sType = |
| 8003 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 8004 | pipe_ms_state_ci.pNext = NULL; |
| 8005 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
| 8006 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 8007 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 8008 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8009 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8010 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8011 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 8012 | pipeline_layout_ci.pNext = NULL; |
| 8013 | pipeline_layout_ci.setLayoutCount = 1; |
| 8014 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8015 | |
| 8016 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8017 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 8018 | &pipeline_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8019 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 8020 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8021 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 8022 | VK_SHADER_STAGE_VERTEX_BIT, this); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 8023 | // 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] | 8024 | // on more devices |
| 8025 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 8026 | VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8027 | |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 8028 | VkPipelineObj pipe(m_device); |
| 8029 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 8030 | pipe.AddShader(&fs); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 8031 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 8032 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 8033 | |
| 8034 | BeginCommandBuffer(); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8035 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8036 | // Main thing we care about for this test is that the VkImage obj we're |
| 8037 | // clearing matches Color Attachment of FB |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8038 | // Also pass down other dummy params to keep driver and paramchecker happy |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 8039 | VkClearAttachment color_attachment; |
| 8040 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8041 | color_attachment.clearValue.color.float32[0] = 1.0; |
| 8042 | color_attachment.clearValue.color.float32[1] = 1.0; |
| 8043 | color_attachment.clearValue.color.float32[2] = 1.0; |
| 8044 | color_attachment.clearValue.color.float32[3] = 1.0; |
| 8045 | color_attachment.colorAttachment = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8046 | VkClearRect clear_rect = { |
| 8047 | {{0, 0}, {(uint32_t)m_width, (uint32_t)m_height}}}; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8048 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8049 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
| 8050 | &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8051 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8052 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 8053 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8054 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 8055 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 8056 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8057 | } |
| 8058 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8059 | TEST_F(VkLayerTest, VtxBufferBadIndex) { |
| 8060 | VkResult err; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8061 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8062 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 8063 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | dfcd9b6 | 2015-12-14 15:14:10 -0700 | [diff] [blame] | 8064 | "but no vertex buffers are attached to this Pipeline State Object"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8065 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8066 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 8067 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8068 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8069 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 8070 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8071 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8072 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8073 | |
| 8074 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8075 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 8076 | ds_pool_ci.pNext = NULL; |
| 8077 | ds_pool_ci.maxSets = 1; |
| 8078 | ds_pool_ci.poolSizeCount = 1; |
| 8079 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8080 | |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 8081 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8082 | err = |
| 8083 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8084 | ASSERT_VK_SUCCESS(err); |
| 8085 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8086 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8087 | dsl_binding.binding = 0; |
| 8088 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8089 | dsl_binding.descriptorCount = 1; |
| 8090 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 8091 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8092 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8093 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8094 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 8095 | ds_layout_ci.pNext = NULL; |
| 8096 | ds_layout_ci.bindingCount = 1; |
| 8097 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8098 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8099 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8100 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 8101 | &ds_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8102 | ASSERT_VK_SUCCESS(err); |
| 8103 | |
| 8104 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8105 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 8106 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 8107 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 8108 | alloc_info.descriptorPool = ds_pool; |
| 8109 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8110 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 8111 | &descriptorSet); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8112 | ASSERT_VK_SUCCESS(err); |
| 8113 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8114 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8115 | pipe_ms_state_ci.sType = |
| 8116 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 8117 | pipe_ms_state_ci.pNext = NULL; |
| 8118 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 8119 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 8120 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 8121 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8122 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8123 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8124 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 8125 | pipeline_layout_ci.pNext = NULL; |
| 8126 | pipeline_layout_ci.setLayoutCount = 1; |
| 8127 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 8128 | VkPipelineLayout pipeline_layout; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8129 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8130 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 8131 | &pipeline_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8132 | ASSERT_VK_SUCCESS(err); |
| 8133 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8134 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 8135 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8136 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 8137 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 8138 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8139 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 8140 | VkPipelineObj pipe(m_device); |
| 8141 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 8142 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 8143 | pipe.AddColorAttachment(); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 8144 | pipe.SetMSAA(&pipe_ms_state_ci); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 8145 | pipe.SetViewport(m_viewports); |
| 8146 | pipe.SetScissor(m_scissors); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 8147 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 8148 | |
| 8149 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8150 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 8151 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 8152 | // Don't care about actual data, just need to get to draw to flag error |
| 8153 | static const float vbo_data[3] = {1.f, 0.f, 1.f}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8154 | VkConstantBufferObj vbo(m_device, sizeof(vbo_data), sizeof(float), |
| 8155 | (const void *)&vbo_data); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 8156 | 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] | 8157 | Draw(1, 0, 0, 0); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8158 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8159 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 8160 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8161 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 8162 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 8163 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8164 | } |
Tobin Ehlis | c555a3c | 2016-05-04 14:08:34 -0600 | [diff] [blame] | 8165 | // INVALID_IMAGE_LAYOUT tests (one other case is hit by MapMemWithoutHostVisibleBit and not here) |
| 8166 | TEST_F(VkLayerTest, InvalidImageLayout) { |
| 8167 | TEST_DESCRIPTION("Hit all possible validation checks associated with the " |
| 8168 | "DRAWSTATE_INVALID_IMAGE_LAYOUT enum. Generally these involve having" |
| 8169 | "images in the wrong layout when they're copied or transitioned."); |
| 8170 | // 3 in ValidateCmdBufImageLayouts |
| 8171 | // * -1 Attempt to submit cmd buf w/ deleted image |
| 8172 | // * -2 Cmd buf submit of image w/ layout not matching first use w/ subresource |
| 8173 | // * -3 Cmd buf submit of image w/ layout not matching first use w/o subresource |
| 8174 | m_errorMonitor->SetDesiredFailureMsg( |
| 8175 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 8176 | "Layout for input image should be TRANSFER_SRC_OPTIMAL instead of GENERAL."); |
| 8177 | |
| 8178 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8179 | // Create src & dst images to use for copy operations |
| 8180 | VkImage src_image; |
| 8181 | VkImage dst_image; |
| 8182 | |
| 8183 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8184 | const int32_t tex_width = 32; |
| 8185 | const int32_t tex_height = 32; |
| 8186 | |
| 8187 | VkImageCreateInfo image_create_info = {}; |
| 8188 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8189 | image_create_info.pNext = NULL; |
| 8190 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8191 | image_create_info.format = tex_format; |
| 8192 | image_create_info.extent.width = tex_width; |
| 8193 | image_create_info.extent.height = tex_height; |
| 8194 | image_create_info.extent.depth = 1; |
| 8195 | image_create_info.mipLevels = 1; |
| 8196 | image_create_info.arrayLayers = 4; |
| 8197 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8198 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 8199 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 8200 | image_create_info.flags = 0; |
| 8201 | |
| 8202 | VkResult err = vkCreateImage(m_device->device(), &image_create_info, NULL, &src_image); |
| 8203 | ASSERT_VK_SUCCESS(err); |
| 8204 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dst_image); |
| 8205 | ASSERT_VK_SUCCESS(err); |
| 8206 | |
| 8207 | BeginCommandBuffer(); |
| 8208 | VkImageCopy copyRegion; |
| 8209 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8210 | copyRegion.srcSubresource.mipLevel = 0; |
| 8211 | copyRegion.srcSubresource.baseArrayLayer = 0; |
| 8212 | copyRegion.srcSubresource.layerCount = 1; |
| 8213 | copyRegion.srcOffset.x = 0; |
| 8214 | copyRegion.srcOffset.y = 0; |
| 8215 | copyRegion.srcOffset.z = 0; |
| 8216 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8217 | copyRegion.dstSubresource.mipLevel = 0; |
| 8218 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 8219 | copyRegion.dstSubresource.layerCount = 1; |
| 8220 | copyRegion.dstOffset.x = 0; |
| 8221 | copyRegion.dstOffset.y = 0; |
| 8222 | copyRegion.dstOffset.z = 0; |
| 8223 | copyRegion.extent.width = 1; |
| 8224 | copyRegion.extent.height = 1; |
| 8225 | copyRegion.extent.depth = 1; |
| 8226 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 8227 | m_errorMonitor->VerifyFound(); |
| 8228 | // Now cause error due to src image layout changing |
| 8229 | m_errorMonitor->SetDesiredFailureMsg( |
| 8230 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8231 | "Cannot copy from an image whose source layout is VK_IMAGE_LAYOUT_UNDEFINED and doesn't match the current layout VK_IMAGE_LAYOUT_GENERAL."); |
| 8232 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_UNDEFINED, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 8233 | m_errorMonitor->VerifyFound(); |
| 8234 | // Final src error is due to bad layout type |
| 8235 | m_errorMonitor->SetDesiredFailureMsg( |
| 8236 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8237 | "Layout for input image is VK_IMAGE_LAYOUT_UNDEFINED but can only be TRANSFER_SRC_OPTIMAL or GENERAL."); |
| 8238 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_UNDEFINED, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 8239 | m_errorMonitor->VerifyFound(); |
| 8240 | // Now verify same checks for dst |
| 8241 | m_errorMonitor->SetDesiredFailureMsg( |
| 8242 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 8243 | "Layout for output image should be TRANSFER_DST_OPTIMAL instead of GENERAL."); |
| 8244 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 8245 | m_errorMonitor->VerifyFound(); |
| 8246 | // Now cause error due to src image layout changing |
| 8247 | m_errorMonitor->SetDesiredFailureMsg( |
| 8248 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8249 | "Cannot copy from an image whose dest layout is VK_IMAGE_LAYOUT_UNDEFINED and doesn't match the current layout VK_IMAGE_LAYOUT_GENERAL."); |
| 8250 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_UNDEFINED, 1, ©Region); |
| 8251 | m_errorMonitor->VerifyFound(); |
| 8252 | m_errorMonitor->SetDesiredFailureMsg( |
| 8253 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8254 | "Layout for output image is VK_IMAGE_LAYOUT_UNDEFINED but can only be TRANSFER_DST_OPTIMAL or GENERAL."); |
| 8255 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_UNDEFINED, 1, ©Region); |
| 8256 | m_errorMonitor->VerifyFound(); |
| 8257 | // Now cause error due to bad image layout transition in PipelineBarrier |
| 8258 | VkImageMemoryBarrier image_barrier[1] = {}; |
| 8259 | image_barrier[0].oldLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; |
| 8260 | image_barrier[0].image = src_image; |
| 8261 | image_barrier[0].subresourceRange.layerCount = 2; |
| 8262 | image_barrier[0].subresourceRange.levelCount = 2; |
| 8263 | image_barrier[0].subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8264 | m_errorMonitor->SetDesiredFailureMsg( |
| 8265 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8266 | "You cannot transition the layout from VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL when current layout is VK_IMAGE_LAYOUT_GENERAL."); |
| 8267 | vkCmdPipelineBarrier(m_commandBuffer->handle(), VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, NULL, 0, NULL, 1, image_barrier); |
| 8268 | m_errorMonitor->VerifyFound(); |
| 8269 | |
| 8270 | // Finally some layout errors at RenderPass create time |
| 8271 | // Just hacking in specific state to get to the errors we want so don't copy this unless you know what you're doing. |
| 8272 | VkAttachmentReference attach = {}; |
| 8273 | // perf warning for GENERAL layout w/ non-DS input attachment |
| 8274 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 8275 | VkSubpassDescription subpass = {}; |
| 8276 | subpass.inputAttachmentCount = 1; |
| 8277 | subpass.pInputAttachments = &attach; |
| 8278 | VkRenderPassCreateInfo rpci = {}; |
| 8279 | rpci.subpassCount = 1; |
| 8280 | rpci.pSubpasses = &subpass; |
| 8281 | rpci.attachmentCount = 1; |
| 8282 | VkAttachmentDescription attach_desc = {}; |
| 8283 | attach_desc.format = VK_FORMAT_UNDEFINED; |
| 8284 | rpci.pAttachments = &attach_desc; |
Tobin Ehlis | 1efce02 | 2016-05-11 10:40:34 -0600 | [diff] [blame] | 8285 | rpci.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; |
Tobin Ehlis | c555a3c | 2016-05-04 14:08:34 -0600 | [diff] [blame] | 8286 | VkRenderPass rp; |
| 8287 | m_errorMonitor->SetDesiredFailureMsg( |
| 8288 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 8289 | "Layout for input attachment is GENERAL but should be READ_ONLY_OPTIMAL."); |
| 8290 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 8291 | m_errorMonitor->VerifyFound(); |
| 8292 | // error w/ non-general layout |
| 8293 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; |
| 8294 | |
| 8295 | m_errorMonitor->SetDesiredFailureMsg( |
| 8296 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8297 | "Layout for input attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be READ_ONLY_OPTIMAL or GENERAL."); |
| 8298 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 8299 | m_errorMonitor->VerifyFound(); |
| 8300 | subpass.inputAttachmentCount = 0; |
| 8301 | subpass.colorAttachmentCount = 1; |
| 8302 | subpass.pColorAttachments = &attach; |
| 8303 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 8304 | // perf warning for GENERAL layout on color attachment |
| 8305 | m_errorMonitor->SetDesiredFailureMsg( |
| 8306 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 8307 | "Layout for color attachment is GENERAL but should be COLOR_ATTACHMENT_OPTIMAL."); |
| 8308 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 8309 | m_errorMonitor->VerifyFound(); |
| 8310 | // error w/ non-color opt or GENERAL layout for color attachment |
| 8311 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; |
| 8312 | m_errorMonitor->SetDesiredFailureMsg( |
| 8313 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8314 | "Layout for color attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be COLOR_ATTACHMENT_OPTIMAL or GENERAL."); |
| 8315 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 8316 | m_errorMonitor->VerifyFound(); |
| 8317 | subpass.colorAttachmentCount = 0; |
| 8318 | subpass.pDepthStencilAttachment = &attach; |
| 8319 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 8320 | // perf warning for GENERAL layout on DS attachment |
| 8321 | m_errorMonitor->SetDesiredFailureMsg( |
| 8322 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 8323 | "Layout for depth attachment is GENERAL but should be DEPTH_STENCIL_ATTACHMENT_OPTIMAL."); |
| 8324 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 8325 | m_errorMonitor->VerifyFound(); |
| 8326 | // error w/ non-ds opt or GENERAL layout for color attachment |
| 8327 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; |
| 8328 | m_errorMonitor->SetDesiredFailureMsg( |
| 8329 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8330 | "Layout for depth attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be DEPTH_STENCIL_ATTACHMENT_OPTIMAL or GENERAL."); |
| 8331 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 8332 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 1efce02 | 2016-05-11 10:40:34 -0600 | [diff] [blame] | 8333 | // For this error we need a valid renderpass so create default one |
| 8334 | attach.layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; |
| 8335 | attach.attachment = 0; |
| 8336 | attach_desc.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 8337 | attach_desc.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8338 | attach_desc.storeOp = VK_ATTACHMENT_STORE_OP_STORE; |
| 8339 | attach_desc.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; |
| 8340 | attach_desc.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; |
| 8341 | // Can't do a CLEAR load on READ_ONLY initialLayout |
| 8342 | attach_desc.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; |
| 8343 | attach_desc.initialLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; |
| 8344 | attach_desc.finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 8345 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8346 | " with invalid first layout " |
| 8347 | "VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_" |
| 8348 | "ONLY_OPTIMAL"); |
| 8349 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 8350 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | c555a3c | 2016-05-04 14:08:34 -0600 | [diff] [blame] | 8351 | |
| 8352 | vkDestroyImage(m_device->device(), src_image, NULL); |
| 8353 | vkDestroyImage(m_device->device(), dst_image, NULL); |
| 8354 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 8355 | #endif // DRAW_STATE_TESTS |
| 8356 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 8357 | #if THREADING_TESTS |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8358 | #if GTEST_IS_THREADSAFE |
| 8359 | struct thread_data_struct { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8360 | VkCommandBuffer commandBuffer; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8361 | VkEvent event; |
| 8362 | bool bailout; |
| 8363 | }; |
| 8364 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8365 | extern "C" void *AddToCommandBuffer(void *arg) { |
| 8366 | struct thread_data_struct *data = (struct thread_data_struct *)arg; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8367 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8368 | for (int i = 0; i < 10000; i++) { |
| 8369 | vkCmdSetEvent(data->commandBuffer, data->event, |
| 8370 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8371 | if (data->bailout) { |
| 8372 | break; |
| 8373 | } |
| 8374 | } |
| 8375 | return NULL; |
| 8376 | } |
| 8377 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8378 | TEST_F(VkLayerTest, ThreadCommandBufferCollision) { |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 8379 | test_platform_thread thread; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8380 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8381 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8382 | "THREADING ERROR"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8383 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8384 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8385 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 8386 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8387 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8388 | // Calls AllocateCommandBuffers |
| 8389 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 8390 | |
| 8391 | // Avoid creating RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8392 | commandBuffer.BeginCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8393 | |
| 8394 | VkEventCreateInfo event_info; |
| 8395 | VkEvent event; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8396 | VkResult err; |
| 8397 | |
| 8398 | memset(&event_info, 0, sizeof(event_info)); |
| 8399 | event_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 8400 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8401 | err = vkCreateEvent(device(), &event_info, NULL, &event); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8402 | ASSERT_VK_SUCCESS(err); |
| 8403 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8404 | err = vkResetEvent(device(), event); |
| 8405 | ASSERT_VK_SUCCESS(err); |
| 8406 | |
| 8407 | struct thread_data_struct data; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8408 | data.commandBuffer = commandBuffer.GetBufferHandle(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8409 | data.event = event; |
| 8410 | data.bailout = false; |
| 8411 | m_errorMonitor->SetBailout(&data.bailout); |
| 8412 | // Add many entries to command buffer from another thread. |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 8413 | test_platform_thread_create(&thread, AddToCommandBuffer, (void *)&data); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8414 | // Add many entries to command buffer from this thread at the same time. |
| 8415 | AddToCommandBuffer(&data); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 8416 | |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 8417 | test_platform_thread_join(thread, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8418 | commandBuffer.EndCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8419 | |
Mike Stroyan | 10b8cb7 | 2016-01-22 15:22:03 -0700 | [diff] [blame] | 8420 | m_errorMonitor->SetBailout(NULL); |
| 8421 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8422 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8423 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8424 | vkDestroyEvent(device(), event, NULL); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8425 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 8426 | #endif // GTEST_IS_THREADSAFE |
| 8427 | #endif // THREADING_TESTS |
| 8428 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8429 | #if SHADER_CHECKER_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8430 | TEST_F(VkLayerTest, InvalidSPIRVCodeSize) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8431 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 8432 | "Invalid SPIR-V header"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8433 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8434 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8435 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8436 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8437 | VkShaderModule module; |
| 8438 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 8439 | struct icd_spv_header spv; |
| 8440 | |
| 8441 | spv.magic = ICD_SPV_MAGIC; |
| 8442 | spv.version = ICD_SPV_VERSION; |
| 8443 | spv.gen_magic = 0; |
| 8444 | |
| 8445 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 8446 | moduleCreateInfo.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8447 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8448 | moduleCreateInfo.codeSize = 4; |
| 8449 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8450 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8451 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8452 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8453 | } |
| 8454 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8455 | TEST_F(VkLayerTest, InvalidSPIRVMagic) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8456 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 8457 | "Invalid SPIR-V magic number"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8458 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8459 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8460 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8461 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8462 | VkShaderModule module; |
| 8463 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 8464 | struct icd_spv_header spv; |
| 8465 | |
| 8466 | spv.magic = ~ICD_SPV_MAGIC; |
| 8467 | spv.version = ICD_SPV_VERSION; |
| 8468 | spv.gen_magic = 0; |
| 8469 | |
| 8470 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 8471 | moduleCreateInfo.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8472 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8473 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 8474 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8475 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8476 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8477 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8478 | } |
| 8479 | |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 8480 | #if 0 |
| 8481 | // Not currently covered by SPIRV-Tools validator |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8482 | TEST_F(VkLayerTest, InvalidSPIRVVersion) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8483 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 8484 | "Invalid SPIR-V header"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8485 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8486 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8487 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8488 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8489 | VkShaderModule module; |
| 8490 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 8491 | struct icd_spv_header spv; |
| 8492 | |
| 8493 | spv.magic = ICD_SPV_MAGIC; |
| 8494 | spv.version = ~ICD_SPV_VERSION; |
| 8495 | spv.gen_magic = 0; |
| 8496 | |
| 8497 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 8498 | moduleCreateInfo.pNext = NULL; |
| 8499 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8500 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8501 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 8502 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8503 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8504 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8505 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8506 | } |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 8507 | #endif |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8508 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8509 | TEST_F(VkLayerTest, CreatePipelineVertexOutputNotConsumed) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 8510 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8511 | "not consumed by fragment shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8512 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8513 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 8514 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8515 | |
| 8516 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8517 | "#version 450\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8518 | "\n" |
| 8519 | "layout(location=0) out float x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8520 | "out gl_PerVertex {\n" |
| 8521 | " vec4 gl_Position;\n" |
| 8522 | "};\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8523 | "void main(){\n" |
| 8524 | " gl_Position = vec4(1);\n" |
| 8525 | " x = 0;\n" |
| 8526 | "}\n"; |
| 8527 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8528 | "#version 450\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8529 | "\n" |
| 8530 | "layout(location=0) out vec4 color;\n" |
| 8531 | "void main(){\n" |
| 8532 | " color = vec4(1);\n" |
| 8533 | "}\n"; |
| 8534 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8535 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8536 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8537 | |
| 8538 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 8539 | pipe.AddColorAttachment(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8540 | pipe.AddShader(&vs); |
| 8541 | pipe.AddShader(&fs); |
| 8542 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8543 | VkDescriptorSetObj descriptorSet(m_device); |
| 8544 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8545 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8546 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 8547 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8548 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8549 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8550 | } |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8551 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8552 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvided) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8553 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8554 | "not written by vertex shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8555 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8556 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 8557 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8558 | |
| 8559 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8560 | "#version 450\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8561 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8562 | "out gl_PerVertex {\n" |
| 8563 | " vec4 gl_Position;\n" |
| 8564 | "};\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8565 | "void main(){\n" |
| 8566 | " gl_Position = vec4(1);\n" |
| 8567 | "}\n"; |
| 8568 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8569 | "#version 450\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8570 | "\n" |
| 8571 | "layout(location=0) in float x;\n" |
| 8572 | "layout(location=0) out vec4 color;\n" |
| 8573 | "void main(){\n" |
| 8574 | " color = vec4(x);\n" |
| 8575 | "}\n"; |
| 8576 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8577 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8578 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8579 | |
| 8580 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 8581 | pipe.AddColorAttachment(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8582 | pipe.AddShader(&vs); |
| 8583 | pipe.AddShader(&fs); |
| 8584 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8585 | VkDescriptorSetObj descriptorSet(m_device); |
| 8586 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8587 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8588 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 8589 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8590 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8591 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8592 | } |
| 8593 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8594 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvidedInBlock) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8595 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8596 | "not written by vertex shader"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8597 | |
| 8598 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8599 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8600 | |
| 8601 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8602 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8603 | "\n" |
| 8604 | "out gl_PerVertex {\n" |
| 8605 | " vec4 gl_Position;\n" |
| 8606 | "};\n" |
| 8607 | "void main(){\n" |
| 8608 | " gl_Position = vec4(1);\n" |
| 8609 | "}\n"; |
| 8610 | char const *fsSource = |
| 8611 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8612 | "\n" |
| 8613 | "in block { layout(location=0) float x; } ins;\n" |
| 8614 | "layout(location=0) out vec4 color;\n" |
| 8615 | "void main(){\n" |
| 8616 | " color = vec4(ins.x);\n" |
| 8617 | "}\n"; |
| 8618 | |
| 8619 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8620 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8621 | |
| 8622 | VkPipelineObj pipe(m_device); |
| 8623 | pipe.AddColorAttachment(); |
| 8624 | pipe.AddShader(&vs); |
| 8625 | pipe.AddShader(&fs); |
| 8626 | |
| 8627 | VkDescriptorSetObj descriptorSet(m_device); |
| 8628 | descriptorSet.AppendDummy(); |
| 8629 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8630 | |
| 8631 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8632 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8633 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8634 | } |
| 8635 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8636 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchArraySize) { |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 8637 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 8638 | "Type mismatch on location 0.0: 'ptr to " |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8639 | "output arr[2] of float32' vs 'ptr to " |
| 8640 | "input arr[3] of float32'"); |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 8641 | |
| 8642 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8643 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8644 | |
| 8645 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8646 | "#version 450\n" |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 8647 | "\n" |
| 8648 | "layout(location=0) out float x[2];\n" |
| 8649 | "out gl_PerVertex {\n" |
| 8650 | " vec4 gl_Position;\n" |
| 8651 | "};\n" |
| 8652 | "void main(){\n" |
| 8653 | " x[0] = 0; x[1] = 0;\n" |
| 8654 | " gl_Position = vec4(1);\n" |
| 8655 | "}\n"; |
| 8656 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8657 | "#version 450\n" |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 8658 | "\n" |
| 8659 | "layout(location=0) in float x[3];\n" |
| 8660 | "layout(location=0) out vec4 color;\n" |
| 8661 | "void main(){\n" |
| 8662 | " color = vec4(x[0] + x[1] + x[2]);\n" |
| 8663 | "}\n"; |
| 8664 | |
| 8665 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8666 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8667 | |
| 8668 | VkPipelineObj pipe(m_device); |
| 8669 | pipe.AddColorAttachment(); |
| 8670 | pipe.AddShader(&vs); |
| 8671 | pipe.AddShader(&fs); |
| 8672 | |
| 8673 | VkDescriptorSetObj descriptorSet(m_device); |
| 8674 | descriptorSet.AppendDummy(); |
| 8675 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8676 | |
| 8677 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8678 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8679 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 8680 | } |
| 8681 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8682 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatch) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8683 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8684 | "Type mismatch on location 0"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8685 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8686 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 8687 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8688 | |
| 8689 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8690 | "#version 450\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8691 | "\n" |
| 8692 | "layout(location=0) out int x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8693 | "out gl_PerVertex {\n" |
| 8694 | " vec4 gl_Position;\n" |
| 8695 | "};\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8696 | "void main(){\n" |
| 8697 | " x = 0;\n" |
| 8698 | " gl_Position = vec4(1);\n" |
| 8699 | "}\n"; |
| 8700 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8701 | "#version 450\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8702 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8703 | "layout(location=0) in float x;\n" /* VS writes int */ |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8704 | "layout(location=0) out vec4 color;\n" |
| 8705 | "void main(){\n" |
| 8706 | " color = vec4(x);\n" |
| 8707 | "}\n"; |
| 8708 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8709 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8710 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8711 | |
| 8712 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 8713 | pipe.AddColorAttachment(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8714 | pipe.AddShader(&vs); |
| 8715 | pipe.AddShader(&fs); |
| 8716 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8717 | VkDescriptorSetObj descriptorSet(m_device); |
| 8718 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8719 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8720 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 8721 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8722 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8723 | m_errorMonitor->VerifyFound(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8724 | } |
| 8725 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8726 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchInBlock) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8727 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8728 | "Type mismatch on location 0"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8729 | |
| 8730 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8731 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8732 | |
| 8733 | char const *vsSource = |
| 8734 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8735 | "\n" |
| 8736 | "out block { layout(location=0) int x; } outs;\n" |
| 8737 | "out gl_PerVertex {\n" |
| 8738 | " vec4 gl_Position;\n" |
| 8739 | "};\n" |
| 8740 | "void main(){\n" |
| 8741 | " outs.x = 0;\n" |
| 8742 | " gl_Position = vec4(1);\n" |
| 8743 | "}\n"; |
| 8744 | char const *fsSource = |
| 8745 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8746 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8747 | "in block { layout(location=0) float x; } ins;\n" /* VS writes int */ |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8748 | "layout(location=0) out vec4 color;\n" |
| 8749 | "void main(){\n" |
| 8750 | " color = vec4(ins.x);\n" |
| 8751 | "}\n"; |
| 8752 | |
| 8753 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8754 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8755 | |
| 8756 | VkPipelineObj pipe(m_device); |
| 8757 | pipe.AddColorAttachment(); |
| 8758 | pipe.AddShader(&vs); |
| 8759 | pipe.AddShader(&fs); |
| 8760 | |
| 8761 | VkDescriptorSetObj descriptorSet(m_device); |
| 8762 | descriptorSet.AppendDummy(); |
| 8763 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8764 | |
| 8765 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8766 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8767 | m_errorMonitor->VerifyFound(); |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 8768 | } |
| 8769 | |
| 8770 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByLocation) { |
| 8771 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8772 | "location 0.0 which is not written by vertex shader"); |
| 8773 | |
| 8774 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8775 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8776 | |
| 8777 | char const *vsSource = |
| 8778 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 8779 | "\n" |
| 8780 | "out block { layout(location=1) float x; } outs;\n" |
| 8781 | "out gl_PerVertex {\n" |
| 8782 | " vec4 gl_Position;\n" |
| 8783 | "};\n" |
| 8784 | "void main(){\n" |
| 8785 | " outs.x = 0;\n" |
| 8786 | " gl_Position = vec4(1);\n" |
| 8787 | "}\n"; |
| 8788 | char const *fsSource = |
| 8789 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 8790 | "\n" |
| 8791 | "in block { layout(location=0) float x; } ins;\n" |
| 8792 | "layout(location=0) out vec4 color;\n" |
| 8793 | "void main(){\n" |
| 8794 | " color = vec4(ins.x);\n" |
| 8795 | "}\n"; |
| 8796 | |
| 8797 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8798 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8799 | |
| 8800 | VkPipelineObj pipe(m_device); |
| 8801 | pipe.AddColorAttachment(); |
| 8802 | pipe.AddShader(&vs); |
| 8803 | pipe.AddShader(&fs); |
| 8804 | |
| 8805 | VkDescriptorSetObj descriptorSet(m_device); |
| 8806 | descriptorSet.AppendDummy(); |
| 8807 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8808 | |
| 8809 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8810 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8811 | m_errorMonitor->VerifyFound(); |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 8812 | } |
| 8813 | |
| 8814 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByComponent) { |
| 8815 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8816 | "location 0.1 which is not written by vertex shader"); |
| 8817 | |
| 8818 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8819 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8820 | |
| 8821 | char const *vsSource = |
| 8822 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 8823 | "\n" |
| 8824 | "out block { layout(location=0, component=0) float x; } outs;\n" |
| 8825 | "out gl_PerVertex {\n" |
| 8826 | " vec4 gl_Position;\n" |
| 8827 | "};\n" |
| 8828 | "void main(){\n" |
| 8829 | " outs.x = 0;\n" |
| 8830 | " gl_Position = vec4(1);\n" |
| 8831 | "}\n"; |
| 8832 | char const *fsSource = |
| 8833 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 8834 | "\n" |
| 8835 | "in block { layout(location=0, component=1) float x; } ins;\n" |
| 8836 | "layout(location=0) out vec4 color;\n" |
| 8837 | "void main(){\n" |
| 8838 | " color = vec4(ins.x);\n" |
| 8839 | "}\n"; |
| 8840 | |
| 8841 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8842 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8843 | |
| 8844 | VkPipelineObj pipe(m_device); |
| 8845 | pipe.AddColorAttachment(); |
| 8846 | pipe.AddShader(&vs); |
| 8847 | pipe.AddShader(&fs); |
| 8848 | |
| 8849 | VkDescriptorSetObj descriptorSet(m_device); |
| 8850 | descriptorSet.AppendDummy(); |
| 8851 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8852 | |
| 8853 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8854 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8855 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8856 | } |
| 8857 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8858 | TEST_F(VkLayerTest, CreatePipelineAttribNotConsumed) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 8859 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8860 | "location 0 not consumed by VS"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8861 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8862 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 8863 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8864 | |
| 8865 | VkVertexInputBindingDescription input_binding; |
| 8866 | memset(&input_binding, 0, sizeof(input_binding)); |
| 8867 | |
| 8868 | VkVertexInputAttributeDescription input_attrib; |
| 8869 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 8870 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 8871 | |
| 8872 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8873 | "#version 450\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8874 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8875 | "out gl_PerVertex {\n" |
| 8876 | " vec4 gl_Position;\n" |
| 8877 | "};\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8878 | "void main(){\n" |
| 8879 | " gl_Position = vec4(1);\n" |
| 8880 | "}\n"; |
| 8881 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8882 | "#version 450\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8883 | "\n" |
| 8884 | "layout(location=0) out vec4 color;\n" |
| 8885 | "void main(){\n" |
| 8886 | " color = vec4(1);\n" |
| 8887 | "}\n"; |
| 8888 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8889 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8890 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8891 | |
| 8892 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 8893 | pipe.AddColorAttachment(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8894 | pipe.AddShader(&vs); |
| 8895 | pipe.AddShader(&fs); |
| 8896 | |
| 8897 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 8898 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 8899 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8900 | VkDescriptorSetObj descriptorSet(m_device); |
| 8901 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8902 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8903 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 8904 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8905 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8906 | m_errorMonitor->VerifyFound(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8907 | } |
| 8908 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8909 | TEST_F(VkLayerTest, CreatePipelineAttribLocationMismatch) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 8910 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8911 | "location 0 not consumed by VS"); |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 8912 | |
| 8913 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8914 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8915 | |
| 8916 | VkVertexInputBindingDescription input_binding; |
| 8917 | memset(&input_binding, 0, sizeof(input_binding)); |
| 8918 | |
| 8919 | VkVertexInputAttributeDescription input_attrib; |
| 8920 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 8921 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 8922 | |
| 8923 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8924 | "#version 450\n" |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 8925 | "\n" |
| 8926 | "layout(location=1) in float x;\n" |
| 8927 | "out gl_PerVertex {\n" |
| 8928 | " vec4 gl_Position;\n" |
| 8929 | "};\n" |
| 8930 | "void main(){\n" |
| 8931 | " gl_Position = vec4(x);\n" |
| 8932 | "}\n"; |
| 8933 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8934 | "#version 450\n" |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 8935 | "\n" |
| 8936 | "layout(location=0) out vec4 color;\n" |
| 8937 | "void main(){\n" |
| 8938 | " color = vec4(1);\n" |
| 8939 | "}\n"; |
| 8940 | |
| 8941 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8942 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8943 | |
| 8944 | VkPipelineObj pipe(m_device); |
| 8945 | pipe.AddColorAttachment(); |
| 8946 | pipe.AddShader(&vs); |
| 8947 | pipe.AddShader(&fs); |
| 8948 | |
| 8949 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 8950 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 8951 | |
| 8952 | VkDescriptorSetObj descriptorSet(m_device); |
| 8953 | descriptorSet.AppendDummy(); |
| 8954 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8955 | |
| 8956 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8957 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8958 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 8959 | } |
| 8960 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8961 | TEST_F(VkLayerTest, CreatePipelineAttribNotProvided) { |
| 8962 | m_errorMonitor->SetDesiredFailureMsg( |
| 8963 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8964 | "VS consumes input at location 0 but not provided"); |
| 8965 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8966 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 8967 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8968 | |
| 8969 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8970 | "#version 450\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8971 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8972 | "layout(location=0) in vec4 x;\n" /* not provided */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8973 | "out gl_PerVertex {\n" |
| 8974 | " vec4 gl_Position;\n" |
| 8975 | "};\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8976 | "void main(){\n" |
| 8977 | " gl_Position = x;\n" |
| 8978 | "}\n"; |
| 8979 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8980 | "#version 450\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8981 | "\n" |
| 8982 | "layout(location=0) out vec4 color;\n" |
| 8983 | "void main(){\n" |
| 8984 | " color = vec4(1);\n" |
| 8985 | "}\n"; |
| 8986 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8987 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8988 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8989 | |
| 8990 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 8991 | pipe.AddColorAttachment(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8992 | pipe.AddShader(&vs); |
| 8993 | pipe.AddShader(&fs); |
| 8994 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8995 | VkDescriptorSetObj descriptorSet(m_device); |
| 8996 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8997 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8998 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 8999 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9000 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9001 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 9002 | } |
| 9003 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9004 | TEST_F(VkLayerTest, CreatePipelineAttribTypeMismatch) { |
| 9005 | m_errorMonitor->SetDesiredFailureMsg( |
| 9006 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9007 | "location 0 does not match VS input type"); |
| 9008 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9009 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 9010 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9011 | |
| 9012 | VkVertexInputBindingDescription input_binding; |
| 9013 | memset(&input_binding, 0, sizeof(input_binding)); |
| 9014 | |
| 9015 | VkVertexInputAttributeDescription input_attrib; |
| 9016 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 9017 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 9018 | |
| 9019 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9020 | "#version 450\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9021 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9022 | "layout(location=0) in int x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9023 | "out gl_PerVertex {\n" |
| 9024 | " vec4 gl_Position;\n" |
| 9025 | "};\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9026 | "void main(){\n" |
| 9027 | " gl_Position = vec4(x);\n" |
| 9028 | "}\n"; |
| 9029 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9030 | "#version 450\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9031 | "\n" |
| 9032 | "layout(location=0) out vec4 color;\n" |
| 9033 | "void main(){\n" |
| 9034 | " color = vec4(1);\n" |
| 9035 | "}\n"; |
| 9036 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9037 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9038 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9039 | |
| 9040 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9041 | pipe.AddColorAttachment(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9042 | pipe.AddShader(&vs); |
| 9043 | pipe.AddShader(&fs); |
| 9044 | |
| 9045 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 9046 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 9047 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9048 | VkDescriptorSetObj descriptorSet(m_device); |
| 9049 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9050 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9051 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9052 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9053 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9054 | m_errorMonitor->VerifyFound(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9055 | } |
| 9056 | |
Chris Forbes | c68b43c | 2016-04-06 11:18:47 +1200 | [diff] [blame] | 9057 | TEST_F(VkLayerTest, CreatePipelineDuplicateStage) { |
| 9058 | m_errorMonitor->SetDesiredFailureMsg( |
| 9059 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9060 | "Multiple shaders provided for stage VK_SHADER_STAGE_VERTEX_BIT"); |
| 9061 | |
| 9062 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9063 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9064 | |
| 9065 | char const *vsSource = |
| 9066 | "#version 450\n" |
| 9067 | "\n" |
| 9068 | "out gl_PerVertex {\n" |
| 9069 | " vec4 gl_Position;\n" |
| 9070 | "};\n" |
| 9071 | "void main(){\n" |
| 9072 | " gl_Position = vec4(1);\n" |
| 9073 | "}\n"; |
| 9074 | char const *fsSource = |
| 9075 | "#version 450\n" |
| 9076 | "\n" |
| 9077 | "layout(location=0) out vec4 color;\n" |
| 9078 | "void main(){\n" |
| 9079 | " color = vec4(1);\n" |
| 9080 | "}\n"; |
| 9081 | |
| 9082 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9083 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9084 | |
| 9085 | VkPipelineObj pipe(m_device); |
| 9086 | pipe.AddColorAttachment(); |
| 9087 | pipe.AddShader(&vs); |
| 9088 | pipe.AddShader(&vs); |
| 9089 | pipe.AddShader(&fs); |
| 9090 | |
| 9091 | VkDescriptorSetObj descriptorSet(m_device); |
| 9092 | descriptorSet.AppendDummy(); |
| 9093 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9094 | |
| 9095 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9096 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9097 | m_errorMonitor->VerifyFound(); |
Chris Forbes | c68b43c | 2016-04-06 11:18:47 +1200 | [diff] [blame] | 9098 | } |
| 9099 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9100 | TEST_F(VkLayerTest, CreatePipelineAttribMatrixType) { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9101 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9102 | |
| 9103 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9104 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9105 | |
| 9106 | VkVertexInputBindingDescription input_binding; |
| 9107 | memset(&input_binding, 0, sizeof(input_binding)); |
| 9108 | |
| 9109 | VkVertexInputAttributeDescription input_attribs[2]; |
| 9110 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 9111 | |
| 9112 | for (int i = 0; i < 2; i++) { |
| 9113 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 9114 | input_attribs[i].location = i; |
| 9115 | } |
| 9116 | |
| 9117 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9118 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9119 | "\n" |
| 9120 | "layout(location=0) in mat2x4 x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9121 | "out gl_PerVertex {\n" |
| 9122 | " vec4 gl_Position;\n" |
| 9123 | "};\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9124 | "void main(){\n" |
| 9125 | " gl_Position = x[0] + x[1];\n" |
| 9126 | "}\n"; |
| 9127 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9128 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9129 | "\n" |
| 9130 | "layout(location=0) out vec4 color;\n" |
| 9131 | "void main(){\n" |
| 9132 | " color = vec4(1);\n" |
| 9133 | "}\n"; |
| 9134 | |
| 9135 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9136 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9137 | |
| 9138 | VkPipelineObj pipe(m_device); |
| 9139 | pipe.AddColorAttachment(); |
| 9140 | pipe.AddShader(&vs); |
| 9141 | pipe.AddShader(&fs); |
| 9142 | |
| 9143 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 9144 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 9145 | |
| 9146 | VkDescriptorSetObj descriptorSet(m_device); |
| 9147 | descriptorSet.AppendDummy(); |
| 9148 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9149 | |
| 9150 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9151 | |
| 9152 | /* expect success */ |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9153 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9154 | } |
| 9155 | |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9156 | TEST_F(VkLayerTest, CreatePipelineAttribArrayType) |
| 9157 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9158 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9159 | |
| 9160 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9161 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9162 | |
| 9163 | VkVertexInputBindingDescription input_binding; |
| 9164 | memset(&input_binding, 0, sizeof(input_binding)); |
| 9165 | |
| 9166 | VkVertexInputAttributeDescription input_attribs[2]; |
| 9167 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 9168 | |
| 9169 | for (int i = 0; i < 2; i++) { |
| 9170 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 9171 | input_attribs[i].location = i; |
| 9172 | } |
| 9173 | |
| 9174 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9175 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9176 | "\n" |
| 9177 | "layout(location=0) in vec4 x[2];\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9178 | "out gl_PerVertex {\n" |
| 9179 | " vec4 gl_Position;\n" |
| 9180 | "};\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9181 | "void main(){\n" |
| 9182 | " gl_Position = x[0] + x[1];\n" |
| 9183 | "}\n"; |
| 9184 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9185 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9186 | "\n" |
| 9187 | "layout(location=0) out vec4 color;\n" |
| 9188 | "void main(){\n" |
| 9189 | " color = vec4(1);\n" |
| 9190 | "}\n"; |
| 9191 | |
| 9192 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9193 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9194 | |
| 9195 | VkPipelineObj pipe(m_device); |
| 9196 | pipe.AddColorAttachment(); |
| 9197 | pipe.AddShader(&vs); |
| 9198 | pipe.AddShader(&fs); |
| 9199 | |
| 9200 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 9201 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 9202 | |
| 9203 | VkDescriptorSetObj descriptorSet(m_device); |
| 9204 | descriptorSet.AppendDummy(); |
| 9205 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9206 | |
| 9207 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9208 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9209 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9210 | } |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9211 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9212 | TEST_F(VkLayerTest, CreatePipelineSimplePositive) |
| 9213 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9214 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9215 | |
| 9216 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9217 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9218 | |
| 9219 | char const *vsSource = |
| 9220 | "#version 450\n" |
| 9221 | "out gl_PerVertex {\n" |
| 9222 | " vec4 gl_Position;\n" |
| 9223 | "};\n" |
| 9224 | "void main(){\n" |
| 9225 | " gl_Position = vec4(0);\n" |
| 9226 | "}\n"; |
| 9227 | char const *fsSource = |
| 9228 | "#version 450\n" |
| 9229 | "\n" |
| 9230 | "layout(location=0) out vec4 color;\n" |
| 9231 | "void main(){\n" |
| 9232 | " color = vec4(1);\n" |
| 9233 | "}\n"; |
| 9234 | |
| 9235 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9236 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9237 | |
| 9238 | VkPipelineObj pipe(m_device); |
| 9239 | pipe.AddColorAttachment(); |
| 9240 | pipe.AddShader(&vs); |
| 9241 | pipe.AddShader(&fs); |
| 9242 | |
| 9243 | VkDescriptorSetObj descriptorSet(m_device); |
| 9244 | descriptorSet.AppendDummy(); |
| 9245 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9246 | |
| 9247 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9248 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9249 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9250 | } |
| 9251 | |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 9252 | TEST_F(VkLayerTest, CreatePipelineRelaxedTypeMatch) |
| 9253 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9254 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 9255 | |
| 9256 | // VK 1.0.8 Specification, 14.1.3 "Additionally,..." block |
| 9257 | |
| 9258 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9259 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9260 | |
| 9261 | char const *vsSource = |
| 9262 | "#version 450\n" |
| 9263 | "out gl_PerVertex {\n" |
| 9264 | " vec4 gl_Position;\n" |
| 9265 | "};\n" |
| 9266 | "layout(location=0) out vec3 x;\n" |
| 9267 | "layout(location=1) out ivec3 y;\n" |
| 9268 | "layout(location=2) out vec3 z;\n" |
| 9269 | "void main(){\n" |
| 9270 | " gl_Position = vec4(0);\n" |
| 9271 | " x = vec3(0); y = ivec3(0); z = vec3(0);\n" |
| 9272 | "}\n"; |
| 9273 | char const *fsSource = |
| 9274 | "#version 450\n" |
| 9275 | "\n" |
| 9276 | "layout(location=0) out vec4 color;\n" |
| 9277 | "layout(location=0) in float x;\n" |
| 9278 | "layout(location=1) flat in int y;\n" |
| 9279 | "layout(location=2) in vec2 z;\n" |
| 9280 | "void main(){\n" |
| 9281 | " color = vec4(1 + x + y + z.x);\n" |
| 9282 | "}\n"; |
| 9283 | |
| 9284 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9285 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9286 | |
| 9287 | VkPipelineObj pipe(m_device); |
| 9288 | pipe.AddColorAttachment(); |
| 9289 | pipe.AddShader(&vs); |
| 9290 | pipe.AddShader(&fs); |
| 9291 | |
| 9292 | VkDescriptorSetObj descriptorSet(m_device); |
| 9293 | descriptorSet.AppendDummy(); |
| 9294 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9295 | |
| 9296 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9297 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9298 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 9299 | } |
| 9300 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9301 | TEST_F(VkLayerTest, CreatePipelineTessPerVertex) |
| 9302 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9303 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9304 | |
| 9305 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9306 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9307 | |
Chris Forbes | c1e852d | 2016-04-04 19:26:42 +1200 | [diff] [blame] | 9308 | if (!m_device->phy().features().tessellationShader) { |
| 9309 | printf("Device does not support tessellation shaders; skipped.\n"); |
| 9310 | return; |
| 9311 | } |
| 9312 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9313 | char const *vsSource = |
| 9314 | "#version 450\n" |
| 9315 | "void main(){}\n"; |
| 9316 | char const *tcsSource = |
| 9317 | "#version 450\n" |
| 9318 | "layout(location=0) out int x[];\n" |
| 9319 | "layout(vertices=3) out;\n" |
| 9320 | "void main(){\n" |
| 9321 | " gl_TessLevelOuter[0] = gl_TessLevelOuter[1] = gl_TessLevelOuter[2] = 1;\n" |
| 9322 | " gl_TessLevelInner[0] = 1;\n" |
| 9323 | " x[gl_InvocationID] = gl_InvocationID;\n" |
| 9324 | "}\n"; |
| 9325 | char const *tesSource = |
| 9326 | "#version 450\n" |
| 9327 | "layout(triangles, equal_spacing, cw) in;\n" |
| 9328 | "layout(location=0) in int x[];\n" |
| 9329 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 9330 | "void main(){\n" |
| 9331 | " gl_Position.xyz = gl_TessCoord;\n" |
| 9332 | " gl_Position.w = x[0] + x[1] + x[2];\n" |
| 9333 | "}\n"; |
| 9334 | char const *fsSource = |
| 9335 | "#version 450\n" |
| 9336 | "layout(location=0) out vec4 color;\n" |
| 9337 | "void main(){\n" |
| 9338 | " color = vec4(1);\n" |
| 9339 | "}\n"; |
| 9340 | |
| 9341 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9342 | VkShaderObj tcs(m_device, tcsSource, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 9343 | VkShaderObj tes(m_device, tesSource, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
| 9344 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9345 | |
| 9346 | VkPipelineInputAssemblyStateCreateInfo iasci{ |
| 9347 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, |
| 9348 | nullptr, |
| 9349 | 0, |
| 9350 | VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, |
| 9351 | VK_FALSE}; |
| 9352 | |
Chris Forbes | b4cacb6 | 2016-04-04 19:15:00 +1200 | [diff] [blame] | 9353 | VkPipelineTessellationStateCreateInfo tsci{ |
| 9354 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, |
| 9355 | nullptr, |
| 9356 | 0, |
| 9357 | 3}; |
| 9358 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9359 | VkPipelineObj pipe(m_device); |
| 9360 | pipe.SetInputAssembly(&iasci); |
Chris Forbes | b4cacb6 | 2016-04-04 19:15:00 +1200 | [diff] [blame] | 9361 | pipe.SetTessellation(&tsci); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9362 | pipe.AddColorAttachment(); |
| 9363 | pipe.AddShader(&vs); |
| 9364 | pipe.AddShader(&tcs); |
| 9365 | pipe.AddShader(&tes); |
| 9366 | pipe.AddShader(&fs); |
| 9367 | |
| 9368 | VkDescriptorSetObj descriptorSet(m_device); |
| 9369 | descriptorSet.AppendDummy(); |
| 9370 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9371 | |
| 9372 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9373 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9374 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9375 | } |
| 9376 | |
Chris Forbes | a0ab815 | 2016-04-20 13:34:27 +1200 | [diff] [blame] | 9377 | TEST_F(VkLayerTest, CreatePipelineGeometryInputBlockPositive) |
| 9378 | { |
| 9379 | m_errorMonitor->ExpectSuccess(); |
| 9380 | |
| 9381 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9382 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9383 | |
| 9384 | if (!m_device->phy().features().geometryShader) { |
| 9385 | printf("Device does not support geometry shaders; skipped.\n"); |
| 9386 | return; |
| 9387 | } |
| 9388 | |
| 9389 | char const *vsSource = |
| 9390 | "#version 450\n" |
| 9391 | "layout(location=0) out VertexData { vec4 x; } vs_out;\n" |
| 9392 | "void main(){\n" |
| 9393 | " vs_out.x = vec4(1);\n" |
| 9394 | "}\n"; |
| 9395 | char const *gsSource = |
| 9396 | "#version 450\n" |
| 9397 | "layout(triangles) in;\n" |
| 9398 | "layout(triangle_strip, max_vertices=3) out;\n" |
| 9399 | "layout(location=0) in VertexData { vec4 x; } gs_in[];\n" |
| 9400 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 9401 | "void main() {\n" |
| 9402 | " gl_Position = gs_in[0].x;\n" |
| 9403 | " EmitVertex();\n" |
| 9404 | "}\n"; |
| 9405 | char const *fsSource = |
| 9406 | "#version 450\n" |
| 9407 | "layout(location=0) out vec4 color;\n" |
| 9408 | "void main(){\n" |
| 9409 | " color = vec4(1);\n" |
| 9410 | "}\n"; |
| 9411 | |
| 9412 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9413 | VkShaderObj gs(m_device, gsSource, VK_SHADER_STAGE_GEOMETRY_BIT, this); |
| 9414 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9415 | |
| 9416 | VkPipelineObj pipe(m_device); |
| 9417 | pipe.AddColorAttachment(); |
| 9418 | pipe.AddShader(&vs); |
| 9419 | pipe.AddShader(&gs); |
| 9420 | pipe.AddShader(&fs); |
| 9421 | |
| 9422 | VkDescriptorSetObj descriptorSet(m_device); |
| 9423 | descriptorSet.AppendDummy(); |
| 9424 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9425 | |
| 9426 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9427 | |
| 9428 | m_errorMonitor->VerifyNotFound(); |
| 9429 | } |
| 9430 | |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 9431 | TEST_F(VkLayerTest, CreatePipelineTessPatchDecorationMismatch) |
| 9432 | { |
| 9433 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9434 | "is per-vertex in tessellation control shader stage " |
| 9435 | "but per-patch in tessellation evaluation shader stage"); |
| 9436 | |
| 9437 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9438 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9439 | |
Chris Forbes | c1e852d | 2016-04-04 19:26:42 +1200 | [diff] [blame] | 9440 | if (!m_device->phy().features().tessellationShader) { |
| 9441 | printf("Device does not support tessellation shaders; skipped.\n"); |
| 9442 | return; |
| 9443 | } |
| 9444 | |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 9445 | char const *vsSource = |
| 9446 | "#version 450\n" |
| 9447 | "void main(){}\n"; |
| 9448 | char const *tcsSource = |
| 9449 | "#version 450\n" |
| 9450 | "layout(location=0) out int x[];\n" |
| 9451 | "layout(vertices=3) out;\n" |
| 9452 | "void main(){\n" |
| 9453 | " gl_TessLevelOuter[0] = gl_TessLevelOuter[1] = gl_TessLevelOuter[2] = 1;\n" |
| 9454 | " gl_TessLevelInner[0] = 1;\n" |
| 9455 | " x[gl_InvocationID] = gl_InvocationID;\n" |
| 9456 | "}\n"; |
| 9457 | char const *tesSource = |
| 9458 | "#version 450\n" |
| 9459 | "layout(triangles, equal_spacing, cw) in;\n" |
| 9460 | "layout(location=0) patch in int x;\n" |
| 9461 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 9462 | "void main(){\n" |
| 9463 | " gl_Position.xyz = gl_TessCoord;\n" |
| 9464 | " gl_Position.w = x;\n" |
| 9465 | "}\n"; |
| 9466 | char const *fsSource = |
| 9467 | "#version 450\n" |
| 9468 | "layout(location=0) out vec4 color;\n" |
| 9469 | "void main(){\n" |
| 9470 | " color = vec4(1);\n" |
| 9471 | "}\n"; |
| 9472 | |
| 9473 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9474 | VkShaderObj tcs(m_device, tcsSource, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 9475 | VkShaderObj tes(m_device, tesSource, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
| 9476 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9477 | |
| 9478 | VkPipelineInputAssemblyStateCreateInfo iasci{ |
| 9479 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, |
| 9480 | nullptr, |
| 9481 | 0, |
| 9482 | VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, |
| 9483 | VK_FALSE}; |
| 9484 | |
| 9485 | VkPipelineTessellationStateCreateInfo tsci{ |
| 9486 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, |
| 9487 | nullptr, |
| 9488 | 0, |
| 9489 | 3}; |
| 9490 | |
| 9491 | VkPipelineObj pipe(m_device); |
| 9492 | pipe.SetInputAssembly(&iasci); |
| 9493 | pipe.SetTessellation(&tsci); |
| 9494 | pipe.AddColorAttachment(); |
| 9495 | pipe.AddShader(&vs); |
| 9496 | pipe.AddShader(&tcs); |
| 9497 | pipe.AddShader(&tes); |
| 9498 | pipe.AddShader(&fs); |
| 9499 | |
| 9500 | VkDescriptorSetObj descriptorSet(m_device); |
| 9501 | descriptorSet.AppendDummy(); |
| 9502 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9503 | |
| 9504 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9505 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9506 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 9507 | } |
| 9508 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9509 | TEST_F(VkLayerTest, CreatePipelineAttribBindingConflict) { |
| 9510 | m_errorMonitor->SetDesiredFailureMsg( |
| 9511 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9512 | "Duplicate vertex input binding descriptions for binding 0"); |
| 9513 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9514 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 9515 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9516 | |
| 9517 | /* Two binding descriptions for binding 0 */ |
| 9518 | VkVertexInputBindingDescription input_bindings[2]; |
| 9519 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 9520 | |
| 9521 | VkVertexInputAttributeDescription input_attrib; |
| 9522 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 9523 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 9524 | |
| 9525 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9526 | "#version 450\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9527 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9528 | "layout(location=0) in float x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9529 | "out gl_PerVertex {\n" |
| 9530 | " vec4 gl_Position;\n" |
| 9531 | "};\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9532 | "void main(){\n" |
| 9533 | " gl_Position = vec4(x);\n" |
| 9534 | "}\n"; |
| 9535 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9536 | "#version 450\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9537 | "\n" |
| 9538 | "layout(location=0) out vec4 color;\n" |
| 9539 | "void main(){\n" |
| 9540 | " color = vec4(1);\n" |
| 9541 | "}\n"; |
| 9542 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9543 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9544 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9545 | |
| 9546 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9547 | pipe.AddColorAttachment(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9548 | pipe.AddShader(&vs); |
| 9549 | pipe.AddShader(&fs); |
| 9550 | |
| 9551 | pipe.AddVertexInputBindings(input_bindings, 2); |
| 9552 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 9553 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9554 | VkDescriptorSetObj descriptorSet(m_device); |
| 9555 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9556 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9557 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9558 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9559 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9560 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9561 | } |
Chris Forbes | 8f68b56 | 2015-05-25 11:13:32 +1200 | [diff] [blame] | 9562 | |
Chris Forbes | 35efec7 | 2016-04-21 14:32:08 +1200 | [diff] [blame] | 9563 | TEST_F(VkLayerTest, CreatePipeline64BitAttributesPositive) { |
| 9564 | m_errorMonitor->ExpectSuccess(); |
| 9565 | |
| 9566 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9567 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9568 | |
| 9569 | if (!m_device->phy().features().tessellationShader) { |
| 9570 | printf("Device does not support 64bit vertex attributes; skipped.\n"); |
| 9571 | return; |
| 9572 | } |
| 9573 | |
| 9574 | VkVertexInputBindingDescription input_bindings[1]; |
| 9575 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 9576 | |
| 9577 | VkVertexInputAttributeDescription input_attribs[4]; |
| 9578 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 9579 | input_attribs[0].location = 0; |
| 9580 | input_attribs[0].offset = 0; |
| 9581 | input_attribs[0].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 9582 | input_attribs[1].location = 2; |
| 9583 | input_attribs[1].offset = 32; |
| 9584 | input_attribs[1].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 9585 | input_attribs[2].location = 4; |
| 9586 | input_attribs[2].offset = 64; |
| 9587 | input_attribs[2].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 9588 | input_attribs[3].location = 6; |
| 9589 | input_attribs[3].offset = 96; |
| 9590 | input_attribs[3].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 9591 | |
| 9592 | char const *vsSource = |
| 9593 | "#version 450\n" |
| 9594 | "\n" |
| 9595 | "layout(location=0) in dmat4 x;\n" |
| 9596 | "out gl_PerVertex {\n" |
| 9597 | " vec4 gl_Position;\n" |
| 9598 | "};\n" |
| 9599 | "void main(){\n" |
| 9600 | " gl_Position = vec4(x[0][0]);\n" |
| 9601 | "}\n"; |
| 9602 | char const *fsSource = |
| 9603 | "#version 450\n" |
| 9604 | "\n" |
| 9605 | "layout(location=0) out vec4 color;\n" |
| 9606 | "void main(){\n" |
| 9607 | " color = vec4(1);\n" |
| 9608 | "}\n"; |
| 9609 | |
| 9610 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9611 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9612 | |
| 9613 | VkPipelineObj pipe(m_device); |
| 9614 | pipe.AddColorAttachment(); |
| 9615 | pipe.AddShader(&vs); |
| 9616 | pipe.AddShader(&fs); |
| 9617 | |
| 9618 | pipe.AddVertexInputBindings(input_bindings, 1); |
| 9619 | pipe.AddVertexInputAttribs(input_attribs, 4); |
| 9620 | |
| 9621 | VkDescriptorSetObj descriptorSet(m_device); |
| 9622 | descriptorSet.AppendDummy(); |
| 9623 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9624 | |
| 9625 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9626 | |
| 9627 | m_errorMonitor->VerifyNotFound(); |
| 9628 | } |
| 9629 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9630 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotWritten) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9631 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9632 | "Attachment 0 not written by FS"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9633 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9634 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9635 | |
| 9636 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9637 | "#version 450\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9638 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9639 | "out gl_PerVertex {\n" |
| 9640 | " vec4 gl_Position;\n" |
| 9641 | "};\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9642 | "void main(){\n" |
| 9643 | " gl_Position = vec4(1);\n" |
| 9644 | "}\n"; |
| 9645 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9646 | "#version 450\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9647 | "\n" |
| 9648 | "void main(){\n" |
| 9649 | "}\n"; |
| 9650 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9651 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9652 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9653 | |
| 9654 | VkPipelineObj pipe(m_device); |
| 9655 | pipe.AddShader(&vs); |
| 9656 | pipe.AddShader(&fs); |
| 9657 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9658 | /* set up CB 0, not written */ |
| 9659 | pipe.AddColorAttachment(); |
| 9660 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9661 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9662 | VkDescriptorSetObj descriptorSet(m_device); |
| 9663 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9664 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9665 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9666 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9667 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9668 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9669 | } |
| 9670 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9671 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotConsumed) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9672 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 9673 | VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9674 | "FS writes to output location 1 with no matching attachment"); |
| 9675 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9676 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9677 | |
| 9678 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9679 | "#version 450\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9680 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9681 | "out gl_PerVertex {\n" |
| 9682 | " vec4 gl_Position;\n" |
| 9683 | "};\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9684 | "void main(){\n" |
| 9685 | " gl_Position = vec4(1);\n" |
| 9686 | "}\n"; |
| 9687 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9688 | "#version 450\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9689 | "\n" |
| 9690 | "layout(location=0) out vec4 x;\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9691 | "layout(location=1) out vec4 y;\n" /* no matching attachment for this */ |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9692 | "void main(){\n" |
| 9693 | " x = vec4(1);\n" |
| 9694 | " y = vec4(1);\n" |
| 9695 | "}\n"; |
| 9696 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9697 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9698 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9699 | |
| 9700 | VkPipelineObj pipe(m_device); |
| 9701 | pipe.AddShader(&vs); |
| 9702 | pipe.AddShader(&fs); |
| 9703 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9704 | /* set up CB 0, not written */ |
| 9705 | pipe.AddColorAttachment(); |
| 9706 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9707 | /* FS writes CB 1, but we don't configure it */ |
| 9708 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9709 | VkDescriptorSetObj descriptorSet(m_device); |
| 9710 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9711 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9712 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9713 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9714 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9715 | m_errorMonitor->VerifyFound(); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9716 | } |
| 9717 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9718 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputTypeMismatch) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9719 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9720 | "does not match FS output type"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9721 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9722 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9723 | |
| 9724 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9725 | "#version 450\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9726 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9727 | "out gl_PerVertex {\n" |
| 9728 | " vec4 gl_Position;\n" |
| 9729 | "};\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9730 | "void main(){\n" |
| 9731 | " gl_Position = vec4(1);\n" |
| 9732 | "}\n"; |
| 9733 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9734 | "#version 450\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9735 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9736 | "layout(location=0) out ivec4 x;\n" /* not UNORM */ |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9737 | "void main(){\n" |
| 9738 | " x = ivec4(1);\n" |
| 9739 | "}\n"; |
| 9740 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9741 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9742 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9743 | |
| 9744 | VkPipelineObj pipe(m_device); |
| 9745 | pipe.AddShader(&vs); |
| 9746 | pipe.AddShader(&fs); |
| 9747 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9748 | /* set up CB 0; type is UNORM by default */ |
| 9749 | pipe.AddColorAttachment(); |
| 9750 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9751 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9752 | VkDescriptorSetObj descriptorSet(m_device); |
| 9753 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9754 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9755 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9756 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9757 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9758 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9759 | } |
Chris Forbes | 7b1b893 | 2015-06-05 14:43:36 +1200 | [diff] [blame] | 9760 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9761 | TEST_F(VkLayerTest, CreatePipelineUniformBlockNotProvided) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9762 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9763 | "not declared in pipeline layout"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9764 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 9765 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 9766 | |
| 9767 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9768 | "#version 450\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 9769 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9770 | "out gl_PerVertex {\n" |
| 9771 | " vec4 gl_Position;\n" |
| 9772 | "};\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 9773 | "void main(){\n" |
| 9774 | " gl_Position = vec4(1);\n" |
| 9775 | "}\n"; |
| 9776 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9777 | "#version 450\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 9778 | "\n" |
| 9779 | "layout(location=0) out vec4 x;\n" |
| 9780 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 9781 | "void main(){\n" |
| 9782 | " x = vec4(bar.y);\n" |
| 9783 | "}\n"; |
| 9784 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9785 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9786 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 9787 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 9788 | VkPipelineObj pipe(m_device); |
| 9789 | pipe.AddShader(&vs); |
| 9790 | pipe.AddShader(&fs); |
| 9791 | |
| 9792 | /* set up CB 0; type is UNORM by default */ |
| 9793 | pipe.AddColorAttachment(); |
| 9794 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9795 | |
| 9796 | VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9797 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 9798 | |
| 9799 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9800 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9801 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 9802 | } |
| 9803 | |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 9804 | TEST_F(VkLayerTest, CreatePipelinePushConstantsNotInLayout) { |
| 9805 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9806 | "not declared in layout"); |
| 9807 | |
| 9808 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9809 | |
| 9810 | char const *vsSource = |
| 9811 | "#version 450\n" |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 9812 | "\n" |
| 9813 | "layout(push_constant, std430) uniform foo { float x; } consts;\n" |
| 9814 | "out gl_PerVertex {\n" |
| 9815 | " vec4 gl_Position;\n" |
| 9816 | "};\n" |
| 9817 | "void main(){\n" |
| 9818 | " gl_Position = vec4(consts.x);\n" |
| 9819 | "}\n"; |
| 9820 | char const *fsSource = |
| 9821 | "#version 450\n" |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 9822 | "\n" |
| 9823 | "layout(location=0) out vec4 x;\n" |
| 9824 | "void main(){\n" |
| 9825 | " x = vec4(1);\n" |
| 9826 | "}\n"; |
| 9827 | |
| 9828 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9829 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9830 | |
| 9831 | VkPipelineObj pipe(m_device); |
| 9832 | pipe.AddShader(&vs); |
| 9833 | pipe.AddShader(&fs); |
| 9834 | |
| 9835 | /* set up CB 0; type is UNORM by default */ |
| 9836 | pipe.AddColorAttachment(); |
| 9837 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9838 | |
| 9839 | VkDescriptorSetObj descriptorSet(m_device); |
| 9840 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9841 | |
| 9842 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9843 | |
| 9844 | /* should have generated an error -- no push constant ranges provided! */ |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9845 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 9846 | } |
| 9847 | |
Chris Forbes | 10eb9ae | 2016-05-31 16:09:42 +1200 | [diff] [blame] | 9848 | TEST_F(VkLayerTest, CreateComputePipelineMissingDescriptor) { |
| 9849 | m_errorMonitor->SetDesiredFailureMsg( |
| 9850 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9851 | "Shader uses descriptor slot 0.0"); |
| 9852 | |
| 9853 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9854 | |
| 9855 | char const *csSource = |
| 9856 | "#version 450\n" |
| 9857 | "\n" |
| 9858 | "layout(local_size_x=1) in;\n" |
| 9859 | "layout(set=0, binding=0) buffer block { vec4 x; };\n" |
| 9860 | "void main(){\n" |
| 9861 | " x = vec4(1);\n" |
| 9862 | "}\n"; |
| 9863 | |
| 9864 | VkShaderObj cs(m_device, csSource, VK_SHADER_STAGE_COMPUTE_BIT, this); |
| 9865 | |
| 9866 | VkDescriptorSetObj descriptorSet(m_device); |
| 9867 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9868 | |
| 9869 | VkComputePipelineCreateInfo cpci = { |
| 9870 | VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO, |
| 9871 | nullptr, 0, { |
| 9872 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, |
| 9873 | nullptr, 0, VK_SHADER_STAGE_COMPUTE_BIT, |
| 9874 | cs.handle(), "main", nullptr |
| 9875 | }, |
| 9876 | descriptorSet.GetPipelineLayout(), |
| 9877 | VK_NULL_HANDLE, -1 |
| 9878 | }; |
| 9879 | |
| 9880 | VkPipeline pipe; |
| 9881 | VkResult err = vkCreateComputePipelines( |
| 9882 | m_device->device(), VK_NULL_HANDLE, 1, &cpci, nullptr, &pipe); |
| 9883 | |
| 9884 | m_errorMonitor->VerifyFound(); |
| 9885 | |
| 9886 | if (err == VK_SUCCESS) { |
| 9887 | vkDestroyPipeline(m_device->device(), pipe, nullptr); |
| 9888 | } |
| 9889 | } |
| 9890 | |
| 9891 | TEST_F(VkLayerTest, CreateComputePipelineMissingDescriptorUnusedPositive) { |
| 9892 | m_errorMonitor->ExpectSuccess(); |
| 9893 | |
| 9894 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9895 | |
| 9896 | char const *csSource = |
| 9897 | "#version 450\n" |
| 9898 | "\n" |
| 9899 | "layout(local_size_x=1) in;\n" |
| 9900 | "layout(set=0, binding=0) buffer block { vec4 x; };\n" |
| 9901 | "void main(){\n" |
| 9902 | " // x is not used.\n" |
| 9903 | "}\n"; |
| 9904 | |
| 9905 | VkShaderObj cs(m_device, csSource, VK_SHADER_STAGE_COMPUTE_BIT, this); |
| 9906 | |
| 9907 | VkDescriptorSetObj descriptorSet(m_device); |
| 9908 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9909 | |
| 9910 | VkComputePipelineCreateInfo cpci = { |
| 9911 | VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO, |
| 9912 | nullptr, 0, { |
| 9913 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, |
| 9914 | nullptr, 0, VK_SHADER_STAGE_COMPUTE_BIT, |
| 9915 | cs.handle(), "main", nullptr |
| 9916 | }, |
| 9917 | descriptorSet.GetPipelineLayout(), |
| 9918 | VK_NULL_HANDLE, -1 |
| 9919 | }; |
| 9920 | |
| 9921 | VkPipeline pipe; |
| 9922 | VkResult err = vkCreateComputePipelines( |
| 9923 | m_device->device(), VK_NULL_HANDLE, 1, &cpci, nullptr, &pipe); |
| 9924 | |
| 9925 | m_errorMonitor->VerifyNotFound(); |
| 9926 | |
| 9927 | if (err == VK_SUCCESS) { |
| 9928 | vkDestroyPipeline(m_device->device(), pipe, nullptr); |
| 9929 | } |
| 9930 | } |
| 9931 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 9932 | #endif // SHADER_CHECKER_TESTS |
| 9933 | |
| 9934 | #if DEVICE_LIMITS_TESTS |
Mark Young | c48c4c1 | 2016-04-11 14:26:49 -0600 | [diff] [blame] | 9935 | TEST_F(VkLayerTest, CreateImageLimitsViolationMaxWidth) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9936 | m_errorMonitor->SetDesiredFailureMsg( |
| 9937 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9938 | "CreateImage extents exceed allowable limits for format"); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 9939 | |
| 9940 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 9941 | |
| 9942 | // Create an image |
| 9943 | VkImage image; |
| 9944 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9945 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 9946 | const int32_t tex_width = 32; |
| 9947 | const int32_t tex_height = 32; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 9948 | |
| 9949 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9950 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9951 | image_create_info.pNext = NULL; |
| 9952 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 9953 | image_create_info.format = tex_format; |
| 9954 | image_create_info.extent.width = tex_width; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 9955 | image_create_info.extent.height = tex_height; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9956 | image_create_info.extent.depth = 1; |
| 9957 | image_create_info.mipLevels = 1; |
| 9958 | image_create_info.arrayLayers = 1; |
| 9959 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 9960 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 9961 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 9962 | image_create_info.flags = 0; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 9963 | |
| 9964 | // Introduce error by sending down a bogus width extent |
| 9965 | image_create_info.extent.width = 65536; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9966 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 9967 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9968 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 9969 | } |
| 9970 | |
Mark Young | c48c4c1 | 2016-04-11 14:26:49 -0600 | [diff] [blame] | 9971 | TEST_F(VkLayerTest, CreateImageLimitsViolationMinWidth) { |
| 9972 | m_errorMonitor->SetDesiredFailureMsg( |
| 9973 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9974 | "CreateImage extents is 0 for at least one required dimension"); |
| 9975 | |
| 9976 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9977 | |
| 9978 | // Create an image |
| 9979 | VkImage image; |
| 9980 | |
| 9981 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 9982 | const int32_t tex_width = 32; |
| 9983 | const int32_t tex_height = 32; |
| 9984 | |
| 9985 | VkImageCreateInfo image_create_info = {}; |
| 9986 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9987 | image_create_info.pNext = NULL; |
| 9988 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 9989 | image_create_info.format = tex_format; |
| 9990 | image_create_info.extent.width = tex_width; |
| 9991 | image_create_info.extent.height = tex_height; |
| 9992 | image_create_info.extent.depth = 1; |
| 9993 | image_create_info.mipLevels = 1; |
| 9994 | image_create_info.arrayLayers = 1; |
| 9995 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 9996 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 9997 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 9998 | image_create_info.flags = 0; |
| 9999 | |
| 10000 | // Introduce error by sending down a bogus width extent |
| 10001 | image_create_info.extent.width = 0; |
| 10002 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 10003 | |
| 10004 | m_errorMonitor->VerifyFound(); |
| 10005 | } |
| 10006 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10007 | TEST_F(VkLayerTest, UpdateBufferAlignment) { |
| 10008 | uint32_t updateData[] = {1, 2, 3, 4, 5, 6, 7, 8}; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10009 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 10010 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10011 | "dstOffset, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10012 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10013 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10014 | |
| 10015 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 10016 | vk_testing::Buffer buffer; |
| 10017 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 10018 | |
| 10019 | BeginCommandBuffer(); |
| 10020 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10021 | m_commandBuffer->UpdateBuffer(buffer.handle(), 1, 4, updateData); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10022 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10023 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10024 | // Introduce failure by using size that is not multiple of 4 |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 10025 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10026 | "dataSize, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10027 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10028 | m_commandBuffer->UpdateBuffer(buffer.handle(), 0, 6, updateData); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10029 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10030 | EndCommandBuffer(); |
| 10031 | } |
| 10032 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10033 | TEST_F(VkLayerTest, FillBufferAlignment) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 10034 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10035 | "dstOffset, is not a multiple of 4"); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10036 | |
| 10037 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10038 | |
| 10039 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 10040 | vk_testing::Buffer buffer; |
| 10041 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 10042 | |
| 10043 | BeginCommandBuffer(); |
| 10044 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10045 | m_commandBuffer->FillBuffer(buffer.handle(), 1, 4, 0x11111111); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10046 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10047 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10048 | // Introduce failure by using size that is not multiple of 4 |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 10049 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10050 | "size, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10051 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10052 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 6, 0x11111111); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10053 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10054 | m_errorMonitor->VerifyFound(); |
| 10055 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10056 | EndCommandBuffer(); |
| 10057 | } |
| 10058 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 10059 | #endif // DEVICE_LIMITS_TESTS |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 10060 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10061 | #if IMAGE_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10062 | TEST_F(VkLayerTest, InvalidImageView) { |
| 10063 | VkResult err; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10064 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10065 | m_errorMonitor->SetDesiredFailureMsg( |
| 10066 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10067 | "vkCreateImageView called with baseMipLevel 10 "); |
| 10068 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10069 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10070 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10071 | // Create an image and try to create a view with bad baseMipLevel |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10072 | VkImage image; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10073 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10074 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10075 | const int32_t tex_width = 32; |
| 10076 | const int32_t tex_height = 32; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10077 | |
| 10078 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10079 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10080 | image_create_info.pNext = NULL; |
| 10081 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10082 | image_create_info.format = tex_format; |
| 10083 | image_create_info.extent.width = tex_width; |
| 10084 | image_create_info.extent.height = tex_height; |
| 10085 | image_create_info.extent.depth = 1; |
| 10086 | image_create_info.mipLevels = 1; |
| 10087 | image_create_info.arrayLayers = 1; |
| 10088 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10089 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 10090 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 10091 | image_create_info.flags = 0; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10092 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10093 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10094 | ASSERT_VK_SUCCESS(err); |
| 10095 | |
| 10096 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10097 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10098 | image_view_create_info.image = image; |
| 10099 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 10100 | image_view_create_info.format = tex_format; |
| 10101 | image_view_create_info.subresourceRange.layerCount = 1; |
| 10102 | image_view_create_info.subresourceRange.baseMipLevel = 10; // cause an error |
| 10103 | image_view_create_info.subresourceRange.levelCount = 1; |
| 10104 | image_view_create_info.subresourceRange.aspectMask = |
| 10105 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10106 | |
| 10107 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10108 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 10109 | &view); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10110 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10111 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10112 | } |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10113 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10114 | TEST_F(VkLayerTest, InvalidImageViewAspect) { |
Tobin Ehlis | 1f567a2 | 2016-05-25 16:15:18 -0600 | [diff] [blame] | 10115 | TEST_DESCRIPTION( |
| 10116 | "Create an image and try to create a view with an invalid aspectMask"); |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 10117 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10118 | "vkCreateImageView: Color image " |
| 10119 | "formats must have ONLY the " |
| 10120 | "VK_IMAGE_ASPECT_COLOR_BIT set"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10121 | |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 10122 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 10123 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10124 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
Tobin Ehlis | 1f567a2 | 2016-05-25 16:15:18 -0600 | [diff] [blame] | 10125 | VkImageObj image(m_device); |
| 10126 | image.init(32, 32, tex_format, VK_IMAGE_USAGE_SAMPLED_BIT, |
| 10127 | VK_IMAGE_TILING_LINEAR, 0); |
| 10128 | ASSERT_TRUE(image.initialized()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 10129 | |
| 10130 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10131 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
Tobin Ehlis | 1f567a2 | 2016-05-25 16:15:18 -0600 | [diff] [blame] | 10132 | image_view_create_info.image = image.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10133 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 10134 | image_view_create_info.format = tex_format; |
| 10135 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 10136 | image_view_create_info.subresourceRange.levelCount = 1; |
| 10137 | // Cause an error by setting an invalid image aspect |
| 10138 | image_view_create_info.subresourceRange.aspectMask = |
| 10139 | VK_IMAGE_ASPECT_METADATA_BIT; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 10140 | |
| 10141 | VkImageView view; |
Tobin Ehlis | 1f567a2 | 2016-05-25 16:15:18 -0600 | [diff] [blame] | 10142 | vkCreateImageView(m_device->device(), &image_view_create_info, NULL, &view); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 10143 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10144 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 10145 | } |
| 10146 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10147 | TEST_F(VkLayerTest, CopyImageLayerCountMismatch) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10148 | VkResult err; |
| 10149 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10150 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10151 | m_errorMonitor->SetDesiredFailureMsg( |
| 10152 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10153 | "vkCmdCopyImage: number of layers in source and destination subresources for pRegions"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10154 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10155 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10156 | |
| 10157 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10158 | VkImage srcImage; |
| 10159 | VkImage dstImage; |
| 10160 | VkDeviceMemory srcMem; |
| 10161 | VkDeviceMemory destMem; |
| 10162 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10163 | |
| 10164 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10165 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10166 | image_create_info.pNext = NULL; |
| 10167 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10168 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10169 | image_create_info.extent.width = 32; |
| 10170 | image_create_info.extent.height = 32; |
| 10171 | image_create_info.extent.depth = 1; |
| 10172 | image_create_info.mipLevels = 1; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10173 | image_create_info.arrayLayers = 4; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10174 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10175 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 10176 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 10177 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10178 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10179 | err = |
| 10180 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10181 | ASSERT_VK_SUCCESS(err); |
| 10182 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10183 | err = |
| 10184 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10185 | ASSERT_VK_SUCCESS(err); |
| 10186 | |
| 10187 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10188 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10189 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 10190 | memAlloc.pNext = NULL; |
| 10191 | memAlloc.allocationSize = 0; |
| 10192 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10193 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 10194 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10195 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10196 | pass = |
| 10197 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10198 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10199 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10200 | ASSERT_VK_SUCCESS(err); |
| 10201 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10202 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10203 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10204 | pass = |
| 10205 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10206 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10207 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10208 | ASSERT_VK_SUCCESS(err); |
| 10209 | |
| 10210 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 10211 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10212 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10213 | ASSERT_VK_SUCCESS(err); |
| 10214 | |
| 10215 | BeginCommandBuffer(); |
| 10216 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10217 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10218 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 10219 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10220 | copyRegion.srcSubresource.layerCount = 1; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10221 | copyRegion.srcOffset.x = 0; |
| 10222 | copyRegion.srcOffset.y = 0; |
| 10223 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10224 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10225 | copyRegion.dstSubresource.mipLevel = 0; |
| 10226 | copyRegion.dstSubresource.baseArrayLayer = 0; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10227 | // Introduce failure by forcing the dst layerCount to differ from src |
| 10228 | copyRegion.dstSubresource.layerCount = 3; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10229 | copyRegion.dstOffset.x = 0; |
| 10230 | copyRegion.dstOffset.y = 0; |
| 10231 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10232 | copyRegion.extent.width = 1; |
| 10233 | copyRegion.extent.height = 1; |
| 10234 | copyRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10235 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 10236 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10237 | EndCommandBuffer(); |
| 10238 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10239 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10240 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10241 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10242 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10243 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 10244 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10245 | } |
| 10246 | |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10247 | TEST_F(VkLayerTest, ImageLayerUnsupportedFormat) { |
| 10248 | |
| 10249 | TEST_DESCRIPTION("Creating images with unsuported formats "); |
| 10250 | |
| 10251 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10252 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 10253 | VkImageObj image(m_device); |
| 10254 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 10255 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 10256 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 10257 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 10258 | ASSERT_TRUE(image.initialized()); |
| 10259 | |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 10260 | // Create image with unsupported format - Expect FORMAT_UNSUPPORTED |
| 10261 | VkImageCreateInfo image_create_info; |
| 10262 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10263 | image_create_info.pNext = NULL; |
| 10264 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10265 | image_create_info.format = VK_FORMAT_UNDEFINED; |
| 10266 | image_create_info.extent.width = 32; |
| 10267 | image_create_info.extent.height = 32; |
| 10268 | image_create_info.extent.depth = 1; |
| 10269 | image_create_info.mipLevels = 1; |
| 10270 | image_create_info.arrayLayers = 1; |
| 10271 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10272 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 10273 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 10274 | image_create_info.flags = 0; |
| 10275 | |
| 10276 | m_errorMonitor->SetDesiredFailureMsg( |
| 10277 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10278 | "vkCreateImage: VkFormat for image must not be VK_FORMAT_UNDEFINED"); |
| 10279 | |
| 10280 | VkImage localImage; |
| 10281 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &localImage); |
| 10282 | m_errorMonitor->VerifyFound(); |
| 10283 | |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10284 | VkFormat unsupported = VK_FORMAT_UNDEFINED; |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 10285 | // Look for a format that is COMPLETELY unsupported with this hardware |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10286 | for (int f = VK_FORMAT_BEGIN_RANGE; f <= VK_FORMAT_END_RANGE; f++) { |
| 10287 | VkFormat format = static_cast<VkFormat>(f); |
| 10288 | VkFormatProperties fProps = m_device->format_properties(format); |
| 10289 | if (format != VK_FORMAT_UNDEFINED && fProps.linearTilingFeatures == 0 && |
| 10290 | fProps.optimalTilingFeatures == 0) { |
| 10291 | unsupported = format; |
| 10292 | break; |
| 10293 | } |
| 10294 | } |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 10295 | |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10296 | if (unsupported != VK_FORMAT_UNDEFINED) { |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10297 | image_create_info.format = unsupported; |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10298 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 10299 | "is an unsupported format"); |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10300 | |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 10301 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &localImage); |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10302 | m_errorMonitor->VerifyFound(); |
| 10303 | } |
| 10304 | } |
| 10305 | |
| 10306 | TEST_F(VkLayerTest, ImageLayerViewTests) { |
| 10307 | VkResult ret; |
| 10308 | TEST_DESCRIPTION("Passing bad parameters to CreateImageView"); |
| 10309 | |
| 10310 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10311 | |
| 10312 | VkImageObj image(m_device); |
| 10313 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 10314 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 10315 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 10316 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 10317 | ASSERT_TRUE(image.initialized()); |
| 10318 | |
| 10319 | VkImageView imgView; |
| 10320 | VkImageViewCreateInfo imgViewInfo = {}; |
| 10321 | imgViewInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 10322 | imgViewInfo.image = image.handle(); |
| 10323 | imgViewInfo.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 10324 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10325 | imgViewInfo.subresourceRange.layerCount = 1; |
| 10326 | imgViewInfo.subresourceRange.baseMipLevel = 0; |
| 10327 | imgViewInfo.subresourceRange.levelCount = 1; |
| 10328 | imgViewInfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10329 | |
| 10330 | m_errorMonitor->SetDesiredFailureMsg( |
| 10331 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10332 | "vkCreateImageView called with baseMipLevel"); |
| 10333 | // View can't have baseMipLevel >= image's mipLevels - Expect |
| 10334 | // VIEW_CREATE_ERROR |
| 10335 | imgViewInfo.subresourceRange.baseMipLevel = 1; |
| 10336 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 10337 | m_errorMonitor->VerifyFound(); |
| 10338 | imgViewInfo.subresourceRange.baseMipLevel = 0; |
| 10339 | |
| 10340 | m_errorMonitor->SetDesiredFailureMsg( |
| 10341 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10342 | "vkCreateImageView called with baseArrayLayer"); |
| 10343 | // View can't have baseArrayLayer >= image's arraySize - Expect |
| 10344 | // VIEW_CREATE_ERROR |
| 10345 | imgViewInfo.subresourceRange.baseArrayLayer = 1; |
| 10346 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 10347 | m_errorMonitor->VerifyFound(); |
| 10348 | imgViewInfo.subresourceRange.baseArrayLayer = 0; |
| 10349 | |
| 10350 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10351 | "vkCreateImageView called with 0 in " |
| 10352 | "pCreateInfo->subresourceRange." |
| 10353 | "levelCount"); |
| 10354 | // View's levelCount can't be 0 - Expect VIEW_CREATE_ERROR |
| 10355 | imgViewInfo.subresourceRange.levelCount = 0; |
| 10356 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 10357 | m_errorMonitor->VerifyFound(); |
| 10358 | imgViewInfo.subresourceRange.levelCount = 1; |
| 10359 | |
| 10360 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10361 | "vkCreateImageView called with 0 in " |
| 10362 | "pCreateInfo->subresourceRange." |
| 10363 | "layerCount"); |
| 10364 | // View's layerCount can't be 0 - Expect VIEW_CREATE_ERROR |
| 10365 | imgViewInfo.subresourceRange.layerCount = 0; |
| 10366 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 10367 | m_errorMonitor->VerifyFound(); |
| 10368 | imgViewInfo.subresourceRange.layerCount = 1; |
| 10369 | |
| 10370 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10371 | "but both must be color formats"); |
| 10372 | // Can't use depth format for view into color image - Expect INVALID_FORMAT |
| 10373 | imgViewInfo.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 10374 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 10375 | m_errorMonitor->VerifyFound(); |
| 10376 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10377 | |
| 10378 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10379 | "Formats MUST be IDENTICAL unless " |
| 10380 | "VK_IMAGE_CREATE_MUTABLE_FORMAT BIT " |
| 10381 | "was set on image creation."); |
| 10382 | // Same compatibility class but no MUTABLE_FORMAT bit - Expect |
| 10383 | // VIEW_CREATE_ERROR |
| 10384 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UINT; |
| 10385 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 10386 | m_errorMonitor->VerifyFound(); |
| 10387 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10388 | |
| 10389 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10390 | "can support ImageViews with " |
| 10391 | "differing formats but they must be " |
| 10392 | "in the same compatibility class."); |
| 10393 | // Have MUTABLE_FORMAT bit but not in same compatibility class - Expect |
| 10394 | // VIEW_CREATE_ERROR |
| 10395 | VkImageCreateInfo mutImgInfo = image.create_info(); |
| 10396 | VkImage mutImage; |
| 10397 | mutImgInfo.format = VK_FORMAT_R8_UINT; |
| 10398 | assert( |
| 10399 | m_device->format_properties(VK_FORMAT_R8_UINT).optimalTilingFeatures & |
| 10400 | VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT); |
| 10401 | mutImgInfo.flags = VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT; |
| 10402 | mutImgInfo.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 10403 | ret = vkCreateImage(m_device->handle(), &mutImgInfo, NULL, &mutImage); |
| 10404 | ASSERT_VK_SUCCESS(ret); |
| 10405 | imgViewInfo.image = mutImage; |
| 10406 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 10407 | m_errorMonitor->VerifyFound(); |
| 10408 | imgViewInfo.image = image.handle(); |
| 10409 | vkDestroyImage(m_device->handle(), mutImage, NULL); |
| 10410 | } |
| 10411 | |
| 10412 | TEST_F(VkLayerTest, MiscImageLayerTests) { |
| 10413 | |
| 10414 | TEST_DESCRIPTION("Image layer tests that don't belong elsewhare"); |
| 10415 | |
| 10416 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10417 | |
| 10418 | VkImageObj image(m_device); |
| 10419 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 10420 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 10421 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 10422 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 10423 | ASSERT_TRUE(image.initialized()); |
| 10424 | |
| 10425 | m_errorMonitor->SetDesiredFailureMsg( |
| 10426 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10427 | "number of layers in image subresource is zero"); |
| 10428 | vk_testing::Buffer buffer; |
| 10429 | VkMemoryPropertyFlags reqs = 0; |
| 10430 | buffer.init_as_src(*m_device, 128 * 128 * 4, reqs); |
| 10431 | VkBufferImageCopy region = {}; |
| 10432 | region.bufferRowLength = 128; |
| 10433 | region.bufferImageHeight = 128; |
| 10434 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10435 | // layerCount can't be 0 - Expect MISMATCHED_IMAGE_ASPECT |
| 10436 | region.imageSubresource.layerCount = 0; |
| 10437 | region.imageExtent.height = 4; |
| 10438 | region.imageExtent.width = 4; |
| 10439 | region.imageExtent.depth = 1; |
| 10440 | m_commandBuffer->BeginCommandBuffer(); |
| 10441 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 10442 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 10443 | 1, ®ion); |
| 10444 | m_errorMonitor->VerifyFound(); |
| 10445 | region.imageSubresource.layerCount = 1; |
| 10446 | |
| 10447 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10448 | "aspectMasks for each region must " |
| 10449 | "specify only COLOR or DEPTH or " |
| 10450 | "STENCIL"); |
| 10451 | // Expect MISMATCHED_IMAGE_ASPECT |
| 10452 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_METADATA_BIT; |
| 10453 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 10454 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 10455 | 1, ®ion); |
| 10456 | m_errorMonitor->VerifyFound(); |
| 10457 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10458 | |
| 10459 | m_errorMonitor->SetDesiredFailureMsg( |
| 10460 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10461 | "If the format of srcImage is a depth, stencil, depth stencil or " |
| 10462 | "integer-based format then filter must be VK_FILTER_NEAREST"); |
| 10463 | // Expect INVALID_FILTER |
| 10464 | VkImageObj intImage1(m_device); |
| 10465 | intImage1.init(128, 128, VK_FORMAT_R8_UINT, |
| 10466 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, |
| 10467 | 0); |
| 10468 | VkImageObj intImage2(m_device); |
| 10469 | intImage2.init(128, 128, VK_FORMAT_R8_UINT, |
| 10470 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, |
| 10471 | 0); |
| 10472 | VkImageBlit blitRegion = {}; |
| 10473 | blitRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10474 | blitRegion.srcSubresource.baseArrayLayer = 0; |
| 10475 | blitRegion.srcSubresource.layerCount = 1; |
| 10476 | blitRegion.srcSubresource.mipLevel = 0; |
| 10477 | blitRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10478 | blitRegion.dstSubresource.baseArrayLayer = 0; |
| 10479 | blitRegion.dstSubresource.layerCount = 1; |
| 10480 | blitRegion.dstSubresource.mipLevel = 0; |
| 10481 | |
| 10482 | vkCmdBlitImage(m_commandBuffer->GetBufferHandle(), intImage1.handle(), |
| 10483 | intImage1.layout(), intImage2.handle(), intImage2.layout(), |
| 10484 | 16, &blitRegion, VK_FILTER_LINEAR); |
| 10485 | m_errorMonitor->VerifyFound(); |
| 10486 | |
| 10487 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10488 | "called with 0 in ppMemoryBarriers"); |
| 10489 | VkImageMemoryBarrier img_barrier; |
| 10490 | img_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; |
| 10491 | img_barrier.pNext = NULL; |
| 10492 | img_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 10493 | img_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 10494 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 10495 | img_barrier.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 10496 | img_barrier.image = image.handle(); |
| 10497 | img_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 10498 | img_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 10499 | img_barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10500 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 10501 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 10502 | // layerCount should not be 0 - Expect INVALID_IMAGE_RESOURCE |
| 10503 | img_barrier.subresourceRange.layerCount = 0; |
| 10504 | img_barrier.subresourceRange.levelCount = 1; |
| 10505 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 10506 | VK_PIPELINE_STAGE_HOST_BIT, |
| 10507 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 10508 | nullptr, 1, &img_barrier); |
| 10509 | m_errorMonitor->VerifyFound(); |
| 10510 | img_barrier.subresourceRange.layerCount = 1; |
| 10511 | } |
| 10512 | |
| 10513 | TEST_F(VkLayerTest, ImageFormatLimits) { |
| 10514 | |
| 10515 | TEST_DESCRIPTION("Exceed the limits of image format "); |
| 10516 | |
| 10517 | m_errorMonitor->SetDesiredFailureMsg( |
| 10518 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10519 | "CreateImage extents exceed allowable limits for format"); |
| 10520 | VkImageCreateInfo image_create_info = {}; |
| 10521 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10522 | image_create_info.pNext = NULL; |
| 10523 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10524 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10525 | image_create_info.extent.width = 32; |
| 10526 | image_create_info.extent.height = 32; |
| 10527 | image_create_info.extent.depth = 1; |
| 10528 | image_create_info.mipLevels = 1; |
| 10529 | image_create_info.arrayLayers = 1; |
| 10530 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10531 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 10532 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 10533 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 10534 | image_create_info.flags = 0; |
| 10535 | |
| 10536 | VkImage nullImg; |
| 10537 | VkImageFormatProperties imgFmtProps; |
| 10538 | vkGetPhysicalDeviceImageFormatProperties( |
| 10539 | gpu(), image_create_info.format, image_create_info.imageType, |
| 10540 | image_create_info.tiling, image_create_info.usage, |
| 10541 | image_create_info.flags, &imgFmtProps); |
| 10542 | image_create_info.extent.depth = imgFmtProps.maxExtent.depth + 1; |
| 10543 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 10544 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 10545 | m_errorMonitor->VerifyFound(); |
| 10546 | image_create_info.extent.depth = 1; |
| 10547 | |
| 10548 | m_errorMonitor->SetDesiredFailureMsg( |
| 10549 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10550 | "exceeds allowable maximum supported by format of"); |
| 10551 | image_create_info.mipLevels = imgFmtProps.maxMipLevels + 1; |
| 10552 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 10553 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 10554 | m_errorMonitor->VerifyFound(); |
| 10555 | image_create_info.mipLevels = 1; |
| 10556 | |
| 10557 | m_errorMonitor->SetDesiredFailureMsg( |
| 10558 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10559 | "exceeds allowable maximum supported by format of"); |
| 10560 | image_create_info.arrayLayers = imgFmtProps.maxArrayLayers + 1; |
| 10561 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 10562 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 10563 | m_errorMonitor->VerifyFound(); |
| 10564 | image_create_info.arrayLayers = 1; |
| 10565 | |
| 10566 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10567 | "is not supported by format"); |
| 10568 | int samples = imgFmtProps.sampleCounts >> 1; |
| 10569 | image_create_info.samples = (VkSampleCountFlagBits)samples; |
| 10570 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 10571 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 10572 | m_errorMonitor->VerifyFound(); |
| 10573 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10574 | |
| 10575 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10576 | "pCreateInfo->initialLayout, must be " |
| 10577 | "VK_IMAGE_LAYOUT_UNDEFINED or " |
| 10578 | "VK_IMAGE_LAYOUT_PREINITIALIZED"); |
| 10579 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 10580 | // Expect INVALID_LAYOUT |
| 10581 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 10582 | m_errorMonitor->VerifyFound(); |
| 10583 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 10584 | } |
| 10585 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10586 | TEST_F(VkLayerTest, CopyImageFormatSizeMismatch) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 10587 | VkResult err; |
| 10588 | bool pass; |
| 10589 | |
| 10590 | // Create color images with different format sizes and try to copy between them |
| 10591 | m_errorMonitor->SetDesiredFailureMsg( |
| 10592 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10593 | "vkCmdCopyImage called with unmatched source and dest image format sizes"); |
| 10594 | |
| 10595 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10596 | |
| 10597 | // Create two images of different types and try to copy between them |
| 10598 | VkImage srcImage; |
| 10599 | VkImage dstImage; |
| 10600 | VkDeviceMemory srcMem; |
| 10601 | VkDeviceMemory destMem; |
| 10602 | VkMemoryRequirements memReqs; |
| 10603 | |
| 10604 | VkImageCreateInfo image_create_info = {}; |
| 10605 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10606 | image_create_info.pNext = NULL; |
| 10607 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10608 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10609 | image_create_info.extent.width = 32; |
| 10610 | image_create_info.extent.height = 32; |
| 10611 | image_create_info.extent.depth = 1; |
| 10612 | image_create_info.mipLevels = 1; |
| 10613 | image_create_info.arrayLayers = 1; |
| 10614 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10615 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 10616 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 10617 | image_create_info.flags = 0; |
| 10618 | |
| 10619 | err = |
| 10620 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
| 10621 | ASSERT_VK_SUCCESS(err); |
| 10622 | |
| 10623 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 10624 | // Introduce failure by creating second image with a different-sized format. |
| 10625 | image_create_info.format = VK_FORMAT_R5G5B5A1_UNORM_PACK16; |
| 10626 | |
| 10627 | err = |
| 10628 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
| 10629 | ASSERT_VK_SUCCESS(err); |
| 10630 | |
| 10631 | // Allocate memory |
| 10632 | VkMemoryAllocateInfo memAlloc = {}; |
| 10633 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 10634 | memAlloc.pNext = NULL; |
| 10635 | memAlloc.allocationSize = 0; |
| 10636 | memAlloc.memoryTypeIndex = 0; |
| 10637 | |
| 10638 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
| 10639 | memAlloc.allocationSize = memReqs.size; |
| 10640 | pass = |
| 10641 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 10642 | ASSERT_TRUE(pass); |
| 10643 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
| 10644 | ASSERT_VK_SUCCESS(err); |
| 10645 | |
| 10646 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
| 10647 | memAlloc.allocationSize = memReqs.size; |
| 10648 | pass = |
| 10649 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 10650 | ASSERT_TRUE(pass); |
| 10651 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
| 10652 | ASSERT_VK_SUCCESS(err); |
| 10653 | |
| 10654 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 10655 | ASSERT_VK_SUCCESS(err); |
| 10656 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
| 10657 | ASSERT_VK_SUCCESS(err); |
| 10658 | |
| 10659 | BeginCommandBuffer(); |
| 10660 | VkImageCopy copyRegion; |
| 10661 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10662 | copyRegion.srcSubresource.mipLevel = 0; |
| 10663 | copyRegion.srcSubresource.baseArrayLayer = 0; |
| 10664 | copyRegion.srcSubresource.layerCount = 0; |
| 10665 | copyRegion.srcOffset.x = 0; |
| 10666 | copyRegion.srcOffset.y = 0; |
| 10667 | copyRegion.srcOffset.z = 0; |
| 10668 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10669 | copyRegion.dstSubresource.mipLevel = 0; |
| 10670 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 10671 | copyRegion.dstSubresource.layerCount = 0; |
| 10672 | copyRegion.dstOffset.x = 0; |
| 10673 | copyRegion.dstOffset.y = 0; |
| 10674 | copyRegion.dstOffset.z = 0; |
| 10675 | copyRegion.extent.width = 1; |
| 10676 | copyRegion.extent.height = 1; |
| 10677 | copyRegion.extent.depth = 1; |
| 10678 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 10679 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 10680 | EndCommandBuffer(); |
| 10681 | |
| 10682 | m_errorMonitor->VerifyFound(); |
| 10683 | |
| 10684 | vkDestroyImage(m_device->device(), srcImage, NULL); |
| 10685 | vkDestroyImage(m_device->device(), dstImage, NULL); |
| 10686 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 10687 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10688 | } |
| 10689 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10690 | TEST_F(VkLayerTest, CopyImageDepthStencilFormatMismatch) { |
| 10691 | VkResult err; |
| 10692 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10693 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10694 | // 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] | 10695 | m_errorMonitor->SetDesiredFailureMsg( |
| 10696 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10697 | "vkCmdCopyImage called with unmatched source and dest image depth"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10698 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10699 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10700 | |
| 10701 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10702 | VkImage srcImage; |
| 10703 | VkImage dstImage; |
| 10704 | VkDeviceMemory srcMem; |
| 10705 | VkDeviceMemory destMem; |
| 10706 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10707 | |
| 10708 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10709 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10710 | image_create_info.pNext = NULL; |
| 10711 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10712 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10713 | image_create_info.extent.width = 32; |
| 10714 | image_create_info.extent.height = 32; |
| 10715 | image_create_info.extent.depth = 1; |
| 10716 | image_create_info.mipLevels = 1; |
| 10717 | image_create_info.arrayLayers = 1; |
| 10718 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10719 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 10720 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 10721 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10722 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10723 | err = |
| 10724 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10725 | ASSERT_VK_SUCCESS(err); |
| 10726 | |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 10727 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 10728 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10729 | // Introduce failure by creating second image with a depth/stencil format |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10730 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10731 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 10732 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10733 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10734 | err = |
| 10735 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10736 | ASSERT_VK_SUCCESS(err); |
| 10737 | |
| 10738 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10739 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10740 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 10741 | memAlloc.pNext = NULL; |
| 10742 | memAlloc.allocationSize = 0; |
| 10743 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10744 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 10745 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10746 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10747 | pass = |
| 10748 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10749 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10750 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10751 | ASSERT_VK_SUCCESS(err); |
| 10752 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10753 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10754 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10755 | pass = |
| 10756 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10757 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10758 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10759 | ASSERT_VK_SUCCESS(err); |
| 10760 | |
| 10761 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 10762 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10763 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10764 | ASSERT_VK_SUCCESS(err); |
| 10765 | |
| 10766 | BeginCommandBuffer(); |
| 10767 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10768 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10769 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 10770 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10771 | copyRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10772 | copyRegion.srcOffset.x = 0; |
| 10773 | copyRegion.srcOffset.y = 0; |
| 10774 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10775 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10776 | copyRegion.dstSubresource.mipLevel = 0; |
| 10777 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 10778 | copyRegion.dstSubresource.layerCount = 0; |
| 10779 | copyRegion.dstOffset.x = 0; |
| 10780 | copyRegion.dstOffset.y = 0; |
| 10781 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10782 | copyRegion.extent.width = 1; |
| 10783 | copyRegion.extent.height = 1; |
| 10784 | copyRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10785 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 10786 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10787 | EndCommandBuffer(); |
| 10788 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10789 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10790 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10791 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10792 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10793 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 10794 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10795 | } |
| 10796 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10797 | TEST_F(VkLayerTest, ResolveImageLowSampleCount) { |
| 10798 | VkResult err; |
| 10799 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10800 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10801 | m_errorMonitor->SetDesiredFailureMsg( |
| 10802 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10803 | "vkCmdResolveImage called with source sample count less than 2."); |
| 10804 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10805 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10806 | |
| 10807 | // 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] | 10808 | VkImage srcImage; |
| 10809 | VkImage dstImage; |
| 10810 | VkDeviceMemory srcMem; |
| 10811 | VkDeviceMemory destMem; |
| 10812 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10813 | |
| 10814 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10815 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10816 | image_create_info.pNext = NULL; |
| 10817 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10818 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10819 | image_create_info.extent.width = 32; |
| 10820 | image_create_info.extent.height = 1; |
| 10821 | image_create_info.extent.depth = 1; |
| 10822 | image_create_info.mipLevels = 1; |
| 10823 | image_create_info.arrayLayers = 1; |
| 10824 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10825 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 10826 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 10827 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10828 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10829 | err = |
| 10830 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10831 | ASSERT_VK_SUCCESS(err); |
| 10832 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10833 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10834 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10835 | err = |
| 10836 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10837 | ASSERT_VK_SUCCESS(err); |
| 10838 | |
| 10839 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10840 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10841 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 10842 | memAlloc.pNext = NULL; |
| 10843 | memAlloc.allocationSize = 0; |
| 10844 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10845 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 10846 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10847 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10848 | pass = |
| 10849 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10850 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10851 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10852 | ASSERT_VK_SUCCESS(err); |
| 10853 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10854 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10855 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10856 | pass = |
| 10857 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10858 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10859 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10860 | ASSERT_VK_SUCCESS(err); |
| 10861 | |
| 10862 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 10863 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10864 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10865 | ASSERT_VK_SUCCESS(err); |
| 10866 | |
| 10867 | BeginCommandBuffer(); |
| 10868 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10869 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 10870 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10871 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10872 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10873 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 10874 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10875 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10876 | resolveRegion.srcOffset.x = 0; |
| 10877 | resolveRegion.srcOffset.y = 0; |
| 10878 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10879 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10880 | resolveRegion.dstSubresource.mipLevel = 0; |
| 10881 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 10882 | resolveRegion.dstSubresource.layerCount = 0; |
| 10883 | resolveRegion.dstOffset.x = 0; |
| 10884 | resolveRegion.dstOffset.y = 0; |
| 10885 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10886 | resolveRegion.extent.width = 1; |
| 10887 | resolveRegion.extent.height = 1; |
| 10888 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10889 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 10890 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10891 | EndCommandBuffer(); |
| 10892 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10893 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10894 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10895 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10896 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10897 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 10898 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10899 | } |
| 10900 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10901 | TEST_F(VkLayerTest, ResolveImageHighSampleCount) { |
| 10902 | VkResult err; |
| 10903 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10904 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10905 | m_errorMonitor->SetDesiredFailureMsg( |
| 10906 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10907 | "vkCmdResolveImage called with dest sample count greater than 1."); |
| 10908 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10909 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10910 | |
Chris Forbes | a753069 | 2016-05-08 12:35:39 +1200 | [diff] [blame] | 10911 | // 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] | 10912 | VkImage srcImage; |
| 10913 | VkImage dstImage; |
| 10914 | VkDeviceMemory srcMem; |
| 10915 | VkDeviceMemory destMem; |
| 10916 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10917 | |
| 10918 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10919 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10920 | image_create_info.pNext = NULL; |
| 10921 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10922 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10923 | image_create_info.extent.width = 32; |
| 10924 | image_create_info.extent.height = 1; |
| 10925 | image_create_info.extent.depth = 1; |
| 10926 | image_create_info.mipLevels = 1; |
| 10927 | image_create_info.arrayLayers = 1; |
Chris Forbes | a753069 | 2016-05-08 12:35:39 +1200 | [diff] [blame] | 10928 | image_create_info.samples = VK_SAMPLE_COUNT_4_BIT; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10929 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 10930 | // Note: Some implementations expect color attachment usage for any |
| 10931 | // multisample surface |
| 10932 | image_create_info.usage = |
| 10933 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 10934 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10935 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10936 | err = |
| 10937 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10938 | ASSERT_VK_SUCCESS(err); |
| 10939 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10940 | // Note: Some implementations expect color attachment usage for any |
| 10941 | // multisample surface |
| 10942 | image_create_info.usage = |
| 10943 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10944 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10945 | err = |
| 10946 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10947 | ASSERT_VK_SUCCESS(err); |
| 10948 | |
| 10949 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10950 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10951 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 10952 | memAlloc.pNext = NULL; |
| 10953 | memAlloc.allocationSize = 0; |
| 10954 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10955 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 10956 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10957 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10958 | pass = |
| 10959 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10960 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10961 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10962 | ASSERT_VK_SUCCESS(err); |
| 10963 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10964 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10965 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10966 | pass = |
| 10967 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10968 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10969 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10970 | ASSERT_VK_SUCCESS(err); |
| 10971 | |
| 10972 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 10973 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10974 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10975 | ASSERT_VK_SUCCESS(err); |
| 10976 | |
| 10977 | BeginCommandBuffer(); |
| 10978 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10979 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 10980 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10981 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10982 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10983 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 10984 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10985 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10986 | resolveRegion.srcOffset.x = 0; |
| 10987 | resolveRegion.srcOffset.y = 0; |
| 10988 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10989 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10990 | resolveRegion.dstSubresource.mipLevel = 0; |
| 10991 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 10992 | resolveRegion.dstSubresource.layerCount = 0; |
| 10993 | resolveRegion.dstOffset.x = 0; |
| 10994 | resolveRegion.dstOffset.y = 0; |
| 10995 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10996 | resolveRegion.extent.width = 1; |
| 10997 | resolveRegion.extent.height = 1; |
| 10998 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10999 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 11000 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11001 | EndCommandBuffer(); |
| 11002 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11003 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11004 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11005 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11006 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11007 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 11008 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11009 | } |
| 11010 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11011 | TEST_F(VkLayerTest, ResolveImageFormatMismatch) { |
| 11012 | VkResult err; |
| 11013 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11014 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11015 | m_errorMonitor->SetDesiredFailureMsg( |
| 11016 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11017 | "vkCmdResolveImage called with unmatched source and dest formats."); |
| 11018 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11019 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11020 | |
| 11021 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11022 | VkImage srcImage; |
| 11023 | VkImage dstImage; |
| 11024 | VkDeviceMemory srcMem; |
| 11025 | VkDeviceMemory destMem; |
| 11026 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11027 | |
| 11028 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11029 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11030 | image_create_info.pNext = NULL; |
| 11031 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11032 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 11033 | image_create_info.extent.width = 32; |
| 11034 | image_create_info.extent.height = 1; |
| 11035 | image_create_info.extent.depth = 1; |
| 11036 | image_create_info.mipLevels = 1; |
| 11037 | image_create_info.arrayLayers = 1; |
| 11038 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 11039 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 11040 | // Note: Some implementations expect color attachment usage for any |
| 11041 | // multisample surface |
| 11042 | image_create_info.usage = |
| 11043 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 11044 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11045 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11046 | err = |
| 11047 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11048 | ASSERT_VK_SUCCESS(err); |
| 11049 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11050 | // Set format to something other than source image |
| 11051 | image_create_info.format = VK_FORMAT_R32_SFLOAT; |
| 11052 | // Note: Some implementations expect color attachment usage for any |
| 11053 | // multisample surface |
| 11054 | image_create_info.usage = |
| 11055 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 11056 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11057 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11058 | err = |
| 11059 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11060 | ASSERT_VK_SUCCESS(err); |
| 11061 | |
| 11062 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11063 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11064 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 11065 | memAlloc.pNext = NULL; |
| 11066 | memAlloc.allocationSize = 0; |
| 11067 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11068 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 11069 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11070 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11071 | pass = |
| 11072 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11073 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11074 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11075 | ASSERT_VK_SUCCESS(err); |
| 11076 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11077 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11078 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11079 | pass = |
| 11080 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11081 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11082 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11083 | ASSERT_VK_SUCCESS(err); |
| 11084 | |
| 11085 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 11086 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11087 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11088 | ASSERT_VK_SUCCESS(err); |
| 11089 | |
| 11090 | BeginCommandBuffer(); |
| 11091 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11092 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 11093 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11094 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11095 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11096 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 11097 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11098 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11099 | resolveRegion.srcOffset.x = 0; |
| 11100 | resolveRegion.srcOffset.y = 0; |
| 11101 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11102 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11103 | resolveRegion.dstSubresource.mipLevel = 0; |
| 11104 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 11105 | resolveRegion.dstSubresource.layerCount = 0; |
| 11106 | resolveRegion.dstOffset.x = 0; |
| 11107 | resolveRegion.dstOffset.y = 0; |
| 11108 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11109 | resolveRegion.extent.width = 1; |
| 11110 | resolveRegion.extent.height = 1; |
| 11111 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11112 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 11113 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11114 | EndCommandBuffer(); |
| 11115 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11116 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11117 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11118 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11119 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11120 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 11121 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11122 | } |
| 11123 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11124 | TEST_F(VkLayerTest, ResolveImageTypeMismatch) { |
| 11125 | VkResult err; |
| 11126 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11127 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11128 | m_errorMonitor->SetDesiredFailureMsg( |
| 11129 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11130 | "vkCmdResolveImage called with unmatched source and dest image types."); |
| 11131 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11132 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11133 | |
| 11134 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11135 | VkImage srcImage; |
| 11136 | VkImage dstImage; |
| 11137 | VkDeviceMemory srcMem; |
| 11138 | VkDeviceMemory destMem; |
| 11139 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11140 | |
| 11141 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11142 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11143 | image_create_info.pNext = NULL; |
| 11144 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11145 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 11146 | image_create_info.extent.width = 32; |
| 11147 | image_create_info.extent.height = 1; |
| 11148 | image_create_info.extent.depth = 1; |
| 11149 | image_create_info.mipLevels = 1; |
| 11150 | image_create_info.arrayLayers = 1; |
| 11151 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 11152 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 11153 | // Note: Some implementations expect color attachment usage for any |
| 11154 | // multisample surface |
| 11155 | image_create_info.usage = |
| 11156 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 11157 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11158 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11159 | err = |
| 11160 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11161 | ASSERT_VK_SUCCESS(err); |
| 11162 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11163 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 11164 | // Note: Some implementations expect color attachment usage for any |
| 11165 | // multisample surface |
| 11166 | image_create_info.usage = |
| 11167 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 11168 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11169 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11170 | err = |
| 11171 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11172 | ASSERT_VK_SUCCESS(err); |
| 11173 | |
| 11174 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11175 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11176 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 11177 | memAlloc.pNext = NULL; |
| 11178 | memAlloc.allocationSize = 0; |
| 11179 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11180 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 11181 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11182 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11183 | pass = |
| 11184 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11185 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11186 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11187 | ASSERT_VK_SUCCESS(err); |
| 11188 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11189 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11190 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11191 | pass = |
| 11192 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11193 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11194 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11195 | ASSERT_VK_SUCCESS(err); |
| 11196 | |
| 11197 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 11198 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11199 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11200 | ASSERT_VK_SUCCESS(err); |
| 11201 | |
| 11202 | BeginCommandBuffer(); |
| 11203 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11204 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 11205 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11206 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11207 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11208 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 11209 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11210 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11211 | resolveRegion.srcOffset.x = 0; |
| 11212 | resolveRegion.srcOffset.y = 0; |
| 11213 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11214 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11215 | resolveRegion.dstSubresource.mipLevel = 0; |
| 11216 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 11217 | resolveRegion.dstSubresource.layerCount = 0; |
| 11218 | resolveRegion.dstOffset.x = 0; |
| 11219 | resolveRegion.dstOffset.y = 0; |
| 11220 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11221 | resolveRegion.extent.width = 1; |
| 11222 | resolveRegion.extent.height = 1; |
| 11223 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11224 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 11225 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11226 | EndCommandBuffer(); |
| 11227 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11228 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11229 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11230 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11231 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11232 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 11233 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11234 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11235 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11236 | TEST_F(VkLayerTest, DepthStencilImageViewWithColorAspectBitError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11237 | // 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] | 11238 | // to using a DS format, then cause it to hit error due to COLOR_BIT not |
| 11239 | // set in aspect |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11240 | // The image format check comes 2nd in validation so we trigger it first, |
| 11241 | // 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] | 11242 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11243 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11244 | m_errorMonitor->SetDesiredFailureMsg( |
| 11245 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11246 | "Combination depth/stencil image formats can have only the "); |
| 11247 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11248 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11249 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 11250 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11251 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 11252 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11253 | |
| 11254 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11255 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 11256 | ds_pool_ci.pNext = NULL; |
| 11257 | ds_pool_ci.maxSets = 1; |
| 11258 | ds_pool_ci.poolSizeCount = 1; |
| 11259 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11260 | |
| 11261 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11262 | err = |
| 11263 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11264 | ASSERT_VK_SUCCESS(err); |
| 11265 | |
| 11266 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11267 | dsl_binding.binding = 0; |
| 11268 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 11269 | dsl_binding.descriptorCount = 1; |
| 11270 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 11271 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11272 | |
| 11273 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11274 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 11275 | ds_layout_ci.pNext = NULL; |
| 11276 | ds_layout_ci.bindingCount = 1; |
| 11277 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11278 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11279 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 11280 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11281 | ASSERT_VK_SUCCESS(err); |
| 11282 | |
| 11283 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11284 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 11285 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 11286 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11287 | alloc_info.descriptorPool = ds_pool; |
| 11288 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11289 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 11290 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11291 | ASSERT_VK_SUCCESS(err); |
| 11292 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11293 | VkImage image_bad; |
| 11294 | VkImage image_good; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11295 | // One bad format and one good format for Color attachment |
Tobin Ehlis | 269f032 | 2016-05-25 16:24:21 -0600 | [diff] [blame] | 11296 | const VkFormat tex_format_bad = VK_FORMAT_D24_UNORM_S8_UINT; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11297 | const VkFormat tex_format_good = VK_FORMAT_B8G8R8A8_UNORM; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11298 | const int32_t tex_width = 32; |
| 11299 | const int32_t tex_height = 32; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11300 | |
| 11301 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11302 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11303 | image_create_info.pNext = NULL; |
| 11304 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11305 | image_create_info.format = tex_format_bad; |
| 11306 | image_create_info.extent.width = tex_width; |
| 11307 | image_create_info.extent.height = tex_height; |
| 11308 | image_create_info.extent.depth = 1; |
| 11309 | image_create_info.mipLevels = 1; |
| 11310 | image_create_info.arrayLayers = 1; |
| 11311 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 11312 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 11313 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT | |
| 11314 | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 11315 | image_create_info.flags = 0; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11316 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11317 | err = |
| 11318 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image_bad); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11319 | ASSERT_VK_SUCCESS(err); |
| 11320 | image_create_info.format = tex_format_good; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11321 | image_create_info.usage = |
| 11322 | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 11323 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, |
| 11324 | &image_good); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11325 | ASSERT_VK_SUCCESS(err); |
| 11326 | |
| 11327 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11328 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11329 | image_view_create_info.image = image_bad; |
| 11330 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 11331 | image_view_create_info.format = tex_format_bad; |
| 11332 | image_view_create_info.subresourceRange.baseArrayLayer = 0; |
| 11333 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 11334 | image_view_create_info.subresourceRange.layerCount = 1; |
| 11335 | image_view_create_info.subresourceRange.levelCount = 1; |
| 11336 | image_view_create_info.subresourceRange.aspectMask = |
| 11337 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11338 | |
| 11339 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11340 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 11341 | &view); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11342 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11343 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11344 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11345 | vkDestroyImage(m_device->device(), image_bad, NULL); |
| 11346 | vkDestroyImage(m_device->device(), image_good, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11347 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 11348 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11349 | } |
Tobin Ehlis | 6e23d77 | 2016-05-19 11:08:34 -0600 | [diff] [blame] | 11350 | |
| 11351 | TEST_F(VkLayerTest, ClearImageErrors) { |
| 11352 | TEST_DESCRIPTION("Call ClearColorImage w/ a depth|stencil image and " |
| 11353 | "ClearDepthStencilImage with a color image."); |
| 11354 | |
| 11355 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 11356 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 11357 | |
| 11358 | // Renderpass is started here so end it as Clear cmds can't be in renderpass |
| 11359 | BeginCommandBuffer(); |
| 11360 | m_commandBuffer->EndRenderPass(); |
| 11361 | |
| 11362 | // Color image |
| 11363 | VkClearColorValue clear_color; |
| 11364 | memset(clear_color.uint32, 0, sizeof(uint32_t) * 4); |
| 11365 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 11366 | const VkFormat color_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 11367 | const int32_t img_width = 32; |
| 11368 | const int32_t img_height = 32; |
| 11369 | VkImageCreateInfo image_create_info = {}; |
| 11370 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11371 | image_create_info.pNext = NULL; |
| 11372 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11373 | image_create_info.format = color_format; |
| 11374 | image_create_info.extent.width = img_width; |
| 11375 | image_create_info.extent.height = img_height; |
| 11376 | image_create_info.extent.depth = 1; |
| 11377 | image_create_info.mipLevels = 1; |
| 11378 | image_create_info.arrayLayers = 1; |
| 11379 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 11380 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 11381 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 11382 | |
| 11383 | vk_testing::Image color_image; |
| 11384 | color_image.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 11385 | reqs); |
| 11386 | |
| 11387 | const VkImageSubresourceRange color_range = |
| 11388 | vk_testing::Image::subresource_range(image_create_info, |
| 11389 | VK_IMAGE_ASPECT_COLOR_BIT); |
| 11390 | |
| 11391 | // Depth/Stencil image |
| 11392 | VkClearDepthStencilValue clear_value = {0}; |
| 11393 | reqs = 0; // don't need HOST_VISIBLE DS image |
| 11394 | VkImageCreateInfo ds_image_create_info = vk_testing::Image::create_info(); |
| 11395 | ds_image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11396 | ds_image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 11397 | ds_image_create_info.extent.width = 64; |
| 11398 | ds_image_create_info.extent.height = 64; |
| 11399 | ds_image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 11400 | ds_image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 11401 | |
| 11402 | vk_testing::Image ds_image; |
| 11403 | ds_image.init(*m_device, (const VkImageCreateInfo &)ds_image_create_info, |
| 11404 | reqs); |
| 11405 | |
| 11406 | const VkImageSubresourceRange ds_range = |
| 11407 | vk_testing::Image::subresource_range(ds_image_create_info, |
| 11408 | VK_IMAGE_ASPECT_DEPTH_BIT); |
| 11409 | |
| 11410 | m_errorMonitor->SetDesiredFailureMsg( |
| 11411 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11412 | "vkCmdClearColorImage called with depth/stencil image."); |
| 11413 | |
| 11414 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), ds_image.handle(), |
| 11415 | VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1, |
| 11416 | &color_range); |
| 11417 | |
| 11418 | m_errorMonitor->VerifyFound(); |
| 11419 | |
| 11420 | // Call CmdClearDepthStencilImage with color image |
| 11421 | m_errorMonitor->SetDesiredFailureMsg( |
| 11422 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11423 | "vkCmdClearDepthStencilImage called without a depth/stencil image."); |
| 11424 | |
| 11425 | vkCmdClearDepthStencilImage( |
| 11426 | m_commandBuffer->GetBufferHandle(), color_image.handle(), |
| 11427 | VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, &clear_value, 1, |
| 11428 | &ds_range); |
| 11429 | |
| 11430 | m_errorMonitor->VerifyFound(); |
| 11431 | } |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 11432 | #endif // IMAGE_TESTS |
| 11433 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 11434 | int main(int argc, char **argv) { |
| 11435 | int result; |
| 11436 | |
Cody Northrop | 8e54a40 | 2016-03-08 22:25:52 -0700 | [diff] [blame] | 11437 | #ifdef ANDROID |
| 11438 | int vulkanSupport = InitVulkan(); |
| 11439 | if (vulkanSupport == 0) |
| 11440 | return 1; |
| 11441 | #endif |
| 11442 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 11443 | ::testing::InitGoogleTest(&argc, argv); |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 11444 | VkTestFramework::InitArgs(&argc, argv); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 11445 | |
| 11446 | ::testing::AddGlobalTestEnvironment(new TestEnvironment); |
| 11447 | |
| 11448 | result = RUN_ALL_TESTS(); |
| 11449 | |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 11450 | VkTestFramework::Finish(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 11451 | return result; |
| 11452 | } |