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; |
| 525 | } |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 526 | ds_ci.stencilTestEnable = VK_TRUE; |
| 527 | ds_ci.front = stencil; |
| 528 | ds_ci.back = stencil; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 529 | |
Tobin Ehlis | 4bf96d1 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 530 | pipelineobj.SetDepthStencil(&ds_ci); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 531 | pipelineobj.SetViewport(m_viewports); |
| 532 | pipelineobj.SetScissor(m_scissors); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 533 | descriptorSet.CreateVKDescriptorSet(commandBuffer); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 534 | VkResult err = pipelineobj.CreateVKPipeline( |
| 535 | descriptorSet.GetPipelineLayout(), renderPass()); |
Cody Northrop | 29a08f2 | 2015-08-27 10:20:35 -0600 | [diff] [blame] | 536 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 537 | commandBuffer->BindPipeline(pipelineobj); |
| 538 | commandBuffer->BindDescriptorSet(descriptorSet); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 539 | } |
| 540 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 541 | class VkWsiEnabledLayerTest : public VkLayerTest { |
| 542 | public: |
| 543 | protected: |
| 544 | VkWsiEnabledLayerTest() { |
| 545 | m_enableWSI = true; |
| 546 | } |
| 547 | }; |
| 548 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 549 | // ******************************************************************************************************************** |
| 550 | // ******************************************************************************************************************** |
| 551 | // ******************************************************************************************************************** |
| 552 | // ******************************************************************************************************************** |
Dustin Graves | ffa90fa | 2016-05-06 11:20:38 -0600 | [diff] [blame] | 553 | #if PARAMETER_VALIDATION_TESTS |
| 554 | TEST_F(VkLayerTest, RequiredParameter) { |
| 555 | TEST_DESCRIPTION("Specify VK_NULL_HANDLE, NULL, and 0 for required handle, " |
| 556 | "pointer, array, and array count parameters"); |
| 557 | |
| 558 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 559 | |
| 560 | m_errorMonitor->SetDesiredFailureMsg( |
| 561 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 562 | "required parameter pFeatures specified as NULL"); |
| 563 | // Specify NULL for a pointer to a handle |
| 564 | // Expected to trigger an error with |
| 565 | // parameter_validation::validate_required_pointer |
| 566 | vkGetPhysicalDeviceFeatures(gpu(), NULL); |
| 567 | m_errorMonitor->VerifyFound(); |
| 568 | |
| 569 | m_errorMonitor->SetDesiredFailureMsg( |
| 570 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Dustin Graves | a4bb8c1 | 2016-05-16 17:22:51 -0600 | [diff] [blame^] | 571 | "required parameter pQueueFamilyPropertyCount specified as NULL"); |
Dustin Graves | ffa90fa | 2016-05-06 11:20:38 -0600 | [diff] [blame] | 572 | // Specify NULL for pointer to array count |
| 573 | // Expected to trigger an error with parameter_validation::validate_array |
Dustin Graves | a4bb8c1 | 2016-05-16 17:22:51 -0600 | [diff] [blame^] | 574 | vkGetPhysicalDeviceQueueFamilyProperties(gpu(), NULL, NULL); |
Dustin Graves | ffa90fa | 2016-05-06 11:20:38 -0600 | [diff] [blame] | 575 | m_errorMonitor->VerifyFound(); |
| 576 | |
| 577 | m_errorMonitor->SetDesiredFailureMsg( |
| 578 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 579 | "parameter viewportCount must be greater than 0"); |
| 580 | // Specify 0 for a required array count |
| 581 | // Expected to trigger an error with parameter_validation::validate_array |
| 582 | VkViewport view_port = {}; |
| 583 | m_commandBuffer->SetViewport(0, 0, &view_port); |
| 584 | m_errorMonitor->VerifyFound(); |
| 585 | |
| 586 | m_errorMonitor->SetDesiredFailureMsg( |
| 587 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 588 | "required parameter pViewports specified as NULL"); |
| 589 | // Specify NULL for a required array |
| 590 | // Expected to trigger an error with parameter_validation::validate_array |
| 591 | m_commandBuffer->SetViewport(0, 1, NULL); |
| 592 | m_errorMonitor->VerifyFound(); |
| 593 | |
| 594 | m_errorMonitor->SetDesiredFailureMsg( |
| 595 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 596 | "required parameter memory specified as VK_NULL_HANDLE"); |
| 597 | // Specify VK_NULL_HANDLE for a required handle |
| 598 | // Expected to trigger an error with |
| 599 | // parameter_validation::validate_required_handle |
| 600 | vkUnmapMemory(device(), VK_NULL_HANDLE); |
| 601 | m_errorMonitor->VerifyFound(); |
| 602 | |
| 603 | m_errorMonitor->SetDesiredFailureMsg( |
| 604 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 605 | "required parameter pFences[0] specified as VK_NULL_HANDLE"); |
| 606 | // Specify VK_NULL_HANDLE for a required handle array entry |
| 607 | // Expected to trigger an error with |
| 608 | // parameter_validation::validate_required_handle_array |
| 609 | VkFence fence = VK_NULL_HANDLE; |
| 610 | vkResetFences(device(), 1, &fence); |
| 611 | m_errorMonitor->VerifyFound(); |
| 612 | |
| 613 | m_errorMonitor->SetDesiredFailureMsg( |
| 614 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 615 | "required parameter pAllocateInfo specified as NULL"); |
| 616 | // Specify NULL for a required struct pointer |
| 617 | // Expected to trigger an error with |
| 618 | // parameter_validation::validate_struct_type |
| 619 | VkDeviceMemory memory = VK_NULL_HANDLE; |
| 620 | vkAllocateMemory(device(), NULL, NULL, &memory); |
| 621 | m_errorMonitor->VerifyFound(); |
| 622 | |
| 623 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 624 | "value of faceMask must not be 0"); |
| 625 | // Specify 0 for a required VkFlags parameter |
| 626 | // Expected to trigger an error with parameter_validation::validate_flags |
| 627 | m_commandBuffer->SetStencilReference(0, 0); |
| 628 | m_errorMonitor->VerifyFound(); |
| 629 | |
| 630 | m_errorMonitor->SetDesiredFailureMsg( |
| 631 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 632 | "value of pSubmits[i].pWaitDstStageMask[0] must not be 0"); |
| 633 | // Specify 0 for a required VkFlags array entry |
| 634 | // Expected to trigger an error with |
| 635 | // parameter_validation::validate_flags_array |
| 636 | VkSemaphore semaphore = VK_NULL_HANDLE; |
| 637 | VkPipelineStageFlags stageFlags = 0; |
| 638 | VkSubmitInfo submitInfo = {}; |
| 639 | submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 640 | submitInfo.waitSemaphoreCount = 1; |
| 641 | submitInfo.pWaitSemaphores = &semaphore; |
| 642 | submitInfo.pWaitDstStageMask = &stageFlags; |
| 643 | vkQueueSubmit(m_device->m_queue, 1, &submitInfo, VK_NULL_HANDLE); |
| 644 | m_errorMonitor->VerifyFound(); |
| 645 | } |
Dustin Graves | c99cf5a | 2016-05-09 14:40:29 -0600 | [diff] [blame] | 646 | |
Dustin Graves | fce74c0 | 2016-05-10 11:42:58 -0600 | [diff] [blame] | 647 | TEST_F(VkLayerTest, ReservedParameter) { |
| 648 | TEST_DESCRIPTION("Specify a non-zero value for a reserved parameter"); |
| 649 | |
| 650 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 651 | |
| 652 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 653 | " must be 0"); |
| 654 | // Specify 0 for a reserved VkFlags parameter |
| 655 | // Expected to trigger an error with |
| 656 | // parameter_validation::validate_reserved_flags |
| 657 | VkEvent event_handle = VK_NULL_HANDLE; |
| 658 | VkEventCreateInfo event_info = {}; |
| 659 | event_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 660 | event_info.flags = 1; |
| 661 | vkCreateEvent(device(), &event_info, NULL, &event_handle); |
| 662 | m_errorMonitor->VerifyFound(); |
| 663 | } |
| 664 | |
Dustin Graves | c99cf5a | 2016-05-09 14:40:29 -0600 | [diff] [blame] | 665 | TEST_F(VkLayerTest, InvalidStructSType) { |
| 666 | TEST_DESCRIPTION("Specify an invalid VkStructureType for a Vulkan " |
| 667 | "structure's sType field"); |
| 668 | |
| 669 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 670 | |
| 671 | m_errorMonitor->SetDesiredFailureMsg( |
| 672 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 673 | "parameter pAllocateInfo->sType must be"); |
| 674 | // Zero struct memory, effectively setting sType to |
| 675 | // VK_STRUCTURE_TYPE_APPLICATION_INFO |
| 676 | // Expected to trigger an error with |
| 677 | // parameter_validation::validate_struct_type |
| 678 | VkMemoryAllocateInfo alloc_info = {}; |
| 679 | VkDeviceMemory memory = VK_NULL_HANDLE; |
| 680 | vkAllocateMemory(device(), &alloc_info, NULL, &memory); |
| 681 | m_errorMonitor->VerifyFound(); |
| 682 | |
| 683 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 684 | "parameter pSubmits[0].sType must be"); |
| 685 | // Zero struct memory, effectively setting sType to |
| 686 | // VK_STRUCTURE_TYPE_APPLICATION_INFO |
| 687 | // Expected to trigger an error with |
| 688 | // parameter_validation::validate_struct_type_array |
| 689 | VkSubmitInfo submit_info = {}; |
| 690 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 691 | m_errorMonitor->VerifyFound(); |
| 692 | } |
| 693 | |
| 694 | TEST_F(VkLayerTest, InvalidStructPNext) { |
| 695 | TEST_DESCRIPTION( |
| 696 | "Specify an invalid value for a Vulkan structure's pNext field"); |
| 697 | |
| 698 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 699 | |
| 700 | m_errorMonitor->SetDesiredFailureMsg( |
| 701 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 702 | "value of pAllocateInfo->pNext must be NULL"); |
| 703 | // Set VkMemoryAllocateInfo::pNext to a non-NULL value, when pNext must be |
| 704 | // NULL |
| 705 | // Expected to trigger an error with |
| 706 | // parameter_validation::validate_struct_pnext |
| 707 | VkDeviceMemory memory = VK_NULL_HANDLE; |
| 708 | // Zero-initialization will provide the correct sType |
| 709 | VkApplicationInfo app_info = {}; |
Dustin Graves | 47b6cba | 2016-05-10 17:34:38 -0600 | [diff] [blame] | 710 | VkMemoryAllocateInfo memory_alloc_info = {}; |
| 711 | memory_alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 712 | memory_alloc_info.pNext = &app_info; |
| 713 | vkAllocateMemory(device(), &memory_alloc_info, NULL, &memory); |
Dustin Graves | c99cf5a | 2016-05-09 14:40:29 -0600 | [diff] [blame] | 714 | m_errorMonitor->VerifyFound(); |
| 715 | |
Dustin Graves | 47b6cba | 2016-05-10 17:34:38 -0600 | [diff] [blame] | 716 | m_errorMonitor->SetDesiredFailureMsg( |
| 717 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 718 | " chain includes a structure with unexpected VkStructureType "); |
| 719 | // Set VkGraphicsPipelineCreateInfo::VkPipelineRasterizationStateCreateInfo::pNext to an invalid structure, when pNext is allowed to be a non-NULL value |
| 720 | // Expected to trigger an error with |
| 721 | // parameter_validation::validate_struct_pnext |
| 722 | VkDescriptorPoolSize ds_type_count = {}; |
| 723 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 724 | ds_type_count.descriptorCount = 1; |
| 725 | |
| 726 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 727 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 728 | ds_pool_ci.pNext = NULL; |
| 729 | ds_pool_ci.maxSets = 1; |
| 730 | ds_pool_ci.poolSizeCount = 1; |
| 731 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 732 | |
| 733 | VkDescriptorPool ds_pool; |
| 734 | VkResult err = |
| 735 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 736 | ASSERT_VK_SUCCESS(err); |
| 737 | |
| 738 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 739 | dsl_binding.binding = 0; |
| 740 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 741 | dsl_binding.descriptorCount = 1; |
| 742 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 743 | dsl_binding.pImmutableSamplers = NULL; |
| 744 | |
| 745 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 746 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 747 | ds_layout_ci.pNext = NULL; |
| 748 | ds_layout_ci.bindingCount = 1; |
| 749 | ds_layout_ci.pBindings = &dsl_binding; |
| 750 | |
| 751 | VkDescriptorSetLayout ds_layout; |
| 752 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 753 | &ds_layout); |
| 754 | ASSERT_VK_SUCCESS(err); |
| 755 | |
| 756 | VkDescriptorSet descriptorSet; |
| 757 | VkDescriptorSetAllocateInfo ds_alloc_info = {}; |
| 758 | ds_alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 759 | ds_alloc_info.descriptorSetCount = 1; |
| 760 | ds_alloc_info.descriptorPool = ds_pool; |
| 761 | ds_alloc_info.pSetLayouts = &ds_layout; |
| 762 | err = vkAllocateDescriptorSets(m_device->device(), &ds_alloc_info, |
| 763 | &descriptorSet); |
| 764 | ASSERT_VK_SUCCESS(err); |
| 765 | |
| 766 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 767 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 768 | pipeline_layout_ci.setLayoutCount = 1; |
| 769 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 770 | |
| 771 | VkPipelineLayout pipeline_layout; |
| 772 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 773 | &pipeline_layout); |
| 774 | ASSERT_VK_SUCCESS(err); |
| 775 | |
| 776 | VkViewport vp = {}; // Just need dummy vp to point to |
| 777 | VkRect2D sc = {}; // dummy scissor to point to |
| 778 | |
| 779 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 780 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 781 | vp_state_ci.scissorCount = 1; |
| 782 | vp_state_ci.pScissors = ≻ |
| 783 | vp_state_ci.viewportCount = 1; |
| 784 | vp_state_ci.pViewports = &vp; |
| 785 | |
| 786 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 787 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 788 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 789 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 790 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 791 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 792 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 793 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 794 | |
| 795 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 796 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 797 | gp_ci.pViewportState = &vp_state_ci; |
| 798 | gp_ci.pRasterizationState = &rs_state_ci; |
| 799 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 800 | gp_ci.layout = pipeline_layout; |
| 801 | gp_ci.renderPass = renderPass(); |
| 802 | |
| 803 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 804 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 805 | pc_ci.initialDataSize = 0; |
| 806 | pc_ci.pInitialData = 0; |
| 807 | |
| 808 | VkPipeline pipeline; |
| 809 | VkPipelineCache pipelineCache; |
| 810 | |
| 811 | err = |
| 812 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 813 | ASSERT_VK_SUCCESS(err); |
| 814 | |
| 815 | // Set VkPipelineRasterizationStateCreateInfo::pNext to an invalid value |
| 816 | VkApplicationInfo invalid_pnext_struct = {}; |
| 817 | rs_state_ci.pNext = &invalid_pnext_struct; |
| 818 | |
| 819 | vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 820 | &gp_ci, NULL, &pipeline); |
| 821 | m_errorMonitor->VerifyFound(); |
Dustin Graves | c99cf5a | 2016-05-09 14:40:29 -0600 | [diff] [blame] | 822 | } |
Dustin Graves | 5d33d53 | 2016-05-09 16:21:12 -0600 | [diff] [blame] | 823 | |
| 824 | TEST_F(VkLayerTest, UnrecognizedValue) { |
| 825 | TEST_DESCRIPTION( |
| 826 | "Specify unrecognized Vulkan enumeration, flags, and VkBool32 values"); |
| 827 | |
| 828 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 829 | |
| 830 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 831 | "does not fall within the begin..end " |
| 832 | "range of the core VkFormat " |
| 833 | "enumeration tokens"); |
| 834 | // Specify an invalid VkFormat value |
| 835 | // Expected to trigger an error with |
| 836 | // parameter_validation::validate_ranged_enum |
| 837 | VkFormatProperties format_properties; |
| 838 | vkGetPhysicalDeviceFormatProperties(gpu(), static_cast<VkFormat>(8000), |
| 839 | &format_properties); |
| 840 | m_errorMonitor->VerifyFound(); |
| 841 | |
| 842 | m_errorMonitor->SetDesiredFailureMsg( |
| 843 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 844 | "contains flag bits that are not recognized members of"); |
| 845 | // Specify an invalid VkFlags bitmask value |
| 846 | // Expected to trigger an error with parameter_validation::validate_flags |
| 847 | VkImageFormatProperties image_format_properties; |
| 848 | vkGetPhysicalDeviceImageFormatProperties( |
| 849 | gpu(), VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_TYPE_2D, |
| 850 | VK_IMAGE_TILING_OPTIMAL, static_cast<VkImageUsageFlags>(1 << 25), 0, |
| 851 | &image_format_properties); |
| 852 | m_errorMonitor->VerifyFound(); |
| 853 | |
| 854 | m_errorMonitor->SetDesiredFailureMsg( |
| 855 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 856 | "contains flag bits that are not recognized members of"); |
| 857 | // Specify an invalid VkFlags array entry |
| 858 | // Expected to trigger an error with |
| 859 | // parameter_validation::validate_flags_array |
| 860 | VkSemaphore semaphore = VK_NULL_HANDLE; |
| 861 | VkPipelineStageFlags stage_flags = |
| 862 | static_cast<VkPipelineStageFlags>(1 << 25); |
| 863 | VkSubmitInfo submit_info = {}; |
| 864 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 865 | submit_info.waitSemaphoreCount = 1; |
| 866 | submit_info.pWaitSemaphores = &semaphore; |
| 867 | submit_info.pWaitDstStageMask = &stage_flags; |
| 868 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 869 | m_errorMonitor->VerifyFound(); |
| 870 | |
| 871 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, |
| 872 | "is neither VK_TRUE nor VK_FALSE"); |
| 873 | // Specify an invalid VkBool32 value |
| 874 | // Expected to trigger a warning with |
| 875 | // parameter_validation::validate_bool32 |
| 876 | VkSampler sampler = VK_NULL_HANDLE; |
| 877 | VkSamplerCreateInfo sampler_info = {}; |
| 878 | sampler_info.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 879 | sampler_info.pNext = NULL; |
| 880 | sampler_info.magFilter = VK_FILTER_NEAREST; |
| 881 | sampler_info.minFilter = VK_FILTER_NEAREST; |
| 882 | sampler_info.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 883 | sampler_info.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 884 | sampler_info.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 885 | sampler_info.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 886 | sampler_info.mipLodBias = 1.0; |
| 887 | sampler_info.maxAnisotropy = 1; |
| 888 | sampler_info.compareEnable = VK_FALSE; |
| 889 | sampler_info.compareOp = VK_COMPARE_OP_NEVER; |
| 890 | sampler_info.minLod = 1.0; |
| 891 | sampler_info.maxLod = 1.0; |
| 892 | sampler_info.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 893 | sampler_info.unnormalizedCoordinates = VK_FALSE; |
| 894 | // Not VK_TRUE or VK_FALSE |
| 895 | sampler_info.anisotropyEnable = 3; |
| 896 | vkCreateSampler(m_device->device(), &sampler_info, NULL, &sampler); |
| 897 | m_errorMonitor->VerifyFound(); |
| 898 | } |
Dustin Graves | fce74c0 | 2016-05-10 11:42:58 -0600 | [diff] [blame] | 899 | |
| 900 | TEST_F(VkLayerTest, FailedReturnValue) { |
| 901 | TEST_DESCRIPTION("Check for a message describing a VkResult failure code"); |
| 902 | |
| 903 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 904 | |
Dustin Graves | 13c1e2b | 2016-05-16 15:31:02 -0600 | [diff] [blame] | 905 | // Find an unsupported image format |
| 906 | VkFormat unsupported = VK_FORMAT_UNDEFINED; |
| 907 | for (int f = VK_FORMAT_BEGIN_RANGE; f <= VK_FORMAT_END_RANGE; f++) { |
| 908 | VkFormat format = static_cast<VkFormat>(f); |
| 909 | VkFormatProperties fProps = m_device->format_properties(format); |
| 910 | if (format != VK_FORMAT_UNDEFINED && fProps.linearTilingFeatures == 0 && |
| 911 | fProps.optimalTilingFeatures == 0) { |
| 912 | unsupported = format; |
| 913 | break; |
| 914 | } |
| 915 | } |
| 916 | |
| 917 | if (unsupported != VK_FORMAT_UNDEFINED) { |
| 918 | m_errorMonitor->SetDesiredFailureMsg( |
| 919 | VK_DEBUG_REPORT_WARNING_BIT_EXT, |
| 920 | "the requested format is not supported on this device"); |
| 921 | // Specify an unsupported VkFormat value to generate a |
| 922 | // VK_ERROR_FORMAT_NOT_SUPPORTED return code |
| 923 | // Expected to trigger a warning from |
| 924 | // parameter_validation::validate_result |
| 925 | VkImageFormatProperties image_format_properties; |
| 926 | VkResult err = vkGetPhysicalDeviceImageFormatProperties( |
| 927 | gpu(), unsupported, VK_IMAGE_TYPE_2D, VK_IMAGE_TILING_OPTIMAL, |
| 928 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, 0, &image_format_properties); |
| 929 | ASSERT_TRUE(err == VK_ERROR_FORMAT_NOT_SUPPORTED); |
| 930 | m_errorMonitor->VerifyFound(); |
| 931 | } |
Dustin Graves | fce74c0 | 2016-05-10 11:42:58 -0600 | [diff] [blame] | 932 | } |
Dustin Graves | ffa90fa | 2016-05-06 11:20:38 -0600 | [diff] [blame] | 933 | #endif // PARAMETER_VALIDATION_TESTS |
| 934 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 935 | #if MEM_TRACKER_TESTS |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 936 | #if 0 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 937 | TEST_F(VkLayerTest, CallResetCommandBufferBeforeCompletion) |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 938 | { |
| 939 | vk_testing::Fence testFence; |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 940 | VkFenceCreateInfo fenceInfo = {}; |
| 941 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 942 | fenceInfo.pNext = NULL; |
| 943 | fenceInfo.flags = 0; |
| 944 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 945 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "Resetting CB"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 946 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 947 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tony Barbour | c1eb1a5 | 2015-07-20 13:00:10 -0600 | [diff] [blame] | 948 | |
| 949 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 950 | vk_testing::Buffer buffer; |
| 951 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 952 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 953 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 954 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 4, 0x11111111); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 955 | EndCommandBuffer(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 956 | |
| 957 | testFence.init(*m_device, fenceInfo); |
| 958 | |
| 959 | // Bypass framework since it does the waits automatically |
| 960 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 961 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 962 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 963 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 964 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 965 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 966 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 967 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 968 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 969 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 970 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 971 | |
| 972 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 973 | ASSERT_VK_SUCCESS( err ); |
| 974 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 975 | // Introduce failure by calling begin again before checking fence |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 976 | vkResetCommandBuffer(m_commandBuffer->handle(), 0); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 977 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 978 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 979 | } |
| 980 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 981 | TEST_F(VkLayerTest, CallBeginCommandBufferBeforeCompletion) |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 982 | { |
| 983 | vk_testing::Fence testFence; |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 984 | VkFenceCreateInfo fenceInfo = {}; |
| 985 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 986 | fenceInfo.pNext = NULL; |
| 987 | fenceInfo.flags = 0; |
| 988 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 989 | 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] | 990 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 991 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 992 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 993 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 994 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 995 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 996 | 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] | 997 | EndCommandBuffer(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 998 | |
| 999 | testFence.init(*m_device, fenceInfo); |
| 1000 | |
| 1001 | // Bypass framework since it does the waits automatically |
| 1002 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1003 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 1004 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1005 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1006 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1007 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 1008 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1009 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1010 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1011 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1012 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 1013 | |
| 1014 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1015 | ASSERT_VK_SUCCESS( err ); |
| 1016 | |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 1017 | VkCommandBufferInheritanceInfo hinfo = {}; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1018 | VkCommandBufferBeginInfo info = {}; |
| 1019 | info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
| 1020 | info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1021 | info.renderPass = VK_NULL_HANDLE; |
| 1022 | info.subpass = 0; |
| 1023 | info.framebuffer = VK_NULL_HANDLE; |
Chia-I Wu | b8d47ae | 2015-11-11 10:18:12 +0800 | [diff] [blame] | 1024 | info.occlusionQueryEnable = VK_FALSE; |
| 1025 | info.queryFlags = 0; |
| 1026 | info.pipelineStatistics = 0; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1027 | |
| 1028 | // Introduce failure by calling BCB again before checking fence |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1029 | vkBeginCommandBuffer(m_commandBuffer->handle(), &info); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1030 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1031 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1032 | } |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1033 | #endif |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1034 | |
Mark Lobodzinski | 152fe25 | 2016-05-03 16:49:15 -0600 | [diff] [blame] | 1035 | // This is a positive test. No failures are expected. |
| 1036 | TEST_F(VkLayerTest, TestAliasedMemoryTracking) { |
| 1037 | VkResult err; |
| 1038 | bool pass; |
| 1039 | |
| 1040 | TEST_DESCRIPTION("Create a buffer, allocate memory, bind memory, destroy " |
| 1041 | "the buffer, create an image, and bind the same memory to " |
| 1042 | "it"); |
| 1043 | |
| 1044 | m_errorMonitor->ExpectSuccess(); |
| 1045 | |
| 1046 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1047 | |
| 1048 | VkBuffer buffer; |
| 1049 | VkImage image; |
| 1050 | VkDeviceMemory mem; |
| 1051 | VkMemoryRequirements mem_reqs; |
| 1052 | |
| 1053 | VkBufferCreateInfo buf_info = {}; |
| 1054 | buf_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 1055 | buf_info.pNext = NULL; |
| 1056 | buf_info.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 1057 | buf_info.size = 256; |
| 1058 | buf_info.queueFamilyIndexCount = 0; |
| 1059 | buf_info.pQueueFamilyIndices = NULL; |
| 1060 | buf_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 1061 | buf_info.flags = 0; |
| 1062 | err = vkCreateBuffer(m_device->device(), &buf_info, NULL, &buffer); |
| 1063 | ASSERT_VK_SUCCESS(err); |
| 1064 | |
| 1065 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &mem_reqs); |
| 1066 | |
| 1067 | VkMemoryAllocateInfo alloc_info = {}; |
| 1068 | alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1069 | alloc_info.pNext = NULL; |
| 1070 | alloc_info.memoryTypeIndex = 0; |
| 1071 | |
| 1072 | // Ensure memory is big enough for both bindings |
| 1073 | alloc_info.allocationSize = 0x10000; |
| 1074 | |
| 1075 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &alloc_info, |
| 1076 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 1077 | if (!pass) { |
| 1078 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 1079 | return; |
| 1080 | } |
| 1081 | |
| 1082 | err = vkAllocateMemory(m_device->device(), &alloc_info, NULL, &mem); |
| 1083 | ASSERT_VK_SUCCESS(err); |
| 1084 | |
| 1085 | uint8_t *pData; |
| 1086 | err = vkMapMemory(m_device->device(), mem, 0, mem_reqs.size, 0, |
| 1087 | (void **)&pData); |
| 1088 | ASSERT_VK_SUCCESS(err); |
| 1089 | |
Mark Lobodzinski | 2abefa9 | 2016-05-05 11:45:57 -0600 | [diff] [blame] | 1090 | memset(pData, 0xCADECADE, static_cast<size_t>(mem_reqs.size)); |
Mark Lobodzinski | 152fe25 | 2016-05-03 16:49:15 -0600 | [diff] [blame] | 1091 | |
| 1092 | vkUnmapMemory(m_device->device(), mem); |
| 1093 | |
| 1094 | err = vkBindBufferMemory(m_device->device(), buffer, mem, 0); |
| 1095 | ASSERT_VK_SUCCESS(err); |
| 1096 | |
| 1097 | // NOW, destroy the buffer. Obviously, the resource no longer occupies this |
| 1098 | // memory. In fact, it was never used by the GPU. |
| 1099 | // Just be be sure, wait for idle. |
| 1100 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 1101 | vkDeviceWaitIdle(m_device->device()); |
| 1102 | |
| 1103 | VkImageCreateInfo image_create_info = {}; |
| 1104 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1105 | image_create_info.pNext = NULL; |
| 1106 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1107 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 1108 | image_create_info.extent.width = 64; |
| 1109 | image_create_info.extent.height = 64; |
| 1110 | image_create_info.extent.depth = 1; |
| 1111 | image_create_info.mipLevels = 1; |
| 1112 | image_create_info.arrayLayers = 1; |
| 1113 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1114 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1115 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_PREINITIALIZED; |
| 1116 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 1117 | image_create_info.queueFamilyIndexCount = 0; |
| 1118 | image_create_info.pQueueFamilyIndices = NULL; |
| 1119 | image_create_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 1120 | image_create_info.flags = 0; |
| 1121 | |
| 1122 | VkMemoryAllocateInfo mem_alloc = {}; |
| 1123 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1124 | mem_alloc.pNext = NULL; |
| 1125 | mem_alloc.allocationSize = 0; |
| 1126 | mem_alloc.memoryTypeIndex = 0; |
| 1127 | |
| 1128 | /* Create a mappable image. It will be the texture if linear images are ok |
| 1129 | * to be textures or it will be the staging image if they are not. |
| 1130 | */ |
| 1131 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 1132 | ASSERT_VK_SUCCESS(err); |
| 1133 | |
| 1134 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
| 1135 | |
| 1136 | mem_alloc.allocationSize = mem_reqs.size; |
| 1137 | |
| 1138 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, |
| 1139 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 1140 | if (!pass) { |
| 1141 | vkDestroyImage(m_device->device(), image, NULL); |
| 1142 | return; |
| 1143 | } |
| 1144 | |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1145 | // VALIDATION FAILURE: |
Mark Lobodzinski | 152fe25 | 2016-05-03 16:49:15 -0600 | [diff] [blame] | 1146 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 1147 | ASSERT_VK_SUCCESS(err); |
| 1148 | |
| 1149 | m_errorMonitor->VerifyNotFound(); |
| 1150 | |
| 1151 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 1152 | vkDestroyImage(m_device->device(), image, NULL); |
| 1153 | } |
| 1154 | |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1155 | TEST_F(VkLayerTest, InvalidMemoryAliasing) { |
| 1156 | TEST_DESCRIPTION("Create a buffer and image, allocate memory, and bind the " |
| 1157 | "buffer and image to memory such that they will alias."); |
| 1158 | VkResult err; |
| 1159 | bool pass; |
| 1160 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1161 | |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1162 | VkBuffer buffer, buffer2; |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1163 | VkImage image; |
| 1164 | VkDeviceMemory mem; // buffer will be bound first |
| 1165 | VkDeviceMemory mem_img; // image bound first |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1166 | VkMemoryRequirements buff_mem_reqs, img_mem_reqs; |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1167 | |
| 1168 | VkBufferCreateInfo buf_info = {}; |
| 1169 | buf_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 1170 | buf_info.pNext = NULL; |
| 1171 | buf_info.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 1172 | buf_info.size = 256; |
| 1173 | buf_info.queueFamilyIndexCount = 0; |
| 1174 | buf_info.pQueueFamilyIndices = NULL; |
| 1175 | buf_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 1176 | buf_info.flags = 0; |
| 1177 | err = vkCreateBuffer(m_device->device(), &buf_info, NULL, &buffer); |
| 1178 | ASSERT_VK_SUCCESS(err); |
| 1179 | |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1180 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &buff_mem_reqs); |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1181 | |
| 1182 | VkImageCreateInfo image_create_info = {}; |
| 1183 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1184 | image_create_info.pNext = NULL; |
| 1185 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1186 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 1187 | image_create_info.extent.width = 64; |
| 1188 | image_create_info.extent.height = 64; |
| 1189 | image_create_info.extent.depth = 1; |
| 1190 | image_create_info.mipLevels = 1; |
| 1191 | image_create_info.arrayLayers = 1; |
| 1192 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1193 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1194 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_PREINITIALIZED; |
| 1195 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 1196 | image_create_info.queueFamilyIndexCount = 0; |
| 1197 | image_create_info.pQueueFamilyIndices = NULL; |
| 1198 | image_create_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 1199 | image_create_info.flags = 0; |
| 1200 | |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1201 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 1202 | ASSERT_VK_SUCCESS(err); |
| 1203 | |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1204 | vkGetImageMemoryRequirements(m_device->device(), image, &img_mem_reqs); |
| 1205 | |
| 1206 | VkMemoryAllocateInfo alloc_info = {}; |
| 1207 | alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1208 | alloc_info.pNext = NULL; |
| 1209 | alloc_info.memoryTypeIndex = 0; |
| 1210 | // Ensure memory is big enough for both bindings |
| 1211 | alloc_info.allocationSize = buff_mem_reqs.size + img_mem_reqs.size; |
| 1212 | pass = m_device->phy().set_memory_type( |
| 1213 | buff_mem_reqs.memoryTypeBits | img_mem_reqs.memoryTypeBits, &alloc_info, |
| 1214 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1215 | if (!pass) { |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1216 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1217 | vkDestroyImage(m_device->device(), image, NULL); |
| 1218 | return; |
| 1219 | } |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1220 | err = vkAllocateMemory(m_device->device(), &alloc_info, NULL, &mem); |
| 1221 | ASSERT_VK_SUCCESS(err); |
| 1222 | err = vkBindBufferMemory(m_device->device(), buffer, mem, 0); |
| 1223 | ASSERT_VK_SUCCESS(err); |
| 1224 | |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1225 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1226 | " is aliased with buffer 0x"); |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1227 | // VALIDATION FAILURE due to image mapping overlapping buffer mapping |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1228 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 1229 | m_errorMonitor->VerifyFound(); |
| 1230 | |
| 1231 | // Now correctly bind image to second mem allocation before incorrectly |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1232 | // aliasing buffer2 |
| 1233 | err = vkCreateBuffer(m_device->device(), &buf_info, NULL, &buffer2); |
| 1234 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1235 | err = vkAllocateMemory(m_device->device(), &alloc_info, NULL, &mem_img); |
| 1236 | ASSERT_VK_SUCCESS(err); |
| 1237 | err = vkBindImageMemory(m_device->device(), image, mem_img, 0); |
| 1238 | ASSERT_VK_SUCCESS(err); |
| 1239 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1240 | " is aliased with image 0x"); |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1241 | err = vkBindBufferMemory(m_device->device(), buffer2, mem_img, 0); |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1242 | m_errorMonitor->VerifyFound(); |
| 1243 | |
| 1244 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1245 | vkDestroyBuffer(m_device->device(), buffer2, NULL); |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1246 | vkDestroyImage(m_device->device(), image, NULL); |
| 1247 | vkFreeMemory(m_device->device(), mem, NULL); |
| 1248 | vkFreeMemory(m_device->device(), mem_img, NULL); |
| 1249 | } |
| 1250 | |
Tobin Ehlis | 3537252 | 2016-05-12 08:32:31 -0600 | [diff] [blame] | 1251 | TEST_F(VkLayerTest, InvalidMemoryMapping) { |
| 1252 | TEST_DESCRIPTION("Attempt to map memory in a number of incorrect ways"); |
| 1253 | VkResult err; |
| 1254 | bool pass; |
| 1255 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1256 | |
| 1257 | VkBuffer buffer; |
| 1258 | VkDeviceMemory mem; |
| 1259 | VkMemoryRequirements mem_reqs; |
| 1260 | |
| 1261 | VkBufferCreateInfo buf_info = {}; |
| 1262 | buf_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 1263 | buf_info.pNext = NULL; |
| 1264 | buf_info.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 1265 | buf_info.size = 256; |
| 1266 | buf_info.queueFamilyIndexCount = 0; |
| 1267 | buf_info.pQueueFamilyIndices = NULL; |
| 1268 | buf_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 1269 | buf_info.flags = 0; |
| 1270 | err = vkCreateBuffer(m_device->device(), &buf_info, NULL, &buffer); |
| 1271 | ASSERT_VK_SUCCESS(err); |
| 1272 | |
| 1273 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &mem_reqs); |
| 1274 | VkMemoryAllocateInfo alloc_info = {}; |
| 1275 | alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1276 | alloc_info.pNext = NULL; |
| 1277 | alloc_info.memoryTypeIndex = 0; |
| 1278 | |
| 1279 | // Ensure memory is big enough for both bindings |
| 1280 | static const VkDeviceSize allocation_size = 0x10000; |
| 1281 | alloc_info.allocationSize = allocation_size; |
| 1282 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &alloc_info, |
| 1283 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 1284 | if (!pass) { |
| 1285 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 1286 | return; |
| 1287 | } |
| 1288 | err = vkAllocateMemory(m_device->device(), &alloc_info, NULL, &mem); |
| 1289 | ASSERT_VK_SUCCESS(err); |
| 1290 | |
| 1291 | uint8_t *pData; |
| 1292 | // Attempt to map memory size 0 is invalid |
| 1293 | m_errorMonitor->SetDesiredFailureMsg( |
| 1294 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1295 | "VkMapMemory: Attempting to map memory range of size zero"); |
| 1296 | err = vkMapMemory(m_device->device(), mem, 0, 0, 0, (void **)&pData); |
| 1297 | m_errorMonitor->VerifyFound(); |
| 1298 | // Map memory twice |
| 1299 | err = vkMapMemory(m_device->device(), mem, 0, mem_reqs.size, 0, |
| 1300 | (void **)&pData); |
| 1301 | ASSERT_VK_SUCCESS(err); |
| 1302 | m_errorMonitor->SetDesiredFailureMsg( |
| 1303 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1304 | "VkMapMemory: Attempting to map memory on an already-mapped object "); |
| 1305 | err = vkMapMemory(m_device->device(), mem, 0, mem_reqs.size, 0, |
| 1306 | (void **)&pData); |
| 1307 | m_errorMonitor->VerifyFound(); |
| 1308 | |
| 1309 | // Unmap the memory to avoid re-map error |
| 1310 | vkUnmapMemory(m_device->device(), mem); |
| 1311 | // overstep allocation with VK_WHOLE_SIZE |
| 1312 | m_errorMonitor->SetDesiredFailureMsg( |
| 1313 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1314 | " with size of VK_WHOLE_SIZE oversteps total array size 0x"); |
| 1315 | err = vkMapMemory(m_device->device(), mem, allocation_size + 1, |
| 1316 | VK_WHOLE_SIZE, 0, (void **)&pData); |
| 1317 | m_errorMonitor->VerifyFound(); |
| 1318 | // overstep allocation w/o VK_WHOLE_SIZE |
| 1319 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1320 | " oversteps total array size 0x"); |
| 1321 | err = vkMapMemory(m_device->device(), mem, 1, allocation_size, 0, |
| 1322 | (void **)&pData); |
| 1323 | m_errorMonitor->VerifyFound(); |
| 1324 | // Now error due to unmapping memory that's not mapped |
| 1325 | m_errorMonitor->SetDesiredFailureMsg( |
| 1326 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1327 | "Unmapping Memory without memory being mapped: "); |
| 1328 | vkUnmapMemory(m_device->device(), mem); |
| 1329 | m_errorMonitor->VerifyFound(); |
| 1330 | // Now map memory and cause errors due to flushing invalid ranges |
| 1331 | err = vkMapMemory(m_device->device(), mem, 16, VK_WHOLE_SIZE, 0, |
| 1332 | (void **)&pData); |
| 1333 | ASSERT_VK_SUCCESS(err); |
| 1334 | VkMappedMemoryRange mmr = {}; |
| 1335 | mmr.memory = mem; |
| 1336 | mmr.offset = 15; // Error b/c offset less than offset of mapped mem |
| 1337 | m_errorMonitor->SetDesiredFailureMsg( |
| 1338 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1339 | ") is less than Memory Object's offset ("); |
| 1340 | vkFlushMappedMemoryRanges(m_device->device(), 1, &mmr); |
| 1341 | m_errorMonitor->VerifyFound(); |
| 1342 | // Now flush range that oversteps mapped range |
| 1343 | vkUnmapMemory(m_device->device(), mem); |
| 1344 | err = vkMapMemory(m_device->device(), mem, 0, 256, 0, (void **)&pData); |
| 1345 | ASSERT_VK_SUCCESS(err); |
| 1346 | mmr.offset = 16; |
| 1347 | mmr.size = 256; // flushing bounds (272) exceed mapped bounds (256) |
| 1348 | m_errorMonitor->SetDesiredFailureMsg( |
| 1349 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1350 | ") exceeds the Memory Object's upper-bound ("); |
| 1351 | vkFlushMappedMemoryRanges(m_device->device(), 1, &mmr); |
| 1352 | m_errorMonitor->VerifyFound(); |
| 1353 | |
| 1354 | pass = |
| 1355 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &alloc_info, |
| 1356 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, |
| 1357 | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT); |
| 1358 | if (!pass) { |
| 1359 | vkFreeMemory(m_device->device(), mem, NULL); |
| 1360 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 1361 | return; |
| 1362 | } |
| 1363 | // TODO : If we can get HOST_VISIBLE w/o HOST_COHERENT we can test cases of |
| 1364 | // MEMTRACK_INVALID_MAP in validateAndCopyNoncoherentMemoryToDriver() |
| 1365 | |
| 1366 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 1367 | vkFreeMemory(m_device->device(), mem, NULL); |
| 1368 | } |
| 1369 | |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1370 | TEST_F(VkLayerTest, EnableWsiBeforeUse) { |
| 1371 | VkResult err; |
| 1372 | bool pass; |
| 1373 | |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1374 | // FIXME: After we turn on this code for non-Linux platforms, uncomment the |
| 1375 | // following declaration (which is temporarily being moved below): |
| 1376 | // VkSurfaceKHR surface = VK_NULL_HANDLE; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1377 | VkSwapchainKHR swapchain = VK_NULL_HANDLE; |
| 1378 | VkSwapchainCreateInfoKHR swapchain_create_info = {}; |
| 1379 | uint32_t swapchain_image_count = 0; |
| 1380 | // VkImage swapchain_images[1] = {VK_NULL_HANDLE}; |
| 1381 | uint32_t image_index = 0; |
| 1382 | // VkPresentInfoKHR present_info = {}; |
| 1383 | |
| 1384 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1385 | |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1386 | #ifdef NEED_TO_TEST_THIS_ON_PLATFORM |
| 1387 | #if defined(VK_USE_PLATFORM_ANDROID_KHR) |
| 1388 | // Use the functions from the VK_KHR_android_surface extension without |
| 1389 | // enabling that extension: |
| 1390 | |
| 1391 | // Create a surface: |
| 1392 | VkAndroidSurfaceCreateInfoKHR android_create_info = {}; |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1393 | m_errorMonitor->SetDesiredFailureMsg( |
| 1394 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1395 | "extension was not enabled for this"); |
| 1396 | err = vkCreateAndroidSurfaceKHR(instance(), &android_create_info, NULL, |
| 1397 | &surface); |
| 1398 | pass = (err != VK_SUCCESS); |
| 1399 | ASSERT_TRUE(pass); |
| 1400 | m_errorMonitor->VerifyFound(); |
| 1401 | #endif // VK_USE_PLATFORM_ANDROID_KHR |
| 1402 | |
| 1403 | |
| 1404 | #if defined(VK_USE_PLATFORM_MIR_KHR) |
| 1405 | // Use the functions from the VK_KHR_mir_surface extension without enabling |
| 1406 | // that extension: |
| 1407 | |
| 1408 | // Create a surface: |
| 1409 | VkMirSurfaceCreateInfoKHR mir_create_info = {}; |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1410 | m_errorMonitor->SetDesiredFailureMsg( |
| 1411 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1412 | "extension was not enabled for this"); |
| 1413 | err = vkCreateMirSurfaceKHR(instance(), &mir_create_info, NULL, &surface); |
| 1414 | pass = (err != VK_SUCCESS); |
| 1415 | ASSERT_TRUE(pass); |
| 1416 | m_errorMonitor->VerifyFound(); |
| 1417 | |
| 1418 | // Tell whether an mir_connection supports presentation: |
| 1419 | MirConnection *mir_connection = NULL; |
| 1420 | m_errorMonitor->SetDesiredFailureMsg( |
| 1421 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1422 | "extension was not enabled for this"); |
| 1423 | vkGetPhysicalDeviceMirPresentationSupportKHR(gpu(), 0, mir_connection, |
| 1424 | visual_id); |
| 1425 | m_errorMonitor->VerifyFound(); |
| 1426 | #endif // VK_USE_PLATFORM_MIR_KHR |
| 1427 | |
| 1428 | |
| 1429 | #if defined(VK_USE_PLATFORM_WAYLAND_KHR) |
| 1430 | // Use the functions from the VK_KHR_wayland_surface extension without |
| 1431 | // enabling that extension: |
| 1432 | |
| 1433 | // Create a surface: |
| 1434 | VkWaylandSurfaceCreateInfoKHR wayland_create_info = {}; |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1435 | m_errorMonitor->SetDesiredFailureMsg( |
| 1436 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1437 | "extension was not enabled for this"); |
| 1438 | err = vkCreateWaylandSurfaceKHR(instance(), &wayland_create_info, NULL, |
| 1439 | &surface); |
| 1440 | pass = (err != VK_SUCCESS); |
| 1441 | ASSERT_TRUE(pass); |
| 1442 | m_errorMonitor->VerifyFound(); |
| 1443 | |
| 1444 | // Tell whether an wayland_display supports presentation: |
| 1445 | struct wl_display wayland_display = {}; |
| 1446 | m_errorMonitor->SetDesiredFailureMsg( |
| 1447 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1448 | "extension was not enabled for this"); |
| 1449 | vkGetPhysicalDeviceWaylandPresentationSupportKHR(gpu(), 0, |
| 1450 | &wayland_display); |
| 1451 | m_errorMonitor->VerifyFound(); |
| 1452 | #endif // VK_USE_PLATFORM_WAYLAND_KHR |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1453 | #endif // NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1454 | |
| 1455 | |
| 1456 | #if defined(VK_USE_PLATFORM_WIN32_KHR) |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1457 | // FIXME: REMOVE THIS HERE, AND UNCOMMENT ABOVE, WHEN THIS TEST HAS BEEN PORTED |
| 1458 | // TO NON-LINUX PLATFORMS: |
| 1459 | VkSurfaceKHR surface = VK_NULL_HANDLE; |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1460 | // Use the functions from the VK_KHR_win32_surface extension without |
| 1461 | // enabling that extension: |
| 1462 | |
| 1463 | // Create a surface: |
| 1464 | VkWin32SurfaceCreateInfoKHR win32_create_info = {}; |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1465 | m_errorMonitor->SetDesiredFailureMsg( |
| 1466 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1467 | "extension was not enabled for this"); |
| 1468 | err = vkCreateWin32SurfaceKHR(instance(), &win32_create_info, NULL, |
| 1469 | &surface); |
| 1470 | pass = (err != VK_SUCCESS); |
| 1471 | ASSERT_TRUE(pass); |
| 1472 | m_errorMonitor->VerifyFound(); |
| 1473 | |
| 1474 | // Tell whether win32 supports presentation: |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1475 | m_errorMonitor->SetDesiredFailureMsg( |
| 1476 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1477 | "extension was not enabled for this"); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1478 | vkGetPhysicalDeviceWin32PresentationSupportKHR(gpu(), 0); |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1479 | m_errorMonitor->VerifyFound(); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1480 | // Set this (for now, until all platforms are supported and tested): |
| 1481 | #define NEED_TO_TEST_THIS_ON_PLATFORM |
| 1482 | #endif // VK_USE_PLATFORM_WIN32_KHR |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1483 | |
| 1484 | |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1485 | #if defined(VK_USE_PLATFORM_XCB_KHR) |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1486 | // FIXME: REMOVE THIS HERE, AND UNCOMMENT ABOVE, WHEN THIS TEST HAS BEEN PORTED |
| 1487 | // TO NON-LINUX PLATFORMS: |
| 1488 | VkSurfaceKHR surface = VK_NULL_HANDLE; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1489 | // Use the functions from the VK_KHR_xcb_surface extension without enabling |
| 1490 | // that extension: |
| 1491 | |
| 1492 | // Create a surface: |
| 1493 | VkXcbSurfaceCreateInfoKHR xcb_create_info = {}; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1494 | m_errorMonitor->SetDesiredFailureMsg( |
| 1495 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1496 | "extension was not enabled for this"); |
| 1497 | err = vkCreateXcbSurfaceKHR(instance(), &xcb_create_info, NULL, &surface); |
| 1498 | pass = (err != VK_SUCCESS); |
| 1499 | ASSERT_TRUE(pass); |
| 1500 | m_errorMonitor->VerifyFound(); |
| 1501 | |
| 1502 | // Tell whether an xcb_visualid_t supports presentation: |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1503 | xcb_connection_t *xcb_connection = NULL; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1504 | xcb_visualid_t visual_id = 0; |
| 1505 | m_errorMonitor->SetDesiredFailureMsg( |
| 1506 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1507 | "extension was not enabled for this"); |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1508 | vkGetPhysicalDeviceXcbPresentationSupportKHR(gpu(), 0, xcb_connection, |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1509 | visual_id); |
| 1510 | m_errorMonitor->VerifyFound(); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1511 | // Set this (for now, until all platforms are supported and tested): |
| 1512 | #define NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1513 | #endif // VK_USE_PLATFORM_XCB_KHR |
| 1514 | |
| 1515 | |
Ian Elliott | 1263081 | 2016-04-29 14:35:43 -0600 | [diff] [blame] | 1516 | #if defined(VK_USE_PLATFORM_XLIB_KHR) |
| 1517 | // Use the functions from the VK_KHR_xlib_surface extension without enabling |
| 1518 | // that extension: |
| 1519 | |
| 1520 | // Create a surface: |
| 1521 | VkXlibSurfaceCreateInfoKHR xlib_create_info = {}; |
Ian Elliott | 1263081 | 2016-04-29 14:35:43 -0600 | [diff] [blame] | 1522 | m_errorMonitor->SetDesiredFailureMsg( |
| 1523 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1524 | "extension was not enabled for this"); |
| 1525 | err = vkCreateXlibSurfaceKHR(instance(), &xlib_create_info, NULL, &surface); |
| 1526 | pass = (err != VK_SUCCESS); |
| 1527 | ASSERT_TRUE(pass); |
| 1528 | m_errorMonitor->VerifyFound(); |
| 1529 | |
| 1530 | // Tell whether an Xlib VisualID supports presentation: |
| 1531 | Display *dpy = NULL; |
| 1532 | VisualID visual = 0; |
| 1533 | m_errorMonitor->SetDesiredFailureMsg( |
| 1534 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1535 | "extension was not enabled for this"); |
| 1536 | vkGetPhysicalDeviceXlibPresentationSupportKHR(gpu(), 0, dpy, visual); |
| 1537 | m_errorMonitor->VerifyFound(); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1538 | // Set this (for now, until all platforms are supported and tested): |
| 1539 | #define NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1263081 | 2016-04-29 14:35:43 -0600 | [diff] [blame] | 1540 | #endif // VK_USE_PLATFORM_XLIB_KHR |
| 1541 | |
| 1542 | |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1543 | // Use the functions from the VK_KHR_surface extension without enabling |
| 1544 | // that extension: |
| 1545 | |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1546 | #ifdef NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1547 | // Destroy a surface: |
| 1548 | m_errorMonitor->SetDesiredFailureMsg( |
| 1549 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1550 | "extension was not enabled for this"); |
| 1551 | vkDestroySurfaceKHR(instance(), surface, NULL); |
| 1552 | m_errorMonitor->VerifyFound(); |
| 1553 | |
| 1554 | // Check if surface supports presentation: |
| 1555 | VkBool32 supported = false; |
| 1556 | m_errorMonitor->SetDesiredFailureMsg( |
| 1557 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1558 | "extension was not enabled for this"); |
| 1559 | err = vkGetPhysicalDeviceSurfaceSupportKHR(gpu(), 0, surface, &supported); |
| 1560 | pass = (err != VK_SUCCESS); |
| 1561 | ASSERT_TRUE(pass); |
| 1562 | m_errorMonitor->VerifyFound(); |
| 1563 | |
| 1564 | // Check surface capabilities: |
| 1565 | VkSurfaceCapabilitiesKHR capabilities = {}; |
| 1566 | m_errorMonitor->SetDesiredFailureMsg( |
| 1567 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1568 | "extension was not enabled for this"); |
| 1569 | err = vkGetPhysicalDeviceSurfaceCapabilitiesKHR(gpu(), surface, |
| 1570 | &capabilities); |
| 1571 | pass = (err != VK_SUCCESS); |
| 1572 | ASSERT_TRUE(pass); |
| 1573 | m_errorMonitor->VerifyFound(); |
| 1574 | |
| 1575 | // Check surface formats: |
| 1576 | uint32_t format_count = 0; |
| 1577 | VkSurfaceFormatKHR *formats = NULL; |
| 1578 | m_errorMonitor->SetDesiredFailureMsg( |
| 1579 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1580 | "extension was not enabled for this"); |
| 1581 | err = vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, |
| 1582 | &format_count, formats); |
| 1583 | pass = (err != VK_SUCCESS); |
| 1584 | ASSERT_TRUE(pass); |
| 1585 | m_errorMonitor->VerifyFound(); |
| 1586 | |
| 1587 | // Check surface present modes: |
| 1588 | uint32_t present_mode_count = 0; |
| 1589 | VkSurfaceFormatKHR *present_modes = NULL; |
| 1590 | m_errorMonitor->SetDesiredFailureMsg( |
| 1591 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1592 | "extension was not enabled for this"); |
| 1593 | err = vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, |
| 1594 | &present_mode_count, present_modes); |
| 1595 | pass = (err != VK_SUCCESS); |
| 1596 | ASSERT_TRUE(pass); |
| 1597 | m_errorMonitor->VerifyFound(); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1598 | #endif // NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1599 | |
| 1600 | |
| 1601 | // Use the functions from the VK_KHR_swapchain extension without enabling |
| 1602 | // that extension: |
| 1603 | |
| 1604 | // Create a swapchain: |
| 1605 | m_errorMonitor->SetDesiredFailureMsg( |
| 1606 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1607 | "extension was not enabled for this"); |
| 1608 | swapchain_create_info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR; |
| 1609 | swapchain_create_info.pNext = NULL; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1610 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, |
| 1611 | NULL, &swapchain); |
| 1612 | pass = (err != VK_SUCCESS); |
| 1613 | ASSERT_TRUE(pass); |
| 1614 | m_errorMonitor->VerifyFound(); |
| 1615 | |
| 1616 | // Get the images from the swapchain: |
| 1617 | m_errorMonitor->SetDesiredFailureMsg( |
| 1618 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1619 | "extension was not enabled for this"); |
| 1620 | err = vkGetSwapchainImagesKHR(m_device->device(), swapchain, |
| 1621 | &swapchain_image_count, NULL); |
| 1622 | pass = (err != VK_SUCCESS); |
| 1623 | ASSERT_TRUE(pass); |
| 1624 | m_errorMonitor->VerifyFound(); |
| 1625 | |
| 1626 | // Try to acquire an image: |
| 1627 | m_errorMonitor->SetDesiredFailureMsg( |
| 1628 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1629 | "extension was not enabled for this"); |
| 1630 | err = vkAcquireNextImageKHR(m_device->device(), swapchain, 0, |
| 1631 | VK_NULL_HANDLE, VK_NULL_HANDLE, &image_index); |
| 1632 | pass = (err != VK_SUCCESS); |
| 1633 | ASSERT_TRUE(pass); |
| 1634 | m_errorMonitor->VerifyFound(); |
| 1635 | |
| 1636 | // Try to present an image: |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1637 | // |
| 1638 | // NOTE: Currently can't test this because a real swapchain is needed (as |
| 1639 | // opposed to the fake one we created) in order for the layer to lookup the |
| 1640 | // VkDevice used to enable the extension: |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1641 | |
| 1642 | // Destroy the swapchain: |
| 1643 | m_errorMonitor->SetDesiredFailureMsg( |
| 1644 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1645 | "extension was not enabled for this"); |
| 1646 | vkDestroySwapchainKHR(m_device->device(), swapchain, NULL); |
| 1647 | m_errorMonitor->VerifyFound(); |
| 1648 | } |
| 1649 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1650 | TEST_F(VkWsiEnabledLayerTest, TestEnabledWsi) { |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1651 | |
| 1652 | VkSurfaceKHR surface = VK_NULL_HANDLE; |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1653 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1654 | #if defined(VK_USE_PLATFORM_XCB_KHR) |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1655 | VkResult err; |
| 1656 | bool pass; |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1657 | VkSwapchainKHR swapchain = VK_NULL_HANDLE; |
| 1658 | VkSwapchainCreateInfoKHR swapchain_create_info = {}; |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1659 | // uint32_t swapchain_image_count = 0; |
| 1660 | // VkImage swapchain_images[1] = {VK_NULL_HANDLE}; |
| 1661 | // uint32_t image_index = 0; |
| 1662 | // VkPresentInfoKHR present_info = {}; |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1663 | |
| 1664 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1665 | |
| 1666 | // Use the create function from one of the VK_KHR_*_surface extension in |
| 1667 | // order to create a surface, testing all known errors in the process, |
| 1668 | // before successfully creating a surface: |
| 1669 | // First, try to create a surface without a VkXcbSurfaceCreateInfoKHR: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1670 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1671 | "called with NULL pointer"); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1672 | err = vkCreateXcbSurfaceKHR(instance(), NULL, NULL, &surface); |
| 1673 | pass = (err != VK_SUCCESS); |
| 1674 | ASSERT_TRUE(pass); |
| 1675 | m_errorMonitor->VerifyFound(); |
| 1676 | |
| 1677 | // Next, try to create a surface with the wrong |
| 1678 | // VkXcbSurfaceCreateInfoKHR::sType: |
| 1679 | VkXcbSurfaceCreateInfoKHR xcb_create_info = {}; |
| 1680 | xcb_create_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1681 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1682 | "called with the wrong value for"); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1683 | err = vkCreateXcbSurfaceKHR(instance(), &xcb_create_info, NULL, &surface); |
| 1684 | pass = (err != VK_SUCCESS); |
| 1685 | ASSERT_TRUE(pass); |
| 1686 | m_errorMonitor->VerifyFound(); |
| 1687 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1688 | // Create a native window, and then correctly create a surface: |
| 1689 | xcb_connection_t *connection; |
| 1690 | xcb_screen_t *screen; |
| 1691 | xcb_window_t xcb_window; |
| 1692 | xcb_intern_atom_reply_t *atom_wm_delete_window; |
| 1693 | |
| 1694 | const xcb_setup_t *setup; |
| 1695 | xcb_screen_iterator_t iter; |
| 1696 | int scr; |
| 1697 | uint32_t value_mask, value_list[32]; |
| 1698 | int width = 1; |
| 1699 | int height = 1; |
| 1700 | |
| 1701 | connection = xcb_connect(NULL, &scr); |
| 1702 | ASSERT_TRUE(connection != NULL); |
| 1703 | setup = xcb_get_setup(connection); |
| 1704 | iter = xcb_setup_roots_iterator(setup); |
| 1705 | while (scr-- > 0) |
| 1706 | xcb_screen_next(&iter); |
| 1707 | screen = iter.data; |
| 1708 | |
| 1709 | xcb_window = xcb_generate_id(connection); |
| 1710 | |
| 1711 | value_mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK; |
| 1712 | value_list[0] = screen->black_pixel; |
| 1713 | value_list[1] = XCB_EVENT_MASK_KEY_RELEASE | XCB_EVENT_MASK_EXPOSURE | |
| 1714 | XCB_EVENT_MASK_STRUCTURE_NOTIFY; |
| 1715 | |
| 1716 | xcb_create_window(connection, XCB_COPY_FROM_PARENT, xcb_window, |
| 1717 | screen->root, 0, 0, width, height, 0, |
| 1718 | XCB_WINDOW_CLASS_INPUT_OUTPUT, screen->root_visual, |
| 1719 | value_mask, value_list); |
| 1720 | |
| 1721 | /* Magic code that will send notification when window is destroyed */ |
| 1722 | xcb_intern_atom_cookie_t cookie = |
| 1723 | xcb_intern_atom(connection, 1, 12, "WM_PROTOCOLS"); |
| 1724 | xcb_intern_atom_reply_t *reply = |
| 1725 | xcb_intern_atom_reply(connection, cookie, 0); |
| 1726 | |
| 1727 | xcb_intern_atom_cookie_t cookie2 = |
| 1728 | xcb_intern_atom(connection, 0, 16, "WM_DELETE_WINDOW"); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1729 | atom_wm_delete_window = xcb_intern_atom_reply(connection, cookie2, 0); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1730 | xcb_change_property(connection, XCB_PROP_MODE_REPLACE, xcb_window, |
| 1731 | (*reply).atom, 4, 32, 1, |
| 1732 | &(*atom_wm_delete_window).atom); |
| 1733 | free(reply); |
| 1734 | |
| 1735 | xcb_map_window(connection, xcb_window); |
| 1736 | |
| 1737 | // Force the x/y coordinates to 100,100 results are identical in consecutive |
| 1738 | // runs |
| 1739 | const uint32_t coords[] = {100, 100}; |
| 1740 | xcb_configure_window(connection, xcb_window, |
| 1741 | XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, coords); |
| 1742 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1743 | // Finally, try to correctly create a surface: |
| 1744 | xcb_create_info.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR; |
| 1745 | xcb_create_info.pNext = NULL; |
| 1746 | xcb_create_info.flags = 0; |
| 1747 | xcb_create_info.connection = connection; |
| 1748 | xcb_create_info.window = xcb_window; |
| 1749 | err = vkCreateXcbSurfaceKHR(instance(), &xcb_create_info, NULL, &surface); |
| 1750 | pass = (err == VK_SUCCESS); |
| 1751 | ASSERT_TRUE(pass); |
| 1752 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1753 | // Check if surface supports presentation: |
| 1754 | |
| 1755 | // 1st, do so without having queried the queue families: |
| 1756 | VkBool32 supported = false; |
| 1757 | // TODO: Get the following error to come out: |
| 1758 | m_errorMonitor->SetDesiredFailureMsg( |
| 1759 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1760 | "called before calling the vkGetPhysicalDeviceQueueFamilyProperties " |
| 1761 | "function"); |
| 1762 | err = vkGetPhysicalDeviceSurfaceSupportKHR(gpu(), 0, surface, &supported); |
| 1763 | pass = (err != VK_SUCCESS); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1764 | // ASSERT_TRUE(pass); |
| 1765 | // m_errorMonitor->VerifyFound(); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1766 | |
| 1767 | // Next, query a queue family index that's too large: |
| 1768 | m_errorMonitor->SetDesiredFailureMsg( |
| 1769 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1770 | "called with a queueFamilyIndex that is too large"); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1771 | err = vkGetPhysicalDeviceSurfaceSupportKHR(gpu(), 100000, surface, |
| 1772 | &supported); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1773 | pass = (err != VK_SUCCESS); |
| 1774 | ASSERT_TRUE(pass); |
| 1775 | m_errorMonitor->VerifyFound(); |
| 1776 | |
| 1777 | // Finally, do so correctly: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1778 | // FIXME: THIS ISN'T CORRECT--MUST QUERY UNTIL WE FIND A QUEUE FAMILY THAT'S |
| 1779 | // SUPPORTED |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1780 | err = vkGetPhysicalDeviceSurfaceSupportKHR(gpu(), 0, surface, &supported); |
| 1781 | pass = (err == VK_SUCCESS); |
| 1782 | ASSERT_TRUE(pass); |
| 1783 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1784 | // Before proceeding, try to create a swapchain without having called |
| 1785 | // vkGetPhysicalDeviceSurfaceCapabilitiesKHR(): |
| 1786 | swapchain_create_info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR; |
| 1787 | swapchain_create_info.pNext = NULL; |
| 1788 | swapchain_create_info.flags = 0; |
| 1789 | m_errorMonitor->SetDesiredFailureMsg( |
| 1790 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1791 | "called before calling vkGetPhysicalDeviceSurfaceCapabilitiesKHR()."); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1792 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, |
| 1793 | &swapchain); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1794 | pass = (err != VK_SUCCESS); |
| 1795 | ASSERT_TRUE(pass); |
| 1796 | m_errorMonitor->VerifyFound(); |
| 1797 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1798 | // Get the surface capabilities: |
| 1799 | VkSurfaceCapabilitiesKHR surface_capabilities; |
| 1800 | |
| 1801 | // Do so correctly (only error logged by this entrypoint is if the |
| 1802 | // extension isn't enabled): |
| 1803 | err = vkGetPhysicalDeviceSurfaceCapabilitiesKHR(gpu(), surface, |
| 1804 | &surface_capabilities); |
| 1805 | pass = (err == VK_SUCCESS); |
| 1806 | ASSERT_TRUE(pass); |
| 1807 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1808 | // Get the surface formats: |
| 1809 | uint32_t surface_format_count; |
| 1810 | |
| 1811 | // First, try without a pointer to surface_format_count: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1812 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1813 | "called with NULL pointer"); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1814 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, NULL, NULL); |
| 1815 | pass = (err == VK_SUCCESS); |
| 1816 | ASSERT_TRUE(pass); |
| 1817 | m_errorMonitor->VerifyFound(); |
| 1818 | |
| 1819 | // Next, call with a non-NULL pSurfaceFormats, even though we haven't |
| 1820 | // correctly done a 1st try (to get the count): |
| 1821 | m_errorMonitor->SetDesiredFailureMsg( |
| 1822 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1823 | "but no prior positive value has been seen for"); |
| 1824 | surface_format_count = 0; |
| 1825 | vkGetPhysicalDeviceSurfaceFormatsKHR( |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1826 | gpu(), surface, &surface_format_count, |
| 1827 | (VkSurfaceFormatKHR *)&surface_format_count); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1828 | pass = (err == VK_SUCCESS); |
| 1829 | ASSERT_TRUE(pass); |
| 1830 | m_errorMonitor->VerifyFound(); |
| 1831 | |
| 1832 | // 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] | 1833 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, &surface_format_count, |
| 1834 | NULL); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1835 | pass = (err == VK_SUCCESS); |
| 1836 | ASSERT_TRUE(pass); |
| 1837 | |
| 1838 | // Allocate memory for the correct number of VkSurfaceFormatKHR's: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1839 | VkSurfaceFormatKHR *surface_formats = (VkSurfaceFormatKHR *)malloc( |
| 1840 | surface_format_count * sizeof(VkSurfaceFormatKHR)); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1841 | |
| 1842 | // Next, do a 2nd try with surface_format_count being set too high: |
| 1843 | surface_format_count += 5; |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1844 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1845 | "that is greater than the value"); |
| 1846 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, &surface_format_count, |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1847 | surface_formats); |
| 1848 | pass = (err == VK_SUCCESS); |
| 1849 | ASSERT_TRUE(pass); |
| 1850 | m_errorMonitor->VerifyFound(); |
| 1851 | |
| 1852 | // Finally, do a correct 1st and 2nd try: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1853 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, &surface_format_count, |
| 1854 | NULL); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1855 | pass = (err == VK_SUCCESS); |
| 1856 | ASSERT_TRUE(pass); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1857 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, &surface_format_count, |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1858 | surface_formats); |
| 1859 | pass = (err == VK_SUCCESS); |
| 1860 | ASSERT_TRUE(pass); |
| 1861 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1862 | // Get the surface present modes: |
| 1863 | uint32_t surface_present_mode_count; |
| 1864 | |
| 1865 | // First, try without a pointer to surface_format_count: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1866 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1867 | "called with NULL pointer"); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1868 | vkGetPhysicalDeviceSurfacePresentModesKHR(gpu(), surface, NULL, NULL); |
| 1869 | pass = (err == VK_SUCCESS); |
| 1870 | ASSERT_TRUE(pass); |
| 1871 | m_errorMonitor->VerifyFound(); |
| 1872 | |
| 1873 | // Next, call with a non-NULL VkPresentModeKHR, even though we haven't |
| 1874 | // correctly done a 1st try (to get the count): |
| 1875 | m_errorMonitor->SetDesiredFailureMsg( |
| 1876 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1877 | "but no prior positive value has been seen for"); |
| 1878 | surface_present_mode_count = 0; |
| 1879 | vkGetPhysicalDeviceSurfacePresentModesKHR( |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1880 | gpu(), surface, &surface_present_mode_count, |
| 1881 | (VkPresentModeKHR *)&surface_present_mode_count); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1882 | pass = (err == VK_SUCCESS); |
| 1883 | ASSERT_TRUE(pass); |
| 1884 | m_errorMonitor->VerifyFound(); |
| 1885 | |
| 1886 | // 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] | 1887 | vkGetPhysicalDeviceSurfacePresentModesKHR( |
| 1888 | gpu(), surface, &surface_present_mode_count, NULL); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1889 | pass = (err == VK_SUCCESS); |
| 1890 | ASSERT_TRUE(pass); |
| 1891 | |
| 1892 | // Allocate memory for the correct number of VkSurfaceFormatKHR's: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1893 | VkPresentModeKHR *surface_present_modes = (VkPresentModeKHR *)malloc( |
| 1894 | surface_present_mode_count * sizeof(VkPresentModeKHR)); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1895 | |
| 1896 | // Next, do a 2nd try with surface_format_count being set too high: |
| 1897 | surface_present_mode_count += 5; |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1898 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1899 | "that is greater than the value"); |
| 1900 | vkGetPhysicalDeviceSurfacePresentModesKHR( |
| 1901 | gpu(), surface, &surface_present_mode_count, surface_present_modes); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1902 | pass = (err == VK_SUCCESS); |
| 1903 | ASSERT_TRUE(pass); |
| 1904 | m_errorMonitor->VerifyFound(); |
| 1905 | |
| 1906 | // Finally, do a correct 1st and 2nd try: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1907 | vkGetPhysicalDeviceSurfacePresentModesKHR( |
| 1908 | gpu(), surface, &surface_present_mode_count, NULL); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1909 | pass = (err == VK_SUCCESS); |
| 1910 | ASSERT_TRUE(pass); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1911 | vkGetPhysicalDeviceSurfacePresentModesKHR( |
| 1912 | gpu(), surface, &surface_present_mode_count, surface_present_modes); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1913 | pass = (err == VK_SUCCESS); |
| 1914 | ASSERT_TRUE(pass); |
| 1915 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1916 | // Create a swapchain: |
| 1917 | |
| 1918 | // First, try without a pointer to swapchain_create_info: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1919 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1920 | "called with NULL pointer"); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1921 | err = vkCreateSwapchainKHR(m_device->device(), NULL, NULL, &swapchain); |
| 1922 | pass = (err != VK_SUCCESS); |
| 1923 | ASSERT_TRUE(pass); |
| 1924 | m_errorMonitor->VerifyFound(); |
| 1925 | |
| 1926 | // Next, call with a non-NULL swapchain_create_info, that has the wrong |
| 1927 | // sType: |
| 1928 | swapchain_create_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1929 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1930 | "called with the wrong value for"); |
| 1931 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, |
| 1932 | &swapchain); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1933 | pass = (err != VK_SUCCESS); |
| 1934 | ASSERT_TRUE(pass); |
| 1935 | m_errorMonitor->VerifyFound(); |
| 1936 | |
| 1937 | // Next, call with a NULL swapchain pointer: |
| 1938 | swapchain_create_info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR; |
| 1939 | swapchain_create_info.pNext = NULL; |
| 1940 | swapchain_create_info.flags = 0; |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1941 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1942 | "called with NULL pointer"); |
| 1943 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, |
| 1944 | NULL); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1945 | pass = (err != VK_SUCCESS); |
| 1946 | ASSERT_TRUE(pass); |
| 1947 | m_errorMonitor->VerifyFound(); |
| 1948 | |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1949 | // TODO: Enhance swapchain layer so that |
| 1950 | // swapchain_create_info.queueFamilyIndexCount is checked against something? |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1951 | |
| 1952 | // Next, call with a queue family index that's too large: |
| 1953 | uint32_t queueFamilyIndex[2] = {100000, 0}; |
| 1954 | swapchain_create_info.imageSharingMode = VK_SHARING_MODE_CONCURRENT; |
| 1955 | swapchain_create_info.queueFamilyIndexCount = 2; |
| 1956 | swapchain_create_info.pQueueFamilyIndices = queueFamilyIndex; |
| 1957 | m_errorMonitor->SetDesiredFailureMsg( |
| 1958 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1959 | "called with a queueFamilyIndex that is too large"); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1960 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, |
| 1961 | &swapchain); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1962 | pass = (err != VK_SUCCESS); |
| 1963 | ASSERT_TRUE(pass); |
| 1964 | m_errorMonitor->VerifyFound(); |
| 1965 | |
| 1966 | // Next, call a queueFamilyIndexCount that's too small for CONCURRENT: |
| 1967 | swapchain_create_info.imageSharingMode = VK_SHARING_MODE_CONCURRENT; |
| 1968 | swapchain_create_info.queueFamilyIndexCount = 1; |
| 1969 | m_errorMonitor->SetDesiredFailureMsg( |
| 1970 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1971 | "but with a bad value(s) for pCreateInfo->queueFamilyIndexCount or " |
| 1972 | "pCreateInfo->pQueueFamilyIndices)."); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1973 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, |
| 1974 | &swapchain); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1975 | pass = (err != VK_SUCCESS); |
| 1976 | ASSERT_TRUE(pass); |
| 1977 | m_errorMonitor->VerifyFound(); |
| 1978 | |
| 1979 | // Next, call with an invalid imageSharingMode: |
| 1980 | swapchain_create_info.imageSharingMode = VK_SHARING_MODE_MAX_ENUM; |
| 1981 | swapchain_create_info.queueFamilyIndexCount = 1; |
| 1982 | m_errorMonitor->SetDesiredFailureMsg( |
| 1983 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1984 | "called with a non-supported pCreateInfo->imageSharingMode (i.e."); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1985 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, |
| 1986 | &swapchain); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1987 | pass = (err != VK_SUCCESS); |
| 1988 | ASSERT_TRUE(pass); |
| 1989 | m_errorMonitor->VerifyFound(); |
| 1990 | // Fix for the future: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1991 | // FIXME: THIS ISN'T CORRECT--MUST QUERY UNTIL WE FIND A QUEUE FAMILY THAT'S |
| 1992 | // SUPPORTED |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1993 | swapchain_create_info.queueFamilyIndexCount = 0; |
| 1994 | queueFamilyIndex[0] = 0; |
| 1995 | swapchain_create_info.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 1996 | |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1997 | // TODO: CONTINUE TESTING VALIDATION OF vkCreateSwapchainKHR() ... |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1998 | // Get the images from a swapchain: |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1999 | // Acquire an image from a swapchain: |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2000 | // Present an image to a swapchain: |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2001 | // Destroy the swapchain: |
| 2002 | |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2003 | // TODOs: |
| 2004 | // |
| 2005 | // - Try destroying the device without first destroying the swapchain |
| 2006 | // |
| 2007 | // - Try destroying the device without first destroying the surface |
| 2008 | // |
| 2009 | // - Try destroying the surface without first destroying the swapchain |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2010 | |
| 2011 | // Destroy the surface: |
| 2012 | vkDestroySurfaceKHR(instance(), surface, NULL); |
| 2013 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2014 | // Tear down the window: |
| 2015 | xcb_destroy_window(connection, xcb_window); |
| 2016 | xcb_disconnect(connection); |
| 2017 | |
| 2018 | #else // VK_USE_PLATFORM_XCB_KHR |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2019 | return; |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2020 | #endif // VK_USE_PLATFORM_XCB_KHR |
| 2021 | } |
| 2022 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2023 | TEST_F(VkLayerTest, MapMemWithoutHostVisibleBit) { |
| 2024 | VkResult err; |
| 2025 | bool pass; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2026 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2027 | m_errorMonitor->SetDesiredFailureMsg( |
| 2028 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2029 | "Mapping Memory without VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT"); |
| 2030 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2031 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2032 | |
| 2033 | // 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] | 2034 | VkImage image; |
| 2035 | VkDeviceMemory mem; |
| 2036 | VkMemoryRequirements mem_reqs; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2037 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2038 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2039 | const int32_t tex_width = 32; |
| 2040 | const int32_t tex_height = 32; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2041 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2042 | VkImageCreateInfo image_create_info = {}; |
| 2043 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2044 | image_create_info.pNext = NULL; |
| 2045 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2046 | image_create_info.format = tex_format; |
| 2047 | image_create_info.extent.width = tex_width; |
| 2048 | image_create_info.extent.height = tex_height; |
| 2049 | image_create_info.extent.depth = 1; |
| 2050 | image_create_info.mipLevels = 1; |
| 2051 | image_create_info.arrayLayers = 1; |
| 2052 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 2053 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 2054 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 2055 | image_create_info.flags = 0; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2056 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2057 | VkMemoryAllocateInfo mem_alloc = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2058 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2059 | mem_alloc.pNext = NULL; |
| 2060 | mem_alloc.allocationSize = 0; |
| 2061 | // Introduce failure, do NOT set memProps to |
| 2062 | // VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
| 2063 | mem_alloc.memoryTypeIndex = 1; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2064 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2065 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2066 | ASSERT_VK_SUCCESS(err); |
| 2067 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2068 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2069 | |
Mark Lobodzinski | 2306535 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 2070 | mem_alloc.allocationSize = mem_reqs.size; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2071 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2072 | pass = |
| 2073 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0, |
| 2074 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 2075 | if (!pass) { // If we can't find any unmappable memory this test doesn't |
| 2076 | // make sense |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2077 | vkDestroyImage(m_device->device(), image, NULL); |
Tony Barbour | 02fdc7d | 2015-08-04 16:13:01 -0600 | [diff] [blame] | 2078 | return; |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2079 | } |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 2080 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2081 | // allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2082 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2083 | ASSERT_VK_SUCCESS(err); |
| 2084 | |
| 2085 | // Try to bind free memory that has been freed |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 2086 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2087 | ASSERT_VK_SUCCESS(err); |
| 2088 | |
| 2089 | // Map memory as if to initialize the image |
| 2090 | void *mappedAddress = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2091 | err = vkMapMemory(m_device->device(), mem, 0, VK_WHOLE_SIZE, 0, |
| 2092 | &mappedAddress); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2093 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2094 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2095 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2096 | vkDestroyImage(m_device->device(), image, NULL); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2097 | } |
| 2098 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2099 | TEST_F(VkLayerTest, RebindMemory) { |
| 2100 | VkResult err; |
| 2101 | bool pass; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2102 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2103 | m_errorMonitor->SetDesiredFailureMsg( |
| 2104 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2105 | "which has already been bound to mem object"); |
| 2106 | |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2107 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2108 | |
| 2109 | // 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] | 2110 | VkImage image; |
| 2111 | VkDeviceMemory mem1; |
| 2112 | VkDeviceMemory mem2; |
| 2113 | VkMemoryRequirements mem_reqs; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2114 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2115 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2116 | const int32_t tex_width = 32; |
| 2117 | const int32_t tex_height = 32; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2118 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2119 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2120 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 2121 | image_create_info.pNext = NULL; |
| 2122 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2123 | image_create_info.format = tex_format; |
| 2124 | image_create_info.extent.width = tex_width; |
| 2125 | image_create_info.extent.height = tex_height; |
| 2126 | image_create_info.extent.depth = 1; |
| 2127 | image_create_info.mipLevels = 1; |
| 2128 | image_create_info.arrayLayers = 1; |
| 2129 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 2130 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 2131 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 2132 | image_create_info.flags = 0; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2133 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2134 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2135 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 2136 | mem_alloc.pNext = NULL; |
| 2137 | mem_alloc.allocationSize = 0; |
| 2138 | mem_alloc.memoryTypeIndex = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2139 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2140 | // Introduce failure, do NOT set memProps to |
| 2141 | // VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2142 | mem_alloc.memoryTypeIndex = 1; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2143 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2144 | ASSERT_VK_SUCCESS(err); |
| 2145 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2146 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2147 | |
| 2148 | mem_alloc.allocationSize = mem_reqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2149 | pass = |
| 2150 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 2151 | ASSERT_TRUE(pass); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2152 | |
| 2153 | // allocate 2 memory objects |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2154 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem1); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2155 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2156 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem2); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2157 | ASSERT_VK_SUCCESS(err); |
| 2158 | |
| 2159 | // Bind first memory object to Image object |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 2160 | err = vkBindImageMemory(m_device->device(), image, mem1, 0); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2161 | ASSERT_VK_SUCCESS(err); |
| 2162 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2163 | // Introduce validation failure, try to bind a different memory object to |
| 2164 | // the same image object |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 2165 | err = vkBindImageMemory(m_device->device(), image, mem2, 0); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2166 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2167 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2168 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2169 | vkDestroyImage(m_device->device(), image, NULL); |
| 2170 | vkFreeMemory(m_device->device(), mem1, NULL); |
| 2171 | vkFreeMemory(m_device->device(), mem2, NULL); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2172 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2173 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2174 | TEST_F(VkLayerTest, SubmitSignaledFence) { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2175 | vk_testing::Fence testFence; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2176 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2177 | m_errorMonitor->SetDesiredFailureMsg( |
| 2178 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "submitted in SIGNALED state. Fences " |
| 2179 | "must be reset before being submitted"); |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2180 | |
| 2181 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2182 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2183 | fenceInfo.pNext = NULL; |
| 2184 | fenceInfo.flags = VK_FENCE_CREATE_SIGNALED_BIT; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2185 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2186 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2187 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 2188 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2189 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 2190 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2191 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 2192 | m_stencil_clear_color, NULL); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 2193 | EndCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2194 | |
| 2195 | testFence.init(*m_device, fenceInfo); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2196 | |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2197 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 2198 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2199 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2200 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2201 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 2202 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2203 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2204 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2205 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2206 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 2207 | |
| 2208 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2209 | vkQueueWaitIdle(m_device->m_queue); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2210 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2211 | m_errorMonitor->VerifyFound(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2212 | } |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 2213 | // This is a positive test. We used to expect error in this case but spec now |
| 2214 | // allows it |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2215 | TEST_F(VkLayerTest, ResetUnsignaledFence) { |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 2216 | m_errorMonitor->ExpectSuccess(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2217 | vk_testing::Fence testFence; |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2218 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2219 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2220 | fenceInfo.pNext = NULL; |
| 2221 | |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2222 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2223 | testFence.init(*m_device, fenceInfo); |
Chia-I Wu | d9e8e82 | 2015-07-03 11:45:55 +0800 | [diff] [blame] | 2224 | VkFence fences[1] = {testFence.handle()}; |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 2225 | VkResult result = vkResetFences(m_device->device(), 1, fences); |
| 2226 | ASSERT_VK_SUCCESS(result); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2227 | |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 2228 | m_errorMonitor->VerifyNotFound(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2229 | } |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2230 | |
| 2231 | TEST_F(VkLayerTest, InvalidUsageBits) |
| 2232 | { |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2233 | TEST_DESCRIPTION( |
Karl Schultz | b5bc11e | 2016-05-04 08:36:08 -0600 | [diff] [blame] | 2234 | "Specify wrong usage for image then create conflicting view of image " |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2235 | "Initialize buffer with wrong usage then perform copy expecting errors " |
| 2236 | "from both the image and the buffer (2 calls)"); |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2237 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2238 | "Invalid usage flag for image "); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2239 | |
| 2240 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2241 | VkImageObj image(m_device); |
| 2242 | // Initialize image with USAGE_INPUT_ATTACHMENT |
| 2243 | image.init(128, 128, VK_FORMAT_D32_SFLOAT_S8_UINT, |
Karl Schultz | b5bc11e | 2016-05-04 08:36:08 -0600 | [diff] [blame] | 2244 | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
| 2245 | ASSERT_TRUE(image.initialized()); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2246 | |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2247 | VkImageView dsv; |
| 2248 | VkImageViewCreateInfo dsvci = {}; |
| 2249 | dsvci.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 2250 | dsvci.image = image.handle(); |
| 2251 | dsvci.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 2252 | dsvci.format = VK_FORMAT_D32_SFLOAT_S8_UINT; |
| 2253 | dsvci.subresourceRange.layerCount = 1; |
| 2254 | dsvci.subresourceRange.baseMipLevel = 0; |
| 2255 | dsvci.subresourceRange.levelCount = 1; |
| 2256 | dsvci.subresourceRange.aspectMask = |
| 2257 | VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2258 | |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2259 | // Create a view with depth / stencil aspect for image with different usage |
| 2260 | vkCreateImageView(m_device->device(), &dsvci, NULL, &dsv); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2261 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2262 | m_errorMonitor->VerifyFound(); |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2263 | |
| 2264 | // Initialize buffer with TRANSFER_DST usage |
| 2265 | vk_testing::Buffer buffer; |
| 2266 | VkMemoryPropertyFlags reqs = 0; |
| 2267 | buffer.init_as_dst(*m_device, 128 * 128, reqs); |
| 2268 | VkBufferImageCopy region = {}; |
| 2269 | region.bufferRowLength = 128; |
| 2270 | region.bufferImageHeight = 128; |
| 2271 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 2272 | region.imageSubresource.layerCount = 1; |
| 2273 | region.imageExtent.height = 16; |
| 2274 | region.imageExtent.width = 16; |
| 2275 | region.imageExtent.depth = 1; |
| 2276 | |
| 2277 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2278 | "Invalid usage flag for buffer "); |
| 2279 | // Buffer usage not set to TRANSFER_SRC and image usage not set to |
| 2280 | // TRANSFER_DST |
| 2281 | BeginCommandBuffer(); |
| 2282 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 2283 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 2284 | 1, ®ion); |
| 2285 | m_errorMonitor->VerifyFound(); |
| 2286 | |
| 2287 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2288 | "Invalid usage flag for image "); |
| 2289 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 2290 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 2291 | 1, ®ion); |
| 2292 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2293 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 2294 | #endif // MEM_TRACKER_TESTS |
| 2295 | |
Tobin Ehlis | 4bf96d1 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 2296 | #if OBJ_TRACKER_TESTS |
Mark Lobodzinski | fc5cc66 | 2016-05-02 17:17:41 -0600 | [diff] [blame] | 2297 | |
| 2298 | TEST_F(VkLayerTest, LeakAnObject) { |
| 2299 | VkResult err; |
| 2300 | |
| 2301 | TEST_DESCRIPTION( |
| 2302 | "Create a fence and destroy its device without first destroying the fence."); |
| 2303 | |
| 2304 | // Note that we have to create a new device since destroying the |
| 2305 | // framework's device causes Teardown() to fail and just calling Teardown |
| 2306 | // will destroy the errorMonitor. |
| 2307 | |
| 2308 | m_errorMonitor->SetDesiredFailureMsg( |
| 2309 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2310 | "OBJ ERROR : VK_DEBUG_REPORT_OBJECT_TYPE_FENCE_EXT object"); |
| 2311 | |
| 2312 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2313 | |
| 2314 | const std::vector<VkQueueFamilyProperties> queue_props = |
| 2315 | m_device->queue_props; |
| 2316 | std::vector<VkDeviceQueueCreateInfo> queue_info; |
| 2317 | queue_info.reserve(queue_props.size()); |
| 2318 | std::vector<std::vector<float>> queue_priorities; |
| 2319 | for (uint32_t i = 0; i < (uint32_t)queue_props.size(); i++) { |
| 2320 | VkDeviceQueueCreateInfo qi = {}; |
| 2321 | qi.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO; |
| 2322 | qi.pNext = NULL; |
| 2323 | qi.queueFamilyIndex = i; |
| 2324 | qi.queueCount = queue_props[i].queueCount; |
| 2325 | queue_priorities.emplace_back(qi.queueCount, 0.0f); |
| 2326 | qi.pQueuePriorities = queue_priorities[i].data(); |
| 2327 | queue_info.push_back(qi); |
| 2328 | } |
| 2329 | |
| 2330 | std::vector<const char *> device_layer_names; |
| 2331 | std::vector<const char *> device_extension_names; |
| 2332 | device_layer_names.push_back("VK_LAYER_GOOGLE_threading"); |
| 2333 | device_layer_names.push_back("VK_LAYER_LUNARG_parameter_validation"); |
| 2334 | device_layer_names.push_back("VK_LAYER_LUNARG_object_tracker"); |
| 2335 | device_layer_names.push_back("VK_LAYER_LUNARG_core_validation"); |
| 2336 | device_layer_names.push_back("VK_LAYER_LUNARG_device_limits"); |
| 2337 | device_layer_names.push_back("VK_LAYER_LUNARG_image"); |
| 2338 | device_layer_names.push_back("VK_LAYER_GOOGLE_unique_objects"); |
| 2339 | |
| 2340 | // The sacrificial device object |
| 2341 | VkDevice testDevice; |
| 2342 | VkDeviceCreateInfo device_create_info = {}; |
| 2343 | auto features = m_device->phy().features(); |
| 2344 | device_create_info.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO; |
| 2345 | device_create_info.pNext = NULL; |
| 2346 | device_create_info.queueCreateInfoCount = queue_info.size(); |
| 2347 | device_create_info.pQueueCreateInfos = queue_info.data(); |
| 2348 | device_create_info.enabledLayerCount = device_layer_names.size(); |
| 2349 | device_create_info.ppEnabledLayerNames = device_layer_names.data(); |
| 2350 | device_create_info.pEnabledFeatures = &features; |
| 2351 | err = vkCreateDevice(gpu(), &device_create_info, NULL, &testDevice); |
| 2352 | ASSERT_VK_SUCCESS(err); |
| 2353 | |
| 2354 | VkFence fence; |
| 2355 | VkFenceCreateInfo fence_create_info = {}; |
| 2356 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2357 | fence_create_info.pNext = NULL; |
| 2358 | fence_create_info.flags = 0; |
| 2359 | err = vkCreateFence(testDevice, &fence_create_info, NULL, &fence); |
| 2360 | ASSERT_VK_SUCCESS(err); |
| 2361 | |
| 2362 | // Induce failure by not calling vkDestroyFence |
| 2363 | vkDestroyDevice(testDevice, NULL); |
| 2364 | m_errorMonitor->VerifyFound(); |
| 2365 | } |
| 2366 | |
| 2367 | TEST_F(VkLayerTest, InvalidCommandPoolConsistency) { |
| 2368 | |
| 2369 | TEST_DESCRIPTION("Allocate command buffers from one command pool and " |
| 2370 | "attempt to delete them from another."); |
| 2371 | |
| 2372 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2373 | "FreeCommandBuffers is attempting to free Command Buffer"); |
| 2374 | |
| 2375 | VkCommandPool command_pool_one; |
| 2376 | VkCommandPool command_pool_two; |
| 2377 | |
| 2378 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2379 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2380 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2381 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2382 | |
| 2383 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2384 | &command_pool_one); |
| 2385 | |
| 2386 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2387 | &command_pool_two); |
| 2388 | |
| 2389 | VkCommandBuffer command_buffer[9]; |
| 2390 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2391 | command_buffer_allocate_info.sType = |
| 2392 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2393 | command_buffer_allocate_info.commandPool = command_pool_one; |
| 2394 | command_buffer_allocate_info.commandBufferCount = 9; |
| 2395 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2396 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2397 | command_buffer); |
| 2398 | |
| 2399 | vkFreeCommandBuffers(m_device->device(), command_pool_two, 4, |
| 2400 | &command_buffer[3]); |
| 2401 | |
| 2402 | m_errorMonitor->VerifyFound(); |
| 2403 | |
| 2404 | vkDestroyCommandPool(m_device->device(), command_pool_one, NULL); |
| 2405 | vkDestroyCommandPool(m_device->device(), command_pool_two, NULL); |
| 2406 | } |
| 2407 | |
| 2408 | TEST_F(VkLayerTest, InvalidDescriptorPoolConsistency) { |
| 2409 | VkResult err; |
| 2410 | |
| 2411 | TEST_DESCRIPTION("Allocate descriptor sets from one DS pool and " |
| 2412 | "attempt to delete them from another."); |
| 2413 | |
| 2414 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2415 | "FreeDescriptorSets is attempting to free descriptorSet"); |
| 2416 | |
| 2417 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2418 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2419 | |
| 2420 | VkDescriptorPoolSize ds_type_count = {}; |
| 2421 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 2422 | ds_type_count.descriptorCount = 1; |
| 2423 | |
| 2424 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2425 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2426 | ds_pool_ci.pNext = NULL; |
| 2427 | ds_pool_ci.flags = 0; |
| 2428 | ds_pool_ci.maxSets = 1; |
| 2429 | ds_pool_ci.poolSizeCount = 1; |
| 2430 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 2431 | |
| 2432 | VkDescriptorPool ds_pool_one; |
| 2433 | err = |
| 2434 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool_one); |
| 2435 | ASSERT_VK_SUCCESS(err); |
| 2436 | |
| 2437 | // Create a second descriptor pool |
| 2438 | VkDescriptorPool ds_pool_two; |
| 2439 | err = |
| 2440 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool_two); |
| 2441 | ASSERT_VK_SUCCESS(err); |
| 2442 | |
| 2443 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 2444 | dsl_binding.binding = 0; |
| 2445 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 2446 | dsl_binding.descriptorCount = 1; |
| 2447 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2448 | dsl_binding.pImmutableSamplers = NULL; |
| 2449 | |
| 2450 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2451 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2452 | ds_layout_ci.pNext = NULL; |
| 2453 | ds_layout_ci.bindingCount = 1; |
| 2454 | ds_layout_ci.pBindings = &dsl_binding; |
| 2455 | |
| 2456 | VkDescriptorSetLayout ds_layout; |
| 2457 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2458 | &ds_layout); |
| 2459 | ASSERT_VK_SUCCESS(err); |
| 2460 | |
| 2461 | VkDescriptorSet descriptorSet; |
| 2462 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 2463 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 2464 | alloc_info.descriptorSetCount = 1; |
| 2465 | alloc_info.descriptorPool = ds_pool_one; |
| 2466 | alloc_info.pSetLayouts = &ds_layout; |
| 2467 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 2468 | &descriptorSet); |
| 2469 | ASSERT_VK_SUCCESS(err); |
| 2470 | |
| 2471 | err = vkFreeDescriptorSets(m_device->device(), ds_pool_two, 1, &descriptorSet); |
| 2472 | |
| 2473 | m_errorMonitor->VerifyFound(); |
| 2474 | |
| 2475 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2476 | vkDestroyDescriptorPool(m_device->device(), ds_pool_one, NULL); |
| 2477 | vkDestroyDescriptorPool(m_device->device(), ds_pool_two, NULL); |
| 2478 | } |
| 2479 | |
| 2480 | TEST_F(VkLayerTest, CreateUnknownObject) { |
| 2481 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2482 | "Invalid VkImage Object "); |
| 2483 | |
| 2484 | TEST_DESCRIPTION( |
| 2485 | "Pass an invalid image object handle into a Vulkan API call."); |
| 2486 | |
| 2487 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2488 | |
| 2489 | // Pass bogus handle into GetImageMemoryRequirements |
| 2490 | VkMemoryRequirements mem_reqs; |
| 2491 | uint64_t fakeImageHandle = 0xCADECADE; |
| 2492 | VkImage fauxImage = reinterpret_cast<VkImage &>(fakeImageHandle); |
| 2493 | |
| 2494 | vkGetImageMemoryRequirements(m_device->device(), fauxImage, &mem_reqs); |
| 2495 | |
| 2496 | m_errorMonitor->VerifyFound(); |
| 2497 | } |
| 2498 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2499 | TEST_F(VkLayerTest, PipelineNotBound) { |
| 2500 | VkResult err; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2501 | |
Mark Lobodzinski | fc5cc66 | 2016-05-02 17:17:41 -0600 | [diff] [blame] | 2502 | TEST_DESCRIPTION( |
| 2503 | "Pass in an invalid pipeline object handle into a Vulkan API call."); |
| 2504 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2505 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2506 | "Invalid VkPipeline Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2507 | |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2508 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2509 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2510 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2511 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2512 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2513 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2514 | |
| 2515 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2516 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2517 | ds_pool_ci.pNext = NULL; |
| 2518 | ds_pool_ci.maxSets = 1; |
| 2519 | ds_pool_ci.poolSizeCount = 1; |
| 2520 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2521 | |
| 2522 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2523 | err = |
| 2524 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2525 | ASSERT_VK_SUCCESS(err); |
| 2526 | |
| 2527 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2528 | dsl_binding.binding = 0; |
| 2529 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2530 | dsl_binding.descriptorCount = 1; |
| 2531 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2532 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2533 | |
| 2534 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2535 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2536 | ds_layout_ci.pNext = NULL; |
| 2537 | ds_layout_ci.bindingCount = 1; |
| 2538 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2539 | |
| 2540 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2541 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2542 | &ds_layout); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2543 | ASSERT_VK_SUCCESS(err); |
| 2544 | |
| 2545 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2546 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2547 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2548 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2549 | alloc_info.descriptorPool = ds_pool; |
| 2550 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2551 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 2552 | &descriptorSet); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2553 | ASSERT_VK_SUCCESS(err); |
| 2554 | |
| 2555 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2556 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 2557 | pipeline_layout_ci.pNext = NULL; |
| 2558 | pipeline_layout_ci.setLayoutCount = 1; |
| 2559 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2560 | |
| 2561 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2562 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2563 | &pipeline_layout); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2564 | ASSERT_VK_SUCCESS(err); |
| 2565 | |
Mark Young | ad77905 | 2016-01-06 14:26:04 -0700 | [diff] [blame] | 2566 | VkPipeline badPipeline = (VkPipeline)((size_t)0xbaadb1be); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2567 | |
| 2568 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2569 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 2570 | VK_PIPELINE_BIND_POINT_GRAPHICS, badPipeline); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2571 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2572 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2573 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2574 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2575 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2576 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2577 | } |
| 2578 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2579 | TEST_F(VkLayerTest, BindInvalidMemory) { |
| 2580 | VkResult err; |
| 2581 | bool pass; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2582 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2583 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2584 | "Invalid VkDeviceMemory Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2585 | |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2586 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2587 | |
| 2588 | // 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] | 2589 | VkImage image; |
| 2590 | VkDeviceMemory mem; |
| 2591 | VkMemoryRequirements mem_reqs; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2592 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2593 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2594 | const int32_t tex_width = 32; |
| 2595 | const int32_t tex_height = 32; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2596 | |
| 2597 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2598 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 2599 | image_create_info.pNext = NULL; |
| 2600 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2601 | image_create_info.format = tex_format; |
| 2602 | image_create_info.extent.width = tex_width; |
| 2603 | image_create_info.extent.height = tex_height; |
| 2604 | image_create_info.extent.depth = 1; |
| 2605 | image_create_info.mipLevels = 1; |
| 2606 | image_create_info.arrayLayers = 1; |
| 2607 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 2608 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 2609 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 2610 | image_create_info.flags = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2611 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2612 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2613 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 2614 | mem_alloc.pNext = NULL; |
| 2615 | mem_alloc.allocationSize = 0; |
| 2616 | mem_alloc.memoryTypeIndex = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2617 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2618 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2619 | ASSERT_VK_SUCCESS(err); |
| 2620 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2621 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2622 | |
| 2623 | mem_alloc.allocationSize = mem_reqs.size; |
| 2624 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2625 | pass = |
| 2626 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 2627 | ASSERT_TRUE(pass); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2628 | |
| 2629 | // allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2630 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2631 | ASSERT_VK_SUCCESS(err); |
| 2632 | |
| 2633 | // Introduce validation failure, free memory before binding |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2634 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2635 | |
| 2636 | // Try to bind free memory that has been freed |
| 2637 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 2638 | // This may very well return an error. |
| 2639 | (void)err; |
| 2640 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2641 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2642 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2643 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2644 | } |
| 2645 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2646 | TEST_F(VkLayerTest, BindMemoryToDestroyedObject) { |
| 2647 | VkResult err; |
| 2648 | bool pass; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2649 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2650 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2651 | "Invalid VkImage Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2652 | |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2653 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2654 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2655 | // Create an image object, allocate memory, destroy the object and then try |
| 2656 | // to bind it |
| 2657 | VkImage image; |
| 2658 | VkDeviceMemory mem; |
| 2659 | VkMemoryRequirements mem_reqs; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2660 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2661 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2662 | const int32_t tex_width = 32; |
| 2663 | const int32_t tex_height = 32; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2664 | |
| 2665 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2666 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 2667 | image_create_info.pNext = NULL; |
| 2668 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2669 | image_create_info.format = tex_format; |
| 2670 | image_create_info.extent.width = tex_width; |
| 2671 | image_create_info.extent.height = tex_height; |
| 2672 | image_create_info.extent.depth = 1; |
| 2673 | image_create_info.mipLevels = 1; |
| 2674 | image_create_info.arrayLayers = 1; |
| 2675 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 2676 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 2677 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 2678 | image_create_info.flags = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2679 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2680 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2681 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 2682 | mem_alloc.pNext = NULL; |
| 2683 | mem_alloc.allocationSize = 0; |
| 2684 | mem_alloc.memoryTypeIndex = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2685 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2686 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2687 | ASSERT_VK_SUCCESS(err); |
| 2688 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2689 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2690 | |
| 2691 | mem_alloc.allocationSize = mem_reqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2692 | pass = |
| 2693 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 2694 | ASSERT_TRUE(pass); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2695 | |
| 2696 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2697 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2698 | ASSERT_VK_SUCCESS(err); |
| 2699 | |
| 2700 | // Introduce validation failure, destroy Image object before binding |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2701 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2702 | ASSERT_VK_SUCCESS(err); |
| 2703 | |
| 2704 | // Now Try to bind memory to this destroyed object |
| 2705 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 2706 | // This may very well return an error. |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2707 | (void)err; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2708 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2709 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2710 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2711 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2712 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 2713 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 2714 | #endif // OBJ_TRACKER_TESTS |
| 2715 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 2716 | #if DRAW_STATE_TESTS |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 2717 | |
| 2718 | // This is a positive test. No errors should be generated. |
| 2719 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceQWI) { |
| 2720 | |
| 2721 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 2722 | "submitted on separate queues followed by a QueueWaitIdle."); |
| 2723 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 2724 | if ((m_device->queue_props.empty()) || |
| 2725 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 2726 | return; |
| 2727 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 2728 | m_errorMonitor->ExpectSuccess(); |
| 2729 | |
| 2730 | VkSemaphore semaphore; |
| 2731 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 2732 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 2733 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 2734 | &semaphore); |
| 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[2]; |
| 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 = 2; |
| 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[0], &begin_info); |
| 2762 | |
| 2763 | vkCmdPipelineBarrier(command_buffer[0], |
| 2764 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2765 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 2766 | 0, nullptr, 0, nullptr); |
| 2767 | |
| 2768 | VkViewport viewport{}; |
| 2769 | viewport.maxDepth = 1.0f; |
| 2770 | viewport.minDepth = 0.0f; |
| 2771 | viewport.width = 512; |
| 2772 | viewport.height = 512; |
| 2773 | viewport.x = 0; |
| 2774 | viewport.y = 0; |
| 2775 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 2776 | vkEndCommandBuffer(command_buffer[0]); |
| 2777 | } |
| 2778 | { |
| 2779 | VkCommandBufferBeginInfo begin_info{}; |
| 2780 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2781 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 2782 | |
| 2783 | VkViewport viewport{}; |
| 2784 | viewport.maxDepth = 1.0f; |
| 2785 | viewport.minDepth = 0.0f; |
| 2786 | viewport.width = 512; |
| 2787 | viewport.height = 512; |
| 2788 | viewport.x = 0; |
| 2789 | viewport.y = 0; |
| 2790 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 2791 | vkEndCommandBuffer(command_buffer[1]); |
| 2792 | } |
| 2793 | { |
| 2794 | VkSubmitInfo submit_info{}; |
| 2795 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2796 | submit_info.commandBufferCount = 1; |
| 2797 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 2798 | submit_info.signalSemaphoreCount = 1; |
| 2799 | submit_info.pSignalSemaphores = &semaphore; |
| 2800 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2801 | } |
| 2802 | { |
| 2803 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 2804 | VkSubmitInfo submit_info{}; |
| 2805 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2806 | submit_info.commandBufferCount = 1; |
| 2807 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 2808 | submit_info.waitSemaphoreCount = 1; |
| 2809 | submit_info.pWaitSemaphores = &semaphore; |
| 2810 | submit_info.pWaitDstStageMask = flags; |
| 2811 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2812 | } |
| 2813 | |
| 2814 | vkQueueWaitIdle(m_device->m_queue); |
| 2815 | |
| 2816 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 2817 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 2818 | &command_buffer[0]); |
| 2819 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2820 | |
| 2821 | m_errorMonitor->VerifyNotFound(); |
| 2822 | } |
| 2823 | |
| 2824 | // This is a positive test. No errors should be generated. |
| 2825 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceQWIFence) { |
| 2826 | |
| 2827 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 2828 | "submitted on separate queues, the second having a fence" |
| 2829 | "followed by a QueueWaitIdle."); |
| 2830 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 2831 | if ((m_device->queue_props.empty()) || |
| 2832 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 2833 | return; |
| 2834 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 2835 | m_errorMonitor->ExpectSuccess(); |
| 2836 | |
| 2837 | VkFence fence; |
| 2838 | VkFenceCreateInfo fence_create_info{}; |
| 2839 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2840 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 2841 | |
| 2842 | VkSemaphore semaphore; |
| 2843 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 2844 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 2845 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 2846 | &semaphore); |
| 2847 | |
| 2848 | VkCommandPool command_pool; |
| 2849 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2850 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2851 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2852 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2853 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2854 | &command_pool); |
| 2855 | |
| 2856 | VkCommandBuffer command_buffer[2]; |
| 2857 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2858 | command_buffer_allocate_info.sType = |
| 2859 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2860 | command_buffer_allocate_info.commandPool = command_pool; |
| 2861 | command_buffer_allocate_info.commandBufferCount = 2; |
| 2862 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2863 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2864 | command_buffer); |
| 2865 | |
| 2866 | VkQueue queue = VK_NULL_HANDLE; |
| 2867 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 2868 | 1, &queue); |
| 2869 | |
| 2870 | { |
| 2871 | VkCommandBufferBeginInfo begin_info{}; |
| 2872 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2873 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2874 | |
| 2875 | vkCmdPipelineBarrier(command_buffer[0], |
| 2876 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2877 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 2878 | 0, nullptr, 0, nullptr); |
| 2879 | |
| 2880 | VkViewport viewport{}; |
| 2881 | viewport.maxDepth = 1.0f; |
| 2882 | viewport.minDepth = 0.0f; |
| 2883 | viewport.width = 512; |
| 2884 | viewport.height = 512; |
| 2885 | viewport.x = 0; |
| 2886 | viewport.y = 0; |
| 2887 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 2888 | vkEndCommandBuffer(command_buffer[0]); |
| 2889 | } |
| 2890 | { |
| 2891 | VkCommandBufferBeginInfo begin_info{}; |
| 2892 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2893 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 2894 | |
| 2895 | VkViewport viewport{}; |
| 2896 | viewport.maxDepth = 1.0f; |
| 2897 | viewport.minDepth = 0.0f; |
| 2898 | viewport.width = 512; |
| 2899 | viewport.height = 512; |
| 2900 | viewport.x = 0; |
| 2901 | viewport.y = 0; |
| 2902 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 2903 | vkEndCommandBuffer(command_buffer[1]); |
| 2904 | } |
| 2905 | { |
| 2906 | VkSubmitInfo submit_info{}; |
| 2907 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2908 | submit_info.commandBufferCount = 1; |
| 2909 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 2910 | submit_info.signalSemaphoreCount = 1; |
| 2911 | submit_info.pSignalSemaphores = &semaphore; |
| 2912 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2913 | } |
| 2914 | { |
| 2915 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 2916 | VkSubmitInfo submit_info{}; |
| 2917 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2918 | submit_info.commandBufferCount = 1; |
| 2919 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 2920 | submit_info.waitSemaphoreCount = 1; |
| 2921 | submit_info.pWaitSemaphores = &semaphore; |
| 2922 | submit_info.pWaitDstStageMask = flags; |
| 2923 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 2924 | } |
| 2925 | |
| 2926 | vkQueueWaitIdle(m_device->m_queue); |
| 2927 | |
| 2928 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 2929 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 2930 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 2931 | &command_buffer[0]); |
| 2932 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2933 | |
| 2934 | m_errorMonitor->VerifyNotFound(); |
| 2935 | } |
| 2936 | |
| 2937 | // This is a positive test. No errors should be generated. |
| 2938 | TEST_F(VkLayerTest, |
| 2939 | TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceTwoWFF) { |
| 2940 | |
| 2941 | TEST_DESCRIPTION( |
| 2942 | "Two command buffers, each in a separate QueueSubmit call " |
| 2943 | "submitted on separate queues, the second having a fence" |
| 2944 | "followed by two consecutive WaitForFences calls on the same fence."); |
| 2945 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 2946 | if ((m_device->queue_props.empty()) || |
| 2947 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 2948 | return; |
| 2949 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 2950 | m_errorMonitor->ExpectSuccess(); |
| 2951 | |
| 2952 | VkFence fence; |
| 2953 | VkFenceCreateInfo fence_create_info{}; |
| 2954 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2955 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 2956 | |
| 2957 | VkSemaphore semaphore; |
| 2958 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 2959 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 2960 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 2961 | &semaphore); |
| 2962 | |
| 2963 | VkCommandPool command_pool; |
| 2964 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2965 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2966 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2967 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2968 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2969 | &command_pool); |
| 2970 | |
| 2971 | VkCommandBuffer command_buffer[2]; |
| 2972 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2973 | command_buffer_allocate_info.sType = |
| 2974 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2975 | command_buffer_allocate_info.commandPool = command_pool; |
| 2976 | command_buffer_allocate_info.commandBufferCount = 2; |
| 2977 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2978 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2979 | command_buffer); |
| 2980 | |
| 2981 | VkQueue queue = VK_NULL_HANDLE; |
| 2982 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 2983 | 1, &queue); |
| 2984 | |
| 2985 | { |
| 2986 | VkCommandBufferBeginInfo begin_info{}; |
| 2987 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2988 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2989 | |
| 2990 | vkCmdPipelineBarrier(command_buffer[0], |
| 2991 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2992 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 2993 | 0, nullptr, 0, nullptr); |
| 2994 | |
| 2995 | VkViewport viewport{}; |
| 2996 | viewport.maxDepth = 1.0f; |
| 2997 | viewport.minDepth = 0.0f; |
| 2998 | viewport.width = 512; |
| 2999 | viewport.height = 512; |
| 3000 | viewport.x = 0; |
| 3001 | viewport.y = 0; |
| 3002 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3003 | vkEndCommandBuffer(command_buffer[0]); |
| 3004 | } |
| 3005 | { |
| 3006 | VkCommandBufferBeginInfo begin_info{}; |
| 3007 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3008 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3009 | |
| 3010 | VkViewport viewport{}; |
| 3011 | viewport.maxDepth = 1.0f; |
| 3012 | viewport.minDepth = 0.0f; |
| 3013 | viewport.width = 512; |
| 3014 | viewport.height = 512; |
| 3015 | viewport.x = 0; |
| 3016 | viewport.y = 0; |
| 3017 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3018 | vkEndCommandBuffer(command_buffer[1]); |
| 3019 | } |
| 3020 | { |
| 3021 | VkSubmitInfo submit_info{}; |
| 3022 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3023 | submit_info.commandBufferCount = 1; |
| 3024 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3025 | submit_info.signalSemaphoreCount = 1; |
| 3026 | submit_info.pSignalSemaphores = &semaphore; |
| 3027 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3028 | } |
| 3029 | { |
| 3030 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3031 | VkSubmitInfo submit_info{}; |
| 3032 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3033 | submit_info.commandBufferCount = 1; |
| 3034 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3035 | submit_info.waitSemaphoreCount = 1; |
| 3036 | submit_info.pWaitSemaphores = &semaphore; |
| 3037 | submit_info.pWaitDstStageMask = flags; |
| 3038 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 3039 | } |
| 3040 | |
| 3041 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3042 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3043 | |
| 3044 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3045 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 3046 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3047 | &command_buffer[0]); |
| 3048 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3049 | |
| 3050 | m_errorMonitor->VerifyNotFound(); |
| 3051 | } |
| 3052 | |
| 3053 | // This is a positive test. No errors should be generated. |
| 3054 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFence) { |
| 3055 | |
| 3056 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 3057 | "submitted on separate queues, the second having a fence, " |
| 3058 | "followed by a WaitForFences call."); |
| 3059 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 3060 | if ((m_device->queue_props.empty()) || |
| 3061 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 3062 | return; |
| 3063 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3064 | m_errorMonitor->ExpectSuccess(); |
| 3065 | |
| 3066 | VkFence fence; |
| 3067 | VkFenceCreateInfo fence_create_info{}; |
| 3068 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3069 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3070 | |
| 3071 | VkSemaphore semaphore; |
| 3072 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 3073 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 3074 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 3075 | &semaphore); |
| 3076 | |
| 3077 | VkCommandPool command_pool; |
| 3078 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3079 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3080 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3081 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3082 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3083 | &command_pool); |
| 3084 | |
| 3085 | VkCommandBuffer command_buffer[2]; |
| 3086 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3087 | command_buffer_allocate_info.sType = |
| 3088 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3089 | command_buffer_allocate_info.commandPool = command_pool; |
| 3090 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3091 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3092 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3093 | command_buffer); |
| 3094 | |
| 3095 | VkQueue queue = VK_NULL_HANDLE; |
| 3096 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 3097 | 1, &queue); |
| 3098 | |
| 3099 | |
| 3100 | { |
| 3101 | VkCommandBufferBeginInfo begin_info{}; |
| 3102 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3103 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3104 | |
| 3105 | vkCmdPipelineBarrier(command_buffer[0], |
| 3106 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3107 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3108 | 0, nullptr, 0, nullptr); |
| 3109 | |
| 3110 | VkViewport viewport{}; |
| 3111 | viewport.maxDepth = 1.0f; |
| 3112 | viewport.minDepth = 0.0f; |
| 3113 | viewport.width = 512; |
| 3114 | viewport.height = 512; |
| 3115 | viewport.x = 0; |
| 3116 | viewport.y = 0; |
| 3117 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3118 | vkEndCommandBuffer(command_buffer[0]); |
| 3119 | } |
| 3120 | { |
| 3121 | VkCommandBufferBeginInfo begin_info{}; |
| 3122 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3123 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3124 | |
| 3125 | VkViewport viewport{}; |
| 3126 | viewport.maxDepth = 1.0f; |
| 3127 | viewport.minDepth = 0.0f; |
| 3128 | viewport.width = 512; |
| 3129 | viewport.height = 512; |
| 3130 | viewport.x = 0; |
| 3131 | viewport.y = 0; |
| 3132 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3133 | vkEndCommandBuffer(command_buffer[1]); |
| 3134 | } |
| 3135 | { |
| 3136 | VkSubmitInfo submit_info{}; |
| 3137 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3138 | submit_info.commandBufferCount = 1; |
| 3139 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3140 | submit_info.signalSemaphoreCount = 1; |
| 3141 | submit_info.pSignalSemaphores = &semaphore; |
| 3142 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3143 | } |
| 3144 | { |
| 3145 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3146 | VkSubmitInfo submit_info{}; |
| 3147 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3148 | submit_info.commandBufferCount = 1; |
| 3149 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3150 | submit_info.waitSemaphoreCount = 1; |
| 3151 | submit_info.pWaitSemaphores = &semaphore; |
| 3152 | submit_info.pWaitDstStageMask = flags; |
| 3153 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 3154 | } |
| 3155 | |
| 3156 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3157 | |
| 3158 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3159 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 3160 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3161 | &command_buffer[0]); |
| 3162 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3163 | |
| 3164 | m_errorMonitor->VerifyNotFound(); |
| 3165 | } |
| 3166 | |
| 3167 | // This is a positive test. No errors should be generated. |
| 3168 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueWithSemaphoreAndOneFence) { |
| 3169 | |
| 3170 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 3171 | "on the same queue, sharing a signal/wait semaphore, the " |
| 3172 | "second having a fence, " |
| 3173 | "followed by a WaitForFences call."); |
| 3174 | |
| 3175 | m_errorMonitor->ExpectSuccess(); |
| 3176 | |
| 3177 | VkFence fence; |
| 3178 | VkFenceCreateInfo fence_create_info{}; |
| 3179 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3180 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3181 | |
| 3182 | VkSemaphore semaphore; |
| 3183 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 3184 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 3185 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 3186 | &semaphore); |
| 3187 | |
| 3188 | VkCommandPool command_pool; |
| 3189 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3190 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3191 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3192 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3193 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3194 | &command_pool); |
| 3195 | |
| 3196 | VkCommandBuffer command_buffer[2]; |
| 3197 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3198 | command_buffer_allocate_info.sType = |
| 3199 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3200 | command_buffer_allocate_info.commandPool = command_pool; |
| 3201 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3202 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3203 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3204 | command_buffer); |
| 3205 | |
| 3206 | { |
| 3207 | VkCommandBufferBeginInfo begin_info{}; |
| 3208 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3209 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3210 | |
| 3211 | vkCmdPipelineBarrier(command_buffer[0], |
| 3212 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3213 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3214 | 0, nullptr, 0, nullptr); |
| 3215 | |
| 3216 | VkViewport viewport{}; |
| 3217 | viewport.maxDepth = 1.0f; |
| 3218 | viewport.minDepth = 0.0f; |
| 3219 | viewport.width = 512; |
| 3220 | viewport.height = 512; |
| 3221 | viewport.x = 0; |
| 3222 | viewport.y = 0; |
| 3223 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3224 | vkEndCommandBuffer(command_buffer[0]); |
| 3225 | } |
| 3226 | { |
| 3227 | VkCommandBufferBeginInfo begin_info{}; |
| 3228 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3229 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3230 | |
| 3231 | VkViewport viewport{}; |
| 3232 | viewport.maxDepth = 1.0f; |
| 3233 | viewport.minDepth = 0.0f; |
| 3234 | viewport.width = 512; |
| 3235 | viewport.height = 512; |
| 3236 | viewport.x = 0; |
| 3237 | viewport.y = 0; |
| 3238 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3239 | vkEndCommandBuffer(command_buffer[1]); |
| 3240 | } |
| 3241 | { |
| 3242 | VkSubmitInfo submit_info{}; |
| 3243 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3244 | submit_info.commandBufferCount = 1; |
| 3245 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3246 | submit_info.signalSemaphoreCount = 1; |
| 3247 | submit_info.pSignalSemaphores = &semaphore; |
| 3248 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3249 | } |
| 3250 | { |
| 3251 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3252 | VkSubmitInfo submit_info{}; |
| 3253 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3254 | submit_info.commandBufferCount = 1; |
| 3255 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3256 | submit_info.waitSemaphoreCount = 1; |
| 3257 | submit_info.pWaitSemaphores = &semaphore; |
| 3258 | submit_info.pWaitDstStageMask = flags; |
| 3259 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 3260 | } |
| 3261 | |
| 3262 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3263 | |
| 3264 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3265 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 3266 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3267 | &command_buffer[0]); |
| 3268 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3269 | |
| 3270 | m_errorMonitor->VerifyNotFound(); |
| 3271 | } |
| 3272 | |
| 3273 | // This is a positive test. No errors should be generated. |
| 3274 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueNullQueueSubmitWithFence) { |
| 3275 | |
| 3276 | TEST_DESCRIPTION( |
| 3277 | "Two command buffers, each in a separate QueueSubmit call " |
| 3278 | "on the same queue, no fences, followed by a third QueueSubmit with NO " |
| 3279 | "SubmitInfos but with a fence, followed by a WaitForFences call."); |
| 3280 | |
| 3281 | m_errorMonitor->ExpectSuccess(); |
| 3282 | |
| 3283 | VkFence fence; |
| 3284 | VkFenceCreateInfo fence_create_info{}; |
| 3285 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3286 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3287 | |
| 3288 | VkCommandPool command_pool; |
| 3289 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3290 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3291 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3292 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3293 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3294 | &command_pool); |
| 3295 | |
| 3296 | VkCommandBuffer command_buffer[2]; |
| 3297 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3298 | command_buffer_allocate_info.sType = |
| 3299 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3300 | command_buffer_allocate_info.commandPool = command_pool; |
| 3301 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3302 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3303 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3304 | command_buffer); |
| 3305 | |
| 3306 | { |
| 3307 | VkCommandBufferBeginInfo begin_info{}; |
| 3308 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3309 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3310 | |
| 3311 | vkCmdPipelineBarrier(command_buffer[0], |
| 3312 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3313 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3314 | 0, nullptr, 0, nullptr); |
| 3315 | |
| 3316 | VkViewport viewport{}; |
| 3317 | viewport.maxDepth = 1.0f; |
| 3318 | viewport.minDepth = 0.0f; |
| 3319 | viewport.width = 512; |
| 3320 | viewport.height = 512; |
| 3321 | viewport.x = 0; |
| 3322 | viewport.y = 0; |
| 3323 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3324 | vkEndCommandBuffer(command_buffer[0]); |
| 3325 | } |
| 3326 | { |
| 3327 | VkCommandBufferBeginInfo begin_info{}; |
| 3328 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3329 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3330 | |
| 3331 | VkViewport viewport{}; |
| 3332 | viewport.maxDepth = 1.0f; |
| 3333 | viewport.minDepth = 0.0f; |
| 3334 | viewport.width = 512; |
| 3335 | viewport.height = 512; |
| 3336 | viewport.x = 0; |
| 3337 | viewport.y = 0; |
| 3338 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3339 | vkEndCommandBuffer(command_buffer[1]); |
| 3340 | } |
| 3341 | { |
| 3342 | VkSubmitInfo submit_info{}; |
| 3343 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3344 | submit_info.commandBufferCount = 1; |
| 3345 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3346 | submit_info.signalSemaphoreCount = 0; |
| 3347 | submit_info.pSignalSemaphores = VK_NULL_HANDLE; |
| 3348 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3349 | } |
| 3350 | { |
| 3351 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3352 | VkSubmitInfo submit_info{}; |
| 3353 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3354 | submit_info.commandBufferCount = 1; |
| 3355 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3356 | submit_info.waitSemaphoreCount = 0; |
| 3357 | submit_info.pWaitSemaphores = VK_NULL_HANDLE; |
| 3358 | submit_info.pWaitDstStageMask = flags; |
| 3359 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3360 | } |
| 3361 | |
| 3362 | vkQueueSubmit(m_device->m_queue, 0, NULL, fence); |
| 3363 | |
| 3364 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3365 | |
| 3366 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3367 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3368 | &command_buffer[0]); |
| 3369 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3370 | |
| 3371 | m_errorMonitor->VerifyNotFound(); |
| 3372 | } |
| 3373 | |
| 3374 | // This is a positive test. No errors should be generated. |
| 3375 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueOneFence) { |
| 3376 | |
| 3377 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 3378 | "on the same queue, the second having a fence, followed " |
| 3379 | "by a WaitForFences call."); |
| 3380 | |
| 3381 | m_errorMonitor->ExpectSuccess(); |
| 3382 | |
| 3383 | VkFence fence; |
| 3384 | VkFenceCreateInfo fence_create_info{}; |
| 3385 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3386 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3387 | |
| 3388 | VkCommandPool command_pool; |
| 3389 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3390 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3391 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3392 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3393 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3394 | &command_pool); |
| 3395 | |
| 3396 | VkCommandBuffer command_buffer[2]; |
| 3397 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3398 | command_buffer_allocate_info.sType = |
| 3399 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3400 | command_buffer_allocate_info.commandPool = command_pool; |
| 3401 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3402 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3403 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3404 | command_buffer); |
| 3405 | |
| 3406 | { |
| 3407 | VkCommandBufferBeginInfo begin_info{}; |
| 3408 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3409 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3410 | |
| 3411 | vkCmdPipelineBarrier(command_buffer[0], |
| 3412 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3413 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3414 | 0, nullptr, 0, nullptr); |
| 3415 | |
| 3416 | VkViewport viewport{}; |
| 3417 | viewport.maxDepth = 1.0f; |
| 3418 | viewport.minDepth = 0.0f; |
| 3419 | viewport.width = 512; |
| 3420 | viewport.height = 512; |
| 3421 | viewport.x = 0; |
| 3422 | viewport.y = 0; |
| 3423 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3424 | vkEndCommandBuffer(command_buffer[0]); |
| 3425 | } |
| 3426 | { |
| 3427 | VkCommandBufferBeginInfo begin_info{}; |
| 3428 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3429 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3430 | |
| 3431 | VkViewport viewport{}; |
| 3432 | viewport.maxDepth = 1.0f; |
| 3433 | viewport.minDepth = 0.0f; |
| 3434 | viewport.width = 512; |
| 3435 | viewport.height = 512; |
| 3436 | viewport.x = 0; |
| 3437 | viewport.y = 0; |
| 3438 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3439 | vkEndCommandBuffer(command_buffer[1]); |
| 3440 | } |
| 3441 | { |
| 3442 | VkSubmitInfo submit_info{}; |
| 3443 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3444 | submit_info.commandBufferCount = 1; |
| 3445 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3446 | submit_info.signalSemaphoreCount = 0; |
| 3447 | submit_info.pSignalSemaphores = VK_NULL_HANDLE; |
| 3448 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3449 | } |
| 3450 | { |
| 3451 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3452 | VkSubmitInfo submit_info{}; |
| 3453 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3454 | submit_info.commandBufferCount = 1; |
| 3455 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3456 | submit_info.waitSemaphoreCount = 0; |
| 3457 | submit_info.pWaitSemaphores = VK_NULL_HANDLE; |
| 3458 | submit_info.pWaitDstStageMask = flags; |
| 3459 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 3460 | } |
| 3461 | |
| 3462 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3463 | |
| 3464 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3465 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3466 | &command_buffer[0]); |
| 3467 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3468 | |
| 3469 | m_errorMonitor->VerifyNotFound(); |
| 3470 | } |
| 3471 | |
| 3472 | // This is a positive test. No errors should be generated. |
| 3473 | TEST_F(VkLayerTest, TwoSubmitInfosWithSemaphoreOneQueueSubmitsOneFence) { |
| 3474 | |
| 3475 | TEST_DESCRIPTION( |
| 3476 | "Two command buffers each in a separate SubmitInfo sent in a single " |
| 3477 | "QueueSubmit call followed by a WaitForFences call."); |
| 3478 | |
| 3479 | m_errorMonitor->ExpectSuccess(); |
| 3480 | |
| 3481 | VkFence fence; |
| 3482 | VkFenceCreateInfo fence_create_info{}; |
| 3483 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3484 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3485 | |
| 3486 | VkSemaphore semaphore; |
| 3487 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 3488 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 3489 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 3490 | &semaphore); |
| 3491 | |
| 3492 | VkCommandPool command_pool; |
| 3493 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3494 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3495 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3496 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3497 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3498 | &command_pool); |
| 3499 | |
| 3500 | VkCommandBuffer command_buffer[2]; |
| 3501 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3502 | command_buffer_allocate_info.sType = |
| 3503 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3504 | command_buffer_allocate_info.commandPool = command_pool; |
| 3505 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3506 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3507 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3508 | command_buffer); |
| 3509 | |
| 3510 | { |
| 3511 | VkCommandBufferBeginInfo begin_info{}; |
| 3512 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3513 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3514 | |
| 3515 | vkCmdPipelineBarrier(command_buffer[0], |
| 3516 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3517 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3518 | 0, nullptr, 0, nullptr); |
| 3519 | |
| 3520 | VkViewport viewport{}; |
| 3521 | viewport.maxDepth = 1.0f; |
| 3522 | viewport.minDepth = 0.0f; |
| 3523 | viewport.width = 512; |
| 3524 | viewport.height = 512; |
| 3525 | viewport.x = 0; |
| 3526 | viewport.y = 0; |
| 3527 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3528 | vkEndCommandBuffer(command_buffer[0]); |
| 3529 | } |
| 3530 | { |
| 3531 | VkCommandBufferBeginInfo begin_info{}; |
| 3532 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3533 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3534 | |
| 3535 | VkViewport viewport{}; |
| 3536 | viewport.maxDepth = 1.0f; |
| 3537 | viewport.minDepth = 0.0f; |
| 3538 | viewport.width = 512; |
| 3539 | viewport.height = 512; |
| 3540 | viewport.x = 0; |
| 3541 | viewport.y = 0; |
| 3542 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3543 | vkEndCommandBuffer(command_buffer[1]); |
| 3544 | } |
| 3545 | { |
| 3546 | VkSubmitInfo submit_info[2]; |
| 3547 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3548 | |
| 3549 | submit_info[0].sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3550 | submit_info[0].pNext = NULL; |
| 3551 | submit_info[0].commandBufferCount = 1; |
| 3552 | submit_info[0].pCommandBuffers = &command_buffer[0]; |
| 3553 | submit_info[0].signalSemaphoreCount = 1; |
| 3554 | submit_info[0].pSignalSemaphores = &semaphore; |
| 3555 | submit_info[0].waitSemaphoreCount = 0; |
| 3556 | submit_info[0].pWaitSemaphores = NULL; |
| 3557 | submit_info[0].pWaitDstStageMask = 0; |
| 3558 | |
| 3559 | submit_info[1].sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3560 | submit_info[1].pNext = NULL; |
| 3561 | submit_info[1].commandBufferCount = 1; |
| 3562 | submit_info[1].pCommandBuffers = &command_buffer[1]; |
| 3563 | submit_info[1].waitSemaphoreCount = 1; |
| 3564 | submit_info[1].pWaitSemaphores = &semaphore; |
| 3565 | submit_info[1].pWaitDstStageMask = flags; |
| 3566 | submit_info[1].signalSemaphoreCount = 0; |
| 3567 | submit_info[1].pSignalSemaphores = NULL; |
| 3568 | vkQueueSubmit(m_device->m_queue, 2, &submit_info[0], fence); |
| 3569 | } |
| 3570 | |
| 3571 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3572 | |
| 3573 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3574 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3575 | &command_buffer[0]); |
| 3576 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3577 | |
| 3578 | m_errorMonitor->VerifyNotFound(); |
| 3579 | } |
| 3580 | |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 3581 | TEST_F(VkLayerTest, DynamicStatesNotBound) { |
| 3582 | TEST_DESCRIPTION( |
| 3583 | "Run a series of simple draw calls to validate all the different " |
| 3584 | "failure cases that can occur when dynamic state is required but not " |
| 3585 | "correctly bound." |
| 3586 | "Here are the different dynamic state cases verified by this test:\n" |
| 3587 | "-Line Width\n-Depth Bias\n-Viewport State\n-Scissor State\n-Blend " |
| 3588 | "State\n-Depth Bounds\n-Stencil Read Mask\n-Stencil Write " |
| 3589 | "Mask\n-Stencil Reference"); |
| 3590 | |
| 3591 | // Dynamic line width |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3592 | m_errorMonitor->SetDesiredFailureMsg( |
| 3593 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3594 | "Dynamic line width state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3595 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 3596 | BsoFailLineWidth); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3597 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 3598 | // Dynamic depth bias |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3599 | m_errorMonitor->SetDesiredFailureMsg( |
| 3600 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3601 | "Dynamic depth bias state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3602 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 3603 | BsoFailDepthBias); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3604 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 3605 | // Dynamic viewport state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3606 | m_errorMonitor->SetDesiredFailureMsg( |
| 3607 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3608 | "Dynamic viewport state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3609 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 3610 | BsoFailViewport); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3611 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 3612 | // Dynamic scissor state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3613 | m_errorMonitor->SetDesiredFailureMsg( |
| 3614 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3615 | "Dynamic scissor state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3616 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 3617 | BsoFailScissor); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3618 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 3619 | // Dynamic blend state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3620 | m_errorMonitor->SetDesiredFailureMsg( |
| 3621 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3622 | "Dynamic depth bounds state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3623 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 3624 | BsoFailDepthBounds); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3625 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 3626 | // Dynamic stencil read mask |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3627 | m_errorMonitor->SetDesiredFailureMsg( |
| 3628 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3629 | "Dynamic stencil read mask state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3630 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 3631 | BsoFailStencilReadMask); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3632 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 3633 | // Dynamic stencil write mask |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3634 | m_errorMonitor->SetDesiredFailureMsg( |
| 3635 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3636 | "Dynamic stencil write mask state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3637 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 3638 | BsoFailStencilWriteMask); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3639 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 3640 | // Dynamic stencil reference |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3641 | m_errorMonitor->SetDesiredFailureMsg( |
| 3642 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3643 | "Dynamic stencil reference state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3644 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 3645 | BsoFailStencilReference); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3646 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 3647 | } |
| 3648 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3649 | TEST_F(VkLayerTest, CommandBufferTwoSubmits) { |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 3650 | vk_testing::Fence testFence; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3651 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3652 | m_errorMonitor->SetDesiredFailureMsg( |
| 3653 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3654 | "was begun w/ VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set, but has " |
| 3655 | "been submitted"); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 3656 | |
| 3657 | VkFenceCreateInfo fenceInfo = {}; |
| 3658 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3659 | fenceInfo.pNext = NULL; |
| 3660 | fenceInfo.flags = 0; |
| 3661 | |
| 3662 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3663 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 3664 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3665 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3666 | // We luck out b/c by default the framework creates CB w/ the |
| 3667 | // VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 3668 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3669 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 3670 | m_stencil_clear_color, NULL); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 3671 | EndCommandBuffer(); |
| 3672 | |
| 3673 | testFence.init(*m_device, fenceInfo); |
| 3674 | |
| 3675 | // Bypass framework since it does the waits automatically |
| 3676 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 3677 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 3678 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3679 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3680 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 3681 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 3682 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3683 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3684 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3685 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 3686 | submit_info.pSignalSemaphores = NULL; |
| 3687 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3688 | err = vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
| 3689 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 3690 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3691 | // Cause validation error by re-submitting cmd buffer that should only be |
| 3692 | // submitted once |
| 3693 | err = vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 3694 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3695 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 3696 | } |
| 3697 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3698 | TEST_F(VkLayerTest, AllocDescriptorFromEmptyPool) { |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 3699 | // Initiate Draw w/o a PSO bound |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3700 | VkResult err; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 3701 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3702 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3703 | "Unable to allocate 1 descriptors of " |
| 3704 | "type " |
| 3705 | "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3706 | |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 3707 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3708 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 3709 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3710 | // Create Pool w/ 1 Sampler descriptor, but try to alloc Uniform Buffer |
| 3711 | // descriptor from it |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3712 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3713 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 3714 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 3715 | |
| 3716 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3717 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3718 | ds_pool_ci.pNext = NULL; |
| 3719 | ds_pool_ci.flags = 0; |
| 3720 | ds_pool_ci.maxSets = 1; |
| 3721 | ds_pool_ci.poolSizeCount = 1; |
| 3722 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 3723 | |
| 3724 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3725 | err = |
| 3726 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 3727 | ASSERT_VK_SUCCESS(err); |
| 3728 | |
| 3729 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3730 | dsl_binding.binding = 0; |
| 3731 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3732 | dsl_binding.descriptorCount = 1; |
| 3733 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3734 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 3735 | |
| 3736 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3737 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3738 | ds_layout_ci.pNext = NULL; |
| 3739 | ds_layout_ci.bindingCount = 1; |
| 3740 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 3741 | |
| 3742 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3743 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3744 | &ds_layout); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 3745 | ASSERT_VK_SUCCESS(err); |
| 3746 | |
| 3747 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3748 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3749 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3750 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3751 | alloc_info.descriptorPool = ds_pool; |
| 3752 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3753 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3754 | &descriptorSet); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 3755 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3756 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 3757 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3758 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3759 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 3760 | } |
| 3761 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3762 | TEST_F(VkLayerTest, FreeDescriptorFromOneShotPool) { |
| 3763 | VkResult err; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3764 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3765 | m_errorMonitor->SetDesiredFailureMsg( |
| 3766 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3767 | "It is invalid to call vkFreeDescriptorSets() with a pool created " |
| 3768 | "without setting VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3769 | |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3770 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3771 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3772 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3773 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3774 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3775 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3776 | |
| 3777 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3778 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3779 | ds_pool_ci.pNext = NULL; |
| 3780 | ds_pool_ci.maxSets = 1; |
| 3781 | ds_pool_ci.poolSizeCount = 1; |
| 3782 | ds_pool_ci.flags = 0; |
| 3783 | // Not specifying VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT means |
| 3784 | // app can only call vkResetDescriptorPool on this pool.; |
| 3785 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3786 | |
| 3787 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3788 | err = |
| 3789 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3790 | ASSERT_VK_SUCCESS(err); |
| 3791 | |
| 3792 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3793 | dsl_binding.binding = 0; |
| 3794 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3795 | dsl_binding.descriptorCount = 1; |
| 3796 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3797 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3798 | |
| 3799 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3800 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3801 | ds_layout_ci.pNext = NULL; |
| 3802 | ds_layout_ci.bindingCount = 1; |
| 3803 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3804 | |
| 3805 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3806 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3807 | &ds_layout); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3808 | ASSERT_VK_SUCCESS(err); |
| 3809 | |
| 3810 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3811 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3812 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3813 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3814 | alloc_info.descriptorPool = ds_pool; |
| 3815 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3816 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3817 | &descriptorSet); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3818 | ASSERT_VK_SUCCESS(err); |
| 3819 | |
| 3820 | err = vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptorSet); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3821 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3822 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3823 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3824 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3825 | } |
| 3826 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3827 | TEST_F(VkLayerTest, InvalidDescriptorPool) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3828 | // Attempt to clear Descriptor Pool with bad object. |
| 3829 | // ObjectTracker should catch this. |
| 3830 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3831 | "Invalid VkDescriptorPool Object 0xbaad6001"); |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 3832 | uint64_t fake_pool_handle = 0xbaad6001; |
| 3833 | VkDescriptorPool bad_pool = reinterpret_cast<VkDescriptorPool &>(fake_pool_handle); |
| 3834 | vkResetDescriptorPool(device(), bad_pool, 0); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3835 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3836 | } |
| 3837 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3838 | TEST_F(VkLayerTest, InvalidDescriptorSet) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3839 | // Attempt to bind an invalid Descriptor Set to a valid Command Buffer |
| 3840 | // ObjectTracker should catch this. |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3841 | // Create a valid cmd buffer |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3842 | // call vkCmdBindDescriptorSets w/ false Descriptor Set |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 3843 | |
| 3844 | uint64_t fake_set_handle = 0xbaad6001; |
| 3845 | VkDescriptorSet bad_set = reinterpret_cast<VkDescriptorSet &>(fake_set_handle); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3846 | VkResult err; |
| 3847 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3848 | "Invalid VkDescriptorSet Object 0xbaad6001"); |
| 3849 | |
| 3850 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3851 | |
| 3852 | VkDescriptorSetLayoutBinding layout_bindings[1] = {}; |
| 3853 | layout_bindings[0].binding = 0; |
| 3854 | layout_bindings[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3855 | layout_bindings[0].descriptorCount = 1; |
| 3856 | layout_bindings[0].stageFlags = VK_SHADER_STAGE_VERTEX_BIT; |
| 3857 | layout_bindings[0].pImmutableSamplers = NULL; |
| 3858 | |
| 3859 | VkDescriptorSetLayout descriptor_set_layout; |
| 3860 | VkDescriptorSetLayoutCreateInfo dslci = {}; |
| 3861 | dslci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3862 | dslci.pNext = NULL; |
| 3863 | dslci.bindingCount = 1; |
| 3864 | dslci.pBindings = layout_bindings; |
| 3865 | err = vkCreateDescriptorSetLayout(device(), &dslci, NULL, &descriptor_set_layout); |
Karl Schultz | 5cb2111 | 2016-04-21 17:17:40 -0600 | [diff] [blame] | 3866 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3867 | |
| 3868 | VkPipelineLayout pipeline_layout; |
| 3869 | VkPipelineLayoutCreateInfo plci = {}; |
| 3870 | plci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3871 | plci.pNext = NULL; |
| 3872 | plci.setLayoutCount = 1; |
| 3873 | plci.pSetLayouts = &descriptor_set_layout; |
| 3874 | err = vkCreatePipelineLayout(device(), &plci, NULL, &pipeline_layout); |
Karl Schultz | 5cb2111 | 2016-04-21 17:17:40 -0600 | [diff] [blame] | 3875 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3876 | |
| 3877 | BeginCommandBuffer(); |
| 3878 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 3879 | pipeline_layout, 0, 1, &bad_set, 0, NULL); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3880 | m_errorMonitor->VerifyFound(); |
| 3881 | EndCommandBuffer(); |
| 3882 | vkDestroyPipelineLayout(device(), pipeline_layout, NULL); |
| 3883 | vkDestroyDescriptorSetLayout(device(), descriptor_set_layout, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3884 | } |
| 3885 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3886 | TEST_F(VkLayerTest, InvalidDescriptorSetLayout) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3887 | // Attempt to create a Pipeline Layout with an invalid Descriptor Set Layout. |
| 3888 | // ObjectTracker should catch this. |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 3889 | uint64_t fake_layout_handle = 0xbaad6001; |
| 3890 | VkDescriptorSetLayout bad_layout = reinterpret_cast<VkDescriptorSetLayout &>(fake_layout_handle); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3891 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3892 | "Invalid VkDescriptorSetLayout Object 0xbaad6001"); |
| 3893 | |
| 3894 | VkPipelineLayout pipeline_layout; |
| 3895 | VkPipelineLayoutCreateInfo plci = {}; |
| 3896 | plci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3897 | plci.pNext = NULL; |
| 3898 | plci.setLayoutCount = 1; |
| 3899 | plci.pSetLayouts = &bad_layout; |
| 3900 | vkCreatePipelineLayout(device(), &plci, NULL, &pipeline_layout); |
| 3901 | |
| 3902 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3903 | } |
| 3904 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3905 | TEST_F(VkLayerTest, InvalidPipeline) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3906 | // Attempt to bind an invalid Pipeline to a valid Command Buffer |
| 3907 | // ObjectTracker should catch this. |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3908 | // Create a valid cmd buffer |
| 3909 | // call vkCmdBindPipeline w/ false Pipeline |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 3910 | uint64_t fake_pipeline_handle = 0xbaad6001; |
| 3911 | VkPipeline bad_pipeline = reinterpret_cast<VkPipeline &>(fake_pipeline_handle); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3912 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3913 | "Invalid VkPipeline Object 0xbaad6001"); |
| 3914 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3915 | BeginCommandBuffer(); |
| 3916 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 3917 | VK_PIPELINE_BIND_POINT_GRAPHICS, bad_pipeline); |
| 3918 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b8b6b27 | 2016-05-02 13:26:06 -0600 | [diff] [blame] | 3919 | |
| 3920 | // Now issue a draw call with no pipeline bound |
| 3921 | m_errorMonitor->SetDesiredFailureMsg( |
| 3922 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3923 | "At Draw/Dispatch time no valid VkPipeline is bound!"); |
| 3924 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3925 | BeginCommandBuffer(); |
| 3926 | Draw(1, 0, 0, 0); |
| 3927 | m_errorMonitor->VerifyFound(); |
| 3928 | // Finally same check once more but with Dispatch/Compute |
| 3929 | m_errorMonitor->SetDesiredFailureMsg( |
| 3930 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3931 | "At Draw/Dispatch time no valid VkPipeline is bound!"); |
| 3932 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3933 | BeginCommandBuffer(); |
| 3934 | vkCmdDispatch(m_commandBuffer->GetBufferHandle(), 0, 0, 0); |
| 3935 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3936 | } |
| 3937 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3938 | TEST_F(VkLayerTest, DescriptorSetNotUpdated) { |
| 3939 | // Create and update CommandBuffer then call QueueSubmit w/o calling End on |
| 3940 | // CommandBuffer |
| 3941 | VkResult err; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3942 | |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 3943 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3944 | " bound but it was never updated. "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3945 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3946 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 3947 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 3948 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3949 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3950 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3951 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3952 | |
| 3953 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3954 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3955 | ds_pool_ci.pNext = NULL; |
| 3956 | ds_pool_ci.maxSets = 1; |
| 3957 | ds_pool_ci.poolSizeCount = 1; |
| 3958 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 3959 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3960 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3961 | err = |
| 3962 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3963 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3964 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3965 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3966 | dsl_binding.binding = 0; |
| 3967 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3968 | dsl_binding.descriptorCount = 1; |
| 3969 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3970 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3971 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3972 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3973 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3974 | ds_layout_ci.pNext = NULL; |
| 3975 | ds_layout_ci.bindingCount = 1; |
| 3976 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3977 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3978 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3979 | &ds_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3980 | ASSERT_VK_SUCCESS(err); |
| 3981 | |
| 3982 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3983 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3984 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3985 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3986 | alloc_info.descriptorPool = ds_pool; |
| 3987 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3988 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3989 | &descriptorSet); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3990 | ASSERT_VK_SUCCESS(err); |
| 3991 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3992 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3993 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3994 | pipeline_layout_ci.pNext = NULL; |
| 3995 | pipeline_layout_ci.setLayoutCount = 1; |
| 3996 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3997 | |
| 3998 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3999 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4000 | &pipeline_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4001 | ASSERT_VK_SUCCESS(err); |
| 4002 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4003 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4004 | VK_SHADER_STAGE_VERTEX_BIT, this); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4005 | // 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] | 4006 | // on more devices |
| 4007 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4008 | VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4009 | |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 4010 | VkPipelineObj pipe(m_device); |
| 4011 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 4012 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 4013 | pipe.AddColorAttachment(); |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 4014 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4015 | |
| 4016 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4017 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4018 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 4019 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 4020 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 4021 | 1, &descriptorSet, 0, NULL); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4022 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4023 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 4024 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4025 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4026 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4027 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4028 | } |
| 4029 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4030 | TEST_F(VkLayerTest, InvalidBufferViewObject) { |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4031 | // Create a single TEXEL_BUFFER descriptor and send it an invalid bufferView |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4032 | VkResult err; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4033 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4034 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4035 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Attempted write update to texel buffer " |
| 4036 | "descriptor with invalid buffer view"); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4037 | |
| 4038 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4039 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4040 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 4041 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4042 | |
| 4043 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4044 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4045 | ds_pool_ci.pNext = NULL; |
| 4046 | ds_pool_ci.maxSets = 1; |
| 4047 | ds_pool_ci.poolSizeCount = 1; |
| 4048 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4049 | |
| 4050 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4051 | err = |
| 4052 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4053 | ASSERT_VK_SUCCESS(err); |
| 4054 | |
| 4055 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4056 | dsl_binding.binding = 0; |
| 4057 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 4058 | dsl_binding.descriptorCount = 1; |
| 4059 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4060 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4061 | |
| 4062 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4063 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4064 | ds_layout_ci.pNext = NULL; |
| 4065 | ds_layout_ci.bindingCount = 1; |
| 4066 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4067 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4068 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4069 | &ds_layout); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4070 | ASSERT_VK_SUCCESS(err); |
| 4071 | |
| 4072 | VkDescriptorSet descriptorSet; |
| 4073 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4074 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4075 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4076 | alloc_info.descriptorPool = ds_pool; |
| 4077 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4078 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4079 | &descriptorSet); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4080 | ASSERT_VK_SUCCESS(err); |
| 4081 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4082 | VkBufferView view = |
| 4083 | (VkBufferView)((size_t)0xbaadbeef); // invalid bufferView object |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4084 | VkWriteDescriptorSet descriptor_write; |
| 4085 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 4086 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 4087 | descriptor_write.dstSet = descriptorSet; |
| 4088 | descriptor_write.dstBinding = 0; |
| 4089 | descriptor_write.descriptorCount = 1; |
| 4090 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 4091 | descriptor_write.pTexelBufferView = &view; |
| 4092 | |
| 4093 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 4094 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4095 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4096 | |
| 4097 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4098 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 4099 | } |
| 4100 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4101 | TEST_F(VkLayerTest, InvalidDynamicOffsetCases) { |
| 4102 | // Create a descriptorSet w/ dynamic descriptor and then hit 3 offset error |
| 4103 | // cases: |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4104 | // 1. No dynamicOffset supplied |
| 4105 | // 2. Too many dynamicOffsets supplied |
| 4106 | // 3. Dynamic offset oversteps buffer being updated |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4107 | VkResult err; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4108 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4109 | " requires 1 dynamicOffsets, but only " |
| 4110 | "0 dynamicOffsets are left in " |
| 4111 | "pDynamicOffsets "); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4112 | |
| 4113 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4114 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 4115 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4116 | |
| 4117 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4118 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 4119 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4120 | |
| 4121 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4122 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4123 | ds_pool_ci.pNext = NULL; |
| 4124 | ds_pool_ci.maxSets = 1; |
| 4125 | ds_pool_ci.poolSizeCount = 1; |
| 4126 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4127 | |
| 4128 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4129 | err = |
| 4130 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4131 | ASSERT_VK_SUCCESS(err); |
| 4132 | |
| 4133 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4134 | dsl_binding.binding = 0; |
| 4135 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 4136 | dsl_binding.descriptorCount = 1; |
| 4137 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4138 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4139 | |
| 4140 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4141 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4142 | ds_layout_ci.pNext = NULL; |
| 4143 | ds_layout_ci.bindingCount = 1; |
| 4144 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4145 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4146 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4147 | &ds_layout); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4148 | ASSERT_VK_SUCCESS(err); |
| 4149 | |
| 4150 | VkDescriptorSet descriptorSet; |
| 4151 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4152 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4153 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4154 | alloc_info.descriptorPool = ds_pool; |
| 4155 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4156 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4157 | &descriptorSet); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4158 | ASSERT_VK_SUCCESS(err); |
| 4159 | |
| 4160 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4161 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4162 | pipeline_layout_ci.pNext = NULL; |
| 4163 | pipeline_layout_ci.setLayoutCount = 1; |
| 4164 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4165 | |
| 4166 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4167 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4168 | &pipeline_layout); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4169 | ASSERT_VK_SUCCESS(err); |
| 4170 | |
| 4171 | // Create a buffer to update the descriptor with |
| 4172 | uint32_t qfi = 0; |
| 4173 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4174 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 4175 | buffCI.size = 1024; |
| 4176 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 4177 | buffCI.queueFamilyIndexCount = 1; |
| 4178 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4179 | |
| 4180 | VkBuffer dyub; |
| 4181 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 4182 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4183 | // Allocate memory and bind to buffer so we can make it to the appropriate |
| 4184 | // error |
| 4185 | VkMemoryAllocateInfo mem_alloc = {}; |
| 4186 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 4187 | mem_alloc.pNext = NULL; |
| 4188 | mem_alloc.allocationSize = 1024; |
Chris Forbes | b6116cc | 2016-05-08 11:39:59 +1200 | [diff] [blame] | 4189 | mem_alloc.memoryTypeIndex = 0; |
| 4190 | |
| 4191 | VkMemoryRequirements memReqs; |
| 4192 | vkGetBufferMemoryRequirements(m_device->device(), dyub, &memReqs); |
| 4193 | bool pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &mem_alloc, |
| 4194 | 0); |
| 4195 | if (!pass) { |
| 4196 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
| 4197 | return; |
| 4198 | } |
| 4199 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4200 | VkDeviceMemory mem; |
| 4201 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
| 4202 | ASSERT_VK_SUCCESS(err); |
| 4203 | err = vkBindBufferMemory(m_device->device(), dyub, mem, 0); |
| 4204 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4205 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 4206 | VkDescriptorBufferInfo buffInfo = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4207 | buffInfo.buffer = dyub; |
| 4208 | buffInfo.offset = 0; |
| 4209 | buffInfo.range = 1024; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4210 | |
| 4211 | VkWriteDescriptorSet descriptor_write; |
| 4212 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 4213 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 4214 | descriptor_write.dstSet = descriptorSet; |
| 4215 | descriptor_write.dstBinding = 0; |
| 4216 | descriptor_write.descriptorCount = 1; |
| 4217 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 4218 | descriptor_write.pBufferInfo = &buffInfo; |
| 4219 | |
| 4220 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 4221 | |
| 4222 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4223 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 4224 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 4225 | 1, &descriptorSet, 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4226 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4227 | uint32_t pDynOff[2] = {512, 756}; |
| 4228 | // 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] | 4229 | m_errorMonitor->SetDesiredFailureMsg( |
| 4230 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4231 | "Attempting to bind 1 descriptorSets with 1 dynamic descriptors, but "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4232 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 4233 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 4234 | 1, &descriptorSet, 2, pDynOff); |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 4235 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4236 | // Finally cause error due to dynamicOffset being too big |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4237 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4238 | " dynamic offset 512 combined with " |
| 4239 | "offset 0 and range 1024 that " |
| 4240 | "oversteps the buffer size of 1024"); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4241 | // Create PSO to be used for draw-time errors below |
| 4242 | char const *vsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 4243 | "#version 450\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4244 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 4245 | "out gl_PerVertex { \n" |
| 4246 | " vec4 gl_Position;\n" |
| 4247 | "};\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4248 | "void main(){\n" |
| 4249 | " gl_Position = vec4(1);\n" |
| 4250 | "}\n"; |
| 4251 | char const *fsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 4252 | "#version 450\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4253 | "\n" |
| 4254 | "layout(location=0) out vec4 x;\n" |
| 4255 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 4256 | "void main(){\n" |
| 4257 | " x = vec4(bar.y);\n" |
| 4258 | "}\n"; |
| 4259 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4260 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 4261 | VkPipelineObj pipe(m_device); |
| 4262 | pipe.AddShader(&vs); |
| 4263 | pipe.AddShader(&fs); |
| 4264 | pipe.AddColorAttachment(); |
| 4265 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 4266 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4267 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4268 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 4269 | // This update should succeed, but offset size of 512 will overstep buffer |
| 4270 | // /w range 1024 & size 1024 |
| 4271 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 4272 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 4273 | 1, &descriptorSet, 1, pDynOff); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4274 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4275 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4276 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4277 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
Tobin Ehlis | 512098e | 2016-05-05 09:06:12 -0600 | [diff] [blame] | 4278 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4279 | |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4280 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4281 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 4282 | } |
| 4283 | |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4284 | TEST_F(VkLayerTest, InvalidPushConstants) { |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4285 | VkResult err; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4286 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4287 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 4288 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4289 | |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4290 | VkPipelineLayout pipeline_layout; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4291 | VkPushConstantRange pc_range = {}; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4292 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 4293 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4294 | pipeline_layout_ci.pushConstantRangeCount = 1; |
| 4295 | pipeline_layout_ci.pPushConstantRanges = &pc_range; |
| 4296 | |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4297 | // |
| 4298 | // Check for invalid push constant ranges in pipeline layouts. |
| 4299 | // |
| 4300 | struct PipelineLayoutTestCase { |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4301 | VkPushConstantRange const range; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4302 | char const *msg; |
| 4303 | }; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4304 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4305 | const uint32_t too_big = m_device->props.limits.maxPushConstantsSize + 0x4; |
| 4306 | const std::array<PipelineLayoutTestCase, 10> range_tests = {{ |
| 4307 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 0}, |
| 4308 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 4309 | "size 0."}, |
| 4310 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 1}, |
| 4311 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 4312 | "size 1."}, |
| 4313 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 1}, |
| 4314 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 4315 | "size 1."}, |
| 4316 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 0}, |
| 4317 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 4318 | "size 0."}, |
| 4319 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 4}, |
| 4320 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 4321 | "offset 1. Offset must"}, |
| 4322 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, too_big}, |
| 4323 | "vkCreatePipelineLayout() call has push constants index 0 " |
| 4324 | "with offset "}, |
| 4325 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, too_big}, |
| 4326 | "vkCreatePipelineLayout() call has push constants " |
| 4327 | "index 0 with offset "}, |
| 4328 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, 0}, |
| 4329 | "vkCreatePipelineLayout() call has push constants index 0 " |
| 4330 | "with offset "}, |
| 4331 | {{VK_SHADER_STAGE_VERTEX_BIT, 0xFFFFFFF0, 0x00000020}, |
| 4332 | "vkCreatePipelineLayout() call has push " |
| 4333 | "constants index 0 with offset "}, |
| 4334 | {{VK_SHADER_STAGE_VERTEX_BIT, 0x00000020, 0xFFFFFFF0}, |
| 4335 | "vkCreatePipelineLayout() call has push " |
| 4336 | "constants index 0 with offset "}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4337 | }}; |
| 4338 | |
| 4339 | // Check for invalid offset and size |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4340 | for (const auto &iter : range_tests) { |
| 4341 | pc_range = iter.range; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4342 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4343 | iter.msg); |
| 4344 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, |
| 4345 | NULL, &pipeline_layout); |
| 4346 | m_errorMonitor->VerifyFound(); |
| 4347 | if (VK_SUCCESS == err) { |
| 4348 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4349 | } |
| 4350 | } |
| 4351 | |
| 4352 | // Check for invalid stage flag |
| 4353 | pc_range.offset = 0; |
| 4354 | pc_range.size = 16; |
| 4355 | pc_range.stageFlags = 0; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4356 | m_errorMonitor->SetDesiredFailureMsg( |
| 4357 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4358 | "vkCreatePipelineLayout() call has no stageFlags set."); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4359 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4360 | &pipeline_layout); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4361 | m_errorMonitor->VerifyFound(); |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4362 | if (VK_SUCCESS == err) { |
| 4363 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4364 | } |
| 4365 | |
| 4366 | // Check for overlapping ranges |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4367 | const uint32_t ranges_per_test = 5; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4368 | struct OverlappingRangeTestCase { |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4369 | VkPushConstantRange const ranges[ranges_per_test]; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4370 | char const *msg; |
| 4371 | }; |
| 4372 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4373 | const std::array<OverlappingRangeTestCase, 5> overlapping_range_tests = { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4374 | {{{{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4375 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4376 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4377 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4378 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, |
| 4379 | "vkCreatePipelineLayout() call has push constants with overlapping " |
| 4380 | "ranges: 0:[0, 4), 1:[0, 4)"}, |
| 4381 | { |
| 4382 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4383 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, |
| 4384 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, |
| 4385 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 8}, |
| 4386 | {VK_SHADER_STAGE_VERTEX_BIT, 16, 4}}, |
| 4387 | "vkCreatePipelineLayout() call has push constants with " |
| 4388 | "overlapping " |
| 4389 | "ranges: 3:[12, 20), 4:[16, 20)", |
| 4390 | }, |
| 4391 | { |
| 4392 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, |
| 4393 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 8}, |
| 4394 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, |
| 4395 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, |
| 4396 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, |
| 4397 | "vkCreatePipelineLayout() call has push constants with " |
| 4398 | "overlapping " |
| 4399 | "ranges: 0:[16, 20), 1:[12, 20)", |
| 4400 | }, |
| 4401 | { |
| 4402 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, |
| 4403 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, |
| 4404 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, |
| 4405 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 8}, |
| 4406 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, |
| 4407 | "vkCreatePipelineLayout() call has push constants with " |
| 4408 | "overlapping " |
| 4409 | "ranges: 0:[16, 20), 3:[12, 20)", |
| 4410 | }, |
| 4411 | { |
| 4412 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, |
| 4413 | {VK_SHADER_STAGE_VERTEX_BIT, 32, 4}, |
| 4414 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 96}, |
| 4415 | {VK_SHADER_STAGE_VERTEX_BIT, 40, 8}, |
| 4416 | {VK_SHADER_STAGE_VERTEX_BIT, 52, 4}}, |
| 4417 | "vkCreatePipelineLayout() call has push constants with " |
| 4418 | "overlapping " |
| 4419 | "ranges: 0:[16, 20), 2:[4, 100)", |
| 4420 | }}}; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4421 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4422 | for (const auto &iter : overlapping_range_tests) { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4423 | pipeline_layout_ci.pPushConstantRanges = iter.ranges; |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4424 | pipeline_layout_ci.pushConstantRangeCount = ranges_per_test; |
| 4425 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4426 | iter.msg); |
| 4427 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, |
| 4428 | NULL, &pipeline_layout); |
| 4429 | m_errorMonitor->VerifyFound(); |
| 4430 | if (VK_SUCCESS == err) { |
| 4431 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4432 | } |
| 4433 | } |
| 4434 | |
| 4435 | // 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] | 4436 | const std::array<OverlappingRangeTestCase, 2> overlapping_range_tests_pos = |
| 4437 | {{{{{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4438 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, |
| 4439 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, |
| 4440 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 4}, |
| 4441 | {VK_SHADER_STAGE_VERTEX_BIT, 16, 4}}, |
| 4442 | ""}, |
| 4443 | {{{VK_SHADER_STAGE_VERTEX_BIT, 92, 24}, |
| 4444 | {VK_SHADER_STAGE_VERTEX_BIT, 80, 4}, |
| 4445 | {VK_SHADER_STAGE_VERTEX_BIT, 64, 8}, |
| 4446 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 16}, |
| 4447 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, |
| 4448 | ""}}}; |
| 4449 | for (const auto &iter : overlapping_range_tests_pos) { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4450 | pipeline_layout_ci.pPushConstantRanges = iter.ranges; |
| 4451 | m_errorMonitor->ExpectSuccess(); |
| 4452 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, |
| 4453 | NULL, &pipeline_layout); |
| 4454 | m_errorMonitor->VerifyNotFound(); |
| 4455 | if (VK_SUCCESS == err) { |
| 4456 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4457 | } |
| 4458 | } |
| 4459 | |
| 4460 | // |
| 4461 | // CmdPushConstants tests |
| 4462 | // |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4463 | const uint8_t dummy_values[100] = {}; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4464 | |
| 4465 | // 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] | 4466 | const std::array<PipelineLayoutTestCase, 16> cmd_range_tests = {{ |
| 4467 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 0}, |
| 4468 | "vkCmdPushConstants() call has push constants with size 0. Size " |
| 4469 | "must be greater than zero and a multiple of 4."}, |
| 4470 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 1}, |
| 4471 | "vkCmdPushConstants() call has push constants with size 1. Size " |
| 4472 | "must be greater than zero and a multiple of 4."}, |
| 4473 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 1}, |
| 4474 | "vkCmdPushConstants() call has push constants with size 1. Size " |
| 4475 | "must be greater than zero and a multiple of 4."}, |
| 4476 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 0}, |
| 4477 | "vkCmdPushConstants() call has push constants with offset 1. " |
| 4478 | "Offset must be a multiple of 4."}, |
| 4479 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 4}, |
| 4480 | "vkCmdPushConstants() call has push constants with offset 1. " |
| 4481 | "Offset must be a multiple of 4."}, |
| 4482 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 20}, |
| 4483 | "vkCmdPushConstants() Push constant range [0, 20) with stageFlags = " |
| 4484 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4485 | {{VK_SHADER_STAGE_VERTEX_BIT, 60, 8}, |
| 4486 | "vkCmdPushConstants() Push constant range [60, 68) with stageFlags = " |
| 4487 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4488 | {{VK_SHADER_STAGE_VERTEX_BIT, 76, 8}, |
| 4489 | "vkCmdPushConstants() Push constant range [76, 84) with stageFlags = " |
| 4490 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4491 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 80}, |
| 4492 | "vkCmdPushConstants() Push constant range [0, 80) with stageFlags = " |
| 4493 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4494 | {{VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, 0, 4}, |
| 4495 | "vkCmdPushConstants() stageFlags = 0x2 do not match the stageFlags in " |
| 4496 | "any of the ranges in pipeline layout"}, |
| 4497 | {{VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, |
| 4498 | 0, 16}, |
| 4499 | "vkCmdPushConstants() stageFlags = 0x3 do not match the stageFlags in " |
| 4500 | "any of the ranges in pipeline layout"}, |
| 4501 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, too_big}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4502 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4503 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, too_big}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4504 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4505 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, 0}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4506 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4507 | {{VK_SHADER_STAGE_VERTEX_BIT, 0xFFFFFFF0, 0x00000020}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4508 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4509 | {{VK_SHADER_STAGE_VERTEX_BIT, 0x00000020, 0xFFFFFFF0}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4510 | "vkCmdPushConstants() call has push constants with offset "}, |
| 4511 | }}; |
| 4512 | |
| 4513 | // Two ranges for testing robustness |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4514 | const VkPushConstantRange pc_range2[] = { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4515 | {VK_SHADER_STAGE_VERTEX_BIT, 64, 16}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4516 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4517 | }; |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4518 | pipeline_layout_ci.pushConstantRangeCount = |
| 4519 | sizeof(pc_range2) / sizeof(VkPushConstantRange); |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4520 | pipeline_layout_ci.pPushConstantRanges = pc_range2; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4521 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4522 | &pipeline_layout); |
| 4523 | ASSERT_VK_SUCCESS(err); |
| 4524 | BeginCommandBuffer(); |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4525 | for (const auto &iter : cmd_range_tests) { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4526 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4527 | iter.msg); |
| 4528 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4529 | iter.range.stageFlags, iter.range.offset, |
| 4530 | iter.range.size, dummy_values); |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4531 | m_errorMonitor->VerifyFound(); |
| 4532 | } |
| 4533 | |
| 4534 | // Check for invalid stage flag |
| 4535 | m_errorMonitor->SetDesiredFailureMsg( |
| 4536 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4537 | "vkCmdPushConstants() call has no stageFlags set."); |
| 4538 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, 0, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4539 | 0, 16, dummy_values); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4540 | m_errorMonitor->VerifyFound(); |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4541 | EndCommandBuffer(); |
| 4542 | vkResetCommandBuffer(m_commandBuffer->GetBufferHandle(), 0); |
| 4543 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4544 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4545 | // overlapping range tests with cmd |
| 4546 | const std::array<PipelineLayoutTestCase, 3> cmd_overlap_tests = {{ |
| 4547 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 20}, |
| 4548 | "vkCmdPushConstants() Push constant range [0, 20) with stageFlags = " |
| 4549 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4550 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, |
| 4551 | "vkCmdPushConstants() Push constant range [16, 20) with stageFlags = " |
| 4552 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4553 | {{VK_SHADER_STAGE_VERTEX_BIT, 40, 16}, |
| 4554 | "vkCmdPushConstants() Push constant range [40, 56) with stageFlags = " |
| 4555 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4556 | }}; |
| 4557 | const VkPushConstantRange pc_range3[] = { |
| 4558 | {VK_SHADER_STAGE_VERTEX_BIT, 20, 16}, |
| 4559 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, |
| 4560 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4561 | {VK_SHADER_STAGE_VERTEX_BIT, 44, 8}, |
| 4562 | {VK_SHADER_STAGE_VERTEX_BIT, 80, 12}, |
| 4563 | {VK_SHADER_STAGE_VERTEX_BIT, 36, 8}, |
| 4564 | {VK_SHADER_STAGE_VERTEX_BIT, 56, 28}, |
| 4565 | }; |
| 4566 | pipeline_layout_ci.pushConstantRangeCount = |
| 4567 | sizeof(pc_range3) / sizeof(VkPushConstantRange); |
| 4568 | pipeline_layout_ci.pPushConstantRanges = pc_range3; |
| 4569 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4570 | &pipeline_layout); |
| 4571 | ASSERT_VK_SUCCESS(err); |
| 4572 | BeginCommandBuffer(); |
| 4573 | for (const auto &iter : cmd_overlap_tests) { |
| 4574 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4575 | iter.msg); |
| 4576 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, |
| 4577 | iter.range.stageFlags, iter.range.offset, |
| 4578 | iter.range.size, dummy_values); |
| 4579 | m_errorMonitor->VerifyFound(); |
| 4580 | } |
| 4581 | EndCommandBuffer(); |
| 4582 | vkResetCommandBuffer(m_commandBuffer->GetBufferHandle(), 0); |
| 4583 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4584 | |
| 4585 | // positive overlapping range tests with cmd |
| 4586 | const std::array<PipelineLayoutTestCase, 4> cmd_overlap_tests_pos = {{ |
| 4587 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, ""}, |
| 4588 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, ""}, |
| 4589 | {{VK_SHADER_STAGE_VERTEX_BIT, 20, 12}, ""}, |
| 4590 | {{VK_SHADER_STAGE_VERTEX_BIT, 56, 36}, ""}, |
| 4591 | }}; |
| 4592 | const VkPushConstantRange pc_range4[] = { |
| 4593 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 64}, |
| 4594 | {VK_SHADER_STAGE_VERTEX_BIT, 20, 16}, |
| 4595 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, |
| 4596 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4597 | {VK_SHADER_STAGE_VERTEX_BIT, 44, 8}, |
| 4598 | {VK_SHADER_STAGE_VERTEX_BIT, 80, 12}, |
| 4599 | {VK_SHADER_STAGE_VERTEX_BIT, 36, 8}, |
| 4600 | {VK_SHADER_STAGE_VERTEX_BIT, 56, 28}, |
| 4601 | }; |
| 4602 | pipeline_layout_ci.pushConstantRangeCount = |
| 4603 | sizeof(pc_range4) / sizeof(VkPushConstantRange); |
| 4604 | pipeline_layout_ci.pPushConstantRanges = pc_range4; |
| 4605 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4606 | &pipeline_layout); |
| 4607 | ASSERT_VK_SUCCESS(err); |
| 4608 | BeginCommandBuffer(); |
| 4609 | for (const auto &iter : cmd_overlap_tests_pos) { |
| 4610 | m_errorMonitor->ExpectSuccess(); |
| 4611 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, |
| 4612 | iter.range.stageFlags, iter.range.offset, |
| 4613 | iter.range.size, dummy_values); |
| 4614 | m_errorMonitor->VerifyNotFound(); |
| 4615 | } |
| 4616 | EndCommandBuffer(); |
| 4617 | vkResetCommandBuffer(m_commandBuffer->GetBufferHandle(), 0); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4618 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4619 | } |
| 4620 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4621 | TEST_F(VkLayerTest, DescriptorSetCompatibility) { |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4622 | // Test various desriptorSet errors with bad binding combinations |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4623 | VkResult err; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4624 | |
| 4625 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4626 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 4627 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4628 | |
| 4629 | static const uint32_t NUM_DESCRIPTOR_TYPES = 5; |
| 4630 | VkDescriptorPoolSize ds_type_count[NUM_DESCRIPTOR_TYPES] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4631 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4632 | ds_type_count[0].descriptorCount = 10; |
| 4633 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 4634 | ds_type_count[1].descriptorCount = 2; |
| 4635 | ds_type_count[2].type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 4636 | ds_type_count[2].descriptorCount = 2; |
| 4637 | ds_type_count[3].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 4638 | ds_type_count[3].descriptorCount = 5; |
| 4639 | // TODO : LunarG ILO driver currently asserts in desc.c w/ INPUT_ATTACHMENT |
| 4640 | // type |
| 4641 | // ds_type_count[4].type = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; |
| 4642 | ds_type_count[4].type = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
| 4643 | ds_type_count[4].descriptorCount = 2; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4644 | |
| 4645 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4646 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4647 | ds_pool_ci.pNext = NULL; |
| 4648 | ds_pool_ci.maxSets = 5; |
| 4649 | ds_pool_ci.poolSizeCount = NUM_DESCRIPTOR_TYPES; |
| 4650 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4651 | |
| 4652 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4653 | err = |
| 4654 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4655 | ASSERT_VK_SUCCESS(err); |
| 4656 | |
| 4657 | static const uint32_t MAX_DS_TYPES_IN_LAYOUT = 2; |
| 4658 | VkDescriptorSetLayoutBinding dsl_binding[MAX_DS_TYPES_IN_LAYOUT] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4659 | dsl_binding[0].binding = 0; |
| 4660 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4661 | dsl_binding[0].descriptorCount = 5; |
| 4662 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 4663 | dsl_binding[0].pImmutableSamplers = NULL; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4664 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4665 | // Create layout identical to set0 layout but w/ different stageFlags |
| 4666 | VkDescriptorSetLayoutBinding dsl_fs_stage_only = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4667 | dsl_fs_stage_only.binding = 0; |
| 4668 | dsl_fs_stage_only.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4669 | dsl_fs_stage_only.descriptorCount = 5; |
| 4670 | dsl_fs_stage_only.stageFlags = |
| 4671 | VK_SHADER_STAGE_FRAGMENT_BIT; // Different stageFlags to cause error at |
| 4672 | // bind time |
| 4673 | dsl_fs_stage_only.pImmutableSamplers = NULL; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4674 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4675 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4676 | ds_layout_ci.pNext = NULL; |
| 4677 | ds_layout_ci.bindingCount = 1; |
| 4678 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4679 | static const uint32_t NUM_LAYOUTS = 4; |
| 4680 | VkDescriptorSetLayout ds_layout[NUM_LAYOUTS] = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4681 | VkDescriptorSetLayout ds_layout_fs_only = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4682 | // Create 4 unique layouts for full pipelineLayout, and 1 special fs-only |
| 4683 | // layout for error case |
| 4684 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4685 | &ds_layout[0]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4686 | ASSERT_VK_SUCCESS(err); |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 4687 | ds_layout_ci.pBindings = &dsl_fs_stage_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4688 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4689 | &ds_layout_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4690 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4691 | dsl_binding[0].binding = 0; |
| 4692 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4693 | dsl_binding[0].descriptorCount = 2; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 4694 | dsl_binding[1].binding = 1; |
| 4695 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 4696 | dsl_binding[1].descriptorCount = 2; |
| 4697 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 4698 | dsl_binding[1].pImmutableSamplers = NULL; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 4699 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4700 | ds_layout_ci.bindingCount = 2; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4701 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4702 | &ds_layout[1]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4703 | ASSERT_VK_SUCCESS(err); |
| 4704 | dsl_binding[0].binding = 0; |
| 4705 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4706 | dsl_binding[0].descriptorCount = 5; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4707 | ds_layout_ci.bindingCount = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4708 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4709 | &ds_layout[2]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4710 | ASSERT_VK_SUCCESS(err); |
| 4711 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4712 | dsl_binding[0].descriptorCount = 2; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4713 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4714 | &ds_layout[3]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4715 | ASSERT_VK_SUCCESS(err); |
| 4716 | |
| 4717 | static const uint32_t NUM_SETS = 4; |
| 4718 | VkDescriptorSet descriptorSet[NUM_SETS] = {}; |
| 4719 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4720 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4721 | alloc_info.descriptorSetCount = NUM_LAYOUTS; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4722 | alloc_info.descriptorPool = ds_pool; |
| 4723 | alloc_info.pSetLayouts = ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4724 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4725 | descriptorSet); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4726 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4727 | VkDescriptorSet ds0_fs_only = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4728 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4729 | alloc_info.pSetLayouts = &ds_layout_fs_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4730 | err = |
| 4731 | vkAllocateDescriptorSets(m_device->device(), &alloc_info, &ds0_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4732 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4733 | |
| 4734 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4735 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4736 | pipeline_layout_ci.pNext = NULL; |
| 4737 | pipeline_layout_ci.setLayoutCount = NUM_LAYOUTS; |
| 4738 | pipeline_layout_ci.pSetLayouts = ds_layout; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4739 | |
| 4740 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4741 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4742 | &pipeline_layout); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4743 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4744 | // Create pipelineLayout with only one setLayout |
| 4745 | pipeline_layout_ci.setLayoutCount = 1; |
| 4746 | VkPipelineLayout single_pipe_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4747 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4748 | &single_pipe_layout); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4749 | ASSERT_VK_SUCCESS(err); |
| 4750 | // Create pipelineLayout with 2 descriptor setLayout at index 0 |
| 4751 | pipeline_layout_ci.pSetLayouts = &ds_layout[3]; |
| 4752 | VkPipelineLayout pipe_layout_one_desc; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4753 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4754 | &pipe_layout_one_desc); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4755 | ASSERT_VK_SUCCESS(err); |
| 4756 | // Create pipelineLayout with 5 SAMPLER descriptor setLayout at index 0 |
| 4757 | pipeline_layout_ci.pSetLayouts = &ds_layout[2]; |
| 4758 | VkPipelineLayout pipe_layout_five_samp; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4759 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4760 | &pipe_layout_five_samp); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4761 | ASSERT_VK_SUCCESS(err); |
| 4762 | // Create pipelineLayout with UB type, but stageFlags for FS only |
| 4763 | pipeline_layout_ci.pSetLayouts = &ds_layout_fs_only; |
| 4764 | VkPipelineLayout pipe_layout_fs_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4765 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4766 | &pipe_layout_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4767 | ASSERT_VK_SUCCESS(err); |
| 4768 | // Create pipelineLayout w/ incompatible set0 layout, but set1 is fine |
| 4769 | VkDescriptorSetLayout pl_bad_s0[2] = {}; |
| 4770 | pl_bad_s0[0] = ds_layout_fs_only; |
| 4771 | pl_bad_s0[1] = ds_layout[1]; |
| 4772 | pipeline_layout_ci.setLayoutCount = 2; |
| 4773 | pipeline_layout_ci.pSetLayouts = pl_bad_s0; |
| 4774 | VkPipelineLayout pipe_layout_bad_set0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4775 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4776 | &pipe_layout_bad_set0); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4777 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4778 | |
| 4779 | // Create a buffer to update the descriptor with |
| 4780 | uint32_t qfi = 0; |
| 4781 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4782 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 4783 | buffCI.size = 1024; |
| 4784 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 4785 | buffCI.queueFamilyIndexCount = 1; |
| 4786 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4787 | |
| 4788 | VkBuffer dyub; |
| 4789 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 4790 | ASSERT_VK_SUCCESS(err); |
| 4791 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 4792 | static const uint32_t NUM_BUFFS = 5; |
| 4793 | VkDescriptorBufferInfo buffInfo[NUM_BUFFS] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4794 | for (uint32_t i = 0; i < NUM_BUFFS; ++i) { |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4795 | buffInfo[i].buffer = dyub; |
| 4796 | buffInfo[i].offset = 0; |
| 4797 | buffInfo[i].range = 1024; |
| 4798 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4799 | VkImage image; |
| 4800 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 4801 | const int32_t tex_width = 32; |
| 4802 | const int32_t tex_height = 32; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4803 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4804 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4805 | image_create_info.pNext = NULL; |
| 4806 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4807 | image_create_info.format = tex_format; |
| 4808 | image_create_info.extent.width = tex_width; |
| 4809 | image_create_info.extent.height = tex_height; |
| 4810 | image_create_info.extent.depth = 1; |
| 4811 | image_create_info.mipLevels = 1; |
| 4812 | image_create_info.arrayLayers = 1; |
| 4813 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 4814 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 4815 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 4816 | image_create_info.flags = 0; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4817 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 4818 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4819 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4820 | VkMemoryRequirements memReqs; |
| 4821 | VkDeviceMemory imageMem; |
| 4822 | bool pass; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 4823 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4824 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 4825 | memAlloc.pNext = NULL; |
| 4826 | memAlloc.allocationSize = 0; |
| 4827 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 4828 | vkGetImageMemoryRequirements(m_device->device(), image, &memReqs); |
| 4829 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4830 | pass = |
| 4831 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 4832 | ASSERT_TRUE(pass); |
| 4833 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &imageMem); |
| 4834 | ASSERT_VK_SUCCESS(err); |
| 4835 | err = vkBindImageMemory(m_device->device(), image, imageMem, 0); |
| 4836 | ASSERT_VK_SUCCESS(err); |
| 4837 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4838 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4839 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 4840 | image_view_create_info.image = image; |
| 4841 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 4842 | image_view_create_info.format = tex_format; |
| 4843 | image_view_create_info.subresourceRange.layerCount = 1; |
| 4844 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 4845 | image_view_create_info.subresourceRange.levelCount = 1; |
| 4846 | image_view_create_info.subresourceRange.aspectMask = |
| 4847 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4848 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4849 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4850 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 4851 | &view); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4852 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 4853 | VkDescriptorImageInfo imageInfo[4] = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4854 | imageInfo[0].imageView = view; |
| 4855 | imageInfo[0].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 4856 | imageInfo[1].imageView = view; |
| 4857 | imageInfo[1].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 4858 | imageInfo[2].imageView = view; |
| 4859 | imageInfo[2].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 4860 | imageInfo[3].imageView = view; |
| 4861 | imageInfo[3].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4862 | |
| 4863 | static const uint32_t NUM_SET_UPDATES = 3; |
| 4864 | VkWriteDescriptorSet descriptor_write[NUM_SET_UPDATES] = {}; |
| 4865 | descriptor_write[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 4866 | descriptor_write[0].dstSet = descriptorSet[0]; |
| 4867 | descriptor_write[0].dstBinding = 0; |
| 4868 | descriptor_write[0].descriptorCount = 5; |
| 4869 | descriptor_write[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4870 | descriptor_write[0].pBufferInfo = buffInfo; |
| 4871 | descriptor_write[1].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 4872 | descriptor_write[1].dstSet = descriptorSet[1]; |
| 4873 | descriptor_write[1].dstBinding = 0; |
| 4874 | descriptor_write[1].descriptorCount = 2; |
| 4875 | descriptor_write[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 4876 | descriptor_write[1].pImageInfo = imageInfo; |
| 4877 | descriptor_write[2].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 4878 | descriptor_write[2].dstSet = descriptorSet[1]; |
| 4879 | descriptor_write[2].dstBinding = 1; |
| 4880 | descriptor_write[2].descriptorCount = 2; |
| 4881 | descriptor_write[2].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 4882 | descriptor_write[2].pImageInfo = &imageInfo[2]; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4883 | |
| 4884 | vkUpdateDescriptorSets(m_device->device(), 3, descriptor_write, 0, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4885 | |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 4886 | // Create PSO to be used for draw-time errors below |
| 4887 | char const *vsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 4888 | "#version 450\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 4889 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 4890 | "out gl_PerVertex {\n" |
| 4891 | " vec4 gl_Position;\n" |
| 4892 | "};\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 4893 | "void main(){\n" |
| 4894 | " gl_Position = vec4(1);\n" |
| 4895 | "}\n"; |
| 4896 | char const *fsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 4897 | "#version 450\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 4898 | "\n" |
| 4899 | "layout(location=0) out vec4 x;\n" |
| 4900 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 4901 | "void main(){\n" |
| 4902 | " x = vec4(bar.y);\n" |
| 4903 | "}\n"; |
| 4904 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4905 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4906 | VkPipelineObj pipe(m_device); |
| 4907 | pipe.AddShader(&vs); |
| 4908 | pipe.AddShader(&fs); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 4909 | pipe.AddColorAttachment(); |
| 4910 | pipe.CreateVKPipeline(pipe_layout_fs_only, renderPass()); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4911 | |
| 4912 | BeginCommandBuffer(); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 4913 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4914 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4915 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 4916 | // NOTE : I believe LunarG ilo driver has bug (LX#189) that requires binding |
| 4917 | // of PSO |
| 4918 | // here before binding DSs. Otherwise we assert in cmd_copy_dset_data() of |
| 4919 | // cmd_pipeline.c |
| 4920 | // due to the fact that cmd_alloc_dset_data() has not been called in |
| 4921 | // cmd_bind_graphics_pipeline() |
| 4922 | // TODO : Want to cause various binding incompatibility issues here to test |
| 4923 | // DrawState |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4924 | // First cause various verify_layout_compatibility() fails |
| 4925 | // Second disturb early and late sets and verify INFO msgs |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4926 | // verify_set_layout_compatibility fail cases: |
| 4927 | // 1. invalid VkPipelineLayout (layout) passed into vkCmdBindDescriptorSets |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4928 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4929 | " due to: invalid VkPipelineLayout "); |
| 4930 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 4931 | VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 4932 | (VkPipelineLayout)((size_t)0xbaadb1be), 0, 1, |
| 4933 | &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4934 | m_errorMonitor->VerifyFound(); |
| 4935 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4936 | // 2. layoutIndex exceeds # of layouts in layout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4937 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4938 | " attempting to bind set to index 1"); |
| 4939 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 4940 | VK_PIPELINE_BIND_POINT_GRAPHICS, single_pipe_layout, |
| 4941 | 0, 2, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4942 | m_errorMonitor->VerifyFound(); |
| 4943 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4944 | vkDestroyPipelineLayout(m_device->device(), single_pipe_layout, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4945 | // 3. Pipeline setLayout[0] has 2 descriptors, but set being bound has 5 |
| 4946 | // descriptors |
| 4947 | m_errorMonitor->SetDesiredFailureMsg( |
| 4948 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 4949 | " has 2 descriptors, but DescriptorSetLayout "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4950 | vkCmdBindDescriptorSets( |
| 4951 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 4952 | pipe_layout_one_desc, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4953 | m_errorMonitor->VerifyFound(); |
| 4954 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4955 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_one_desc, NULL); |
| 4956 | // 4. same # of descriptors but mismatch in type |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4957 | m_errorMonitor->SetDesiredFailureMsg( |
| 4958 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 4959 | " is type 'VK_DESCRIPTOR_TYPE_SAMPLER' but binding "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4960 | vkCmdBindDescriptorSets( |
| 4961 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 4962 | pipe_layout_five_samp, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4963 | m_errorMonitor->VerifyFound(); |
| 4964 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4965 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_five_samp, NULL); |
| 4966 | // 5. same # of descriptors but mismatch in stageFlags |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4967 | m_errorMonitor->SetDesiredFailureMsg( |
| 4968 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 4969 | " has stageFlags 16 but binding 0 for DescriptorSetLayout "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4970 | vkCmdBindDescriptorSets( |
| 4971 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 4972 | pipe_layout_fs_only, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4973 | m_errorMonitor->VerifyFound(); |
| 4974 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4975 | // Cause INFO messages due to disturbing previously bound Sets |
| 4976 | // First bind sets 0 & 1 |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4977 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 4978 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 4979 | 2, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4980 | // 1. Disturb bound set0 by re-binding set1 w/ updated pipelineLayout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4981 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 4982 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4983 | " previously bound as set #0 was disturbed "); |
| 4984 | vkCmdBindDescriptorSets( |
| 4985 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 4986 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4987 | m_errorMonitor->VerifyFound(); |
| 4988 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4989 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 4990 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 4991 | 2, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4992 | // 2. Disturb set after last bound set |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 4993 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4994 | " newly bound as set #0 so set #1 and " |
| 4995 | "any subsequent sets were disturbed "); |
| 4996 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 4997 | VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 4998 | pipe_layout_fs_only, 0, 1, &ds0_fs_only, 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4999 | m_errorMonitor->VerifyFound(); |
| 5000 | |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5001 | // Cause draw-time errors due to PSO incompatibilities |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5002 | // 1. Error due to not binding required set (we actually use same code as |
| 5003 | // above to disturb set0) |
| 5004 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5005 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 5006 | 2, &descriptorSet[0], 0, NULL); |
| 5007 | vkCmdBindDescriptorSets( |
| 5008 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5009 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
| 5010 | m_errorMonitor->SetDesiredFailureMsg( |
| 5011 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5012 | " uses set #0 but that set is not bound."); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5013 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5014 | m_errorMonitor->VerifyFound(); |
| 5015 | |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 5016 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_bad_set0, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5017 | // 2. Error due to bound set not being compatible with PSO's |
| 5018 | // VkPipelineLayout (diff stageFlags in this case) |
| 5019 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5020 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 5021 | 2, &descriptorSet[0], 0, NULL); |
| 5022 | m_errorMonitor->SetDesiredFailureMsg( |
| 5023 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5024 | " bound as set #0 is not compatible with "); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5025 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5026 | m_errorMonitor->VerifyFound(); |
| 5027 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5028 | // Remaining clean-up |
| 5029 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_fs_only, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5030 | for (uint32_t i = 0; i < NUM_LAYOUTS; ++i) { |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5031 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout[i], NULL); |
| 5032 | } |
| 5033 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout_fs_only, NULL); |
Tobin Ehlis | 9bfd449 | 2016-05-05 15:09:11 -0600 | [diff] [blame] | 5034 | vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &ds0_fs_only); |
| 5035 | vkFreeDescriptorSets(m_device->device(), ds_pool, NUM_SETS, descriptorSet); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5036 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5037 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5038 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 5039 | } |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5040 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5041 | TEST_F(VkLayerTest, NoBeginCommandBuffer) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5042 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5043 | m_errorMonitor->SetDesiredFailureMsg( |
| 5044 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5045 | "You must call vkBeginCommandBuffer() before this call to "); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5046 | |
| 5047 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5048 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5049 | // Call EndCommandBuffer() w/o calling BeginCommandBuffer() |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5050 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5051 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5052 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5053 | } |
| 5054 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5055 | TEST_F(VkLayerTest, SecondaryCommandBufferNullRenderpass) { |
| 5056 | VkResult err; |
| 5057 | VkCommandBuffer draw_cmd; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5058 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5059 | m_errorMonitor->SetDesiredFailureMsg( |
| 5060 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 61b36f3 | 2015-12-16 08:19:42 -0700 | [diff] [blame] | 5061 | " must specify a valid renderpass parameter."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5062 | |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 5063 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 5064 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5065 | VkCommandBufferAllocateInfo cmd = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5066 | cmd.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 5067 | cmd.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5068 | cmd.commandPool = m_commandPool; |
| 5069 | cmd.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5070 | cmd.commandBufferCount = 1; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 5071 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5072 | err = vkAllocateCommandBuffers(m_device->device(), &cmd, &draw_cmd); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5073 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 5074 | |
| 5075 | // Force the failure by not setting the Renderpass and Framebuffer fields |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5076 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5077 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5078 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 5079 | cmd_buf_info.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5080 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT | |
| 5081 | VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5082 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 5083 | |
| 5084 | // The error should be caught by validation of the BeginCommandBuffer call |
| 5085 | vkBeginCommandBuffer(draw_cmd, &cmd_buf_info); |
| 5086 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5087 | m_errorMonitor->VerifyFound(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5088 | vkFreeCommandBuffers(m_device->device(), m_commandPool, 1, &draw_cmd); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 5089 | } |
| 5090 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5091 | TEST_F(VkLayerTest, CommandBufferResetErrors) { |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5092 | // Cause error due to Begin while recording CB |
| 5093 | // Then cause 2 errors for attempting to reset CB w/o having |
| 5094 | // VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT set for the pool from |
| 5095 | // which CBs were allocated. Note that this bit is off by default. |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5096 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5097 | "Cannot call Begin on CB"); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5098 | |
| 5099 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5100 | |
| 5101 | // Calls AllocateCommandBuffers |
| 5102 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
| 5103 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5104 | // Force the failure by setting the Renderpass and Framebuffer fields with |
| 5105 | // (fake) data |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5106 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5107 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5108 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 5109 | cmd_buf_info.pNext = NULL; |
| 5110 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5111 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5112 | |
| 5113 | // Begin CB to transition to recording state |
| 5114 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
| 5115 | // Can't re-begin. This should trigger error |
| 5116 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5117 | m_errorMonitor->VerifyFound(); |
| 5118 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5119 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5120 | "Attempt to reset command buffer "); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5121 | VkCommandBufferResetFlags flags = 0; // Don't care about flags for this test |
| 5122 | // Reset attempt will trigger error due to incorrect CommandPool state |
| 5123 | vkResetCommandBuffer(commandBuffer.GetBufferHandle(), flags); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5124 | m_errorMonitor->VerifyFound(); |
| 5125 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5126 | m_errorMonitor->SetDesiredFailureMsg( |
| 5127 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5128 | " attempts to implicitly reset cmdBuffer created from "); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5129 | // Transition CB to RECORDED state |
| 5130 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
| 5131 | // Now attempting to Begin will implicitly reset, which triggers error |
| 5132 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5133 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5134 | } |
| 5135 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5136 | TEST_F(VkLayerTest, InvalidPipelineCreateState) { |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5137 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5138 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5139 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5140 | m_errorMonitor->SetDesiredFailureMsg( |
| 5141 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5142 | "Invalid Pipeline CreateInfo State: Vtx Shader required"); |
| 5143 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5144 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 5145 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 5146 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5147 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5148 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5149 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5150 | |
| 5151 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5152 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5153 | ds_pool_ci.pNext = NULL; |
| 5154 | ds_pool_ci.maxSets = 1; |
| 5155 | ds_pool_ci.poolSizeCount = 1; |
| 5156 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 5157 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5158 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5159 | err = |
| 5160 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5161 | ASSERT_VK_SUCCESS(err); |
| 5162 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5163 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5164 | dsl_binding.binding = 0; |
| 5165 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5166 | dsl_binding.descriptorCount = 1; |
| 5167 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5168 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5169 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5170 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5171 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5172 | ds_layout_ci.pNext = NULL; |
| 5173 | ds_layout_ci.bindingCount = 1; |
| 5174 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5175 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5176 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5177 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5178 | &ds_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5179 | ASSERT_VK_SUCCESS(err); |
| 5180 | |
| 5181 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5182 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5183 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5184 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5185 | alloc_info.descriptorPool = ds_pool; |
| 5186 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5187 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5188 | &descriptorSet); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5189 | ASSERT_VK_SUCCESS(err); |
| 5190 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5191 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5192 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5193 | pipeline_layout_ci.setLayoutCount = 1; |
| 5194 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5195 | |
| 5196 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5197 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5198 | &pipeline_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5199 | ASSERT_VK_SUCCESS(err); |
| 5200 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5201 | VkViewport vp = {}; // Just need dummy vp to point to |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5202 | VkRect2D sc = {}; // dummy scissor to point to |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5203 | |
| 5204 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5205 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 5206 | vp_state_ci.scissorCount = 1; |
| 5207 | vp_state_ci.pScissors = ≻ |
| 5208 | vp_state_ci.viewportCount = 1; |
| 5209 | vp_state_ci.pViewports = &vp; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5210 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 5211 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 5212 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 5213 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 5214 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 5215 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 5216 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 5217 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 5218 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 5219 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5220 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5221 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 5222 | gp_ci.pViewportState = &vp_state_ci; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 5223 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5224 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 5225 | gp_ci.layout = pipeline_layout; |
| 5226 | gp_ci.renderPass = renderPass(); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5227 | |
| 5228 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5229 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 5230 | pc_ci.initialDataSize = 0; |
| 5231 | pc_ci.pInitialData = 0; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5232 | |
| 5233 | VkPipeline pipeline; |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 5234 | VkPipelineCache pipelineCache; |
| 5235 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5236 | err = |
| 5237 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 5238 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5239 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 5240 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 5241 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5242 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5243 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5244 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 5245 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5246 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5247 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5248 | } |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5249 | /*// TODO : This test should be good, but needs Tess support in compiler to run |
| 5250 | TEST_F(VkLayerTest, InvalidPatchControlPoints) |
| 5251 | { |
| 5252 | // Attempt to Create Gfx Pipeline w/o a VS |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5253 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5254 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5255 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5256 | "Invalid Pipeline CreateInfo State: VK_PRIMITIVE_TOPOLOGY_PATCH |
| 5257 | primitive "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5258 | |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5259 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5260 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5261 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5262 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5263 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5264 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5265 | |
| 5266 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 5267 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5268 | ds_pool_ci.pNext = NULL; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5269 | ds_pool_ci.poolSizeCount = 1; |
| 5270 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5271 | |
| 5272 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5273 | err = vkCreateDescriptorPool(m_device->device(), |
| 5274 | 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] | 5275 | ASSERT_VK_SUCCESS(err); |
| 5276 | |
| 5277 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5278 | dsl_binding.binding = 0; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5279 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 5280 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5281 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5282 | dsl_binding.pImmutableSamplers = NULL; |
| 5283 | |
| 5284 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5285 | ds_layout_ci.sType = |
| 5286 | VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5287 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5288 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 5289 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5290 | |
| 5291 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5292 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5293 | &ds_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5294 | ASSERT_VK_SUCCESS(err); |
| 5295 | |
| 5296 | VkDescriptorSet descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5297 | err = vkAllocateDescriptorSets(m_device->device(), ds_pool, |
| 5298 | VK_DESCRIPTOR_SET_USAGE_NON_FREE, 1, &ds_layout, &descriptorSet); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5299 | ASSERT_VK_SUCCESS(err); |
| 5300 | |
| 5301 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5302 | pipeline_layout_ci.sType = |
| 5303 | VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5304 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5305 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5306 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 5307 | |
| 5308 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5309 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5310 | &pipeline_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5311 | ASSERT_VK_SUCCESS(err); |
| 5312 | |
| 5313 | VkPipelineShaderStageCreateInfo shaderStages[3]; |
| 5314 | memset(&shaderStages, 0, 3 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 5315 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5316 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, |
| 5317 | this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5318 | // 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] | 5319 | VkShaderObj |
| 5320 | tc(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, |
| 5321 | this); |
| 5322 | VkShaderObj |
| 5323 | te(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, |
| 5324 | this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5325 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5326 | shaderStages[0].sType = |
| 5327 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5328 | shaderStages[0].stage = VK_SHADER_STAGE_VERTEX_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5329 | shaderStages[0].shader = vs.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5330 | shaderStages[1].sType = |
| 5331 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5332 | shaderStages[1].stage = VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5333 | shaderStages[1].shader = tc.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5334 | shaderStages[2].sType = |
| 5335 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5336 | shaderStages[2].stage = VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5337 | shaderStages[2].shader = te.handle(); |
| 5338 | |
| 5339 | VkPipelineInputAssemblyStateCreateInfo iaCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5340 | iaCI.sType = |
| 5341 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
Chia-I Wu | 515eb8f | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5342 | iaCI.topology = VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5343 | |
| 5344 | VkPipelineTessellationStateCreateInfo tsCI = {}; |
| 5345 | tsCI.sType = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO; |
| 5346 | tsCI.patchControlPoints = 0; // This will cause an error |
| 5347 | |
| 5348 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 5349 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 5350 | gp_ci.pNext = NULL; |
| 5351 | gp_ci.stageCount = 3; |
| 5352 | gp_ci.pStages = shaderStages; |
| 5353 | gp_ci.pVertexInputState = NULL; |
| 5354 | gp_ci.pInputAssemblyState = &iaCI; |
| 5355 | gp_ci.pTessellationState = &tsCI; |
| 5356 | gp_ci.pViewportState = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5357 | gp_ci.pRasterizationState = NULL; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5358 | gp_ci.pMultisampleState = NULL; |
| 5359 | gp_ci.pDepthStencilState = NULL; |
| 5360 | gp_ci.pColorBlendState = NULL; |
| 5361 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 5362 | gp_ci.layout = pipeline_layout; |
| 5363 | gp_ci.renderPass = renderPass(); |
| 5364 | |
| 5365 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 5366 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 5367 | pc_ci.pNext = NULL; |
| 5368 | pc_ci.initialSize = 0; |
| 5369 | pc_ci.initialData = 0; |
| 5370 | pc_ci.maxSize = 0; |
| 5371 | |
| 5372 | VkPipeline pipeline; |
| 5373 | VkPipelineCache pipelineCache; |
| 5374 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5375 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, |
| 5376 | &pipelineCache); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5377 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5378 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 5379 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5380 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5381 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5382 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5383 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 5384 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5385 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5386 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5387 | } |
| 5388 | */ |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5389 | // Set scissor and viewport counts to different numbers |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5390 | TEST_F(VkLayerTest, PSOViewportScissorCountMismatch) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5391 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5392 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5393 | m_errorMonitor->SetDesiredFailureMsg( |
| 5394 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5395 | "Gfx Pipeline viewport count (1) must match scissor count (0)."); |
| 5396 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5397 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5398 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5399 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5400 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5401 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5402 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5403 | |
| 5404 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5405 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5406 | ds_pool_ci.maxSets = 1; |
| 5407 | ds_pool_ci.poolSizeCount = 1; |
| 5408 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5409 | |
| 5410 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5411 | err = |
| 5412 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5413 | ASSERT_VK_SUCCESS(err); |
| 5414 | |
| 5415 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5416 | dsl_binding.binding = 0; |
| 5417 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5418 | dsl_binding.descriptorCount = 1; |
| 5419 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5420 | |
| 5421 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5422 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5423 | ds_layout_ci.bindingCount = 1; |
| 5424 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5425 | |
| 5426 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5427 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5428 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5429 | ASSERT_VK_SUCCESS(err); |
| 5430 | |
| 5431 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5432 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5433 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5434 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5435 | alloc_info.descriptorPool = ds_pool; |
| 5436 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5437 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5438 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5439 | ASSERT_VK_SUCCESS(err); |
| 5440 | |
| 5441 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5442 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5443 | pipeline_layout_ci.setLayoutCount = 1; |
| 5444 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5445 | |
| 5446 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5447 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5448 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5449 | ASSERT_VK_SUCCESS(err); |
| 5450 | |
| 5451 | VkViewport vp = {}; // Just need dummy vp to point to |
| 5452 | |
| 5453 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5454 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 5455 | vp_state_ci.scissorCount = 0; |
| 5456 | vp_state_ci.viewportCount = 1; // Count mismatch should cause error |
| 5457 | vp_state_ci.pViewports = &vp; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5458 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 5459 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 5460 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 5461 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 5462 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 5463 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 5464 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 5465 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 5466 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 5467 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 5468 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5469 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5470 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5471 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 5472 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5473 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 5474 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 5475 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5476 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5477 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 5478 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5479 | |
| 5480 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5481 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 5482 | gp_ci.stageCount = 2; |
| 5483 | gp_ci.pStages = shaderStages; |
| 5484 | gp_ci.pViewportState = &vp_state_ci; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 5485 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5486 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 5487 | gp_ci.layout = pipeline_layout; |
| 5488 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5489 | |
| 5490 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5491 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5492 | |
| 5493 | VkPipeline pipeline; |
| 5494 | VkPipelineCache pipelineCache; |
| 5495 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5496 | err = |
| 5497 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5498 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5499 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 5500 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5501 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5502 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5503 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5504 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 5505 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5506 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5507 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5508 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5509 | // Don't set viewport state in PSO. This is an error b/c we always need this |
| 5510 | // state |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 5511 | // 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] | 5512 | TEST_F(VkLayerTest, PSOViewportStateNotSet) { |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5513 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5514 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5515 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5516 | m_errorMonitor->SetDesiredFailureMsg( |
| 5517 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5518 | "Gfx Pipeline pViewportState is null. Even if "); |
| 5519 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5520 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5521 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5522 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5523 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5524 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5525 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5526 | |
| 5527 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5528 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5529 | ds_pool_ci.maxSets = 1; |
| 5530 | ds_pool_ci.poolSizeCount = 1; |
| 5531 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5532 | |
| 5533 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5534 | err = |
| 5535 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5536 | ASSERT_VK_SUCCESS(err); |
| 5537 | |
| 5538 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5539 | dsl_binding.binding = 0; |
| 5540 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5541 | dsl_binding.descriptorCount = 1; |
| 5542 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5543 | |
| 5544 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5545 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5546 | ds_layout_ci.bindingCount = 1; |
| 5547 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5548 | |
| 5549 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5550 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5551 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5552 | ASSERT_VK_SUCCESS(err); |
| 5553 | |
| 5554 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5555 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5556 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5557 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5558 | alloc_info.descriptorPool = ds_pool; |
| 5559 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5560 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5561 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5562 | ASSERT_VK_SUCCESS(err); |
| 5563 | |
| 5564 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5565 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5566 | pipeline_layout_ci.setLayoutCount = 1; |
| 5567 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5568 | |
| 5569 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5570 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5571 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5572 | ASSERT_VK_SUCCESS(err); |
| 5573 | |
| 5574 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 5575 | // Set scissor as dynamic to avoid second error |
| 5576 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5577 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 5578 | dyn_state_ci.dynamicStateCount = 1; |
| 5579 | dyn_state_ci.pDynamicStates = &sc_state; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5580 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 5581 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5582 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5583 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5584 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 5585 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5586 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 5587 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 5588 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5589 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5590 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 5591 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5592 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 5593 | |
| 5594 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 5595 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 5596 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 5597 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 5598 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 5599 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 5600 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 5601 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 5602 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5603 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5604 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 5605 | gp_ci.stageCount = 2; |
| 5606 | gp_ci.pStages = shaderStages; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 5607 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5608 | gp_ci.pViewportState = NULL; // Not setting VP state w/o dynamic vp state |
| 5609 | // should cause validation error |
| 5610 | gp_ci.pDynamicState = &dyn_state_ci; |
| 5611 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 5612 | gp_ci.layout = pipeline_layout; |
| 5613 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -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; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5617 | |
| 5618 | VkPipeline pipeline; |
| 5619 | VkPipelineCache pipelineCache; |
| 5620 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5621 | err = |
| 5622 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5623 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5624 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 5625 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5626 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5627 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5628 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5629 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 5630 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5631 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5632 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5633 | } |
| 5634 | // Create PSO w/o non-zero viewportCount but no viewport data |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5635 | // Then run second test where dynamic scissor count doesn't match PSO scissor |
| 5636 | // count |
| 5637 | TEST_F(VkLayerTest, PSOViewportCountWithoutDataAndDynScissorMismatch) { |
| 5638 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5639 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5640 | m_errorMonitor->SetDesiredFailureMsg( |
| 5641 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5642 | "Gfx Pipeline viewportCount is 1, but pViewports is NULL. "); |
| 5643 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5644 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5645 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5646 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5647 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5648 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5649 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5650 | |
| 5651 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5652 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5653 | ds_pool_ci.maxSets = 1; |
| 5654 | ds_pool_ci.poolSizeCount = 1; |
| 5655 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5656 | |
| 5657 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5658 | err = |
| 5659 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5660 | ASSERT_VK_SUCCESS(err); |
| 5661 | |
| 5662 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5663 | dsl_binding.binding = 0; |
| 5664 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5665 | dsl_binding.descriptorCount = 1; |
| 5666 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5667 | |
| 5668 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5669 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5670 | ds_layout_ci.bindingCount = 1; |
| 5671 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5672 | |
| 5673 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5674 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5675 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5676 | ASSERT_VK_SUCCESS(err); |
| 5677 | |
| 5678 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5679 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5680 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5681 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5682 | alloc_info.descriptorPool = ds_pool; |
| 5683 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5684 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5685 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -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 = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5690 | pipeline_layout_ci.setLayoutCount = 1; |
| 5691 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5692 | |
| 5693 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5694 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5695 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5696 | ASSERT_VK_SUCCESS(err); |
| 5697 | |
| 5698 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5699 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 5700 | vp_state_ci.viewportCount = 1; |
| 5701 | vp_state_ci.pViewports = NULL; // Null vp w/ count of 1 should cause error |
| 5702 | vp_state_ci.scissorCount = 1; |
| 5703 | vp_state_ci.pScissors = |
| 5704 | NULL; // Scissor is dynamic (below) so this won't cause error |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5705 | |
| 5706 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 5707 | // Set scissor as dynamic to avoid that error |
| 5708 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5709 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 5710 | dyn_state_ci.dynamicStateCount = 1; |
| 5711 | dyn_state_ci.pDynamicStates = &sc_state; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5712 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 5713 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5714 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5715 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5716 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 5717 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5718 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 5719 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 5720 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5721 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5722 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 5723 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5724 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 5725 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 5726 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 5727 | vi_ci.pNext = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5728 | vi_ci.vertexBindingDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 5729 | vi_ci.pVertexBindingDescriptions = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5730 | vi_ci.vertexAttributeDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 5731 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 5732 | |
| 5733 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 5734 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 5735 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 5736 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5737 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5738 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 5739 | rs_ci.pNext = nullptr; |
| 5740 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 5741 | VkPipelineColorBlendAttachmentState att = {}; |
| 5742 | att.blendEnable = VK_FALSE; |
| 5743 | att.colorWriteMask = 0xf; |
| 5744 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 5745 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 5746 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 5747 | cb_ci.pNext = nullptr; |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 5748 | cb_ci.attachmentCount = 1; |
| 5749 | cb_ci.pAttachments = &att; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 5750 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5751 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5752 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 5753 | gp_ci.stageCount = 2; |
| 5754 | gp_ci.pStages = shaderStages; |
| 5755 | gp_ci.pVertexInputState = &vi_ci; |
| 5756 | gp_ci.pInputAssemblyState = &ia_ci; |
| 5757 | gp_ci.pViewportState = &vp_state_ci; |
| 5758 | gp_ci.pRasterizationState = &rs_ci; |
| 5759 | gp_ci.pColorBlendState = &cb_ci; |
| 5760 | gp_ci.pDynamicState = &dyn_state_ci; |
| 5761 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 5762 | gp_ci.layout = pipeline_layout; |
| 5763 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5764 | |
| 5765 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5766 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5767 | |
| 5768 | VkPipeline pipeline; |
| 5769 | VkPipelineCache pipelineCache; |
| 5770 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5771 | err = |
| 5772 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5773 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5774 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 5775 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5776 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5777 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5778 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 5779 | // 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] | 5780 | // First need to successfully create the PSO from above by setting |
| 5781 | // pViewports |
| 5782 | m_errorMonitor->SetDesiredFailureMsg( |
| 5783 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5784 | "Dynamic scissorCount from vkCmdSetScissor() is 2, but PSO " |
| 5785 | "scissorCount is 1. These counts must match."); |
| 5786 | |
| 5787 | VkViewport vp = {}; // Just need dummy vp to point to |
| 5788 | vp_state_ci.pViewports = &vp; |
| 5789 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 5790 | &gp_ci, NULL, &pipeline); |
| 5791 | ASSERT_VK_SUCCESS(err); |
| 5792 | BeginCommandBuffer(); |
| 5793 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 5794 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
| 5795 | VkRect2D scissors[2] = {}; // don't care about data |
| 5796 | // Count of 2 doesn't match PSO count of 1 |
| 5797 | vkCmdSetScissor(m_commandBuffer->GetBufferHandle(), 0, 2, scissors); |
| 5798 | Draw(1, 0, 0, 0); |
| 5799 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5800 | m_errorMonitor->VerifyFound(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5801 | |
| 5802 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 5803 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5804 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5805 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 5806 | } |
| 5807 | // Create PSO w/o non-zero scissorCount but no scissor data |
| 5808 | // Then run second test where dynamic viewportCount doesn't match PSO |
| 5809 | // viewportCount |
| 5810 | TEST_F(VkLayerTest, PSOScissorCountWithoutDataAndDynViewportMismatch) { |
| 5811 | VkResult err; |
| 5812 | |
| 5813 | m_errorMonitor->SetDesiredFailureMsg( |
| 5814 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5815 | "Gfx Pipeline scissorCount is 1, but pScissors is NULL. "); |
| 5816 | |
| 5817 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5818 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5819 | |
| 5820 | VkDescriptorPoolSize ds_type_count = {}; |
| 5821 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5822 | ds_type_count.descriptorCount = 1; |
| 5823 | |
| 5824 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 5825 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5826 | ds_pool_ci.maxSets = 1; |
| 5827 | ds_pool_ci.poolSizeCount = 1; |
| 5828 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 5829 | |
| 5830 | VkDescriptorPool ds_pool; |
| 5831 | err = |
| 5832 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 5833 | ASSERT_VK_SUCCESS(err); |
| 5834 | |
| 5835 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 5836 | dsl_binding.binding = 0; |
| 5837 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5838 | dsl_binding.descriptorCount = 1; |
| 5839 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5840 | |
| 5841 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 5842 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5843 | ds_layout_ci.bindingCount = 1; |
| 5844 | ds_layout_ci.pBindings = &dsl_binding; |
| 5845 | |
| 5846 | VkDescriptorSetLayout ds_layout; |
| 5847 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5848 | &ds_layout); |
| 5849 | ASSERT_VK_SUCCESS(err); |
| 5850 | |
| 5851 | VkDescriptorSet descriptorSet; |
| 5852 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 5853 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 5854 | alloc_info.descriptorSetCount = 1; |
| 5855 | alloc_info.descriptorPool = ds_pool; |
| 5856 | alloc_info.pSetLayouts = &ds_layout; |
| 5857 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5858 | &descriptorSet); |
| 5859 | ASSERT_VK_SUCCESS(err); |
| 5860 | |
| 5861 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 5862 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5863 | pipeline_layout_ci.setLayoutCount = 1; |
| 5864 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 5865 | |
| 5866 | VkPipelineLayout pipeline_layout; |
| 5867 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5868 | &pipeline_layout); |
| 5869 | ASSERT_VK_SUCCESS(err); |
| 5870 | |
| 5871 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 5872 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 5873 | vp_state_ci.scissorCount = 1; |
| 5874 | vp_state_ci.pScissors = |
| 5875 | NULL; // Null scissor w/ count of 1 should cause error |
| 5876 | vp_state_ci.viewportCount = 1; |
| 5877 | vp_state_ci.pViewports = |
| 5878 | NULL; // vp is dynamic (below) so this won't cause error |
| 5879 | |
| 5880 | VkDynamicState vp_state = VK_DYNAMIC_STATE_VIEWPORT; |
| 5881 | // Set scissor as dynamic to avoid that error |
| 5882 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 5883 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 5884 | dyn_state_ci.dynamicStateCount = 1; |
| 5885 | dyn_state_ci.pDynamicStates = &vp_state; |
| 5886 | |
| 5887 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 5888 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 5889 | |
| 5890 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 5891 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5892 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 5893 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 5894 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5895 | // but add it to be able to run on more devices |
| 5896 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 5897 | shaderStages[1] = fs.GetStageCreateInfo(); |
| 5898 | |
| 5899 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 5900 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 5901 | vi_ci.pNext = nullptr; |
| 5902 | vi_ci.vertexBindingDescriptionCount = 0; |
| 5903 | vi_ci.pVertexBindingDescriptions = nullptr; |
| 5904 | vi_ci.vertexAttributeDescriptionCount = 0; |
| 5905 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 5906 | |
| 5907 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 5908 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 5909 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 5910 | |
| 5911 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
| 5912 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 5913 | rs_ci.pNext = nullptr; |
| 5914 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 5915 | VkPipelineColorBlendAttachmentState att = {}; |
| 5916 | att.blendEnable = VK_FALSE; |
| 5917 | att.colorWriteMask = 0xf; |
| 5918 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5919 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 5920 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 5921 | cb_ci.pNext = nullptr; |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 5922 | cb_ci.attachmentCount = 1; |
| 5923 | cb_ci.pAttachments = &att; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5924 | |
| 5925 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 5926 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 5927 | gp_ci.stageCount = 2; |
| 5928 | gp_ci.pStages = shaderStages; |
| 5929 | gp_ci.pVertexInputState = &vi_ci; |
| 5930 | gp_ci.pInputAssemblyState = &ia_ci; |
| 5931 | gp_ci.pViewportState = &vp_state_ci; |
| 5932 | gp_ci.pRasterizationState = &rs_ci; |
| 5933 | gp_ci.pColorBlendState = &cb_ci; |
| 5934 | gp_ci.pDynamicState = &dyn_state_ci; |
| 5935 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 5936 | gp_ci.layout = pipeline_layout; |
| 5937 | gp_ci.renderPass = renderPass(); |
| 5938 | |
| 5939 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 5940 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 5941 | |
| 5942 | VkPipeline pipeline; |
| 5943 | VkPipelineCache pipelineCache; |
| 5944 | |
| 5945 | err = |
| 5946 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 5947 | ASSERT_VK_SUCCESS(err); |
| 5948 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 5949 | &gp_ci, NULL, &pipeline); |
| 5950 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5951 | m_errorMonitor->VerifyFound(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5952 | |
| 5953 | // Now hit second fail case where we set scissor w/ different count than PSO |
| 5954 | // First need to successfully create the PSO from above by setting |
| 5955 | // pViewports |
| 5956 | m_errorMonitor->SetDesiredFailureMsg( |
| 5957 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5958 | "Dynamic viewportCount from vkCmdSetViewport() is 2, but PSO " |
| 5959 | "viewportCount is 1. These counts must match."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5960 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 5961 | VkRect2D sc = {}; // Just need dummy vp to point to |
| 5962 | vp_state_ci.pScissors = ≻ |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5963 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 5964 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 5965 | ASSERT_VK_SUCCESS(err); |
| 5966 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5967 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 5968 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 5969 | VkViewport viewports[2] = {}; // don't care about data |
| 5970 | // Count of 2 doesn't match PSO count of 1 |
Jon Ashburn | 19d3bf1 | 2015-12-30 14:06:55 -0700 | [diff] [blame] | 5971 | vkCmdSetViewport(m_commandBuffer->GetBufferHandle(), 0, 2, viewports); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 5972 | Draw(1, 0, 0, 0); |
| 5973 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5974 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5975 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5976 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 5977 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5978 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5979 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5980 | } |
| 5981 | |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 5982 | TEST_F(VkLayerTest, PSOLineWidthInvalid) { |
| 5983 | VkResult err; |
| 5984 | |
| 5985 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 5986 | "Attempt to set lineWidth to -1"); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 5987 | |
| 5988 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5989 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5990 | |
| 5991 | VkDescriptorPoolSize ds_type_count = {}; |
| 5992 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5993 | ds_type_count.descriptorCount = 1; |
| 5994 | |
| 5995 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 5996 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5997 | ds_pool_ci.maxSets = 1; |
| 5998 | ds_pool_ci.poolSizeCount = 1; |
| 5999 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 6000 | |
| 6001 | VkDescriptorPool ds_pool; |
| 6002 | err = |
| 6003 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 6004 | ASSERT_VK_SUCCESS(err); |
| 6005 | |
| 6006 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 6007 | dsl_binding.binding = 0; |
| 6008 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6009 | dsl_binding.descriptorCount = 1; |
| 6010 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6011 | |
| 6012 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 6013 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6014 | ds_layout_ci.bindingCount = 1; |
| 6015 | ds_layout_ci.pBindings = &dsl_binding; |
| 6016 | |
| 6017 | VkDescriptorSetLayout ds_layout; |
| 6018 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6019 | &ds_layout); |
| 6020 | ASSERT_VK_SUCCESS(err); |
| 6021 | |
| 6022 | VkDescriptorSet descriptorSet; |
| 6023 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 6024 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 6025 | alloc_info.descriptorSetCount = 1; |
| 6026 | alloc_info.descriptorPool = ds_pool; |
| 6027 | alloc_info.pSetLayouts = &ds_layout; |
| 6028 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6029 | &descriptorSet); |
| 6030 | ASSERT_VK_SUCCESS(err); |
| 6031 | |
| 6032 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 6033 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6034 | pipeline_layout_ci.setLayoutCount = 1; |
| 6035 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 6036 | |
| 6037 | VkPipelineLayout pipeline_layout; |
| 6038 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6039 | &pipeline_layout); |
| 6040 | ASSERT_VK_SUCCESS(err); |
| 6041 | |
| 6042 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 6043 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 6044 | vp_state_ci.scissorCount = 1; |
| 6045 | vp_state_ci.pScissors = NULL; |
| 6046 | vp_state_ci.viewportCount = 1; |
| 6047 | vp_state_ci.pViewports = NULL; |
| 6048 | |
| 6049 | VkDynamicState dynamic_states[3] = {VK_DYNAMIC_STATE_VIEWPORT, |
| 6050 | VK_DYNAMIC_STATE_SCISSOR, |
| 6051 | VK_DYNAMIC_STATE_LINE_WIDTH}; |
| 6052 | // Set scissor as dynamic to avoid that error |
| 6053 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 6054 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 6055 | dyn_state_ci.dynamicStateCount = 2; |
| 6056 | dyn_state_ci.pDynamicStates = dynamic_states; |
| 6057 | |
| 6058 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 6059 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 6060 | |
| 6061 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6062 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6063 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6064 | VK_SHADER_STAGE_FRAGMENT_BIT, |
| 6065 | this); // TODO - We shouldn't need a fragment shader |
| 6066 | // but add it to be able to run on more devices |
| 6067 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 6068 | shaderStages[1] = fs.GetStageCreateInfo(); |
| 6069 | |
| 6070 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 6071 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 6072 | vi_ci.pNext = nullptr; |
| 6073 | vi_ci.vertexBindingDescriptionCount = 0; |
| 6074 | vi_ci.pVertexBindingDescriptions = nullptr; |
| 6075 | vi_ci.vertexAttributeDescriptionCount = 0; |
| 6076 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 6077 | |
| 6078 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 6079 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 6080 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 6081 | |
| 6082 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
| 6083 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 6084 | rs_ci.pNext = nullptr; |
| 6085 | |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 6086 | // Check too low (line width of -1.0f). |
| 6087 | rs_ci.lineWidth = -1.0f; |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6088 | |
| 6089 | VkPipelineColorBlendAttachmentState att = {}; |
| 6090 | att.blendEnable = VK_FALSE; |
| 6091 | att.colorWriteMask = 0xf; |
| 6092 | |
| 6093 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 6094 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 6095 | cb_ci.pNext = nullptr; |
| 6096 | cb_ci.attachmentCount = 1; |
| 6097 | cb_ci.pAttachments = &att; |
| 6098 | |
| 6099 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 6100 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 6101 | gp_ci.stageCount = 2; |
| 6102 | gp_ci.pStages = shaderStages; |
| 6103 | gp_ci.pVertexInputState = &vi_ci; |
| 6104 | gp_ci.pInputAssemblyState = &ia_ci; |
| 6105 | gp_ci.pViewportState = &vp_state_ci; |
| 6106 | gp_ci.pRasterizationState = &rs_ci; |
| 6107 | gp_ci.pColorBlendState = &cb_ci; |
| 6108 | gp_ci.pDynamicState = &dyn_state_ci; |
| 6109 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 6110 | gp_ci.layout = pipeline_layout; |
| 6111 | gp_ci.renderPass = renderPass(); |
| 6112 | |
| 6113 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 6114 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 6115 | |
| 6116 | VkPipeline pipeline; |
| 6117 | VkPipelineCache pipelineCache; |
| 6118 | |
| 6119 | err = |
| 6120 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 6121 | ASSERT_VK_SUCCESS(err); |
| 6122 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6123 | &gp_ci, NULL, &pipeline); |
| 6124 | |
| 6125 | m_errorMonitor->VerifyFound(); |
| 6126 | |
| 6127 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6128 | "Attempt to set lineWidth to 65536"); |
| 6129 | |
| 6130 | // Check too high (line width of 65536.0f). |
| 6131 | rs_ci.lineWidth = 65536.0f; |
| 6132 | |
| 6133 | err = |
| 6134 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 6135 | ASSERT_VK_SUCCESS(err); |
| 6136 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6137 | &gp_ci, NULL, &pipeline); |
| 6138 | |
| 6139 | m_errorMonitor->VerifyFound(); |
| 6140 | |
| 6141 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 6142 | "Attempt to set lineWidth to -1"); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6143 | |
| 6144 | dyn_state_ci.dynamicStateCount = 3; |
| 6145 | |
| 6146 | rs_ci.lineWidth = 1.0f; |
| 6147 | |
| 6148 | err = |
| 6149 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 6150 | ASSERT_VK_SUCCESS(err); |
| 6151 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6152 | &gp_ci, NULL, &pipeline); |
| 6153 | BeginCommandBuffer(); |
| 6154 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 6155 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
| 6156 | |
| 6157 | // Check too low with dynamic setting. |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 6158 | vkCmdSetLineWidth(m_commandBuffer->GetBufferHandle(), -1.0f); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6159 | m_errorMonitor->VerifyFound(); |
| 6160 | |
| 6161 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6162 | "Attempt to set lineWidth to 65536"); |
| 6163 | |
| 6164 | // Check too high with dynamic setting. |
| 6165 | vkCmdSetLineWidth(m_commandBuffer->GetBufferHandle(), 65536.0f); |
| 6166 | m_errorMonitor->VerifyFound(); |
| 6167 | EndCommandBuffer(); |
| 6168 | |
| 6169 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 6170 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6171 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6172 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 6173 | } |
| 6174 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6175 | TEST_F(VkLayerTest, NullRenderPass) { |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 6176 | // Bind a NULL RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6177 | m_errorMonitor->SetDesiredFailureMsg( |
| 6178 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6179 | "You cannot use a NULL RenderPass object in vkCmdBeginRenderPass()"); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 6180 | |
| 6181 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6182 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 6183 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 6184 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6185 | // Don't care about RenderPass handle b/c error should be flagged before |
| 6186 | // that |
| 6187 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), NULL, |
| 6188 | VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 6189 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6190 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 6191 | } |
| 6192 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6193 | TEST_F(VkLayerTest, RenderPassWithinRenderPass) { |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6194 | // Bind a BeginRenderPass within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6195 | m_errorMonitor->SetDesiredFailureMsg( |
| 6196 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6197 | "It is invalid to issue this call inside an active render pass"); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6198 | |
| 6199 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6200 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6201 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 6202 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6203 | // Just create a dummy Renderpass that's non-NULL so we can get to the |
| 6204 | // proper error |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6205 | VkRenderPassBeginInfo rp_begin = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6206 | rp_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; |
| 6207 | rp_begin.pNext = NULL; |
| 6208 | rp_begin.renderPass = renderPass(); |
| 6209 | rp_begin.framebuffer = framebuffer(); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6210 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6211 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &rp_begin, |
| 6212 | VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6213 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6214 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 6215 | } |
| 6216 | |
Cody Northrop | 3bb4d96 | 2016-05-09 16:15:57 -0600 | [diff] [blame] | 6217 | TEST_F(VkLayerTest, EndCommandBufferWithinRenderPass) { |
| 6218 | |
| 6219 | TEST_DESCRIPTION("End a command buffer with an active render pass"); |
| 6220 | |
| 6221 | m_errorMonitor->SetDesiredFailureMsg( |
| 6222 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6223 | "It is invalid to issue this call inside an active render pass"); |
| 6224 | |
| 6225 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6226 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6227 | |
| 6228 | // The framework's BeginCommandBuffer calls CreateRenderPass |
| 6229 | BeginCommandBuffer(); |
| 6230 | |
| 6231 | // Call directly into vkEndCommandBuffer instead of the |
| 6232 | // the framework's EndCommandBuffer, which inserts a |
| 6233 | // vkEndRenderPass |
| 6234 | vkEndCommandBuffer(m_commandBuffer->GetBufferHandle()); |
| 6235 | |
| 6236 | m_errorMonitor->VerifyFound(); |
| 6237 | |
| 6238 | // TODO: Add test for VK_COMMAND_BUFFER_LEVEL_SECONDARY |
| 6239 | // TODO: Add test for VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT |
| 6240 | } |
| 6241 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6242 | TEST_F(VkLayerTest, FillBufferWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6243 | // Call CmdFillBuffer within an active renderpass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6244 | m_errorMonitor->SetDesiredFailureMsg( |
| 6245 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6246 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6247 | |
| 6248 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6249 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6250 | |
| 6251 | // Renderpass is started here |
| 6252 | BeginCommandBuffer(); |
| 6253 | |
| 6254 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6255 | vk_testing::Buffer dstBuffer; |
| 6256 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6257 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6258 | m_commandBuffer->FillBuffer(dstBuffer.handle(), 0, 4, 0x11111111); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6259 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6260 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6261 | } |
| 6262 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6263 | TEST_F(VkLayerTest, UpdateBufferWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6264 | // Call CmdUpdateBuffer within an active renderpass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6265 | m_errorMonitor->SetDesiredFailureMsg( |
| 6266 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6267 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6268 | |
| 6269 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6270 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6271 | |
| 6272 | // Renderpass is started here |
| 6273 | BeginCommandBuffer(); |
| 6274 | |
| 6275 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6276 | vk_testing::Buffer dstBuffer; |
| 6277 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6278 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6279 | VkDeviceSize dstOffset = 0; |
| 6280 | VkDeviceSize dataSize = 1024; |
| 6281 | const uint32_t *pData = NULL; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6282 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6283 | vkCmdUpdateBuffer(m_commandBuffer->GetBufferHandle(), dstBuffer.handle(), |
| 6284 | dstOffset, dataSize, pData); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6285 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6286 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6287 | } |
| 6288 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6289 | TEST_F(VkLayerTest, ClearColorImageWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6290 | // Call CmdClearColorImage within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6291 | m_errorMonitor->SetDesiredFailureMsg( |
| 6292 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6293 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6294 | |
| 6295 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6296 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6297 | |
| 6298 | // Renderpass is started here |
| 6299 | BeginCommandBuffer(); |
| 6300 | |
Michael Lentine | 0a369f6 | 2016-02-03 16:51:46 -0600 | [diff] [blame] | 6301 | VkClearColorValue clear_color; |
| 6302 | memset(clear_color.uint32, 0, sizeof(uint32_t) * 4); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6303 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 6304 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6305 | const int32_t tex_width = 32; |
| 6306 | const int32_t tex_height = 32; |
| 6307 | VkImageCreateInfo image_create_info = {}; |
| 6308 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6309 | image_create_info.pNext = NULL; |
| 6310 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6311 | image_create_info.format = tex_format; |
| 6312 | image_create_info.extent.width = tex_width; |
| 6313 | image_create_info.extent.height = tex_height; |
| 6314 | image_create_info.extent.depth = 1; |
| 6315 | image_create_info.mipLevels = 1; |
| 6316 | image_create_info.arrayLayers = 1; |
| 6317 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 6318 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 6319 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6320 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6321 | vk_testing::Image dstImage; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6322 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 6323 | reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6324 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6325 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
| 6326 | image_create_info, VK_IMAGE_ASPECT_COLOR_BIT); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6327 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6328 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), dstImage.handle(), |
| 6329 | VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1, &range); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6330 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6331 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6332 | } |
| 6333 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6334 | TEST_F(VkLayerTest, ClearDepthStencilImageWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6335 | // Call CmdClearDepthStencilImage within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6336 | m_errorMonitor->SetDesiredFailureMsg( |
| 6337 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6338 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6339 | |
| 6340 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6341 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6342 | |
| 6343 | // Renderpass is started here |
| 6344 | BeginCommandBuffer(); |
| 6345 | |
| 6346 | VkClearDepthStencilValue clear_value = {0}; |
Dustin Graves | a2e5c94 | 2016-02-11 18:28:06 -0700 | [diff] [blame] | 6347 | VkMemoryPropertyFlags reqs = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6348 | VkImageCreateInfo image_create_info = vk_testing::Image::create_info(); |
| 6349 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6350 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 6351 | image_create_info.extent.width = 64; |
| 6352 | image_create_info.extent.height = 64; |
| 6353 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 6354 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6355 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6356 | vk_testing::Image dstImage; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6357 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 6358 | reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6359 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6360 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
| 6361 | image_create_info, VK_IMAGE_ASPECT_DEPTH_BIT); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6362 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6363 | vkCmdClearDepthStencilImage( |
| 6364 | m_commandBuffer->GetBufferHandle(), dstImage.handle(), |
| 6365 | VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, &clear_value, 1, |
| 6366 | &range); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6367 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6368 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6369 | } |
| 6370 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6371 | TEST_F(VkLayerTest, ClearColorAttachmentsOutsideRenderPass) { |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 6372 | // Call CmdClearAttachmentss outside of an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6373 | VkResult err; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6374 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6375 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6376 | "vkCmdClearAttachments: This call " |
| 6377 | "must be issued inside an active " |
| 6378 | "render pass"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6379 | |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6380 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6381 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6382 | |
| 6383 | // Start no RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6384 | err = m_commandBuffer->BeginCommandBuffer(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6385 | ASSERT_VK_SUCCESS(err); |
| 6386 | |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 6387 | VkClearAttachment color_attachment; |
| 6388 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 6389 | color_attachment.clearValue.color.float32[0] = 0; |
| 6390 | color_attachment.clearValue.color.float32[1] = 0; |
| 6391 | color_attachment.clearValue.color.float32[2] = 0; |
| 6392 | color_attachment.clearValue.color.float32[3] = 0; |
| 6393 | color_attachment.colorAttachment = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6394 | VkClearRect clear_rect = {{{0, 0}, {32, 32}}}; |
| 6395 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
| 6396 | &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6397 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6398 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6399 | } |
| 6400 | |
Karl Schultz | 9e66a29 | 2016-04-21 15:57:51 -0600 | [diff] [blame] | 6401 | TEST_F(VkLayerTest, BufferMemoryBarrierNoBuffer) { |
| 6402 | // Try to add a buffer memory barrier with no buffer. |
| 6403 | m_errorMonitor->SetDesiredFailureMsg( |
| 6404 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6405 | "required parameter pBufferMemoryBarriers[i].buffer specified as VK_NULL_HANDLE"); |
| 6406 | |
| 6407 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6408 | BeginCommandBuffer(); |
| 6409 | |
| 6410 | VkBufferMemoryBarrier buf_barrier = {}; |
| 6411 | buf_barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; |
| 6412 | buf_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 6413 | buf_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 6414 | buf_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 6415 | buf_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 6416 | buf_barrier.buffer = VK_NULL_HANDLE; |
| 6417 | buf_barrier.offset = 0; |
| 6418 | buf_barrier.size = VK_WHOLE_SIZE; |
| 6419 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6420 | VK_PIPELINE_STAGE_HOST_BIT, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, |
| 6421 | 0, 0, nullptr, 1, &buf_barrier, 0, nullptr); |
| 6422 | |
| 6423 | m_errorMonitor->VerifyFound(); |
| 6424 | } |
| 6425 | |
Tony Barbour | 7fd5c0f | 2016-05-03 16:11:53 -0600 | [diff] [blame] | 6426 | TEST_F(VkLayerTest, InvalidBarriers) { |
| 6427 | TEST_DESCRIPTION("A variety of ways to get VK_INVALID_BARRIER "); |
| 6428 | |
| 6429 | m_errorMonitor->SetDesiredFailureMsg( |
| 6430 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Barriers cannot be set during subpass"); |
| 6431 | |
| 6432 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6433 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6434 | |
| 6435 | VkMemoryBarrier mem_barrier = {}; |
| 6436 | mem_barrier.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER; |
| 6437 | mem_barrier.pNext = NULL; |
| 6438 | mem_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 6439 | mem_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 6440 | BeginCommandBuffer(); |
| 6441 | // BeginCommandBuffer() starts a render pass |
| 6442 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6443 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6444 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 1, |
| 6445 | &mem_barrier, 0, nullptr, 0, nullptr); |
| 6446 | m_errorMonitor->VerifyFound(); |
| 6447 | |
| 6448 | m_errorMonitor->SetDesiredFailureMsg( |
| 6449 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6450 | "Image Layout cannot be transitioned to UNDEFINED"); |
| 6451 | VkImageObj image(m_device); |
| 6452 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 6453 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
| 6454 | ASSERT_TRUE(image.initialized()); |
| 6455 | VkImageMemoryBarrier img_barrier = {}; |
| 6456 | img_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; |
| 6457 | img_barrier.pNext = NULL; |
| 6458 | img_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 6459 | img_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 6460 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 6461 | // New layout can't be UNDEFINED |
| 6462 | img_barrier.newLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 6463 | img_barrier.image = image.handle(); |
| 6464 | img_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 6465 | img_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 6466 | img_barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 6467 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 6468 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 6469 | img_barrier.subresourceRange.layerCount = 1; |
| 6470 | img_barrier.subresourceRange.levelCount = 1; |
| 6471 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6472 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6473 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 6474 | nullptr, 1, &img_barrier); |
| 6475 | m_errorMonitor->VerifyFound(); |
| 6476 | img_barrier.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 6477 | |
| 6478 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6479 | "Subresource must have the sum of the " |
| 6480 | "baseArrayLayer"); |
| 6481 | // baseArrayLayer + layerCount must be <= image's arrayLayers |
| 6482 | img_barrier.subresourceRange.baseArrayLayer = 1; |
| 6483 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6484 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6485 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 6486 | nullptr, 1, &img_barrier); |
| 6487 | m_errorMonitor->VerifyFound(); |
| 6488 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 6489 | |
| 6490 | m_errorMonitor->SetDesiredFailureMsg( |
| 6491 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6492 | "Subresource must have the sum of the baseMipLevel"); |
| 6493 | // baseMipLevel + levelCount must be <= image's mipLevels |
| 6494 | img_barrier.subresourceRange.baseMipLevel = 1; |
| 6495 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6496 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6497 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 6498 | nullptr, 1, &img_barrier); |
| 6499 | m_errorMonitor->VerifyFound(); |
| 6500 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 6501 | |
| 6502 | m_errorMonitor->SetDesiredFailureMsg( |
| 6503 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6504 | "Buffer Barriers cannot be used during a render pass"); |
| 6505 | vk_testing::Buffer buffer; |
| 6506 | buffer.init(*m_device, 256); |
| 6507 | VkBufferMemoryBarrier buf_barrier = {}; |
| 6508 | buf_barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; |
| 6509 | buf_barrier.pNext = NULL; |
| 6510 | buf_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 6511 | buf_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 6512 | buf_barrier.buffer = buffer.handle(); |
| 6513 | buf_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 6514 | buf_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 6515 | buf_barrier.offset = 0; |
| 6516 | buf_barrier.size = VK_WHOLE_SIZE; |
| 6517 | // Can't send buffer barrier during a render pass |
| 6518 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6519 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6520 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 6521 | &buf_barrier, 0, nullptr); |
| 6522 | m_errorMonitor->VerifyFound(); |
| 6523 | vkCmdEndRenderPass(m_commandBuffer->GetBufferHandle()); |
| 6524 | |
| 6525 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6526 | "which is not less than total size"); |
| 6527 | buf_barrier.offset = 257; |
| 6528 | // Offset greater than total size |
| 6529 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6530 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6531 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 6532 | &buf_barrier, 0, nullptr); |
| 6533 | m_errorMonitor->VerifyFound(); |
| 6534 | buf_barrier.offset = 0; |
| 6535 | |
| 6536 | m_errorMonitor->SetDesiredFailureMsg( |
| 6537 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "whose sum is greater than total size"); |
| 6538 | buf_barrier.size = 257; |
| 6539 | // Size greater than total size |
| 6540 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6541 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6542 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 6543 | &buf_barrier, 0, nullptr); |
| 6544 | m_errorMonitor->VerifyFound(); |
| 6545 | buf_barrier.size = VK_WHOLE_SIZE; |
| 6546 | |
| 6547 | m_errorMonitor->SetDesiredFailureMsg( |
| 6548 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6549 | "Image is a depth and stencil format and thus must " |
| 6550 | "have both VK_IMAGE_ASPECT_DEPTH_BIT and " |
| 6551 | "VK_IMAGE_ASPECT_STENCIL_BIT set."); |
| 6552 | VkDepthStencilObj ds_image(m_device); |
| 6553 | ds_image.Init(m_device, 128, 128, VK_FORMAT_D24_UNORM_S8_UINT); |
| 6554 | ASSERT_TRUE(ds_image.initialized()); |
| 6555 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 6556 | img_barrier.newLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; |
| 6557 | img_barrier.image = ds_image.handle(); |
| 6558 | // Leave aspectMask at COLOR on purpose |
| 6559 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6560 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6561 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 6562 | nullptr, 1, &img_barrier); |
| 6563 | m_errorMonitor->VerifyFound(); |
| 6564 | } |
| 6565 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6566 | TEST_F(VkLayerTest, IdxBufferAlignmentError) { |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 6567 | // Bind a BeginRenderPass within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6568 | VkResult err; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 6569 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6570 | m_errorMonitor->SetDesiredFailureMsg( |
| 6571 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6572 | "vkCmdBindIndexBuffer() offset (0x7) does not fall on "); |
| 6573 | |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 6574 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6575 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 6576 | uint32_t qfi = 0; |
| 6577 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6578 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 6579 | buffCI.size = 1024; |
| 6580 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
| 6581 | buffCI.queueFamilyIndexCount = 1; |
| 6582 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 6583 | |
| 6584 | VkBuffer ib; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6585 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 6586 | ASSERT_VK_SUCCESS(err); |
| 6587 | |
| 6588 | BeginCommandBuffer(); |
| 6589 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6590 | // vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 6591 | // VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 6592 | // 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] | 6593 | vkCmdBindIndexBuffer(m_commandBuffer->GetBufferHandle(), ib, 7, |
| 6594 | VK_INDEX_TYPE_UINT16); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 6595 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6596 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 6597 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6598 | vkDestroyBuffer(m_device->device(), ib, NULL); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 6599 | } |
| 6600 | |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 6601 | TEST_F(VkLayerTest, InvalidQueueFamilyIndex) { |
| 6602 | // Create an out-of-range queueFamilyIndex |
| 6603 | m_errorMonitor->SetDesiredFailureMsg( |
| 6604 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Dustin Graves | de62853 | 2016-04-21 16:30:17 -0600 | [diff] [blame] | 6605 | "vkCreateBuffer: pCreateInfo->pQueueFamilyIndices[0] (777) must be one " |
| 6606 | "of the indices specified when the device was created, via the " |
| 6607 | "VkDeviceQueueCreateInfo structure."); |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 6608 | |
| 6609 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6610 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6611 | VkBufferCreateInfo buffCI = {}; |
| 6612 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 6613 | buffCI.size = 1024; |
| 6614 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
| 6615 | buffCI.queueFamilyIndexCount = 1; |
| 6616 | // Introduce failure by specifying invalid queue_family_index |
| 6617 | uint32_t qfi = 777; |
| 6618 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 6619 | buffCI.sharingMode = VK_SHARING_MODE_CONCURRENT; // qfi only matters in CONCURRENT mode |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 6620 | |
| 6621 | VkBuffer ib; |
| 6622 | vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
| 6623 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6624 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 6625 | } |
| 6626 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6627 | TEST_F(VkLayerTest, ExecuteCommandsPrimaryCB) { |
| 6628 | // Attempt vkCmdExecuteCommands w/ a primary cmd buffer (should only be |
| 6629 | // secondary) |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6630 | |
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 | "vkCmdExecuteCommands() called w/ Primary Cmd Buffer "); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 6634 | |
| 6635 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6636 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 6637 | |
| 6638 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6639 | // ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6640 | VkCommandBuffer primCB = m_commandBuffer->GetBufferHandle(); |
| 6641 | vkCmdExecuteCommands(m_commandBuffer->GetBufferHandle(), 1, &primCB); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 6642 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6643 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 6644 | } |
| 6645 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6646 | TEST_F(VkLayerTest, DSTypeMismatch) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 6647 | // 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] | 6648 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6649 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6650 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 6651 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6652 | " binding #0 with type VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER but update " |
| 6653 | "type is VK_DESCRIPTOR_TYPE_SAMPLER"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6654 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6655 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6656 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6657 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6658 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6659 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6660 | |
| 6661 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6662 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6663 | ds_pool_ci.pNext = NULL; |
| 6664 | ds_pool_ci.maxSets = 1; |
| 6665 | ds_pool_ci.poolSizeCount = 1; |
| 6666 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6667 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6668 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6669 | err = |
| 6670 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6671 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6672 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6673 | dsl_binding.binding = 0; |
| 6674 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6675 | dsl_binding.descriptorCount = 1; |
| 6676 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6677 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6678 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6679 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6680 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6681 | ds_layout_ci.pNext = NULL; |
| 6682 | ds_layout_ci.bindingCount = 1; |
| 6683 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6684 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6685 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6686 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6687 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6688 | ASSERT_VK_SUCCESS(err); |
| 6689 | |
| 6690 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6691 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6692 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6693 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 6694 | alloc_info.descriptorPool = ds_pool; |
| 6695 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6696 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6697 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6698 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6699 | |
Tobin Ehlis | 30db8f8 | 2016-05-05 08:19:48 -0600 | [diff] [blame] | 6700 | VkSamplerCreateInfo sampler_ci = {}; |
| 6701 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 6702 | sampler_ci.pNext = NULL; |
| 6703 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 6704 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 6705 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 6706 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 6707 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 6708 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 6709 | sampler_ci.mipLodBias = 1.0; |
| 6710 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 6711 | sampler_ci.maxAnisotropy = 1; |
| 6712 | sampler_ci.compareEnable = VK_FALSE; |
| 6713 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 6714 | sampler_ci.minLod = 1.0; |
| 6715 | sampler_ci.maxLod = 1.0; |
| 6716 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 6717 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
| 6718 | VkSampler sampler; |
| 6719 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
| 6720 | ASSERT_VK_SUCCESS(err); |
| 6721 | |
| 6722 | VkDescriptorImageInfo info = {}; |
| 6723 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 6724 | |
| 6725 | VkWriteDescriptorSet descriptor_write; |
| 6726 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 6727 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6728 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6729 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6730 | // This is a mismatched type for the layout which expects BUFFER |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 6731 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 6732 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 6733 | |
| 6734 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 6735 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6736 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 6737 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6738 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 6739 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6740 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 6741 | } |
| 6742 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6743 | TEST_F(VkLayerTest, DSUpdateOutOfBounds) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 6744 | // For overlapping Update, have arrayIndex exceed that of layout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6745 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6746 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6747 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 6748 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6749 | " binding #0 with 1 total descriptors but update of 1 descriptors " |
| 6750 | "starting at binding offset of 0 combined with update array element " |
| 6751 | "offset of 1 oversteps the size of this descriptor set."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6752 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6753 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6754 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6755 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6756 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6757 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6758 | |
| 6759 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6760 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6761 | ds_pool_ci.pNext = NULL; |
| 6762 | ds_pool_ci.maxSets = 1; |
| 6763 | ds_pool_ci.poolSizeCount = 1; |
| 6764 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6765 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6766 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6767 | err = |
| 6768 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6769 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6770 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6771 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6772 | dsl_binding.binding = 0; |
| 6773 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6774 | dsl_binding.descriptorCount = 1; |
| 6775 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6776 | dsl_binding.pImmutableSamplers = NULL; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6777 | |
| 6778 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6779 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6780 | ds_layout_ci.pNext = NULL; |
| 6781 | ds_layout_ci.bindingCount = 1; |
| 6782 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6783 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6784 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6785 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6786 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6787 | ASSERT_VK_SUCCESS(err); |
| 6788 | |
| 6789 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6790 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6791 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6792 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 6793 | alloc_info.descriptorPool = ds_pool; |
| 6794 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6795 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6796 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6797 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6798 | |
Tobin Ehlis | 30db8f8 | 2016-05-05 08:19:48 -0600 | [diff] [blame] | 6799 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 6800 | VkDescriptorBufferInfo buff_info = {}; |
| 6801 | buff_info.buffer = |
| 6802 | VkBuffer(0); // Don't care about buffer handle for this test |
| 6803 | buff_info.offset = 0; |
| 6804 | buff_info.range = 1024; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 6805 | |
| 6806 | VkWriteDescriptorSet descriptor_write; |
| 6807 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 6808 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6809 | descriptor_write.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6810 | descriptor_write.dstArrayElement = |
| 6811 | 1; /* This index out of bounds for the update */ |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6812 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 6813 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6814 | descriptor_write.pBufferInfo = &buff_info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 6815 | |
| 6816 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 6817 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6818 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 6819 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6820 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6821 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 6822 | } |
| 6823 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6824 | TEST_F(VkLayerTest, InvalidDSUpdateIndex) { |
| 6825 | // Create layout w/ count of 1 and attempt update to that layout w/ binding |
| 6826 | // index 2 |
| 6827 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6828 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 6829 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6830 | " does not have binding 2."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6831 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6832 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6833 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6834 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6835 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6836 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6837 | |
| 6838 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6839 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6840 | ds_pool_ci.pNext = NULL; |
| 6841 | ds_pool_ci.maxSets = 1; |
| 6842 | ds_pool_ci.poolSizeCount = 1; |
| 6843 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 6844 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6845 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6846 | err = |
| 6847 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6848 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6849 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6850 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6851 | dsl_binding.binding = 0; |
| 6852 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6853 | dsl_binding.descriptorCount = 1; |
| 6854 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6855 | dsl_binding.pImmutableSamplers = NULL; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6856 | |
| 6857 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6858 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6859 | ds_layout_ci.pNext = NULL; |
| 6860 | ds_layout_ci.bindingCount = 1; |
| 6861 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6862 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6863 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6864 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6865 | ASSERT_VK_SUCCESS(err); |
| 6866 | |
| 6867 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6868 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6869 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6870 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 6871 | alloc_info.descriptorPool = ds_pool; |
| 6872 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6873 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6874 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6875 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6876 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6877 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6878 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 6879 | sampler_ci.pNext = NULL; |
| 6880 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 6881 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 6882 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 6883 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 6884 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 6885 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 6886 | sampler_ci.mipLodBias = 1.0; |
| 6887 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 6888 | sampler_ci.maxAnisotropy = 1; |
| 6889 | sampler_ci.compareEnable = VK_FALSE; |
| 6890 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 6891 | sampler_ci.minLod = 1.0; |
| 6892 | sampler_ci.maxLod = 1.0; |
| 6893 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 6894 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6895 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6896 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6897 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6898 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 6899 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 6900 | VkDescriptorImageInfo info = {}; |
| 6901 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 6902 | |
| 6903 | VkWriteDescriptorSet descriptor_write; |
| 6904 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 6905 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6906 | descriptor_write.dstSet = descriptorSet; |
| 6907 | descriptor_write.dstBinding = 2; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6908 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6909 | // 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] | 6910 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 6911 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 6912 | |
| 6913 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 6914 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6915 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 6916 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6917 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 6918 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6919 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 6920 | } |
| 6921 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6922 | TEST_F(VkLayerTest, InvalidDSUpdateStruct) { |
| 6923 | // Call UpdateDS w/ struct type other than valid VK_STRUCTUR_TYPE_UPDATE_* |
| 6924 | // types |
| 6925 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6926 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6927 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6928 | "Unexpected UPDATE struct of type "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6929 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6930 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6931 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6932 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6933 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6934 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6935 | |
| 6936 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6937 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6938 | ds_pool_ci.pNext = NULL; |
| 6939 | ds_pool_ci.maxSets = 1; |
| 6940 | ds_pool_ci.poolSizeCount = 1; |
| 6941 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 6942 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6943 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6944 | err = |
| 6945 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6946 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6947 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6948 | dsl_binding.binding = 0; |
| 6949 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6950 | dsl_binding.descriptorCount = 1; |
| 6951 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6952 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6953 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6954 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6955 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6956 | ds_layout_ci.pNext = NULL; |
| 6957 | ds_layout_ci.bindingCount = 1; |
| 6958 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6959 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6960 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6961 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6962 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6963 | ASSERT_VK_SUCCESS(err); |
| 6964 | |
| 6965 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6966 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6967 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6968 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 6969 | alloc_info.descriptorPool = ds_pool; |
| 6970 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6971 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6972 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6973 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6974 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6975 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6976 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 6977 | sampler_ci.pNext = NULL; |
| 6978 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 6979 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 6980 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 6981 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 6982 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 6983 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 6984 | sampler_ci.mipLodBias = 1.0; |
| 6985 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 6986 | sampler_ci.maxAnisotropy = 1; |
| 6987 | sampler_ci.compareEnable = VK_FALSE; |
| 6988 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 6989 | sampler_ci.minLod = 1.0; |
| 6990 | sampler_ci.maxLod = 1.0; |
| 6991 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 6992 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6993 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6994 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6995 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 6996 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 6997 | VkDescriptorImageInfo info = {}; |
| 6998 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 6999 | |
| 7000 | VkWriteDescriptorSet descriptor_write; |
| 7001 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7002 | descriptor_write.sType = |
| 7003 | (VkStructureType)0x99999999; /* Intentionally broken struct type */ |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7004 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7005 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7006 | // 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] | 7007 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 7008 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7009 | |
| 7010 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 7011 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7012 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7013 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7014 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 7015 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7016 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 7017 | } |
| 7018 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7019 | TEST_F(VkLayerTest, SampleDescriptorUpdateError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7020 | // Create a single Sampler descriptor and send it an invalid Sampler |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7021 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7022 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7023 | m_errorMonitor->SetDesiredFailureMsg( |
| 7024 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7025 | "Attempted write update to sampler descriptor with invalid sampler"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7026 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7027 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7028 | // TODO : Farm Descriptor setup code to helper function(s) to reduce copied |
| 7029 | // code |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7030 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7031 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 7032 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7033 | |
| 7034 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7035 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7036 | ds_pool_ci.pNext = NULL; |
| 7037 | ds_pool_ci.maxSets = 1; |
| 7038 | ds_pool_ci.poolSizeCount = 1; |
| 7039 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7040 | |
| 7041 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7042 | err = |
| 7043 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7044 | ASSERT_VK_SUCCESS(err); |
| 7045 | |
| 7046 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7047 | dsl_binding.binding = 0; |
| 7048 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 7049 | dsl_binding.descriptorCount = 1; |
| 7050 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7051 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7052 | |
| 7053 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7054 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7055 | ds_layout_ci.pNext = NULL; |
| 7056 | ds_layout_ci.bindingCount = 1; |
| 7057 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7058 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7059 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7060 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7061 | ASSERT_VK_SUCCESS(err); |
| 7062 | |
| 7063 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7064 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7065 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7066 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7067 | alloc_info.descriptorPool = ds_pool; |
| 7068 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7069 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7070 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7071 | ASSERT_VK_SUCCESS(err); |
| 7072 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7073 | VkSampler sampler = |
| 7074 | (VkSampler)((size_t)0xbaadbeef); // Sampler with invalid handle |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7075 | |
| 7076 | VkDescriptorImageInfo descriptor_info; |
| 7077 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 7078 | descriptor_info.sampler = sampler; |
| 7079 | |
| 7080 | VkWriteDescriptorSet descriptor_write; |
| 7081 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 7082 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7083 | descriptor_write.dstSet = descriptorSet; |
| 7084 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7085 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7086 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 7087 | descriptor_write.pImageInfo = &descriptor_info; |
| 7088 | |
| 7089 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 7090 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7091 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7092 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7093 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7094 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7095 | } |
| 7096 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7097 | TEST_F(VkLayerTest, ImageViewDescriptorUpdateError) { |
| 7098 | // Create a single combined Image/Sampler descriptor and send it an invalid |
| 7099 | // imageView |
| 7100 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7101 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7102 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7103 | "Attempted write update to combined " |
| 7104 | "image sampler descriptor failed due " |
Tobin Ehlis | 63c4b8a | 2016-05-09 10:29:34 -0600 | [diff] [blame] | 7105 | "to: Invalid VkImageView:"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7106 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7107 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7108 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7109 | ds_type_count.type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 7110 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7111 | |
| 7112 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7113 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7114 | ds_pool_ci.pNext = NULL; |
| 7115 | ds_pool_ci.maxSets = 1; |
| 7116 | ds_pool_ci.poolSizeCount = 1; |
| 7117 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7118 | |
| 7119 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7120 | err = |
| 7121 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7122 | ASSERT_VK_SUCCESS(err); |
| 7123 | |
| 7124 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7125 | dsl_binding.binding = 0; |
| 7126 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 7127 | dsl_binding.descriptorCount = 1; |
| 7128 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7129 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7130 | |
| 7131 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7132 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7133 | ds_layout_ci.pNext = NULL; |
| 7134 | ds_layout_ci.bindingCount = 1; |
| 7135 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7136 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7137 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7138 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7139 | ASSERT_VK_SUCCESS(err); |
| 7140 | |
| 7141 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7142 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7143 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7144 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7145 | alloc_info.descriptorPool = ds_pool; |
| 7146 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7147 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7148 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7149 | ASSERT_VK_SUCCESS(err); |
| 7150 | |
| 7151 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7152 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 7153 | sampler_ci.pNext = NULL; |
| 7154 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 7155 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 7156 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 7157 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7158 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7159 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7160 | sampler_ci.mipLodBias = 1.0; |
| 7161 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 7162 | sampler_ci.maxAnisotropy = 1; |
| 7163 | sampler_ci.compareEnable = VK_FALSE; |
| 7164 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 7165 | sampler_ci.minLod = 1.0; |
| 7166 | sampler_ci.maxLod = 1.0; |
| 7167 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 7168 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7169 | |
| 7170 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7171 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7172 | ASSERT_VK_SUCCESS(err); |
| 7173 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7174 | VkImageView view = |
| 7175 | (VkImageView)((size_t)0xbaadbeef); // invalid imageView object |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7176 | |
| 7177 | VkDescriptorImageInfo descriptor_info; |
| 7178 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 7179 | descriptor_info.sampler = sampler; |
| 7180 | descriptor_info.imageView = view; |
| 7181 | |
| 7182 | VkWriteDescriptorSet descriptor_write; |
| 7183 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 7184 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7185 | descriptor_write.dstSet = descriptorSet; |
| 7186 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7187 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7188 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 7189 | descriptor_write.pImageInfo = &descriptor_info; |
| 7190 | |
| 7191 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 7192 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7193 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7194 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7195 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 7196 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7197 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7198 | } |
| 7199 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7200 | TEST_F(VkLayerTest, CopyDescriptorUpdateErrors) { |
| 7201 | // Create DS w/ layout of 2 types, write update 1 and attempt to copy-update |
| 7202 | // into the other |
| 7203 | VkResult err; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7204 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7205 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7206 | " binding #1 with type " |
| 7207 | "VK_DESCRIPTOR_TYPE_SAMPLER. Types do " |
| 7208 | "not match."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7209 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7210 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7211 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7212 | VkDescriptorPoolSize ds_type_count[2] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7213 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7214 | ds_type_count[0].descriptorCount = 1; |
| 7215 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 7216 | ds_type_count[1].descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7217 | |
| 7218 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7219 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7220 | ds_pool_ci.pNext = NULL; |
| 7221 | ds_pool_ci.maxSets = 1; |
| 7222 | ds_pool_ci.poolSizeCount = 2; |
| 7223 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7224 | |
| 7225 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7226 | err = |
| 7227 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7228 | ASSERT_VK_SUCCESS(err); |
| 7229 | VkDescriptorSetLayoutBinding dsl_binding[2] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7230 | dsl_binding[0].binding = 0; |
| 7231 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7232 | dsl_binding[0].descriptorCount = 1; |
| 7233 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 7234 | dsl_binding[0].pImmutableSamplers = NULL; |
| 7235 | dsl_binding[1].binding = 1; |
| 7236 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 7237 | dsl_binding[1].descriptorCount = 1; |
| 7238 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 7239 | dsl_binding[1].pImmutableSamplers = NULL; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7240 | |
| 7241 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7242 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7243 | ds_layout_ci.pNext = NULL; |
| 7244 | ds_layout_ci.bindingCount = 2; |
| 7245 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7246 | |
| 7247 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7248 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7249 | &ds_layout); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7250 | ASSERT_VK_SUCCESS(err); |
| 7251 | |
| 7252 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7253 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7254 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7255 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7256 | alloc_info.descriptorPool = ds_pool; |
| 7257 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7258 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7259 | &descriptorSet); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7260 | ASSERT_VK_SUCCESS(err); |
| 7261 | |
| 7262 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7263 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 7264 | sampler_ci.pNext = NULL; |
| 7265 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 7266 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 7267 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 7268 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7269 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7270 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7271 | sampler_ci.mipLodBias = 1.0; |
| 7272 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 7273 | sampler_ci.maxAnisotropy = 1; |
| 7274 | sampler_ci.compareEnable = VK_FALSE; |
| 7275 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 7276 | sampler_ci.minLod = 1.0; |
| 7277 | sampler_ci.maxLod = 1.0; |
| 7278 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 7279 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7280 | |
| 7281 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7282 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7283 | ASSERT_VK_SUCCESS(err); |
| 7284 | |
| 7285 | VkDescriptorImageInfo info = {}; |
| 7286 | info.sampler = sampler; |
| 7287 | |
| 7288 | VkWriteDescriptorSet descriptor_write; |
| 7289 | memset(&descriptor_write, 0, sizeof(VkWriteDescriptorSet)); |
| 7290 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7291 | descriptor_write.dstSet = descriptorSet; |
| 7292 | descriptor_write.dstBinding = 1; // SAMPLER binding from layout above |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7293 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7294 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 7295 | descriptor_write.pImageInfo = &info; |
| 7296 | // This write update should succeed |
| 7297 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 7298 | // Now perform a copy update that fails due to type mismatch |
| 7299 | VkCopyDescriptorSet copy_ds_update; |
| 7300 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 7301 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 7302 | copy_ds_update.srcSet = descriptorSet; |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 7303 | copy_ds_update.srcBinding = 1; // Copy from SAMPLER binding |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7304 | copy_ds_update.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7305 | copy_ds_update.dstBinding = 0; // ERROR : copy to UNIFORM binding |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7306 | copy_ds_update.descriptorCount = 1; // copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7307 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 7308 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7309 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7310 | // 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] | 7311 | m_errorMonitor->SetDesiredFailureMsg( |
| 7312 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7313 | " does not have copy update src binding of 3."); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7314 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 7315 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 7316 | copy_ds_update.srcSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7317 | copy_ds_update.srcBinding = |
| 7318 | 3; // ERROR : Invalid binding for matching layout |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7319 | copy_ds_update.dstSet = descriptorSet; |
| 7320 | copy_ds_update.dstBinding = 0; |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 7321 | copy_ds_update.descriptorCount = 1; // Copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7322 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 7323 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7324 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7325 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7326 | // 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] | 7327 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7328 | VK_DEBUG_REPORT_ERROR_BIT_EXT, " binding#1 with offset index of 1 plus " |
| 7329 | "update array offset of 0 and update of " |
| 7330 | "5 descriptors oversteps total number " |
| 7331 | "of descriptors in set: 2."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7332 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7333 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 7334 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 7335 | copy_ds_update.srcSet = descriptorSet; |
| 7336 | copy_ds_update.srcBinding = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7337 | copy_ds_update.dstSet = descriptorSet; |
| 7338 | copy_ds_update.dstBinding = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7339 | copy_ds_update.descriptorCount = |
| 7340 | 5; // ERROR copy 5 descriptors (out of bounds for layout) |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7341 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 7342 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7343 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7344 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7345 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 7346 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7347 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7348 | } |
| 7349 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7350 | TEST_F(VkLayerTest, NumSamplesMismatch) { |
| 7351 | // Create CommandBuffer where MSAA samples doesn't match RenderPass |
| 7352 | // sampleCount |
| 7353 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7354 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7355 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7356 | "Num samples mismatch! "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7357 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7358 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7359 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7360 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7361 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7362 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7363 | |
| 7364 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7365 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7366 | ds_pool_ci.pNext = NULL; |
| 7367 | ds_pool_ci.maxSets = 1; |
| 7368 | ds_pool_ci.poolSizeCount = 1; |
| 7369 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 7370 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7371 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7372 | err = |
| 7373 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7374 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7375 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7376 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 7377 | dsl_binding.binding = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7378 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 7379 | dsl_binding.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7380 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7381 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7382 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7383 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 7384 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7385 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7386 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 7387 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7388 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7389 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7390 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7391 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7392 | ASSERT_VK_SUCCESS(err); |
| 7393 | |
| 7394 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7395 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7396 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7397 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 7398 | alloc_info.descriptorPool = ds_pool; |
| 7399 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7400 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7401 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7402 | ASSERT_VK_SUCCESS(err); |
| 7403 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7404 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7405 | pipe_ms_state_ci.sType = |
| 7406 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 7407 | pipe_ms_state_ci.pNext = NULL; |
| 7408 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
| 7409 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 7410 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 7411 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7412 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7413 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7414 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 7415 | pipeline_layout_ci.pNext = NULL; |
| 7416 | pipeline_layout_ci.setLayoutCount = 1; |
| 7417 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7418 | |
| 7419 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7420 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 7421 | &pipeline_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7422 | ASSERT_VK_SUCCESS(err); |
| 7423 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7424 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 7425 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7426 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 7427 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 7428 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7429 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 7430 | VkPipelineObj pipe(m_device); |
| 7431 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 7432 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 7433 | pipe.AddColorAttachment(); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 7434 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 7435 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7436 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 7437 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7438 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 7439 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7440 | |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 7441 | // Render triangle (the error should trigger on the attempt to draw). |
| 7442 | Draw(3, 1, 0, 0); |
| 7443 | |
| 7444 | // Finalize recording of the command buffer |
| 7445 | EndCommandBuffer(); |
| 7446 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7447 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7448 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7449 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 7450 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7451 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 7452 | } |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 7453 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 7454 | TEST_F(VkLayerTest, NumBlendAttachMismatch) { |
| 7455 | // Create Pipeline where the number of blend attachments doesn't match the |
| 7456 | // number of color attachments. In this case, we don't add any color |
| 7457 | // blend attachments even though we have a color attachment. |
| 7458 | VkResult err; |
| 7459 | |
| 7460 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 7461 | "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] | 7462 | |
| 7463 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7464 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7465 | VkDescriptorPoolSize ds_type_count = {}; |
| 7466 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7467 | ds_type_count.descriptorCount = 1; |
| 7468 | |
| 7469 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 7470 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7471 | ds_pool_ci.pNext = NULL; |
| 7472 | ds_pool_ci.maxSets = 1; |
| 7473 | ds_pool_ci.poolSizeCount = 1; |
| 7474 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 7475 | |
| 7476 | VkDescriptorPool ds_pool; |
| 7477 | err = |
| 7478 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 7479 | ASSERT_VK_SUCCESS(err); |
| 7480 | |
| 7481 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 7482 | dsl_binding.binding = 0; |
| 7483 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7484 | dsl_binding.descriptorCount = 1; |
| 7485 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7486 | dsl_binding.pImmutableSamplers = NULL; |
| 7487 | |
| 7488 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 7489 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7490 | ds_layout_ci.pNext = NULL; |
| 7491 | ds_layout_ci.bindingCount = 1; |
| 7492 | ds_layout_ci.pBindings = &dsl_binding; |
| 7493 | |
| 7494 | VkDescriptorSetLayout ds_layout; |
| 7495 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7496 | &ds_layout); |
| 7497 | ASSERT_VK_SUCCESS(err); |
| 7498 | |
| 7499 | VkDescriptorSet descriptorSet; |
| 7500 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 7501 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 7502 | alloc_info.descriptorSetCount = 1; |
| 7503 | alloc_info.descriptorPool = ds_pool; |
| 7504 | alloc_info.pSetLayouts = &ds_layout; |
| 7505 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7506 | &descriptorSet); |
| 7507 | ASSERT_VK_SUCCESS(err); |
| 7508 | |
| 7509 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 7510 | pipe_ms_state_ci.sType = |
| 7511 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 7512 | pipe_ms_state_ci.pNext = NULL; |
| 7513 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 7514 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 7515 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 7516 | pipe_ms_state_ci.pSampleMask = NULL; |
| 7517 | |
| 7518 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 7519 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 7520 | pipeline_layout_ci.pNext = NULL; |
| 7521 | pipeline_layout_ci.setLayoutCount = 1; |
| 7522 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 7523 | |
| 7524 | VkPipelineLayout pipeline_layout; |
| 7525 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 7526 | &pipeline_layout); |
| 7527 | ASSERT_VK_SUCCESS(err); |
| 7528 | |
| 7529 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 7530 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7531 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 7532 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 7533 | this); // We shouldn't need a fragment shader |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 7534 | // but add it to be able to run on more devices |
| 7535 | VkPipelineObj pipe(m_device); |
| 7536 | pipe.AddShader(&vs); |
| 7537 | pipe.AddShader(&fs); |
| 7538 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 7539 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 7540 | |
| 7541 | BeginCommandBuffer(); |
| 7542 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 7543 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 7544 | |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 7545 | // Render triangle (the error should trigger on the attempt to draw). |
| 7546 | Draw(3, 1, 0, 0); |
| 7547 | |
| 7548 | // Finalize recording of the command buffer |
| 7549 | EndCommandBuffer(); |
| 7550 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7551 | m_errorMonitor->VerifyFound(); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 7552 | |
| 7553 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 7554 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7555 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 7556 | } |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 7557 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7558 | TEST_F(VkLayerTest, ClearCmdNoDraw) { |
| 7559 | // Create CommandBuffer where we add ClearCmd for FB Color attachment prior |
| 7560 | // to issuing a Draw |
| 7561 | VkResult err; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7562 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7563 | m_errorMonitor->SetDesiredFailureMsg( |
Tony Barbour | 7e56d30 | 2016-03-02 15:12:01 -0700 | [diff] [blame] | 7564 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7565 | "vkCmdClearAttachments() issued on CB object "); |
| 7566 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7567 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7568 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7569 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7570 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7571 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7572 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7573 | |
| 7574 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7575 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7576 | ds_pool_ci.pNext = NULL; |
| 7577 | ds_pool_ci.maxSets = 1; |
| 7578 | ds_pool_ci.poolSizeCount = 1; |
| 7579 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7580 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7581 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7582 | err = |
| 7583 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7584 | ASSERT_VK_SUCCESS(err); |
| 7585 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7586 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7587 | dsl_binding.binding = 0; |
| 7588 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7589 | dsl_binding.descriptorCount = 1; |
| 7590 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7591 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7592 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7593 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7594 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7595 | ds_layout_ci.pNext = NULL; |
| 7596 | ds_layout_ci.bindingCount = 1; |
| 7597 | ds_layout_ci.pBindings = &dsl_binding; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 7598 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7599 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7600 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7601 | &ds_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7602 | ASSERT_VK_SUCCESS(err); |
| 7603 | |
| 7604 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7605 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7606 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7607 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 7608 | alloc_info.descriptorPool = ds_pool; |
| 7609 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7610 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7611 | &descriptorSet); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7612 | ASSERT_VK_SUCCESS(err); |
| 7613 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7614 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7615 | pipe_ms_state_ci.sType = |
| 7616 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 7617 | pipe_ms_state_ci.pNext = NULL; |
| 7618 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
| 7619 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 7620 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 7621 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7622 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7623 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7624 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 7625 | pipeline_layout_ci.pNext = NULL; |
| 7626 | pipeline_layout_ci.setLayoutCount = 1; |
| 7627 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7628 | |
| 7629 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7630 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 7631 | &pipeline_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7632 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 7633 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7634 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 7635 | VK_SHADER_STAGE_VERTEX_BIT, this); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 7636 | // 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] | 7637 | // on more devices |
| 7638 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 7639 | VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7640 | |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 7641 | VkPipelineObj pipe(m_device); |
| 7642 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 7643 | pipe.AddShader(&fs); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 7644 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 7645 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 7646 | |
| 7647 | BeginCommandBuffer(); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7648 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7649 | // Main thing we care about for this test is that the VkImage obj we're |
| 7650 | // clearing matches Color Attachment of FB |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7651 | // Also pass down other dummy params to keep driver and paramchecker happy |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 7652 | VkClearAttachment color_attachment; |
| 7653 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 7654 | color_attachment.clearValue.color.float32[0] = 1.0; |
| 7655 | color_attachment.clearValue.color.float32[1] = 1.0; |
| 7656 | color_attachment.clearValue.color.float32[2] = 1.0; |
| 7657 | color_attachment.clearValue.color.float32[3] = 1.0; |
| 7658 | color_attachment.colorAttachment = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7659 | VkClearRect clear_rect = { |
| 7660 | {{0, 0}, {(uint32_t)m_width, (uint32_t)m_height}}}; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7661 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7662 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
| 7663 | &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7664 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7665 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7666 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7667 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 7668 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7669 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7670 | } |
| 7671 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7672 | TEST_F(VkLayerTest, VtxBufferBadIndex) { |
| 7673 | VkResult err; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 7674 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7675 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 7676 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | dfcd9b6 | 2015-12-14 15:14:10 -0700 | [diff] [blame] | 7677 | "but no vertex buffers are attached to this Pipeline State Object"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7678 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 7679 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 7680 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 7681 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7682 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7683 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7684 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7685 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7686 | |
| 7687 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7688 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7689 | ds_pool_ci.pNext = NULL; |
| 7690 | ds_pool_ci.maxSets = 1; |
| 7691 | ds_pool_ci.poolSizeCount = 1; |
| 7692 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7693 | |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 7694 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7695 | err = |
| 7696 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 7697 | ASSERT_VK_SUCCESS(err); |
| 7698 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7699 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7700 | dsl_binding.binding = 0; |
| 7701 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7702 | dsl_binding.descriptorCount = 1; |
| 7703 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7704 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 7705 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7706 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7707 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7708 | ds_layout_ci.pNext = NULL; |
| 7709 | ds_layout_ci.bindingCount = 1; |
| 7710 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7711 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 7712 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7713 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7714 | &ds_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 7715 | ASSERT_VK_SUCCESS(err); |
| 7716 | |
| 7717 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7718 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7719 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7720 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 7721 | alloc_info.descriptorPool = ds_pool; |
| 7722 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7723 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7724 | &descriptorSet); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 7725 | ASSERT_VK_SUCCESS(err); |
| 7726 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7727 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7728 | pipe_ms_state_ci.sType = |
| 7729 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 7730 | pipe_ms_state_ci.pNext = NULL; |
| 7731 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 7732 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 7733 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 7734 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 7735 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7736 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7737 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 7738 | pipeline_layout_ci.pNext = NULL; |
| 7739 | pipeline_layout_ci.setLayoutCount = 1; |
| 7740 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 7741 | VkPipelineLayout pipeline_layout; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 7742 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7743 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 7744 | &pipeline_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 7745 | ASSERT_VK_SUCCESS(err); |
| 7746 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7747 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 7748 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7749 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 7750 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 7751 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7752 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 7753 | VkPipelineObj pipe(m_device); |
| 7754 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 7755 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 7756 | pipe.AddColorAttachment(); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 7757 | pipe.SetMSAA(&pipe_ms_state_ci); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 7758 | pipe.SetViewport(m_viewports); |
| 7759 | pipe.SetScissor(m_scissors); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 7760 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 7761 | |
| 7762 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7763 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 7764 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 7765 | // Don't care about actual data, just need to get to draw to flag error |
| 7766 | static const float vbo_data[3] = {1.f, 0.f, 1.f}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7767 | VkConstantBufferObj vbo(m_device, sizeof(vbo_data), sizeof(float), |
| 7768 | (const void *)&vbo_data); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 7769 | 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] | 7770 | Draw(1, 0, 0, 0); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 7771 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7772 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7773 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7774 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 7775 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7776 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 7777 | } |
Tobin Ehlis | c555a3c | 2016-05-04 14:08:34 -0600 | [diff] [blame] | 7778 | // INVALID_IMAGE_LAYOUT tests (one other case is hit by MapMemWithoutHostVisibleBit and not here) |
| 7779 | TEST_F(VkLayerTest, InvalidImageLayout) { |
| 7780 | TEST_DESCRIPTION("Hit all possible validation checks associated with the " |
| 7781 | "DRAWSTATE_INVALID_IMAGE_LAYOUT enum. Generally these involve having" |
| 7782 | "images in the wrong layout when they're copied or transitioned."); |
| 7783 | // 3 in ValidateCmdBufImageLayouts |
| 7784 | // * -1 Attempt to submit cmd buf w/ deleted image |
| 7785 | // * -2 Cmd buf submit of image w/ layout not matching first use w/ subresource |
| 7786 | // * -3 Cmd buf submit of image w/ layout not matching first use w/o subresource |
| 7787 | m_errorMonitor->SetDesiredFailureMsg( |
| 7788 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 7789 | "Layout for input image should be TRANSFER_SRC_OPTIMAL instead of GENERAL."); |
| 7790 | |
| 7791 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7792 | // Create src & dst images to use for copy operations |
| 7793 | VkImage src_image; |
| 7794 | VkImage dst_image; |
| 7795 | |
| 7796 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 7797 | const int32_t tex_width = 32; |
| 7798 | const int32_t tex_height = 32; |
| 7799 | |
| 7800 | VkImageCreateInfo image_create_info = {}; |
| 7801 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 7802 | image_create_info.pNext = NULL; |
| 7803 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 7804 | image_create_info.format = tex_format; |
| 7805 | image_create_info.extent.width = tex_width; |
| 7806 | image_create_info.extent.height = tex_height; |
| 7807 | image_create_info.extent.depth = 1; |
| 7808 | image_create_info.mipLevels = 1; |
| 7809 | image_create_info.arrayLayers = 4; |
| 7810 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 7811 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 7812 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 7813 | image_create_info.flags = 0; |
| 7814 | |
| 7815 | VkResult err = vkCreateImage(m_device->device(), &image_create_info, NULL, &src_image); |
| 7816 | ASSERT_VK_SUCCESS(err); |
| 7817 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dst_image); |
| 7818 | ASSERT_VK_SUCCESS(err); |
| 7819 | |
| 7820 | BeginCommandBuffer(); |
| 7821 | VkImageCopy copyRegion; |
| 7822 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 7823 | copyRegion.srcSubresource.mipLevel = 0; |
| 7824 | copyRegion.srcSubresource.baseArrayLayer = 0; |
| 7825 | copyRegion.srcSubresource.layerCount = 1; |
| 7826 | copyRegion.srcOffset.x = 0; |
| 7827 | copyRegion.srcOffset.y = 0; |
| 7828 | copyRegion.srcOffset.z = 0; |
| 7829 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 7830 | copyRegion.dstSubresource.mipLevel = 0; |
| 7831 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 7832 | copyRegion.dstSubresource.layerCount = 1; |
| 7833 | copyRegion.dstOffset.x = 0; |
| 7834 | copyRegion.dstOffset.y = 0; |
| 7835 | copyRegion.dstOffset.z = 0; |
| 7836 | copyRegion.extent.width = 1; |
| 7837 | copyRegion.extent.height = 1; |
| 7838 | copyRegion.extent.depth = 1; |
| 7839 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 7840 | m_errorMonitor->VerifyFound(); |
| 7841 | // Now cause error due to src image layout changing |
| 7842 | m_errorMonitor->SetDesiredFailureMsg( |
| 7843 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7844 | "Cannot copy from an image whose source layout is VK_IMAGE_LAYOUT_UNDEFINED and doesn't match the current layout VK_IMAGE_LAYOUT_GENERAL."); |
| 7845 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_UNDEFINED, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 7846 | m_errorMonitor->VerifyFound(); |
| 7847 | // Final src error is due to bad layout type |
| 7848 | m_errorMonitor->SetDesiredFailureMsg( |
| 7849 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7850 | "Layout for input image is VK_IMAGE_LAYOUT_UNDEFINED but can only be TRANSFER_SRC_OPTIMAL or GENERAL."); |
| 7851 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_UNDEFINED, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 7852 | m_errorMonitor->VerifyFound(); |
| 7853 | // Now verify same checks for dst |
| 7854 | m_errorMonitor->SetDesiredFailureMsg( |
| 7855 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 7856 | "Layout for output image should be TRANSFER_DST_OPTIMAL instead of GENERAL."); |
| 7857 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 7858 | m_errorMonitor->VerifyFound(); |
| 7859 | // Now cause error due to src image layout changing |
| 7860 | m_errorMonitor->SetDesiredFailureMsg( |
| 7861 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7862 | "Cannot copy from an image whose dest layout is VK_IMAGE_LAYOUT_UNDEFINED and doesn't match the current layout VK_IMAGE_LAYOUT_GENERAL."); |
| 7863 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_UNDEFINED, 1, ©Region); |
| 7864 | m_errorMonitor->VerifyFound(); |
| 7865 | m_errorMonitor->SetDesiredFailureMsg( |
| 7866 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7867 | "Layout for output image is VK_IMAGE_LAYOUT_UNDEFINED but can only be TRANSFER_DST_OPTIMAL or GENERAL."); |
| 7868 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_UNDEFINED, 1, ©Region); |
| 7869 | m_errorMonitor->VerifyFound(); |
| 7870 | // Now cause error due to bad image layout transition in PipelineBarrier |
| 7871 | VkImageMemoryBarrier image_barrier[1] = {}; |
| 7872 | image_barrier[0].oldLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; |
| 7873 | image_barrier[0].image = src_image; |
| 7874 | image_barrier[0].subresourceRange.layerCount = 2; |
| 7875 | image_barrier[0].subresourceRange.levelCount = 2; |
| 7876 | image_barrier[0].subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 7877 | m_errorMonitor->SetDesiredFailureMsg( |
| 7878 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7879 | "You cannot transition the layout from VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL when current layout is VK_IMAGE_LAYOUT_GENERAL."); |
| 7880 | vkCmdPipelineBarrier(m_commandBuffer->handle(), VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, NULL, 0, NULL, 1, image_barrier); |
| 7881 | m_errorMonitor->VerifyFound(); |
| 7882 | |
| 7883 | // Finally some layout errors at RenderPass create time |
| 7884 | // Just hacking in specific state to get to the errors we want so don't copy this unless you know what you're doing. |
| 7885 | VkAttachmentReference attach = {}; |
| 7886 | // perf warning for GENERAL layout w/ non-DS input attachment |
| 7887 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 7888 | VkSubpassDescription subpass = {}; |
| 7889 | subpass.inputAttachmentCount = 1; |
| 7890 | subpass.pInputAttachments = &attach; |
| 7891 | VkRenderPassCreateInfo rpci = {}; |
| 7892 | rpci.subpassCount = 1; |
| 7893 | rpci.pSubpasses = &subpass; |
| 7894 | rpci.attachmentCount = 1; |
| 7895 | VkAttachmentDescription attach_desc = {}; |
| 7896 | attach_desc.format = VK_FORMAT_UNDEFINED; |
| 7897 | rpci.pAttachments = &attach_desc; |
Tobin Ehlis | 1efce02 | 2016-05-11 10:40:34 -0600 | [diff] [blame] | 7898 | rpci.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; |
Tobin Ehlis | c555a3c | 2016-05-04 14:08:34 -0600 | [diff] [blame] | 7899 | VkRenderPass rp; |
| 7900 | m_errorMonitor->SetDesiredFailureMsg( |
| 7901 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 7902 | "Layout for input attachment is GENERAL but should be READ_ONLY_OPTIMAL."); |
| 7903 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 7904 | m_errorMonitor->VerifyFound(); |
| 7905 | // error w/ non-general layout |
| 7906 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; |
| 7907 | |
| 7908 | m_errorMonitor->SetDesiredFailureMsg( |
| 7909 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7910 | "Layout for input attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be READ_ONLY_OPTIMAL or GENERAL."); |
| 7911 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 7912 | m_errorMonitor->VerifyFound(); |
| 7913 | subpass.inputAttachmentCount = 0; |
| 7914 | subpass.colorAttachmentCount = 1; |
| 7915 | subpass.pColorAttachments = &attach; |
| 7916 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 7917 | // perf warning for GENERAL layout on color attachment |
| 7918 | m_errorMonitor->SetDesiredFailureMsg( |
| 7919 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 7920 | "Layout for color attachment is GENERAL but should be COLOR_ATTACHMENT_OPTIMAL."); |
| 7921 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 7922 | m_errorMonitor->VerifyFound(); |
| 7923 | // error w/ non-color opt or GENERAL layout for color attachment |
| 7924 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; |
| 7925 | m_errorMonitor->SetDesiredFailureMsg( |
| 7926 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7927 | "Layout for color attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be COLOR_ATTACHMENT_OPTIMAL or GENERAL."); |
| 7928 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 7929 | m_errorMonitor->VerifyFound(); |
| 7930 | subpass.colorAttachmentCount = 0; |
| 7931 | subpass.pDepthStencilAttachment = &attach; |
| 7932 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 7933 | // perf warning for GENERAL layout on DS attachment |
| 7934 | m_errorMonitor->SetDesiredFailureMsg( |
| 7935 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 7936 | "Layout for depth attachment is GENERAL but should be DEPTH_STENCIL_ATTACHMENT_OPTIMAL."); |
| 7937 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 7938 | m_errorMonitor->VerifyFound(); |
| 7939 | // error w/ non-ds opt or GENERAL layout for color attachment |
| 7940 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; |
| 7941 | m_errorMonitor->SetDesiredFailureMsg( |
| 7942 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7943 | "Layout for depth attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be DEPTH_STENCIL_ATTACHMENT_OPTIMAL or GENERAL."); |
| 7944 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 7945 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 1efce02 | 2016-05-11 10:40:34 -0600 | [diff] [blame] | 7946 | // For this error we need a valid renderpass so create default one |
| 7947 | attach.layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; |
| 7948 | attach.attachment = 0; |
| 7949 | attach_desc.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 7950 | attach_desc.samples = VK_SAMPLE_COUNT_1_BIT; |
| 7951 | attach_desc.storeOp = VK_ATTACHMENT_STORE_OP_STORE; |
| 7952 | attach_desc.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; |
| 7953 | attach_desc.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; |
| 7954 | // Can't do a CLEAR load on READ_ONLY initialLayout |
| 7955 | attach_desc.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; |
| 7956 | attach_desc.initialLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; |
| 7957 | attach_desc.finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 7958 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7959 | " with invalid first layout " |
| 7960 | "VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_" |
| 7961 | "ONLY_OPTIMAL"); |
| 7962 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 7963 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | c555a3c | 2016-05-04 14:08:34 -0600 | [diff] [blame] | 7964 | |
| 7965 | vkDestroyImage(m_device->device(), src_image, NULL); |
| 7966 | vkDestroyImage(m_device->device(), dst_image, NULL); |
| 7967 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 7968 | #endif // DRAW_STATE_TESTS |
| 7969 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 7970 | #if THREADING_TESTS |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 7971 | #if GTEST_IS_THREADSAFE |
| 7972 | struct thread_data_struct { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7973 | VkCommandBuffer commandBuffer; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 7974 | VkEvent event; |
| 7975 | bool bailout; |
| 7976 | }; |
| 7977 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7978 | extern "C" void *AddToCommandBuffer(void *arg) { |
| 7979 | struct thread_data_struct *data = (struct thread_data_struct *)arg; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 7980 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7981 | for (int i = 0; i < 10000; i++) { |
| 7982 | vkCmdSetEvent(data->commandBuffer, data->event, |
| 7983 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 7984 | if (data->bailout) { |
| 7985 | break; |
| 7986 | } |
| 7987 | } |
| 7988 | return NULL; |
| 7989 | } |
| 7990 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7991 | TEST_F(VkLayerTest, ThreadCommandBufferCollision) { |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 7992 | test_platform_thread thread; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 7993 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7994 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7995 | "THREADING ERROR"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7996 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 7997 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7998 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 7999 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8000 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8001 | // Calls AllocateCommandBuffers |
| 8002 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 8003 | |
| 8004 | // Avoid creating RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8005 | commandBuffer.BeginCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8006 | |
| 8007 | VkEventCreateInfo event_info; |
| 8008 | VkEvent event; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8009 | VkResult err; |
| 8010 | |
| 8011 | memset(&event_info, 0, sizeof(event_info)); |
| 8012 | event_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 8013 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8014 | err = vkCreateEvent(device(), &event_info, NULL, &event); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8015 | ASSERT_VK_SUCCESS(err); |
| 8016 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8017 | err = vkResetEvent(device(), event); |
| 8018 | ASSERT_VK_SUCCESS(err); |
| 8019 | |
| 8020 | struct thread_data_struct data; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8021 | data.commandBuffer = commandBuffer.GetBufferHandle(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8022 | data.event = event; |
| 8023 | data.bailout = false; |
| 8024 | m_errorMonitor->SetBailout(&data.bailout); |
| 8025 | // Add many entries to command buffer from another thread. |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 8026 | test_platform_thread_create(&thread, AddToCommandBuffer, (void *)&data); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8027 | // Add many entries to command buffer from this thread at the same time. |
| 8028 | AddToCommandBuffer(&data); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 8029 | |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 8030 | test_platform_thread_join(thread, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8031 | commandBuffer.EndCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8032 | |
Mike Stroyan | 10b8cb7 | 2016-01-22 15:22:03 -0700 | [diff] [blame] | 8033 | m_errorMonitor->SetBailout(NULL); |
| 8034 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8035 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8036 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8037 | vkDestroyEvent(device(), event, NULL); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8038 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 8039 | #endif // GTEST_IS_THREADSAFE |
| 8040 | #endif // THREADING_TESTS |
| 8041 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8042 | #if SHADER_CHECKER_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8043 | TEST_F(VkLayerTest, InvalidSPIRVCodeSize) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8044 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 8045 | "Invalid SPIR-V header"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8046 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8047 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8048 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8049 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8050 | VkShaderModule module; |
| 8051 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 8052 | struct icd_spv_header spv; |
| 8053 | |
| 8054 | spv.magic = ICD_SPV_MAGIC; |
| 8055 | spv.version = ICD_SPV_VERSION; |
| 8056 | spv.gen_magic = 0; |
| 8057 | |
| 8058 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 8059 | moduleCreateInfo.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8060 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8061 | moduleCreateInfo.codeSize = 4; |
| 8062 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8063 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8064 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8065 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8066 | } |
| 8067 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8068 | TEST_F(VkLayerTest, InvalidSPIRVMagic) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8069 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 8070 | "Invalid SPIR-V magic number"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8071 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8072 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8073 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8074 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8075 | VkShaderModule module; |
| 8076 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 8077 | struct icd_spv_header spv; |
| 8078 | |
| 8079 | spv.magic = ~ICD_SPV_MAGIC; |
| 8080 | spv.version = ICD_SPV_VERSION; |
| 8081 | spv.gen_magic = 0; |
| 8082 | |
| 8083 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 8084 | moduleCreateInfo.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8085 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8086 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 8087 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8088 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8089 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8090 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8091 | } |
| 8092 | |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 8093 | #if 0 |
| 8094 | // Not currently covered by SPIRV-Tools validator |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8095 | TEST_F(VkLayerTest, InvalidSPIRVVersion) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8096 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 8097 | "Invalid SPIR-V header"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8098 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8099 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8100 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8101 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8102 | VkShaderModule module; |
| 8103 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 8104 | struct icd_spv_header spv; |
| 8105 | |
| 8106 | spv.magic = ICD_SPV_MAGIC; |
| 8107 | spv.version = ~ICD_SPV_VERSION; |
| 8108 | spv.gen_magic = 0; |
| 8109 | |
| 8110 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 8111 | moduleCreateInfo.pNext = NULL; |
| 8112 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8113 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8114 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 8115 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8116 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8117 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8118 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8119 | } |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 8120 | #endif |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8121 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8122 | TEST_F(VkLayerTest, CreatePipelineVertexOutputNotConsumed) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 8123 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8124 | "not consumed by fragment shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8125 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8126 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 8127 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8128 | |
| 8129 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8130 | "#version 450\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8131 | "\n" |
| 8132 | "layout(location=0) out float x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8133 | "out gl_PerVertex {\n" |
| 8134 | " vec4 gl_Position;\n" |
| 8135 | "};\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8136 | "void main(){\n" |
| 8137 | " gl_Position = vec4(1);\n" |
| 8138 | " x = 0;\n" |
| 8139 | "}\n"; |
| 8140 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8141 | "#version 450\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8142 | "\n" |
| 8143 | "layout(location=0) out vec4 color;\n" |
| 8144 | "void main(){\n" |
| 8145 | " color = vec4(1);\n" |
| 8146 | "}\n"; |
| 8147 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8148 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8149 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8150 | |
| 8151 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 8152 | pipe.AddColorAttachment(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8153 | pipe.AddShader(&vs); |
| 8154 | pipe.AddShader(&fs); |
| 8155 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8156 | VkDescriptorSetObj descriptorSet(m_device); |
| 8157 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8158 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8159 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 8160 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8161 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8162 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8163 | } |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8164 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8165 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvided) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8166 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8167 | "not written by vertex shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8168 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8169 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 8170 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8171 | |
| 8172 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8173 | "#version 450\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8174 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8175 | "out gl_PerVertex {\n" |
| 8176 | " vec4 gl_Position;\n" |
| 8177 | "};\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8178 | "void main(){\n" |
| 8179 | " gl_Position = vec4(1);\n" |
| 8180 | "}\n"; |
| 8181 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8182 | "#version 450\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8183 | "\n" |
| 8184 | "layout(location=0) in float x;\n" |
| 8185 | "layout(location=0) out vec4 color;\n" |
| 8186 | "void main(){\n" |
| 8187 | " color = vec4(x);\n" |
| 8188 | "}\n"; |
| 8189 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8190 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8191 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8192 | |
| 8193 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 8194 | pipe.AddColorAttachment(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8195 | pipe.AddShader(&vs); |
| 8196 | pipe.AddShader(&fs); |
| 8197 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8198 | VkDescriptorSetObj descriptorSet(m_device); |
| 8199 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8200 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8201 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 8202 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8203 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8204 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8205 | } |
| 8206 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8207 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvidedInBlock) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8208 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8209 | "not written by vertex shader"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8210 | |
| 8211 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8212 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8213 | |
| 8214 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8215 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8216 | "\n" |
| 8217 | "out gl_PerVertex {\n" |
| 8218 | " vec4 gl_Position;\n" |
| 8219 | "};\n" |
| 8220 | "void main(){\n" |
| 8221 | " gl_Position = vec4(1);\n" |
| 8222 | "}\n"; |
| 8223 | char const *fsSource = |
| 8224 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8225 | "\n" |
| 8226 | "in block { layout(location=0) float x; } ins;\n" |
| 8227 | "layout(location=0) out vec4 color;\n" |
| 8228 | "void main(){\n" |
| 8229 | " color = vec4(ins.x);\n" |
| 8230 | "}\n"; |
| 8231 | |
| 8232 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8233 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8234 | |
| 8235 | VkPipelineObj pipe(m_device); |
| 8236 | pipe.AddColorAttachment(); |
| 8237 | pipe.AddShader(&vs); |
| 8238 | pipe.AddShader(&fs); |
| 8239 | |
| 8240 | VkDescriptorSetObj descriptorSet(m_device); |
| 8241 | descriptorSet.AppendDummy(); |
| 8242 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8243 | |
| 8244 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8245 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8246 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8247 | } |
| 8248 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8249 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchArraySize) { |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 8250 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 8251 | "Type mismatch on location 0.0: 'ptr to " |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8252 | "output arr[2] of float32' vs 'ptr to " |
| 8253 | "input arr[3] of float32'"); |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 8254 | |
| 8255 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8256 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8257 | |
| 8258 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8259 | "#version 450\n" |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 8260 | "\n" |
| 8261 | "layout(location=0) out float x[2];\n" |
| 8262 | "out gl_PerVertex {\n" |
| 8263 | " vec4 gl_Position;\n" |
| 8264 | "};\n" |
| 8265 | "void main(){\n" |
| 8266 | " x[0] = 0; x[1] = 0;\n" |
| 8267 | " gl_Position = vec4(1);\n" |
| 8268 | "}\n"; |
| 8269 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8270 | "#version 450\n" |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 8271 | "\n" |
| 8272 | "layout(location=0) in float x[3];\n" |
| 8273 | "layout(location=0) out vec4 color;\n" |
| 8274 | "void main(){\n" |
| 8275 | " color = vec4(x[0] + x[1] + x[2]);\n" |
| 8276 | "}\n"; |
| 8277 | |
| 8278 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8279 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8280 | |
| 8281 | VkPipelineObj pipe(m_device); |
| 8282 | pipe.AddColorAttachment(); |
| 8283 | pipe.AddShader(&vs); |
| 8284 | pipe.AddShader(&fs); |
| 8285 | |
| 8286 | VkDescriptorSetObj descriptorSet(m_device); |
| 8287 | descriptorSet.AppendDummy(); |
| 8288 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8289 | |
| 8290 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8291 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8292 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 8293 | } |
| 8294 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8295 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatch) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8296 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8297 | "Type mismatch on location 0"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8298 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8299 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 8300 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8301 | |
| 8302 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8303 | "#version 450\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8304 | "\n" |
| 8305 | "layout(location=0) out int x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8306 | "out gl_PerVertex {\n" |
| 8307 | " vec4 gl_Position;\n" |
| 8308 | "};\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8309 | "void main(){\n" |
| 8310 | " x = 0;\n" |
| 8311 | " gl_Position = vec4(1);\n" |
| 8312 | "}\n"; |
| 8313 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8314 | "#version 450\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8315 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8316 | "layout(location=0) in float x;\n" /* VS writes int */ |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8317 | "layout(location=0) out vec4 color;\n" |
| 8318 | "void main(){\n" |
| 8319 | " color = vec4(x);\n" |
| 8320 | "}\n"; |
| 8321 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8322 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8323 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8324 | |
| 8325 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 8326 | pipe.AddColorAttachment(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8327 | pipe.AddShader(&vs); |
| 8328 | pipe.AddShader(&fs); |
| 8329 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8330 | VkDescriptorSetObj descriptorSet(m_device); |
| 8331 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8332 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8333 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 8334 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8335 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8336 | m_errorMonitor->VerifyFound(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8337 | } |
| 8338 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8339 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchInBlock) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8340 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8341 | "Type mismatch on location 0"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8342 | |
| 8343 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8344 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8345 | |
| 8346 | char const *vsSource = |
| 8347 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8348 | "\n" |
| 8349 | "out block { layout(location=0) int x; } outs;\n" |
| 8350 | "out gl_PerVertex {\n" |
| 8351 | " vec4 gl_Position;\n" |
| 8352 | "};\n" |
| 8353 | "void main(){\n" |
| 8354 | " outs.x = 0;\n" |
| 8355 | " gl_Position = vec4(1);\n" |
| 8356 | "}\n"; |
| 8357 | char const *fsSource = |
| 8358 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8359 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8360 | "in block { layout(location=0) float x; } ins;\n" /* VS writes int */ |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8361 | "layout(location=0) out vec4 color;\n" |
| 8362 | "void main(){\n" |
| 8363 | " color = vec4(ins.x);\n" |
| 8364 | "}\n"; |
| 8365 | |
| 8366 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8367 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8368 | |
| 8369 | VkPipelineObj pipe(m_device); |
| 8370 | pipe.AddColorAttachment(); |
| 8371 | pipe.AddShader(&vs); |
| 8372 | pipe.AddShader(&fs); |
| 8373 | |
| 8374 | VkDescriptorSetObj descriptorSet(m_device); |
| 8375 | descriptorSet.AppendDummy(); |
| 8376 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8377 | |
| 8378 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8379 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8380 | m_errorMonitor->VerifyFound(); |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 8381 | } |
| 8382 | |
| 8383 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByLocation) { |
| 8384 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8385 | "location 0.0 which is not written by vertex shader"); |
| 8386 | |
| 8387 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8388 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8389 | |
| 8390 | char const *vsSource = |
| 8391 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 8392 | "\n" |
| 8393 | "out block { layout(location=1) float x; } outs;\n" |
| 8394 | "out gl_PerVertex {\n" |
| 8395 | " vec4 gl_Position;\n" |
| 8396 | "};\n" |
| 8397 | "void main(){\n" |
| 8398 | " outs.x = 0;\n" |
| 8399 | " gl_Position = vec4(1);\n" |
| 8400 | "}\n"; |
| 8401 | char const *fsSource = |
| 8402 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 8403 | "\n" |
| 8404 | "in block { layout(location=0) float x; } ins;\n" |
| 8405 | "layout(location=0) out vec4 color;\n" |
| 8406 | "void main(){\n" |
| 8407 | " color = vec4(ins.x);\n" |
| 8408 | "}\n"; |
| 8409 | |
| 8410 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8411 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8412 | |
| 8413 | VkPipelineObj pipe(m_device); |
| 8414 | pipe.AddColorAttachment(); |
| 8415 | pipe.AddShader(&vs); |
| 8416 | pipe.AddShader(&fs); |
| 8417 | |
| 8418 | VkDescriptorSetObj descriptorSet(m_device); |
| 8419 | descriptorSet.AppendDummy(); |
| 8420 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8421 | |
| 8422 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8423 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8424 | m_errorMonitor->VerifyFound(); |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 8425 | } |
| 8426 | |
| 8427 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByComponent) { |
| 8428 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8429 | "location 0.1 which is not written by vertex shader"); |
| 8430 | |
| 8431 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8432 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8433 | |
| 8434 | char const *vsSource = |
| 8435 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 8436 | "\n" |
| 8437 | "out block { layout(location=0, component=0) float x; } outs;\n" |
| 8438 | "out gl_PerVertex {\n" |
| 8439 | " vec4 gl_Position;\n" |
| 8440 | "};\n" |
| 8441 | "void main(){\n" |
| 8442 | " outs.x = 0;\n" |
| 8443 | " gl_Position = vec4(1);\n" |
| 8444 | "}\n"; |
| 8445 | char const *fsSource = |
| 8446 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 8447 | "\n" |
| 8448 | "in block { layout(location=0, component=1) float x; } ins;\n" |
| 8449 | "layout(location=0) out vec4 color;\n" |
| 8450 | "void main(){\n" |
| 8451 | " color = vec4(ins.x);\n" |
| 8452 | "}\n"; |
| 8453 | |
| 8454 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8455 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8456 | |
| 8457 | VkPipelineObj pipe(m_device); |
| 8458 | pipe.AddColorAttachment(); |
| 8459 | pipe.AddShader(&vs); |
| 8460 | pipe.AddShader(&fs); |
| 8461 | |
| 8462 | VkDescriptorSetObj descriptorSet(m_device); |
| 8463 | descriptorSet.AppendDummy(); |
| 8464 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8465 | |
| 8466 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8467 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8468 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8469 | } |
| 8470 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8471 | TEST_F(VkLayerTest, CreatePipelineAttribNotConsumed) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 8472 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8473 | "location 0 not consumed by VS"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8474 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8475 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 8476 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8477 | |
| 8478 | VkVertexInputBindingDescription input_binding; |
| 8479 | memset(&input_binding, 0, sizeof(input_binding)); |
| 8480 | |
| 8481 | VkVertexInputAttributeDescription input_attrib; |
| 8482 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 8483 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 8484 | |
| 8485 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8486 | "#version 450\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8487 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8488 | "out gl_PerVertex {\n" |
| 8489 | " vec4 gl_Position;\n" |
| 8490 | "};\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8491 | "void main(){\n" |
| 8492 | " gl_Position = vec4(1);\n" |
| 8493 | "}\n"; |
| 8494 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8495 | "#version 450\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8496 | "\n" |
| 8497 | "layout(location=0) out vec4 color;\n" |
| 8498 | "void main(){\n" |
| 8499 | " color = vec4(1);\n" |
| 8500 | "}\n"; |
| 8501 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8502 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8503 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8504 | |
| 8505 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 8506 | pipe.AddColorAttachment(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8507 | pipe.AddShader(&vs); |
| 8508 | pipe.AddShader(&fs); |
| 8509 | |
| 8510 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 8511 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 8512 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8513 | VkDescriptorSetObj descriptorSet(m_device); |
| 8514 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8515 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8516 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 8517 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8518 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8519 | m_errorMonitor->VerifyFound(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8520 | } |
| 8521 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8522 | TEST_F(VkLayerTest, CreatePipelineAttribLocationMismatch) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 8523 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8524 | "location 0 not consumed by VS"); |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 8525 | |
| 8526 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8527 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8528 | |
| 8529 | VkVertexInputBindingDescription input_binding; |
| 8530 | memset(&input_binding, 0, sizeof(input_binding)); |
| 8531 | |
| 8532 | VkVertexInputAttributeDescription input_attrib; |
| 8533 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 8534 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 8535 | |
| 8536 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8537 | "#version 450\n" |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 8538 | "\n" |
| 8539 | "layout(location=1) in float x;\n" |
| 8540 | "out gl_PerVertex {\n" |
| 8541 | " vec4 gl_Position;\n" |
| 8542 | "};\n" |
| 8543 | "void main(){\n" |
| 8544 | " gl_Position = vec4(x);\n" |
| 8545 | "}\n"; |
| 8546 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8547 | "#version 450\n" |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 8548 | "\n" |
| 8549 | "layout(location=0) out vec4 color;\n" |
| 8550 | "void main(){\n" |
| 8551 | " color = vec4(1);\n" |
| 8552 | "}\n"; |
| 8553 | |
| 8554 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8555 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8556 | |
| 8557 | VkPipelineObj pipe(m_device); |
| 8558 | pipe.AddColorAttachment(); |
| 8559 | pipe.AddShader(&vs); |
| 8560 | pipe.AddShader(&fs); |
| 8561 | |
| 8562 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 8563 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 8564 | |
| 8565 | VkDescriptorSetObj descriptorSet(m_device); |
| 8566 | descriptorSet.AppendDummy(); |
| 8567 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8568 | |
| 8569 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8570 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8571 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 8572 | } |
| 8573 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8574 | TEST_F(VkLayerTest, CreatePipelineAttribNotProvided) { |
| 8575 | m_errorMonitor->SetDesiredFailureMsg( |
| 8576 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8577 | "VS consumes input at location 0 but not provided"); |
| 8578 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8579 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 8580 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8581 | |
| 8582 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8583 | "#version 450\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8584 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8585 | "layout(location=0) in vec4 x;\n" /* not provided */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8586 | "out gl_PerVertex {\n" |
| 8587 | " vec4 gl_Position;\n" |
| 8588 | "};\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8589 | "void main(){\n" |
| 8590 | " gl_Position = x;\n" |
| 8591 | "}\n"; |
| 8592 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8593 | "#version 450\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8594 | "\n" |
| 8595 | "layout(location=0) out vec4 color;\n" |
| 8596 | "void main(){\n" |
| 8597 | " color = vec4(1);\n" |
| 8598 | "}\n"; |
| 8599 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8600 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8601 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8602 | |
| 8603 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 8604 | pipe.AddColorAttachment(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8605 | pipe.AddShader(&vs); |
| 8606 | pipe.AddShader(&fs); |
| 8607 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8608 | VkDescriptorSetObj descriptorSet(m_device); |
| 8609 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8610 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8611 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 8612 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8613 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8614 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8615 | } |
| 8616 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8617 | TEST_F(VkLayerTest, CreatePipelineAttribTypeMismatch) { |
| 8618 | m_errorMonitor->SetDesiredFailureMsg( |
| 8619 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8620 | "location 0 does not match VS input type"); |
| 8621 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 8622 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 8623 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 8624 | |
| 8625 | VkVertexInputBindingDescription input_binding; |
| 8626 | memset(&input_binding, 0, sizeof(input_binding)); |
| 8627 | |
| 8628 | VkVertexInputAttributeDescription input_attrib; |
| 8629 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 8630 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 8631 | |
| 8632 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8633 | "#version 450\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 8634 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8635 | "layout(location=0) in int x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8636 | "out gl_PerVertex {\n" |
| 8637 | " vec4 gl_Position;\n" |
| 8638 | "};\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 8639 | "void main(){\n" |
| 8640 | " gl_Position = vec4(x);\n" |
| 8641 | "}\n"; |
| 8642 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8643 | "#version 450\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 8644 | "\n" |
| 8645 | "layout(location=0) out vec4 color;\n" |
| 8646 | "void main(){\n" |
| 8647 | " color = vec4(1);\n" |
| 8648 | "}\n"; |
| 8649 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8650 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8651 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 8652 | |
| 8653 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 8654 | pipe.AddColorAttachment(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 8655 | pipe.AddShader(&vs); |
| 8656 | pipe.AddShader(&fs); |
| 8657 | |
| 8658 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 8659 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 8660 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 8661 | VkDescriptorSetObj descriptorSet(m_device); |
| 8662 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8663 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 8664 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 8665 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 8666 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8667 | m_errorMonitor->VerifyFound(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 8668 | } |
| 8669 | |
Chris Forbes | c68b43c | 2016-04-06 11:18:47 +1200 | [diff] [blame] | 8670 | TEST_F(VkLayerTest, CreatePipelineDuplicateStage) { |
| 8671 | m_errorMonitor->SetDesiredFailureMsg( |
| 8672 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8673 | "Multiple shaders provided for stage VK_SHADER_STAGE_VERTEX_BIT"); |
| 8674 | |
| 8675 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8676 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8677 | |
| 8678 | char const *vsSource = |
| 8679 | "#version 450\n" |
| 8680 | "\n" |
| 8681 | "out gl_PerVertex {\n" |
| 8682 | " vec4 gl_Position;\n" |
| 8683 | "};\n" |
| 8684 | "void main(){\n" |
| 8685 | " gl_Position = vec4(1);\n" |
| 8686 | "}\n"; |
| 8687 | char const *fsSource = |
| 8688 | "#version 450\n" |
| 8689 | "\n" |
| 8690 | "layout(location=0) out vec4 color;\n" |
| 8691 | "void main(){\n" |
| 8692 | " color = vec4(1);\n" |
| 8693 | "}\n"; |
| 8694 | |
| 8695 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8696 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8697 | |
| 8698 | VkPipelineObj pipe(m_device); |
| 8699 | pipe.AddColorAttachment(); |
| 8700 | pipe.AddShader(&vs); |
| 8701 | pipe.AddShader(&vs); |
| 8702 | pipe.AddShader(&fs); |
| 8703 | |
| 8704 | VkDescriptorSetObj descriptorSet(m_device); |
| 8705 | descriptorSet.AppendDummy(); |
| 8706 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8707 | |
| 8708 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8709 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8710 | m_errorMonitor->VerifyFound(); |
Chris Forbes | c68b43c | 2016-04-06 11:18:47 +1200 | [diff] [blame] | 8711 | } |
| 8712 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8713 | TEST_F(VkLayerTest, CreatePipelineAttribMatrixType) { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8714 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 8715 | |
| 8716 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8717 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8718 | |
| 8719 | VkVertexInputBindingDescription input_binding; |
| 8720 | memset(&input_binding, 0, sizeof(input_binding)); |
| 8721 | |
| 8722 | VkVertexInputAttributeDescription input_attribs[2]; |
| 8723 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 8724 | |
| 8725 | for (int i = 0; i < 2; i++) { |
| 8726 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 8727 | input_attribs[i].location = i; |
| 8728 | } |
| 8729 | |
| 8730 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8731 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 8732 | "\n" |
| 8733 | "layout(location=0) in mat2x4 x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8734 | "out gl_PerVertex {\n" |
| 8735 | " vec4 gl_Position;\n" |
| 8736 | "};\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 8737 | "void main(){\n" |
| 8738 | " gl_Position = x[0] + x[1];\n" |
| 8739 | "}\n"; |
| 8740 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8741 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 8742 | "\n" |
| 8743 | "layout(location=0) out vec4 color;\n" |
| 8744 | "void main(){\n" |
| 8745 | " color = vec4(1);\n" |
| 8746 | "}\n"; |
| 8747 | |
| 8748 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8749 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8750 | |
| 8751 | VkPipelineObj pipe(m_device); |
| 8752 | pipe.AddColorAttachment(); |
| 8753 | pipe.AddShader(&vs); |
| 8754 | pipe.AddShader(&fs); |
| 8755 | |
| 8756 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 8757 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 8758 | |
| 8759 | VkDescriptorSetObj descriptorSet(m_device); |
| 8760 | descriptorSet.AppendDummy(); |
| 8761 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8762 | |
| 8763 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8764 | |
| 8765 | /* expect success */ |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8766 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 8767 | } |
| 8768 | |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 8769 | TEST_F(VkLayerTest, CreatePipelineAttribArrayType) |
| 8770 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8771 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 8772 | |
| 8773 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8774 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8775 | |
| 8776 | VkVertexInputBindingDescription input_binding; |
| 8777 | memset(&input_binding, 0, sizeof(input_binding)); |
| 8778 | |
| 8779 | VkVertexInputAttributeDescription input_attribs[2]; |
| 8780 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 8781 | |
| 8782 | for (int i = 0; i < 2; i++) { |
| 8783 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 8784 | input_attribs[i].location = i; |
| 8785 | } |
| 8786 | |
| 8787 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8788 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 8789 | "\n" |
| 8790 | "layout(location=0) in vec4 x[2];\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8791 | "out gl_PerVertex {\n" |
| 8792 | " vec4 gl_Position;\n" |
| 8793 | "};\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 8794 | "void main(){\n" |
| 8795 | " gl_Position = x[0] + x[1];\n" |
| 8796 | "}\n"; |
| 8797 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8798 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 8799 | "\n" |
| 8800 | "layout(location=0) out vec4 color;\n" |
| 8801 | "void main(){\n" |
| 8802 | " color = vec4(1);\n" |
| 8803 | "}\n"; |
| 8804 | |
| 8805 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8806 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8807 | |
| 8808 | VkPipelineObj pipe(m_device); |
| 8809 | pipe.AddColorAttachment(); |
| 8810 | pipe.AddShader(&vs); |
| 8811 | pipe.AddShader(&fs); |
| 8812 | |
| 8813 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 8814 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 8815 | |
| 8816 | VkDescriptorSetObj descriptorSet(m_device); |
| 8817 | descriptorSet.AppendDummy(); |
| 8818 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8819 | |
| 8820 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8821 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8822 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 8823 | } |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 8824 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 8825 | TEST_F(VkLayerTest, CreatePipelineSimplePositive) |
| 8826 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8827 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 8828 | |
| 8829 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8830 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8831 | |
| 8832 | char const *vsSource = |
| 8833 | "#version 450\n" |
| 8834 | "out gl_PerVertex {\n" |
| 8835 | " vec4 gl_Position;\n" |
| 8836 | "};\n" |
| 8837 | "void main(){\n" |
| 8838 | " gl_Position = vec4(0);\n" |
| 8839 | "}\n"; |
| 8840 | char const *fsSource = |
| 8841 | "#version 450\n" |
| 8842 | "\n" |
| 8843 | "layout(location=0) out vec4 color;\n" |
| 8844 | "void main(){\n" |
| 8845 | " color = vec4(1);\n" |
| 8846 | "}\n"; |
| 8847 | |
| 8848 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8849 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8850 | |
| 8851 | VkPipelineObj pipe(m_device); |
| 8852 | pipe.AddColorAttachment(); |
| 8853 | pipe.AddShader(&vs); |
| 8854 | pipe.AddShader(&fs); |
| 8855 | |
| 8856 | VkDescriptorSetObj descriptorSet(m_device); |
| 8857 | descriptorSet.AppendDummy(); |
| 8858 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8859 | |
| 8860 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8861 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8862 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 8863 | } |
| 8864 | |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 8865 | TEST_F(VkLayerTest, CreatePipelineRelaxedTypeMatch) |
| 8866 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8867 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 8868 | |
| 8869 | // VK 1.0.8 Specification, 14.1.3 "Additionally,..." block |
| 8870 | |
| 8871 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8872 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8873 | |
| 8874 | char const *vsSource = |
| 8875 | "#version 450\n" |
| 8876 | "out gl_PerVertex {\n" |
| 8877 | " vec4 gl_Position;\n" |
| 8878 | "};\n" |
| 8879 | "layout(location=0) out vec3 x;\n" |
| 8880 | "layout(location=1) out ivec3 y;\n" |
| 8881 | "layout(location=2) out vec3 z;\n" |
| 8882 | "void main(){\n" |
| 8883 | " gl_Position = vec4(0);\n" |
| 8884 | " x = vec3(0); y = ivec3(0); z = vec3(0);\n" |
| 8885 | "}\n"; |
| 8886 | char const *fsSource = |
| 8887 | "#version 450\n" |
| 8888 | "\n" |
| 8889 | "layout(location=0) out vec4 color;\n" |
| 8890 | "layout(location=0) in float x;\n" |
| 8891 | "layout(location=1) flat in int y;\n" |
| 8892 | "layout(location=2) in vec2 z;\n" |
| 8893 | "void main(){\n" |
| 8894 | " color = vec4(1 + x + y + z.x);\n" |
| 8895 | "}\n"; |
| 8896 | |
| 8897 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8898 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8899 | |
| 8900 | VkPipelineObj pipe(m_device); |
| 8901 | pipe.AddColorAttachment(); |
| 8902 | pipe.AddShader(&vs); |
| 8903 | pipe.AddShader(&fs); |
| 8904 | |
| 8905 | VkDescriptorSetObj descriptorSet(m_device); |
| 8906 | descriptorSet.AppendDummy(); |
| 8907 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8908 | |
| 8909 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8910 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8911 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 8912 | } |
| 8913 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 8914 | TEST_F(VkLayerTest, CreatePipelineTessPerVertex) |
| 8915 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8916 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 8917 | |
| 8918 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8919 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8920 | |
Chris Forbes | c1e852d | 2016-04-04 19:26:42 +1200 | [diff] [blame] | 8921 | if (!m_device->phy().features().tessellationShader) { |
| 8922 | printf("Device does not support tessellation shaders; skipped.\n"); |
| 8923 | return; |
| 8924 | } |
| 8925 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 8926 | char const *vsSource = |
| 8927 | "#version 450\n" |
| 8928 | "void main(){}\n"; |
| 8929 | char const *tcsSource = |
| 8930 | "#version 450\n" |
| 8931 | "layout(location=0) out int x[];\n" |
| 8932 | "layout(vertices=3) out;\n" |
| 8933 | "void main(){\n" |
| 8934 | " gl_TessLevelOuter[0] = gl_TessLevelOuter[1] = gl_TessLevelOuter[2] = 1;\n" |
| 8935 | " gl_TessLevelInner[0] = 1;\n" |
| 8936 | " x[gl_InvocationID] = gl_InvocationID;\n" |
| 8937 | "}\n"; |
| 8938 | char const *tesSource = |
| 8939 | "#version 450\n" |
| 8940 | "layout(triangles, equal_spacing, cw) in;\n" |
| 8941 | "layout(location=0) in int x[];\n" |
| 8942 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 8943 | "void main(){\n" |
| 8944 | " gl_Position.xyz = gl_TessCoord;\n" |
| 8945 | " gl_Position.w = x[0] + x[1] + x[2];\n" |
| 8946 | "}\n"; |
| 8947 | char const *fsSource = |
| 8948 | "#version 450\n" |
| 8949 | "layout(location=0) out vec4 color;\n" |
| 8950 | "void main(){\n" |
| 8951 | " color = vec4(1);\n" |
| 8952 | "}\n"; |
| 8953 | |
| 8954 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8955 | VkShaderObj tcs(m_device, tcsSource, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 8956 | VkShaderObj tes(m_device, tesSource, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
| 8957 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8958 | |
| 8959 | VkPipelineInputAssemblyStateCreateInfo iasci{ |
| 8960 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, |
| 8961 | nullptr, |
| 8962 | 0, |
| 8963 | VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, |
| 8964 | VK_FALSE}; |
| 8965 | |
Chris Forbes | b4cacb6 | 2016-04-04 19:15:00 +1200 | [diff] [blame] | 8966 | VkPipelineTessellationStateCreateInfo tsci{ |
| 8967 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, |
| 8968 | nullptr, |
| 8969 | 0, |
| 8970 | 3}; |
| 8971 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 8972 | VkPipelineObj pipe(m_device); |
| 8973 | pipe.SetInputAssembly(&iasci); |
Chris Forbes | b4cacb6 | 2016-04-04 19:15:00 +1200 | [diff] [blame] | 8974 | pipe.SetTessellation(&tsci); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 8975 | pipe.AddColorAttachment(); |
| 8976 | pipe.AddShader(&vs); |
| 8977 | pipe.AddShader(&tcs); |
| 8978 | pipe.AddShader(&tes); |
| 8979 | pipe.AddShader(&fs); |
| 8980 | |
| 8981 | VkDescriptorSetObj descriptorSet(m_device); |
| 8982 | descriptorSet.AppendDummy(); |
| 8983 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8984 | |
| 8985 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8986 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8987 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 8988 | } |
| 8989 | |
Chris Forbes | a0ab815 | 2016-04-20 13:34:27 +1200 | [diff] [blame] | 8990 | TEST_F(VkLayerTest, CreatePipelineGeometryInputBlockPositive) |
| 8991 | { |
| 8992 | m_errorMonitor->ExpectSuccess(); |
| 8993 | |
| 8994 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8995 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8996 | |
| 8997 | if (!m_device->phy().features().geometryShader) { |
| 8998 | printf("Device does not support geometry shaders; skipped.\n"); |
| 8999 | return; |
| 9000 | } |
| 9001 | |
| 9002 | char const *vsSource = |
| 9003 | "#version 450\n" |
| 9004 | "layout(location=0) out VertexData { vec4 x; } vs_out;\n" |
| 9005 | "void main(){\n" |
| 9006 | " vs_out.x = vec4(1);\n" |
| 9007 | "}\n"; |
| 9008 | char const *gsSource = |
| 9009 | "#version 450\n" |
| 9010 | "layout(triangles) in;\n" |
| 9011 | "layout(triangle_strip, max_vertices=3) out;\n" |
| 9012 | "layout(location=0) in VertexData { vec4 x; } gs_in[];\n" |
| 9013 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 9014 | "void main() {\n" |
| 9015 | " gl_Position = gs_in[0].x;\n" |
| 9016 | " EmitVertex();\n" |
| 9017 | "}\n"; |
| 9018 | char const *fsSource = |
| 9019 | "#version 450\n" |
| 9020 | "layout(location=0) out vec4 color;\n" |
| 9021 | "void main(){\n" |
| 9022 | " color = vec4(1);\n" |
| 9023 | "}\n"; |
| 9024 | |
| 9025 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9026 | VkShaderObj gs(m_device, gsSource, VK_SHADER_STAGE_GEOMETRY_BIT, this); |
| 9027 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9028 | |
| 9029 | VkPipelineObj pipe(m_device); |
| 9030 | pipe.AddColorAttachment(); |
| 9031 | pipe.AddShader(&vs); |
| 9032 | pipe.AddShader(&gs); |
| 9033 | pipe.AddShader(&fs); |
| 9034 | |
| 9035 | VkDescriptorSetObj descriptorSet(m_device); |
| 9036 | descriptorSet.AppendDummy(); |
| 9037 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9038 | |
| 9039 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9040 | |
| 9041 | m_errorMonitor->VerifyNotFound(); |
| 9042 | } |
| 9043 | |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 9044 | TEST_F(VkLayerTest, CreatePipelineTessPatchDecorationMismatch) |
| 9045 | { |
| 9046 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9047 | "is per-vertex in tessellation control shader stage " |
| 9048 | "but per-patch in tessellation evaluation shader stage"); |
| 9049 | |
| 9050 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9051 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9052 | |
Chris Forbes | c1e852d | 2016-04-04 19:26:42 +1200 | [diff] [blame] | 9053 | if (!m_device->phy().features().tessellationShader) { |
| 9054 | printf("Device does not support tessellation shaders; skipped.\n"); |
| 9055 | return; |
| 9056 | } |
| 9057 | |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 9058 | char const *vsSource = |
| 9059 | "#version 450\n" |
| 9060 | "void main(){}\n"; |
| 9061 | char const *tcsSource = |
| 9062 | "#version 450\n" |
| 9063 | "layout(location=0) out int x[];\n" |
| 9064 | "layout(vertices=3) out;\n" |
| 9065 | "void main(){\n" |
| 9066 | " gl_TessLevelOuter[0] = gl_TessLevelOuter[1] = gl_TessLevelOuter[2] = 1;\n" |
| 9067 | " gl_TessLevelInner[0] = 1;\n" |
| 9068 | " x[gl_InvocationID] = gl_InvocationID;\n" |
| 9069 | "}\n"; |
| 9070 | char const *tesSource = |
| 9071 | "#version 450\n" |
| 9072 | "layout(triangles, equal_spacing, cw) in;\n" |
| 9073 | "layout(location=0) patch in int x;\n" |
| 9074 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 9075 | "void main(){\n" |
| 9076 | " gl_Position.xyz = gl_TessCoord;\n" |
| 9077 | " gl_Position.w = x;\n" |
| 9078 | "}\n"; |
| 9079 | char const *fsSource = |
| 9080 | "#version 450\n" |
| 9081 | "layout(location=0) out vec4 color;\n" |
| 9082 | "void main(){\n" |
| 9083 | " color = vec4(1);\n" |
| 9084 | "}\n"; |
| 9085 | |
| 9086 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9087 | VkShaderObj tcs(m_device, tcsSource, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 9088 | VkShaderObj tes(m_device, tesSource, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
| 9089 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9090 | |
| 9091 | VkPipelineInputAssemblyStateCreateInfo iasci{ |
| 9092 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, |
| 9093 | nullptr, |
| 9094 | 0, |
| 9095 | VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, |
| 9096 | VK_FALSE}; |
| 9097 | |
| 9098 | VkPipelineTessellationStateCreateInfo tsci{ |
| 9099 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, |
| 9100 | nullptr, |
| 9101 | 0, |
| 9102 | 3}; |
| 9103 | |
| 9104 | VkPipelineObj pipe(m_device); |
| 9105 | pipe.SetInputAssembly(&iasci); |
| 9106 | pipe.SetTessellation(&tsci); |
| 9107 | pipe.AddColorAttachment(); |
| 9108 | pipe.AddShader(&vs); |
| 9109 | pipe.AddShader(&tcs); |
| 9110 | pipe.AddShader(&tes); |
| 9111 | pipe.AddShader(&fs); |
| 9112 | |
| 9113 | VkDescriptorSetObj descriptorSet(m_device); |
| 9114 | descriptorSet.AppendDummy(); |
| 9115 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9116 | |
| 9117 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9118 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9119 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 9120 | } |
| 9121 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9122 | TEST_F(VkLayerTest, CreatePipelineAttribBindingConflict) { |
| 9123 | m_errorMonitor->SetDesiredFailureMsg( |
| 9124 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9125 | "Duplicate vertex input binding descriptions for binding 0"); |
| 9126 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9127 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 9128 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9129 | |
| 9130 | /* Two binding descriptions for binding 0 */ |
| 9131 | VkVertexInputBindingDescription input_bindings[2]; |
| 9132 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 9133 | |
| 9134 | VkVertexInputAttributeDescription input_attrib; |
| 9135 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 9136 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 9137 | |
| 9138 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9139 | "#version 450\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9140 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9141 | "layout(location=0) in float x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9142 | "out gl_PerVertex {\n" |
| 9143 | " vec4 gl_Position;\n" |
| 9144 | "};\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9145 | "void main(){\n" |
| 9146 | " gl_Position = vec4(x);\n" |
| 9147 | "}\n"; |
| 9148 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9149 | "#version 450\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9150 | "\n" |
| 9151 | "layout(location=0) out vec4 color;\n" |
| 9152 | "void main(){\n" |
| 9153 | " color = vec4(1);\n" |
| 9154 | "}\n"; |
| 9155 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9156 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9157 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9158 | |
| 9159 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9160 | pipe.AddColorAttachment(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9161 | pipe.AddShader(&vs); |
| 9162 | pipe.AddShader(&fs); |
| 9163 | |
| 9164 | pipe.AddVertexInputBindings(input_bindings, 2); |
| 9165 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 9166 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9167 | VkDescriptorSetObj descriptorSet(m_device); |
| 9168 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9169 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9170 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9171 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9172 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9173 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9174 | } |
Chris Forbes | 8f68b56 | 2015-05-25 11:13:32 +1200 | [diff] [blame] | 9175 | |
Chris Forbes | 35efec7 | 2016-04-21 14:32:08 +1200 | [diff] [blame] | 9176 | TEST_F(VkLayerTest, CreatePipeline64BitAttributesPositive) { |
| 9177 | m_errorMonitor->ExpectSuccess(); |
| 9178 | |
| 9179 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9180 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9181 | |
| 9182 | if (!m_device->phy().features().tessellationShader) { |
| 9183 | printf("Device does not support 64bit vertex attributes; skipped.\n"); |
| 9184 | return; |
| 9185 | } |
| 9186 | |
| 9187 | VkVertexInputBindingDescription input_bindings[1]; |
| 9188 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 9189 | |
| 9190 | VkVertexInputAttributeDescription input_attribs[4]; |
| 9191 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 9192 | input_attribs[0].location = 0; |
| 9193 | input_attribs[0].offset = 0; |
| 9194 | input_attribs[0].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 9195 | input_attribs[1].location = 2; |
| 9196 | input_attribs[1].offset = 32; |
| 9197 | input_attribs[1].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 9198 | input_attribs[2].location = 4; |
| 9199 | input_attribs[2].offset = 64; |
| 9200 | input_attribs[2].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 9201 | input_attribs[3].location = 6; |
| 9202 | input_attribs[3].offset = 96; |
| 9203 | input_attribs[3].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 9204 | |
| 9205 | char const *vsSource = |
| 9206 | "#version 450\n" |
| 9207 | "\n" |
| 9208 | "layout(location=0) in dmat4 x;\n" |
| 9209 | "out gl_PerVertex {\n" |
| 9210 | " vec4 gl_Position;\n" |
| 9211 | "};\n" |
| 9212 | "void main(){\n" |
| 9213 | " gl_Position = vec4(x[0][0]);\n" |
| 9214 | "}\n"; |
| 9215 | char const *fsSource = |
| 9216 | "#version 450\n" |
| 9217 | "\n" |
| 9218 | "layout(location=0) out vec4 color;\n" |
| 9219 | "void main(){\n" |
| 9220 | " color = vec4(1);\n" |
| 9221 | "}\n"; |
| 9222 | |
| 9223 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9224 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9225 | |
| 9226 | VkPipelineObj pipe(m_device); |
| 9227 | pipe.AddColorAttachment(); |
| 9228 | pipe.AddShader(&vs); |
| 9229 | pipe.AddShader(&fs); |
| 9230 | |
| 9231 | pipe.AddVertexInputBindings(input_bindings, 1); |
| 9232 | pipe.AddVertexInputAttribs(input_attribs, 4); |
| 9233 | |
| 9234 | VkDescriptorSetObj descriptorSet(m_device); |
| 9235 | descriptorSet.AppendDummy(); |
| 9236 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9237 | |
| 9238 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9239 | |
| 9240 | m_errorMonitor->VerifyNotFound(); |
| 9241 | } |
| 9242 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9243 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotWritten) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9244 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9245 | "Attachment 0 not written by FS"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9246 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9247 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9248 | |
| 9249 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9250 | "#version 450\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9251 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9252 | "out gl_PerVertex {\n" |
| 9253 | " vec4 gl_Position;\n" |
| 9254 | "};\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9255 | "void main(){\n" |
| 9256 | " gl_Position = vec4(1);\n" |
| 9257 | "}\n"; |
| 9258 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9259 | "#version 450\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9260 | "\n" |
| 9261 | "void main(){\n" |
| 9262 | "}\n"; |
| 9263 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9264 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9265 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9266 | |
| 9267 | VkPipelineObj pipe(m_device); |
| 9268 | pipe.AddShader(&vs); |
| 9269 | pipe.AddShader(&fs); |
| 9270 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9271 | /* set up CB 0, not written */ |
| 9272 | pipe.AddColorAttachment(); |
| 9273 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9274 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9275 | VkDescriptorSetObj descriptorSet(m_device); |
| 9276 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9277 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9278 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9279 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9280 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9281 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9282 | } |
| 9283 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9284 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotConsumed) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9285 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 9286 | VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9287 | "FS writes to output location 1 with no matching attachment"); |
| 9288 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9289 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9290 | |
| 9291 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9292 | "#version 450\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9293 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9294 | "out gl_PerVertex {\n" |
| 9295 | " vec4 gl_Position;\n" |
| 9296 | "};\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9297 | "void main(){\n" |
| 9298 | " gl_Position = vec4(1);\n" |
| 9299 | "}\n"; |
| 9300 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9301 | "#version 450\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9302 | "\n" |
| 9303 | "layout(location=0) out vec4 x;\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9304 | "layout(location=1) out vec4 y;\n" /* no matching attachment for this */ |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9305 | "void main(){\n" |
| 9306 | " x = vec4(1);\n" |
| 9307 | " y = vec4(1);\n" |
| 9308 | "}\n"; |
| 9309 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9310 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9311 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9312 | |
| 9313 | VkPipelineObj pipe(m_device); |
| 9314 | pipe.AddShader(&vs); |
| 9315 | pipe.AddShader(&fs); |
| 9316 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9317 | /* set up CB 0, not written */ |
| 9318 | pipe.AddColorAttachment(); |
| 9319 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9320 | /* FS writes CB 1, but we don't configure it */ |
| 9321 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9322 | VkDescriptorSetObj descriptorSet(m_device); |
| 9323 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9324 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9325 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9326 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9327 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9328 | m_errorMonitor->VerifyFound(); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9329 | } |
| 9330 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9331 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputTypeMismatch) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9332 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9333 | "does not match FS output type"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9334 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9335 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9336 | |
| 9337 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9338 | "#version 450\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9339 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9340 | "out gl_PerVertex {\n" |
| 9341 | " vec4 gl_Position;\n" |
| 9342 | "};\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9343 | "void main(){\n" |
| 9344 | " gl_Position = vec4(1);\n" |
| 9345 | "}\n"; |
| 9346 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9347 | "#version 450\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9348 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9349 | "layout(location=0) out ivec4 x;\n" /* not UNORM */ |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9350 | "void main(){\n" |
| 9351 | " x = ivec4(1);\n" |
| 9352 | "}\n"; |
| 9353 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9354 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9355 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9356 | |
| 9357 | VkPipelineObj pipe(m_device); |
| 9358 | pipe.AddShader(&vs); |
| 9359 | pipe.AddShader(&fs); |
| 9360 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9361 | /* set up CB 0; type is UNORM by default */ |
| 9362 | pipe.AddColorAttachment(); |
| 9363 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9364 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9365 | VkDescriptorSetObj descriptorSet(m_device); |
| 9366 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9367 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9368 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9369 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9370 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9371 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9372 | } |
Chris Forbes | 7b1b893 | 2015-06-05 14:43:36 +1200 | [diff] [blame] | 9373 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9374 | TEST_F(VkLayerTest, CreatePipelineUniformBlockNotProvided) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9375 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9376 | "not declared in pipeline layout"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9377 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 9378 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 9379 | |
| 9380 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9381 | "#version 450\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 9382 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9383 | "out gl_PerVertex {\n" |
| 9384 | " vec4 gl_Position;\n" |
| 9385 | "};\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 9386 | "void main(){\n" |
| 9387 | " gl_Position = vec4(1);\n" |
| 9388 | "}\n"; |
| 9389 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9390 | "#version 450\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 9391 | "\n" |
| 9392 | "layout(location=0) out vec4 x;\n" |
| 9393 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 9394 | "void main(){\n" |
| 9395 | " x = vec4(bar.y);\n" |
| 9396 | "}\n"; |
| 9397 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9398 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9399 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 9400 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 9401 | VkPipelineObj pipe(m_device); |
| 9402 | pipe.AddShader(&vs); |
| 9403 | pipe.AddShader(&fs); |
| 9404 | |
| 9405 | /* set up CB 0; type is UNORM by default */ |
| 9406 | pipe.AddColorAttachment(); |
| 9407 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9408 | |
| 9409 | VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9410 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 9411 | |
| 9412 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9413 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9414 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 9415 | } |
| 9416 | |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 9417 | TEST_F(VkLayerTest, CreatePipelinePushConstantsNotInLayout) { |
| 9418 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9419 | "not declared in layout"); |
| 9420 | |
| 9421 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9422 | |
| 9423 | char const *vsSource = |
| 9424 | "#version 450\n" |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 9425 | "\n" |
| 9426 | "layout(push_constant, std430) uniform foo { float x; } consts;\n" |
| 9427 | "out gl_PerVertex {\n" |
| 9428 | " vec4 gl_Position;\n" |
| 9429 | "};\n" |
| 9430 | "void main(){\n" |
| 9431 | " gl_Position = vec4(consts.x);\n" |
| 9432 | "}\n"; |
| 9433 | char const *fsSource = |
| 9434 | "#version 450\n" |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 9435 | "\n" |
| 9436 | "layout(location=0) out vec4 x;\n" |
| 9437 | "void main(){\n" |
| 9438 | " x = vec4(1);\n" |
| 9439 | "}\n"; |
| 9440 | |
| 9441 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9442 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9443 | |
| 9444 | VkPipelineObj pipe(m_device); |
| 9445 | pipe.AddShader(&vs); |
| 9446 | pipe.AddShader(&fs); |
| 9447 | |
| 9448 | /* set up CB 0; type is UNORM by default */ |
| 9449 | pipe.AddColorAttachment(); |
| 9450 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9451 | |
| 9452 | VkDescriptorSetObj descriptorSet(m_device); |
| 9453 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9454 | |
| 9455 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9456 | |
| 9457 | /* should have generated an error -- no push constant ranges provided! */ |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9458 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 9459 | } |
| 9460 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 9461 | #endif // SHADER_CHECKER_TESTS |
| 9462 | |
| 9463 | #if DEVICE_LIMITS_TESTS |
Mark Young | c48c4c1 | 2016-04-11 14:26:49 -0600 | [diff] [blame] | 9464 | TEST_F(VkLayerTest, CreateImageLimitsViolationMaxWidth) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9465 | m_errorMonitor->SetDesiredFailureMsg( |
| 9466 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9467 | "CreateImage extents exceed allowable limits for format"); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 9468 | |
| 9469 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 9470 | |
| 9471 | // Create an image |
| 9472 | VkImage image; |
| 9473 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9474 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 9475 | const int32_t tex_width = 32; |
| 9476 | const int32_t tex_height = 32; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 9477 | |
| 9478 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9479 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9480 | image_create_info.pNext = NULL; |
| 9481 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 9482 | image_create_info.format = tex_format; |
| 9483 | image_create_info.extent.width = tex_width; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 9484 | image_create_info.extent.height = tex_height; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9485 | image_create_info.extent.depth = 1; |
| 9486 | image_create_info.mipLevels = 1; |
| 9487 | image_create_info.arrayLayers = 1; |
| 9488 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 9489 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 9490 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 9491 | image_create_info.flags = 0; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 9492 | |
| 9493 | // Introduce error by sending down a bogus width extent |
| 9494 | image_create_info.extent.width = 65536; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9495 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 9496 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9497 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 9498 | } |
| 9499 | |
Mark Young | c48c4c1 | 2016-04-11 14:26:49 -0600 | [diff] [blame] | 9500 | TEST_F(VkLayerTest, CreateImageLimitsViolationMinWidth) { |
| 9501 | m_errorMonitor->SetDesiredFailureMsg( |
| 9502 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9503 | "CreateImage extents is 0 for at least one required dimension"); |
| 9504 | |
| 9505 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9506 | |
| 9507 | // Create an image |
| 9508 | VkImage image; |
| 9509 | |
| 9510 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 9511 | const int32_t tex_width = 32; |
| 9512 | const int32_t tex_height = 32; |
| 9513 | |
| 9514 | VkImageCreateInfo image_create_info = {}; |
| 9515 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9516 | image_create_info.pNext = NULL; |
| 9517 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 9518 | image_create_info.format = tex_format; |
| 9519 | image_create_info.extent.width = tex_width; |
| 9520 | image_create_info.extent.height = tex_height; |
| 9521 | image_create_info.extent.depth = 1; |
| 9522 | image_create_info.mipLevels = 1; |
| 9523 | image_create_info.arrayLayers = 1; |
| 9524 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 9525 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 9526 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 9527 | image_create_info.flags = 0; |
| 9528 | |
| 9529 | // Introduce error by sending down a bogus width extent |
| 9530 | image_create_info.extent.width = 0; |
| 9531 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 9532 | |
| 9533 | m_errorMonitor->VerifyFound(); |
| 9534 | } |
| 9535 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9536 | TEST_F(VkLayerTest, UpdateBufferAlignment) { |
| 9537 | uint32_t updateData[] = {1, 2, 3, 4, 5, 6, 7, 8}; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9538 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9539 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9540 | "dstOffset, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9541 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9542 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9543 | |
| 9544 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 9545 | vk_testing::Buffer buffer; |
| 9546 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 9547 | |
| 9548 | BeginCommandBuffer(); |
| 9549 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9550 | m_commandBuffer->UpdateBuffer(buffer.handle(), 1, 4, updateData); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9551 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9552 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9553 | // Introduce failure by using size that is not multiple of 4 |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9554 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9555 | "dataSize, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9556 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9557 | m_commandBuffer->UpdateBuffer(buffer.handle(), 0, 6, updateData); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9558 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9559 | EndCommandBuffer(); |
| 9560 | } |
| 9561 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9562 | TEST_F(VkLayerTest, FillBufferAlignment) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9563 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9564 | "dstOffset, is not a multiple of 4"); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9565 | |
| 9566 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9567 | |
| 9568 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 9569 | vk_testing::Buffer buffer; |
| 9570 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 9571 | |
| 9572 | BeginCommandBuffer(); |
| 9573 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9574 | m_commandBuffer->FillBuffer(buffer.handle(), 1, 4, 0x11111111); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9575 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9576 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9577 | // Introduce failure by using size that is not multiple of 4 |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9578 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9579 | "size, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9580 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9581 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 6, 0x11111111); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9582 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9583 | m_errorMonitor->VerifyFound(); |
| 9584 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9585 | EndCommandBuffer(); |
| 9586 | } |
| 9587 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 9588 | #endif // DEVICE_LIMITS_TESTS |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9589 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 9590 | #if IMAGE_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9591 | TEST_F(VkLayerTest, InvalidImageView) { |
| 9592 | VkResult err; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 9593 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9594 | m_errorMonitor->SetDesiredFailureMsg( |
| 9595 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9596 | "vkCreateImageView called with baseMipLevel 10 "); |
| 9597 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 9598 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 9599 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9600 | // Create an image and try to create a view with bad baseMipLevel |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9601 | VkImage image; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 9602 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9603 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 9604 | const int32_t tex_width = 32; |
| 9605 | const int32_t tex_height = 32; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 9606 | |
| 9607 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9608 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9609 | image_create_info.pNext = NULL; |
| 9610 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 9611 | image_create_info.format = tex_format; |
| 9612 | image_create_info.extent.width = tex_width; |
| 9613 | image_create_info.extent.height = tex_height; |
| 9614 | image_create_info.extent.depth = 1; |
| 9615 | image_create_info.mipLevels = 1; |
| 9616 | image_create_info.arrayLayers = 1; |
| 9617 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 9618 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 9619 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 9620 | image_create_info.flags = 0; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 9621 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9622 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 9623 | ASSERT_VK_SUCCESS(err); |
| 9624 | |
| 9625 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9626 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9627 | image_view_create_info.image = image; |
| 9628 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 9629 | image_view_create_info.format = tex_format; |
| 9630 | image_view_create_info.subresourceRange.layerCount = 1; |
| 9631 | image_view_create_info.subresourceRange.baseMipLevel = 10; // cause an error |
| 9632 | image_view_create_info.subresourceRange.levelCount = 1; |
| 9633 | image_view_create_info.subresourceRange.aspectMask = |
| 9634 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 9635 | |
| 9636 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9637 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 9638 | &view); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 9639 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9640 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 9641 | } |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9642 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9643 | TEST_F(VkLayerTest, InvalidImageViewAspect) { |
| 9644 | VkResult err; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 9645 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9646 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9647 | "vkCreateImageView: Color image " |
| 9648 | "formats must have ONLY the " |
| 9649 | "VK_IMAGE_ASPECT_COLOR_BIT set"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9650 | |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 9651 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 9652 | |
| 9653 | // Create an image and try to create a view with an invalid aspectMask |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9654 | VkImage image; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 9655 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9656 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 9657 | const int32_t tex_width = 32; |
| 9658 | const int32_t tex_height = 32; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 9659 | |
| 9660 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9661 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9662 | image_create_info.pNext = NULL; |
| 9663 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 9664 | image_create_info.format = tex_format; |
| 9665 | image_create_info.extent.width = tex_width; |
| 9666 | image_create_info.extent.height = tex_height; |
| 9667 | image_create_info.extent.depth = 1; |
| 9668 | image_create_info.mipLevels = 1; |
| 9669 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 9670 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 9671 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 9672 | image_create_info.flags = 0; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 9673 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9674 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 9675 | ASSERT_VK_SUCCESS(err); |
| 9676 | |
| 9677 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9678 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9679 | image_view_create_info.image = image; |
| 9680 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 9681 | image_view_create_info.format = tex_format; |
| 9682 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 9683 | image_view_create_info.subresourceRange.levelCount = 1; |
| 9684 | // Cause an error by setting an invalid image aspect |
| 9685 | image_view_create_info.subresourceRange.aspectMask = |
| 9686 | VK_IMAGE_ASPECT_METADATA_BIT; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 9687 | |
| 9688 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9689 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 9690 | &view); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 9691 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9692 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 9693 | } |
| 9694 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 9695 | TEST_F(VkLayerTest, CopyImageLayerCountMismatch) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9696 | VkResult err; |
| 9697 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9698 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9699 | m_errorMonitor->SetDesiredFailureMsg( |
| 9700 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 9701 | "vkCmdCopyImage: number of layers in source and destination subresources for pRegions"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9702 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9703 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9704 | |
| 9705 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9706 | VkImage srcImage; |
| 9707 | VkImage dstImage; |
| 9708 | VkDeviceMemory srcMem; |
| 9709 | VkDeviceMemory destMem; |
| 9710 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9711 | |
| 9712 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9713 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9714 | image_create_info.pNext = NULL; |
| 9715 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 9716 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 9717 | image_create_info.extent.width = 32; |
| 9718 | image_create_info.extent.height = 32; |
| 9719 | image_create_info.extent.depth = 1; |
| 9720 | image_create_info.mipLevels = 1; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 9721 | image_create_info.arrayLayers = 4; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9722 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 9723 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 9724 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 9725 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9726 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9727 | err = |
| 9728 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9729 | ASSERT_VK_SUCCESS(err); |
| 9730 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9731 | err = |
| 9732 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9733 | ASSERT_VK_SUCCESS(err); |
| 9734 | |
| 9735 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9736 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9737 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 9738 | memAlloc.pNext = NULL; |
| 9739 | memAlloc.allocationSize = 0; |
| 9740 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9741 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 9742 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9743 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9744 | pass = |
| 9745 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 9746 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9747 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9748 | ASSERT_VK_SUCCESS(err); |
| 9749 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9750 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9751 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9752 | pass = |
| 9753 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9754 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9755 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9756 | ASSERT_VK_SUCCESS(err); |
| 9757 | |
| 9758 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 9759 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9760 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9761 | ASSERT_VK_SUCCESS(err); |
| 9762 | |
| 9763 | BeginCommandBuffer(); |
| 9764 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 9765 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9766 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 9767 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 9768 | copyRegion.srcSubresource.layerCount = 1; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9769 | copyRegion.srcOffset.x = 0; |
| 9770 | copyRegion.srcOffset.y = 0; |
| 9771 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 9772 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9773 | copyRegion.dstSubresource.mipLevel = 0; |
| 9774 | copyRegion.dstSubresource.baseArrayLayer = 0; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 9775 | // Introduce failure by forcing the dst layerCount to differ from src |
| 9776 | copyRegion.dstSubresource.layerCount = 3; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9777 | copyRegion.dstOffset.x = 0; |
| 9778 | copyRegion.dstOffset.y = 0; |
| 9779 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9780 | copyRegion.extent.width = 1; |
| 9781 | copyRegion.extent.height = 1; |
| 9782 | copyRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9783 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 9784 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9785 | EndCommandBuffer(); |
| 9786 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9787 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9788 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9789 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9790 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9791 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 9792 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9793 | } |
| 9794 | |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 9795 | TEST_F(VkLayerTest, ImageLayerUnsupportedFormat) { |
| 9796 | |
| 9797 | TEST_DESCRIPTION("Creating images with unsuported formats "); |
| 9798 | |
| 9799 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9800 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9801 | VkImageObj image(m_device); |
| 9802 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 9803 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 9804 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 9805 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 9806 | ASSERT_TRUE(image.initialized()); |
| 9807 | |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 9808 | // Create image with unsupported format - Expect FORMAT_UNSUPPORTED |
| 9809 | VkImageCreateInfo image_create_info; |
| 9810 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9811 | image_create_info.pNext = NULL; |
| 9812 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 9813 | image_create_info.format = VK_FORMAT_UNDEFINED; |
| 9814 | image_create_info.extent.width = 32; |
| 9815 | image_create_info.extent.height = 32; |
| 9816 | image_create_info.extent.depth = 1; |
| 9817 | image_create_info.mipLevels = 1; |
| 9818 | image_create_info.arrayLayers = 1; |
| 9819 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 9820 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 9821 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 9822 | image_create_info.flags = 0; |
| 9823 | |
| 9824 | m_errorMonitor->SetDesiredFailureMsg( |
| 9825 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9826 | "vkCreateImage: VkFormat for image must not be VK_FORMAT_UNDEFINED"); |
| 9827 | |
| 9828 | VkImage localImage; |
| 9829 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &localImage); |
| 9830 | m_errorMonitor->VerifyFound(); |
| 9831 | |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 9832 | VkFormat unsupported = VK_FORMAT_UNDEFINED; |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 9833 | // Look for a format that is COMPLETELY unsupported with this hardware |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 9834 | for (int f = VK_FORMAT_BEGIN_RANGE; f <= VK_FORMAT_END_RANGE; f++) { |
| 9835 | VkFormat format = static_cast<VkFormat>(f); |
| 9836 | VkFormatProperties fProps = m_device->format_properties(format); |
| 9837 | if (format != VK_FORMAT_UNDEFINED && fProps.linearTilingFeatures == 0 && |
| 9838 | fProps.optimalTilingFeatures == 0) { |
| 9839 | unsupported = format; |
| 9840 | break; |
| 9841 | } |
| 9842 | } |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 9843 | |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 9844 | if (unsupported != VK_FORMAT_UNDEFINED) { |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 9845 | image_create_info.format = unsupported; |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 9846 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 9847 | "is an unsupported format"); |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 9848 | |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 9849 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &localImage); |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 9850 | m_errorMonitor->VerifyFound(); |
| 9851 | } |
| 9852 | } |
| 9853 | |
| 9854 | TEST_F(VkLayerTest, ImageLayerViewTests) { |
| 9855 | VkResult ret; |
| 9856 | TEST_DESCRIPTION("Passing bad parameters to CreateImageView"); |
| 9857 | |
| 9858 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9859 | |
| 9860 | VkImageObj image(m_device); |
| 9861 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 9862 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 9863 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 9864 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 9865 | ASSERT_TRUE(image.initialized()); |
| 9866 | |
| 9867 | VkImageView imgView; |
| 9868 | VkImageViewCreateInfo imgViewInfo = {}; |
| 9869 | imgViewInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 9870 | imgViewInfo.image = image.handle(); |
| 9871 | imgViewInfo.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 9872 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 9873 | imgViewInfo.subresourceRange.layerCount = 1; |
| 9874 | imgViewInfo.subresourceRange.baseMipLevel = 0; |
| 9875 | imgViewInfo.subresourceRange.levelCount = 1; |
| 9876 | imgViewInfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 9877 | |
| 9878 | m_errorMonitor->SetDesiredFailureMsg( |
| 9879 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9880 | "vkCreateImageView called with baseMipLevel"); |
| 9881 | // View can't have baseMipLevel >= image's mipLevels - Expect |
| 9882 | // VIEW_CREATE_ERROR |
| 9883 | imgViewInfo.subresourceRange.baseMipLevel = 1; |
| 9884 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 9885 | m_errorMonitor->VerifyFound(); |
| 9886 | imgViewInfo.subresourceRange.baseMipLevel = 0; |
| 9887 | |
| 9888 | m_errorMonitor->SetDesiredFailureMsg( |
| 9889 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9890 | "vkCreateImageView called with baseArrayLayer"); |
| 9891 | // View can't have baseArrayLayer >= image's arraySize - Expect |
| 9892 | // VIEW_CREATE_ERROR |
| 9893 | imgViewInfo.subresourceRange.baseArrayLayer = 1; |
| 9894 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 9895 | m_errorMonitor->VerifyFound(); |
| 9896 | imgViewInfo.subresourceRange.baseArrayLayer = 0; |
| 9897 | |
| 9898 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9899 | "vkCreateImageView called with 0 in " |
| 9900 | "pCreateInfo->subresourceRange." |
| 9901 | "levelCount"); |
| 9902 | // View's levelCount can't be 0 - Expect VIEW_CREATE_ERROR |
| 9903 | imgViewInfo.subresourceRange.levelCount = 0; |
| 9904 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 9905 | m_errorMonitor->VerifyFound(); |
| 9906 | imgViewInfo.subresourceRange.levelCount = 1; |
| 9907 | |
| 9908 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9909 | "vkCreateImageView called with 0 in " |
| 9910 | "pCreateInfo->subresourceRange." |
| 9911 | "layerCount"); |
| 9912 | // View's layerCount can't be 0 - Expect VIEW_CREATE_ERROR |
| 9913 | imgViewInfo.subresourceRange.layerCount = 0; |
| 9914 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 9915 | m_errorMonitor->VerifyFound(); |
| 9916 | imgViewInfo.subresourceRange.layerCount = 1; |
| 9917 | |
| 9918 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9919 | "but both must be color formats"); |
| 9920 | // Can't use depth format for view into color image - Expect INVALID_FORMAT |
| 9921 | imgViewInfo.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 9922 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 9923 | m_errorMonitor->VerifyFound(); |
| 9924 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 9925 | |
| 9926 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9927 | "Formats MUST be IDENTICAL unless " |
| 9928 | "VK_IMAGE_CREATE_MUTABLE_FORMAT BIT " |
| 9929 | "was set on image creation."); |
| 9930 | // Same compatibility class but no MUTABLE_FORMAT bit - Expect |
| 9931 | // VIEW_CREATE_ERROR |
| 9932 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UINT; |
| 9933 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 9934 | m_errorMonitor->VerifyFound(); |
| 9935 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 9936 | |
| 9937 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9938 | "can support ImageViews with " |
| 9939 | "differing formats but they must be " |
| 9940 | "in the same compatibility class."); |
| 9941 | // Have MUTABLE_FORMAT bit but not in same compatibility class - Expect |
| 9942 | // VIEW_CREATE_ERROR |
| 9943 | VkImageCreateInfo mutImgInfo = image.create_info(); |
| 9944 | VkImage mutImage; |
| 9945 | mutImgInfo.format = VK_FORMAT_R8_UINT; |
| 9946 | assert( |
| 9947 | m_device->format_properties(VK_FORMAT_R8_UINT).optimalTilingFeatures & |
| 9948 | VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT); |
| 9949 | mutImgInfo.flags = VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT; |
| 9950 | mutImgInfo.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 9951 | ret = vkCreateImage(m_device->handle(), &mutImgInfo, NULL, &mutImage); |
| 9952 | ASSERT_VK_SUCCESS(ret); |
| 9953 | imgViewInfo.image = mutImage; |
| 9954 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 9955 | m_errorMonitor->VerifyFound(); |
| 9956 | imgViewInfo.image = image.handle(); |
| 9957 | vkDestroyImage(m_device->handle(), mutImage, NULL); |
| 9958 | } |
| 9959 | |
| 9960 | TEST_F(VkLayerTest, MiscImageLayerTests) { |
| 9961 | |
| 9962 | TEST_DESCRIPTION("Image layer tests that don't belong elsewhare"); |
| 9963 | |
| 9964 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9965 | |
| 9966 | VkImageObj image(m_device); |
| 9967 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 9968 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 9969 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 9970 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 9971 | ASSERT_TRUE(image.initialized()); |
| 9972 | |
| 9973 | m_errorMonitor->SetDesiredFailureMsg( |
| 9974 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9975 | "number of layers in image subresource is zero"); |
| 9976 | vk_testing::Buffer buffer; |
| 9977 | VkMemoryPropertyFlags reqs = 0; |
| 9978 | buffer.init_as_src(*m_device, 128 * 128 * 4, reqs); |
| 9979 | VkBufferImageCopy region = {}; |
| 9980 | region.bufferRowLength = 128; |
| 9981 | region.bufferImageHeight = 128; |
| 9982 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 9983 | // layerCount can't be 0 - Expect MISMATCHED_IMAGE_ASPECT |
| 9984 | region.imageSubresource.layerCount = 0; |
| 9985 | region.imageExtent.height = 4; |
| 9986 | region.imageExtent.width = 4; |
| 9987 | region.imageExtent.depth = 1; |
| 9988 | m_commandBuffer->BeginCommandBuffer(); |
| 9989 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 9990 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 9991 | 1, ®ion); |
| 9992 | m_errorMonitor->VerifyFound(); |
| 9993 | region.imageSubresource.layerCount = 1; |
| 9994 | |
| 9995 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9996 | "aspectMasks for each region must " |
| 9997 | "specify only COLOR or DEPTH or " |
| 9998 | "STENCIL"); |
| 9999 | // Expect MISMATCHED_IMAGE_ASPECT |
| 10000 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_METADATA_BIT; |
| 10001 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 10002 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 10003 | 1, ®ion); |
| 10004 | m_errorMonitor->VerifyFound(); |
| 10005 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10006 | |
| 10007 | m_errorMonitor->SetDesiredFailureMsg( |
| 10008 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10009 | "If the format of srcImage is a depth, stencil, depth stencil or " |
| 10010 | "integer-based format then filter must be VK_FILTER_NEAREST"); |
| 10011 | // Expect INVALID_FILTER |
| 10012 | VkImageObj intImage1(m_device); |
| 10013 | intImage1.init(128, 128, VK_FORMAT_R8_UINT, |
| 10014 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, |
| 10015 | 0); |
| 10016 | VkImageObj intImage2(m_device); |
| 10017 | intImage2.init(128, 128, VK_FORMAT_R8_UINT, |
| 10018 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, |
| 10019 | 0); |
| 10020 | VkImageBlit blitRegion = {}; |
| 10021 | blitRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10022 | blitRegion.srcSubresource.baseArrayLayer = 0; |
| 10023 | blitRegion.srcSubresource.layerCount = 1; |
| 10024 | blitRegion.srcSubresource.mipLevel = 0; |
| 10025 | blitRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10026 | blitRegion.dstSubresource.baseArrayLayer = 0; |
| 10027 | blitRegion.dstSubresource.layerCount = 1; |
| 10028 | blitRegion.dstSubresource.mipLevel = 0; |
| 10029 | |
| 10030 | vkCmdBlitImage(m_commandBuffer->GetBufferHandle(), intImage1.handle(), |
| 10031 | intImage1.layout(), intImage2.handle(), intImage2.layout(), |
| 10032 | 16, &blitRegion, VK_FILTER_LINEAR); |
| 10033 | m_errorMonitor->VerifyFound(); |
| 10034 | |
| 10035 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10036 | "called with 0 in ppMemoryBarriers"); |
| 10037 | VkImageMemoryBarrier img_barrier; |
| 10038 | img_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; |
| 10039 | img_barrier.pNext = NULL; |
| 10040 | img_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 10041 | img_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 10042 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 10043 | img_barrier.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 10044 | img_barrier.image = image.handle(); |
| 10045 | img_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 10046 | img_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 10047 | img_barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10048 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 10049 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 10050 | // layerCount should not be 0 - Expect INVALID_IMAGE_RESOURCE |
| 10051 | img_barrier.subresourceRange.layerCount = 0; |
| 10052 | img_barrier.subresourceRange.levelCount = 1; |
| 10053 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 10054 | VK_PIPELINE_STAGE_HOST_BIT, |
| 10055 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 10056 | nullptr, 1, &img_barrier); |
| 10057 | m_errorMonitor->VerifyFound(); |
| 10058 | img_barrier.subresourceRange.layerCount = 1; |
| 10059 | } |
| 10060 | |
| 10061 | TEST_F(VkLayerTest, ImageFormatLimits) { |
| 10062 | |
| 10063 | TEST_DESCRIPTION("Exceed the limits of image format "); |
| 10064 | |
| 10065 | m_errorMonitor->SetDesiredFailureMsg( |
| 10066 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10067 | "CreateImage extents exceed allowable limits for format"); |
| 10068 | VkImageCreateInfo image_create_info = {}; |
| 10069 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10070 | image_create_info.pNext = NULL; |
| 10071 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10072 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10073 | image_create_info.extent.width = 32; |
| 10074 | image_create_info.extent.height = 32; |
| 10075 | image_create_info.extent.depth = 1; |
| 10076 | image_create_info.mipLevels = 1; |
| 10077 | image_create_info.arrayLayers = 1; |
| 10078 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10079 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 10080 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 10081 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 10082 | image_create_info.flags = 0; |
| 10083 | |
| 10084 | VkImage nullImg; |
| 10085 | VkImageFormatProperties imgFmtProps; |
| 10086 | vkGetPhysicalDeviceImageFormatProperties( |
| 10087 | gpu(), image_create_info.format, image_create_info.imageType, |
| 10088 | image_create_info.tiling, image_create_info.usage, |
| 10089 | image_create_info.flags, &imgFmtProps); |
| 10090 | image_create_info.extent.depth = imgFmtProps.maxExtent.depth + 1; |
| 10091 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 10092 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 10093 | m_errorMonitor->VerifyFound(); |
| 10094 | image_create_info.extent.depth = 1; |
| 10095 | |
| 10096 | m_errorMonitor->SetDesiredFailureMsg( |
| 10097 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10098 | "exceeds allowable maximum supported by format of"); |
| 10099 | image_create_info.mipLevels = imgFmtProps.maxMipLevels + 1; |
| 10100 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 10101 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 10102 | m_errorMonitor->VerifyFound(); |
| 10103 | image_create_info.mipLevels = 1; |
| 10104 | |
| 10105 | m_errorMonitor->SetDesiredFailureMsg( |
| 10106 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10107 | "exceeds allowable maximum supported by format of"); |
| 10108 | image_create_info.arrayLayers = imgFmtProps.maxArrayLayers + 1; |
| 10109 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 10110 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 10111 | m_errorMonitor->VerifyFound(); |
| 10112 | image_create_info.arrayLayers = 1; |
| 10113 | |
| 10114 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10115 | "is not supported by format"); |
| 10116 | int samples = imgFmtProps.sampleCounts >> 1; |
| 10117 | image_create_info.samples = (VkSampleCountFlagBits)samples; |
| 10118 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 10119 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 10120 | m_errorMonitor->VerifyFound(); |
| 10121 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10122 | |
| 10123 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10124 | "pCreateInfo->initialLayout, must be " |
| 10125 | "VK_IMAGE_LAYOUT_UNDEFINED or " |
| 10126 | "VK_IMAGE_LAYOUT_PREINITIALIZED"); |
| 10127 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 10128 | // Expect INVALID_LAYOUT |
| 10129 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 10130 | m_errorMonitor->VerifyFound(); |
| 10131 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 10132 | } |
| 10133 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10134 | TEST_F(VkLayerTest, CopyImageFormatSizeMismatch) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 10135 | VkResult err; |
| 10136 | bool pass; |
| 10137 | |
| 10138 | // Create color images with different format sizes and try to copy between them |
| 10139 | m_errorMonitor->SetDesiredFailureMsg( |
| 10140 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10141 | "vkCmdCopyImage called with unmatched source and dest image format sizes"); |
| 10142 | |
| 10143 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10144 | |
| 10145 | // Create two images of different types and try to copy between them |
| 10146 | VkImage srcImage; |
| 10147 | VkImage dstImage; |
| 10148 | VkDeviceMemory srcMem; |
| 10149 | VkDeviceMemory destMem; |
| 10150 | VkMemoryRequirements memReqs; |
| 10151 | |
| 10152 | VkImageCreateInfo image_create_info = {}; |
| 10153 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10154 | image_create_info.pNext = NULL; |
| 10155 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10156 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10157 | image_create_info.extent.width = 32; |
| 10158 | image_create_info.extent.height = 32; |
| 10159 | image_create_info.extent.depth = 1; |
| 10160 | image_create_info.mipLevels = 1; |
| 10161 | image_create_info.arrayLayers = 1; |
| 10162 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10163 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 10164 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 10165 | image_create_info.flags = 0; |
| 10166 | |
| 10167 | err = |
| 10168 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
| 10169 | ASSERT_VK_SUCCESS(err); |
| 10170 | |
| 10171 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 10172 | // Introduce failure by creating second image with a different-sized format. |
| 10173 | image_create_info.format = VK_FORMAT_R5G5B5A1_UNORM_PACK16; |
| 10174 | |
| 10175 | err = |
| 10176 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
| 10177 | ASSERT_VK_SUCCESS(err); |
| 10178 | |
| 10179 | // Allocate memory |
| 10180 | VkMemoryAllocateInfo memAlloc = {}; |
| 10181 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 10182 | memAlloc.pNext = NULL; |
| 10183 | memAlloc.allocationSize = 0; |
| 10184 | memAlloc.memoryTypeIndex = 0; |
| 10185 | |
| 10186 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
| 10187 | memAlloc.allocationSize = memReqs.size; |
| 10188 | pass = |
| 10189 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 10190 | ASSERT_TRUE(pass); |
| 10191 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
| 10192 | ASSERT_VK_SUCCESS(err); |
| 10193 | |
| 10194 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
| 10195 | memAlloc.allocationSize = memReqs.size; |
| 10196 | pass = |
| 10197 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 10198 | ASSERT_TRUE(pass); |
| 10199 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
| 10200 | ASSERT_VK_SUCCESS(err); |
| 10201 | |
| 10202 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 10203 | ASSERT_VK_SUCCESS(err); |
| 10204 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
| 10205 | ASSERT_VK_SUCCESS(err); |
| 10206 | |
| 10207 | BeginCommandBuffer(); |
| 10208 | VkImageCopy copyRegion; |
| 10209 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10210 | copyRegion.srcSubresource.mipLevel = 0; |
| 10211 | copyRegion.srcSubresource.baseArrayLayer = 0; |
| 10212 | copyRegion.srcSubresource.layerCount = 0; |
| 10213 | copyRegion.srcOffset.x = 0; |
| 10214 | copyRegion.srcOffset.y = 0; |
| 10215 | copyRegion.srcOffset.z = 0; |
| 10216 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10217 | copyRegion.dstSubresource.mipLevel = 0; |
| 10218 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 10219 | copyRegion.dstSubresource.layerCount = 0; |
| 10220 | copyRegion.dstOffset.x = 0; |
| 10221 | copyRegion.dstOffset.y = 0; |
| 10222 | copyRegion.dstOffset.z = 0; |
| 10223 | copyRegion.extent.width = 1; |
| 10224 | copyRegion.extent.height = 1; |
| 10225 | copyRegion.extent.depth = 1; |
| 10226 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 10227 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 10228 | EndCommandBuffer(); |
| 10229 | |
| 10230 | m_errorMonitor->VerifyFound(); |
| 10231 | |
| 10232 | vkDestroyImage(m_device->device(), srcImage, NULL); |
| 10233 | vkDestroyImage(m_device->device(), dstImage, NULL); |
| 10234 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 10235 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10236 | } |
| 10237 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10238 | TEST_F(VkLayerTest, CopyImageDepthStencilFormatMismatch) { |
| 10239 | VkResult err; |
| 10240 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10241 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10242 | // 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] | 10243 | m_errorMonitor->SetDesiredFailureMsg( |
| 10244 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10245 | "vkCmdCopyImage called with unmatched source and dest image depth"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10246 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10247 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10248 | |
| 10249 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10250 | VkImage srcImage; |
| 10251 | VkImage dstImage; |
| 10252 | VkDeviceMemory srcMem; |
| 10253 | VkDeviceMemory destMem; |
| 10254 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10255 | |
| 10256 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10257 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10258 | image_create_info.pNext = NULL; |
| 10259 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10260 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10261 | image_create_info.extent.width = 32; |
| 10262 | image_create_info.extent.height = 32; |
| 10263 | image_create_info.extent.depth = 1; |
| 10264 | image_create_info.mipLevels = 1; |
| 10265 | image_create_info.arrayLayers = 1; |
| 10266 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10267 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 10268 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 10269 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10270 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10271 | err = |
| 10272 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10273 | ASSERT_VK_SUCCESS(err); |
| 10274 | |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 10275 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 10276 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10277 | // Introduce failure by creating second image with a depth/stencil format |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10278 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10279 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 10280 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10281 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10282 | err = |
| 10283 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10284 | ASSERT_VK_SUCCESS(err); |
| 10285 | |
| 10286 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10287 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10288 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 10289 | memAlloc.pNext = NULL; |
| 10290 | memAlloc.allocationSize = 0; |
| 10291 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10292 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 10293 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10294 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10295 | pass = |
| 10296 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10297 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10298 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10299 | ASSERT_VK_SUCCESS(err); |
| 10300 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10301 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10302 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10303 | pass = |
| 10304 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10305 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10306 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10307 | ASSERT_VK_SUCCESS(err); |
| 10308 | |
| 10309 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 10310 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10311 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10312 | ASSERT_VK_SUCCESS(err); |
| 10313 | |
| 10314 | BeginCommandBuffer(); |
| 10315 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10316 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10317 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 10318 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10319 | copyRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10320 | copyRegion.srcOffset.x = 0; |
| 10321 | copyRegion.srcOffset.y = 0; |
| 10322 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10323 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10324 | copyRegion.dstSubresource.mipLevel = 0; |
| 10325 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 10326 | copyRegion.dstSubresource.layerCount = 0; |
| 10327 | copyRegion.dstOffset.x = 0; |
| 10328 | copyRegion.dstOffset.y = 0; |
| 10329 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10330 | copyRegion.extent.width = 1; |
| 10331 | copyRegion.extent.height = 1; |
| 10332 | copyRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10333 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 10334 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10335 | EndCommandBuffer(); |
| 10336 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10337 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10338 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10339 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10340 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10341 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 10342 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10343 | } |
| 10344 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10345 | TEST_F(VkLayerTest, ResolveImageLowSampleCount) { |
| 10346 | VkResult err; |
| 10347 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10348 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10349 | m_errorMonitor->SetDesiredFailureMsg( |
| 10350 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10351 | "vkCmdResolveImage called with source sample count less than 2."); |
| 10352 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10353 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10354 | |
| 10355 | // 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] | 10356 | VkImage srcImage; |
| 10357 | VkImage dstImage; |
| 10358 | VkDeviceMemory srcMem; |
| 10359 | VkDeviceMemory destMem; |
| 10360 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10361 | |
| 10362 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10363 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10364 | image_create_info.pNext = NULL; |
| 10365 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10366 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10367 | image_create_info.extent.width = 32; |
| 10368 | image_create_info.extent.height = 1; |
| 10369 | image_create_info.extent.depth = 1; |
| 10370 | image_create_info.mipLevels = 1; |
| 10371 | image_create_info.arrayLayers = 1; |
| 10372 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10373 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 10374 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 10375 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10376 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10377 | err = |
| 10378 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10379 | ASSERT_VK_SUCCESS(err); |
| 10380 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10381 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10382 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10383 | err = |
| 10384 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10385 | ASSERT_VK_SUCCESS(err); |
| 10386 | |
| 10387 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10388 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10389 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 10390 | memAlloc.pNext = NULL; |
| 10391 | memAlloc.allocationSize = 0; |
| 10392 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10393 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 10394 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10395 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10396 | pass = |
| 10397 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10398 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10399 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10400 | ASSERT_VK_SUCCESS(err); |
| 10401 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10402 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10403 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10404 | pass = |
| 10405 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10406 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10407 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10408 | ASSERT_VK_SUCCESS(err); |
| 10409 | |
| 10410 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 10411 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10412 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10413 | ASSERT_VK_SUCCESS(err); |
| 10414 | |
| 10415 | BeginCommandBuffer(); |
| 10416 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10417 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 10418 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10419 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10420 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10421 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 10422 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10423 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10424 | resolveRegion.srcOffset.x = 0; |
| 10425 | resolveRegion.srcOffset.y = 0; |
| 10426 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10427 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10428 | resolveRegion.dstSubresource.mipLevel = 0; |
| 10429 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 10430 | resolveRegion.dstSubresource.layerCount = 0; |
| 10431 | resolveRegion.dstOffset.x = 0; |
| 10432 | resolveRegion.dstOffset.y = 0; |
| 10433 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10434 | resolveRegion.extent.width = 1; |
| 10435 | resolveRegion.extent.height = 1; |
| 10436 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10437 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 10438 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10439 | EndCommandBuffer(); |
| 10440 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10441 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10442 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10443 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10444 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10445 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 10446 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10447 | } |
| 10448 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10449 | TEST_F(VkLayerTest, ResolveImageHighSampleCount) { |
| 10450 | VkResult err; |
| 10451 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10452 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10453 | m_errorMonitor->SetDesiredFailureMsg( |
| 10454 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10455 | "vkCmdResolveImage called with dest sample count greater than 1."); |
| 10456 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10457 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10458 | |
Chris Forbes | a753069 | 2016-05-08 12:35:39 +1200 | [diff] [blame] | 10459 | // 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] | 10460 | VkImage srcImage; |
| 10461 | VkImage dstImage; |
| 10462 | VkDeviceMemory srcMem; |
| 10463 | VkDeviceMemory destMem; |
| 10464 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10465 | |
| 10466 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10467 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10468 | image_create_info.pNext = NULL; |
| 10469 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10470 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10471 | image_create_info.extent.width = 32; |
| 10472 | image_create_info.extent.height = 1; |
| 10473 | image_create_info.extent.depth = 1; |
| 10474 | image_create_info.mipLevels = 1; |
| 10475 | image_create_info.arrayLayers = 1; |
Chris Forbes | a753069 | 2016-05-08 12:35:39 +1200 | [diff] [blame] | 10476 | image_create_info.samples = VK_SAMPLE_COUNT_4_BIT; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10477 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 10478 | // Note: Some implementations expect color attachment usage for any |
| 10479 | // multisample surface |
| 10480 | image_create_info.usage = |
| 10481 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 10482 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10483 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10484 | err = |
| 10485 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10486 | ASSERT_VK_SUCCESS(err); |
| 10487 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10488 | // Note: Some implementations expect color attachment usage for any |
| 10489 | // multisample surface |
| 10490 | image_create_info.usage = |
| 10491 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10492 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10493 | err = |
| 10494 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10495 | ASSERT_VK_SUCCESS(err); |
| 10496 | |
| 10497 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10498 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10499 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 10500 | memAlloc.pNext = NULL; |
| 10501 | memAlloc.allocationSize = 0; |
| 10502 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10503 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 10504 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10505 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10506 | pass = |
| 10507 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10508 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10509 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10510 | ASSERT_VK_SUCCESS(err); |
| 10511 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10512 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10513 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10514 | pass = |
| 10515 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10516 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10517 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10518 | ASSERT_VK_SUCCESS(err); |
| 10519 | |
| 10520 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 10521 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10522 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10523 | ASSERT_VK_SUCCESS(err); |
| 10524 | |
| 10525 | BeginCommandBuffer(); |
| 10526 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10527 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 10528 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10529 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10530 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10531 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 10532 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10533 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10534 | resolveRegion.srcOffset.x = 0; |
| 10535 | resolveRegion.srcOffset.y = 0; |
| 10536 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10537 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10538 | resolveRegion.dstSubresource.mipLevel = 0; |
| 10539 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 10540 | resolveRegion.dstSubresource.layerCount = 0; |
| 10541 | resolveRegion.dstOffset.x = 0; |
| 10542 | resolveRegion.dstOffset.y = 0; |
| 10543 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10544 | resolveRegion.extent.width = 1; |
| 10545 | resolveRegion.extent.height = 1; |
| 10546 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10547 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 10548 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10549 | EndCommandBuffer(); |
| 10550 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10551 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10552 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10553 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10554 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10555 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 10556 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10557 | } |
| 10558 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10559 | TEST_F(VkLayerTest, ResolveImageFormatMismatch) { |
| 10560 | VkResult err; |
| 10561 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10562 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10563 | m_errorMonitor->SetDesiredFailureMsg( |
| 10564 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10565 | "vkCmdResolveImage called with unmatched source and dest formats."); |
| 10566 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10567 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10568 | |
| 10569 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10570 | VkImage srcImage; |
| 10571 | VkImage dstImage; |
| 10572 | VkDeviceMemory srcMem; |
| 10573 | VkDeviceMemory destMem; |
| 10574 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10575 | |
| 10576 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10577 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10578 | image_create_info.pNext = NULL; |
| 10579 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10580 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10581 | image_create_info.extent.width = 32; |
| 10582 | image_create_info.extent.height = 1; |
| 10583 | image_create_info.extent.depth = 1; |
| 10584 | image_create_info.mipLevels = 1; |
| 10585 | image_create_info.arrayLayers = 1; |
| 10586 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 10587 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 10588 | // Note: Some implementations expect color attachment usage for any |
| 10589 | // multisample surface |
| 10590 | image_create_info.usage = |
| 10591 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 10592 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10593 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10594 | err = |
| 10595 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10596 | ASSERT_VK_SUCCESS(err); |
| 10597 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10598 | // Set format to something other than source image |
| 10599 | image_create_info.format = VK_FORMAT_R32_SFLOAT; |
| 10600 | // Note: Some implementations expect color attachment usage for any |
| 10601 | // multisample surface |
| 10602 | image_create_info.usage = |
| 10603 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 10604 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10605 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10606 | err = |
| 10607 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10608 | ASSERT_VK_SUCCESS(err); |
| 10609 | |
| 10610 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10611 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10612 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 10613 | memAlloc.pNext = NULL; |
| 10614 | memAlloc.allocationSize = 0; |
| 10615 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10616 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 10617 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10618 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10619 | pass = |
| 10620 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10621 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10622 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10623 | ASSERT_VK_SUCCESS(err); |
| 10624 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10625 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10626 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10627 | pass = |
| 10628 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10629 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10630 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10631 | ASSERT_VK_SUCCESS(err); |
| 10632 | |
| 10633 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 10634 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10635 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10636 | ASSERT_VK_SUCCESS(err); |
| 10637 | |
| 10638 | BeginCommandBuffer(); |
| 10639 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10640 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 10641 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10642 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10643 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10644 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 10645 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10646 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10647 | resolveRegion.srcOffset.x = 0; |
| 10648 | resolveRegion.srcOffset.y = 0; |
| 10649 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10650 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10651 | resolveRegion.dstSubresource.mipLevel = 0; |
| 10652 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 10653 | resolveRegion.dstSubresource.layerCount = 0; |
| 10654 | resolveRegion.dstOffset.x = 0; |
| 10655 | resolveRegion.dstOffset.y = 0; |
| 10656 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10657 | resolveRegion.extent.width = 1; |
| 10658 | resolveRegion.extent.height = 1; |
| 10659 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10660 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 10661 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10662 | EndCommandBuffer(); |
| 10663 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10664 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10665 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10666 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10667 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10668 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 10669 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10670 | } |
| 10671 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10672 | TEST_F(VkLayerTest, ResolveImageTypeMismatch) { |
| 10673 | VkResult err; |
| 10674 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10675 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10676 | m_errorMonitor->SetDesiredFailureMsg( |
| 10677 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10678 | "vkCmdResolveImage called with unmatched source and dest image types."); |
| 10679 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10680 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10681 | |
| 10682 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10683 | VkImage srcImage; |
| 10684 | VkImage dstImage; |
| 10685 | VkDeviceMemory srcMem; |
| 10686 | VkDeviceMemory destMem; |
| 10687 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10688 | |
| 10689 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10690 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10691 | image_create_info.pNext = NULL; |
| 10692 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10693 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10694 | image_create_info.extent.width = 32; |
| 10695 | image_create_info.extent.height = 1; |
| 10696 | image_create_info.extent.depth = 1; |
| 10697 | image_create_info.mipLevels = 1; |
| 10698 | image_create_info.arrayLayers = 1; |
| 10699 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 10700 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 10701 | // Note: Some implementations expect color attachment usage for any |
| 10702 | // multisample surface |
| 10703 | image_create_info.usage = |
| 10704 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 10705 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10706 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10707 | err = |
| 10708 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10709 | ASSERT_VK_SUCCESS(err); |
| 10710 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10711 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 10712 | // Note: Some implementations expect color attachment usage for any |
| 10713 | // multisample surface |
| 10714 | image_create_info.usage = |
| 10715 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 10716 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10717 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10718 | err = |
| 10719 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10720 | ASSERT_VK_SUCCESS(err); |
| 10721 | |
| 10722 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10723 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10724 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 10725 | memAlloc.pNext = NULL; |
| 10726 | memAlloc.allocationSize = 0; |
| 10727 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10728 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 10729 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10730 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10731 | pass = |
| 10732 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10733 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10734 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10735 | ASSERT_VK_SUCCESS(err); |
| 10736 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10737 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10738 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10739 | pass = |
| 10740 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10741 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10742 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10743 | ASSERT_VK_SUCCESS(err); |
| 10744 | |
| 10745 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 10746 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10747 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10748 | ASSERT_VK_SUCCESS(err); |
| 10749 | |
| 10750 | BeginCommandBuffer(); |
| 10751 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10752 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 10753 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10754 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10755 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10756 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 10757 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10758 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10759 | resolveRegion.srcOffset.x = 0; |
| 10760 | resolveRegion.srcOffset.y = 0; |
| 10761 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10762 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10763 | resolveRegion.dstSubresource.mipLevel = 0; |
| 10764 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 10765 | resolveRegion.dstSubresource.layerCount = 0; |
| 10766 | resolveRegion.dstOffset.x = 0; |
| 10767 | resolveRegion.dstOffset.y = 0; |
| 10768 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10769 | resolveRegion.extent.width = 1; |
| 10770 | resolveRegion.extent.height = 1; |
| 10771 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10772 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 10773 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10774 | EndCommandBuffer(); |
| 10775 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10776 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10777 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10778 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10779 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10780 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 10781 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10782 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10783 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10784 | TEST_F(VkLayerTest, DepthStencilImageViewWithColorAspectBitError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10785 | // 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] | 10786 | // to using a DS format, then cause it to hit error due to COLOR_BIT not |
| 10787 | // set in aspect |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10788 | // The image format check comes 2nd in validation so we trigger it first, |
| 10789 | // 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] | 10790 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10791 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10792 | m_errorMonitor->SetDesiredFailureMsg( |
| 10793 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10794 | "Combination depth/stencil image formats can have only the "); |
| 10795 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10796 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10797 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 10798 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10799 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 10800 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10801 | |
| 10802 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10803 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 10804 | ds_pool_ci.pNext = NULL; |
| 10805 | ds_pool_ci.maxSets = 1; |
| 10806 | ds_pool_ci.poolSizeCount = 1; |
| 10807 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10808 | |
| 10809 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10810 | err = |
| 10811 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10812 | ASSERT_VK_SUCCESS(err); |
| 10813 | |
| 10814 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10815 | dsl_binding.binding = 0; |
| 10816 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 10817 | dsl_binding.descriptorCount = 1; |
| 10818 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 10819 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10820 | |
| 10821 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10822 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 10823 | ds_layout_ci.pNext = NULL; |
| 10824 | ds_layout_ci.bindingCount = 1; |
| 10825 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10826 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10827 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 10828 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10829 | ASSERT_VK_SUCCESS(err); |
| 10830 | |
| 10831 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10832 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 10833 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 10834 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10835 | alloc_info.descriptorPool = ds_pool; |
| 10836 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10837 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 10838 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10839 | ASSERT_VK_SUCCESS(err); |
| 10840 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10841 | VkImage image_bad; |
| 10842 | VkImage image_good; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10843 | // One bad format and one good format for Color attachment |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10844 | const VkFormat tex_format_bad = VK_FORMAT_D32_SFLOAT_S8_UINT; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10845 | const VkFormat tex_format_good = VK_FORMAT_B8G8R8A8_UNORM; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10846 | const int32_t tex_width = 32; |
| 10847 | const int32_t tex_height = 32; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10848 | |
| 10849 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10850 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10851 | image_create_info.pNext = NULL; |
| 10852 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10853 | image_create_info.format = tex_format_bad; |
| 10854 | image_create_info.extent.width = tex_width; |
| 10855 | image_create_info.extent.height = tex_height; |
| 10856 | image_create_info.extent.depth = 1; |
| 10857 | image_create_info.mipLevels = 1; |
| 10858 | image_create_info.arrayLayers = 1; |
| 10859 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10860 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 10861 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT | |
| 10862 | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 10863 | image_create_info.flags = 0; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10864 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10865 | err = |
| 10866 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image_bad); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10867 | ASSERT_VK_SUCCESS(err); |
| 10868 | image_create_info.format = tex_format_good; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10869 | image_create_info.usage = |
| 10870 | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 10871 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, |
| 10872 | &image_good); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10873 | ASSERT_VK_SUCCESS(err); |
| 10874 | |
| 10875 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10876 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10877 | image_view_create_info.image = image_bad; |
| 10878 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 10879 | image_view_create_info.format = tex_format_bad; |
| 10880 | image_view_create_info.subresourceRange.baseArrayLayer = 0; |
| 10881 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 10882 | image_view_create_info.subresourceRange.layerCount = 1; |
| 10883 | image_view_create_info.subresourceRange.levelCount = 1; |
| 10884 | image_view_create_info.subresourceRange.aspectMask = |
| 10885 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10886 | |
| 10887 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10888 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 10889 | &view); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10890 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10891 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10892 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10893 | vkDestroyImage(m_device->device(), image_bad, NULL); |
| 10894 | vkDestroyImage(m_device->device(), image_good, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10895 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 10896 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10897 | } |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10898 | #endif // IMAGE_TESTS |
| 10899 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 10900 | int main(int argc, char **argv) { |
| 10901 | int result; |
| 10902 | |
Cody Northrop | 8e54a40 | 2016-03-08 22:25:52 -0700 | [diff] [blame] | 10903 | #ifdef ANDROID |
| 10904 | int vulkanSupport = InitVulkan(); |
| 10905 | if (vulkanSupport == 0) |
| 10906 | return 1; |
| 10907 | #endif |
| 10908 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 10909 | ::testing::InitGoogleTest(&argc, argv); |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 10910 | VkTestFramework::InitArgs(&argc, argv); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 10911 | |
| 10912 | ::testing::AddGlobalTestEnvironment(new TestEnvironment); |
| 10913 | |
| 10914 | result = RUN_ALL_TESTS(); |
| 10915 | |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 10916 | VkTestFramework::Finish(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 10917 | return result; |
| 10918 | } |