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, |
| 571 | "required parameter pPhysicalDeviceCount specified as NULL"); |
| 572 | // Specify NULL for pointer to array count |
| 573 | // Expected to trigger an error with parameter_validation::validate_array |
| 574 | vkEnumeratePhysicalDevices(instance(), NULL, NULL); |
| 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) { |
| 1651 | VkResult err; |
| 1652 | bool pass; |
| 1653 | |
| 1654 | VkSurfaceKHR surface = VK_NULL_HANDLE; |
| 1655 | #if defined(VK_USE_PLATFORM_XCB_KHR) |
| 1656 | VkSwapchainKHR swapchain = VK_NULL_HANDLE; |
| 1657 | VkSwapchainCreateInfoKHR swapchain_create_info = {}; |
| 1658 | // uint32_t swapchain_image_count = 0; |
| 1659 | // VkImage swapchain_images[1] = {VK_NULL_HANDLE}; |
| 1660 | // uint32_t image_index = 0; |
| 1661 | // VkPresentInfoKHR present_info = {}; |
| 1662 | |
| 1663 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1664 | |
| 1665 | // Use the create function from one of the VK_KHR_*_surface extension in |
| 1666 | // order to create a surface, testing all known errors in the process, |
| 1667 | // before successfully creating a surface: |
| 1668 | // First, try to create a surface without a VkXcbSurfaceCreateInfoKHR: |
| 1669 | m_errorMonitor->SetDesiredFailureMsg( |
| 1670 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1671 | "called with NULL pointer"); |
| 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; |
| 1681 | m_errorMonitor->SetDesiredFailureMsg( |
| 1682 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1683 | "called with the wrong value for"); |
| 1684 | err = vkCreateXcbSurfaceKHR(instance(), &xcb_create_info, NULL, &surface); |
| 1685 | pass = (err != VK_SUCCESS); |
| 1686 | ASSERT_TRUE(pass); |
| 1687 | m_errorMonitor->VerifyFound(); |
| 1688 | |
| 1689 | |
| 1690 | // Create a native window, and then correctly create a surface: |
| 1691 | xcb_connection_t *connection; |
| 1692 | xcb_screen_t *screen; |
| 1693 | xcb_window_t xcb_window; |
| 1694 | xcb_intern_atom_reply_t *atom_wm_delete_window; |
| 1695 | |
| 1696 | const xcb_setup_t *setup; |
| 1697 | xcb_screen_iterator_t iter; |
| 1698 | int scr; |
| 1699 | uint32_t value_mask, value_list[32]; |
| 1700 | int width = 1; |
| 1701 | int height = 1; |
| 1702 | |
| 1703 | connection = xcb_connect(NULL, &scr); |
| 1704 | ASSERT_TRUE(connection != NULL); |
| 1705 | setup = xcb_get_setup(connection); |
| 1706 | iter = xcb_setup_roots_iterator(setup); |
| 1707 | while (scr-- > 0) |
| 1708 | xcb_screen_next(&iter); |
| 1709 | screen = iter.data; |
| 1710 | |
| 1711 | xcb_window = xcb_generate_id(connection); |
| 1712 | |
| 1713 | value_mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK; |
| 1714 | value_list[0] = screen->black_pixel; |
| 1715 | value_list[1] = XCB_EVENT_MASK_KEY_RELEASE | XCB_EVENT_MASK_EXPOSURE | |
| 1716 | XCB_EVENT_MASK_STRUCTURE_NOTIFY; |
| 1717 | |
| 1718 | xcb_create_window(connection, XCB_COPY_FROM_PARENT, xcb_window, |
| 1719 | screen->root, 0, 0, width, height, 0, |
| 1720 | XCB_WINDOW_CLASS_INPUT_OUTPUT, screen->root_visual, |
| 1721 | value_mask, value_list); |
| 1722 | |
| 1723 | /* Magic code that will send notification when window is destroyed */ |
| 1724 | xcb_intern_atom_cookie_t cookie = |
| 1725 | xcb_intern_atom(connection, 1, 12, "WM_PROTOCOLS"); |
| 1726 | xcb_intern_atom_reply_t *reply = |
| 1727 | xcb_intern_atom_reply(connection, cookie, 0); |
| 1728 | |
| 1729 | xcb_intern_atom_cookie_t cookie2 = |
| 1730 | xcb_intern_atom(connection, 0, 16, "WM_DELETE_WINDOW"); |
| 1731 | atom_wm_delete_window = |
| 1732 | xcb_intern_atom_reply(connection, cookie2, 0); |
| 1733 | xcb_change_property(connection, XCB_PROP_MODE_REPLACE, xcb_window, |
| 1734 | (*reply).atom, 4, 32, 1, |
| 1735 | &(*atom_wm_delete_window).atom); |
| 1736 | free(reply); |
| 1737 | |
| 1738 | xcb_map_window(connection, xcb_window); |
| 1739 | |
| 1740 | // Force the x/y coordinates to 100,100 results are identical in consecutive |
| 1741 | // runs |
| 1742 | const uint32_t coords[] = {100, 100}; |
| 1743 | xcb_configure_window(connection, xcb_window, |
| 1744 | XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, coords); |
| 1745 | |
| 1746 | |
| 1747 | |
| 1748 | // Finally, try to correctly create a surface: |
| 1749 | xcb_create_info.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR; |
| 1750 | xcb_create_info.pNext = NULL; |
| 1751 | xcb_create_info.flags = 0; |
| 1752 | xcb_create_info.connection = connection; |
| 1753 | xcb_create_info.window = xcb_window; |
| 1754 | err = vkCreateXcbSurfaceKHR(instance(), &xcb_create_info, NULL, &surface); |
| 1755 | pass = (err == VK_SUCCESS); |
| 1756 | ASSERT_TRUE(pass); |
| 1757 | |
| 1758 | |
| 1759 | |
| 1760 | // Check if surface supports presentation: |
| 1761 | |
| 1762 | // 1st, do so without having queried the queue families: |
| 1763 | VkBool32 supported = false; |
| 1764 | // TODO: Get the following error to come out: |
| 1765 | m_errorMonitor->SetDesiredFailureMsg( |
| 1766 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1767 | "called before calling the vkGetPhysicalDeviceQueueFamilyProperties " |
| 1768 | "function"); |
| 1769 | err = vkGetPhysicalDeviceSurfaceSupportKHR(gpu(), 0, surface, &supported); |
| 1770 | pass = (err != VK_SUCCESS); |
| 1771 | // ASSERT_TRUE(pass); |
| 1772 | // m_errorMonitor->VerifyFound(); |
| 1773 | |
| 1774 | // Next, query a queue family index that's too large: |
| 1775 | m_errorMonitor->SetDesiredFailureMsg( |
| 1776 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1777 | "called with a queueFamilyIndex that is too large"); |
| 1778 | err = vkGetPhysicalDeviceSurfaceSupportKHR(gpu(), 100000, surface, &supported); |
| 1779 | pass = (err != VK_SUCCESS); |
| 1780 | ASSERT_TRUE(pass); |
| 1781 | m_errorMonitor->VerifyFound(); |
| 1782 | |
| 1783 | // Finally, do so correctly: |
| 1784 | // FIXME: THIS ISN'T CORRECT--MUST QUERY UNTIL WE FIND A QUEUE FAMILY THAT'S SUPPORTED |
| 1785 | err = vkGetPhysicalDeviceSurfaceSupportKHR(gpu(), 0, surface, &supported); |
| 1786 | pass = (err == VK_SUCCESS); |
| 1787 | ASSERT_TRUE(pass); |
| 1788 | |
| 1789 | |
| 1790 | |
| 1791 | // Before proceeding, try to create a swapchain without having called |
| 1792 | // vkGetPhysicalDeviceSurfaceCapabilitiesKHR(): |
| 1793 | swapchain_create_info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR; |
| 1794 | swapchain_create_info.pNext = NULL; |
| 1795 | swapchain_create_info.flags = 0; |
| 1796 | m_errorMonitor->SetDesiredFailureMsg( |
| 1797 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1798 | "called before calling vkGetPhysicalDeviceSurfaceCapabilitiesKHR()."); |
| 1799 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, |
| 1800 | NULL, &swapchain); |
| 1801 | pass = (err != VK_SUCCESS); |
| 1802 | ASSERT_TRUE(pass); |
| 1803 | m_errorMonitor->VerifyFound(); |
| 1804 | |
| 1805 | |
| 1806 | |
| 1807 | // Get the surface capabilities: |
| 1808 | VkSurfaceCapabilitiesKHR surface_capabilities; |
| 1809 | |
| 1810 | // Do so correctly (only error logged by this entrypoint is if the |
| 1811 | // extension isn't enabled): |
| 1812 | err = vkGetPhysicalDeviceSurfaceCapabilitiesKHR(gpu(), surface, |
| 1813 | &surface_capabilities); |
| 1814 | pass = (err == VK_SUCCESS); |
| 1815 | ASSERT_TRUE(pass); |
| 1816 | |
| 1817 | |
| 1818 | |
| 1819 | // Get the surface formats: |
| 1820 | uint32_t surface_format_count; |
| 1821 | |
| 1822 | // First, try without a pointer to surface_format_count: |
| 1823 | m_errorMonitor->SetDesiredFailureMsg( |
| 1824 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1825 | "called with NULL pointer"); |
| 1826 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, NULL, NULL); |
| 1827 | pass = (err == VK_SUCCESS); |
| 1828 | ASSERT_TRUE(pass); |
| 1829 | m_errorMonitor->VerifyFound(); |
| 1830 | |
| 1831 | // Next, call with a non-NULL pSurfaceFormats, even though we haven't |
| 1832 | // correctly done a 1st try (to get the count): |
| 1833 | m_errorMonitor->SetDesiredFailureMsg( |
| 1834 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1835 | "but no prior positive value has been seen for"); |
| 1836 | surface_format_count = 0; |
| 1837 | vkGetPhysicalDeviceSurfaceFormatsKHR( |
| 1838 | gpu(), |
| 1839 | surface, |
| 1840 | &surface_format_count, |
| 1841 | (VkSurfaceFormatKHR *) &surface_format_count); |
| 1842 | pass = (err == VK_SUCCESS); |
| 1843 | ASSERT_TRUE(pass); |
| 1844 | m_errorMonitor->VerifyFound(); |
| 1845 | |
| 1846 | // Next, correctly do a 1st try (with a NULL pointer to surface_formats): |
| 1847 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, |
| 1848 | &surface_format_count, NULL); |
| 1849 | pass = (err == VK_SUCCESS); |
| 1850 | ASSERT_TRUE(pass); |
| 1851 | |
| 1852 | // Allocate memory for the correct number of VkSurfaceFormatKHR's: |
| 1853 | VkSurfaceFormatKHR *surface_formats = |
| 1854 | (VkSurfaceFormatKHR *)malloc(surface_format_count * |
| 1855 | sizeof(VkSurfaceFormatKHR)); |
| 1856 | |
| 1857 | // Next, do a 2nd try with surface_format_count being set too high: |
| 1858 | surface_format_count += 5; |
| 1859 | m_errorMonitor->SetDesiredFailureMsg( |
| 1860 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1861 | "that is greater than the value"); |
| 1862 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, |
| 1863 | &surface_format_count, |
| 1864 | surface_formats); |
| 1865 | pass = (err == VK_SUCCESS); |
| 1866 | ASSERT_TRUE(pass); |
| 1867 | m_errorMonitor->VerifyFound(); |
| 1868 | |
| 1869 | // Finally, do a correct 1st and 2nd try: |
| 1870 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, |
| 1871 | &surface_format_count, NULL); |
| 1872 | pass = (err == VK_SUCCESS); |
| 1873 | ASSERT_TRUE(pass); |
| 1874 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, |
| 1875 | &surface_format_count, |
| 1876 | surface_formats); |
| 1877 | pass = (err == VK_SUCCESS); |
| 1878 | ASSERT_TRUE(pass); |
| 1879 | |
| 1880 | |
| 1881 | |
| 1882 | // Get the surface present modes: |
| 1883 | uint32_t surface_present_mode_count; |
| 1884 | |
| 1885 | // First, try without a pointer to surface_format_count: |
| 1886 | m_errorMonitor->SetDesiredFailureMsg( |
| 1887 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1888 | "called with NULL pointer"); |
| 1889 | vkGetPhysicalDeviceSurfacePresentModesKHR(gpu(), surface, NULL, NULL); |
| 1890 | pass = (err == VK_SUCCESS); |
| 1891 | ASSERT_TRUE(pass); |
| 1892 | m_errorMonitor->VerifyFound(); |
| 1893 | |
| 1894 | // Next, call with a non-NULL VkPresentModeKHR, even though we haven't |
| 1895 | // correctly done a 1st try (to get the count): |
| 1896 | m_errorMonitor->SetDesiredFailureMsg( |
| 1897 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1898 | "but no prior positive value has been seen for"); |
| 1899 | surface_present_mode_count = 0; |
| 1900 | vkGetPhysicalDeviceSurfacePresentModesKHR( |
| 1901 | gpu(), |
| 1902 | surface, |
| 1903 | &surface_present_mode_count, |
| 1904 | (VkPresentModeKHR *) &surface_present_mode_count); |
| 1905 | pass = (err == VK_SUCCESS); |
| 1906 | ASSERT_TRUE(pass); |
| 1907 | m_errorMonitor->VerifyFound(); |
| 1908 | |
| 1909 | // Next, correctly do a 1st try (with a NULL pointer to surface_formats): |
| 1910 | vkGetPhysicalDeviceSurfacePresentModesKHR(gpu(), surface, |
| 1911 | &surface_present_mode_count, |
| 1912 | NULL); |
| 1913 | pass = (err == VK_SUCCESS); |
| 1914 | ASSERT_TRUE(pass); |
| 1915 | |
| 1916 | // Allocate memory for the correct number of VkSurfaceFormatKHR's: |
| 1917 | VkPresentModeKHR *surface_present_modes = |
| 1918 | (VkPresentModeKHR *)malloc(surface_present_mode_count * |
| 1919 | sizeof(VkPresentModeKHR)); |
| 1920 | |
| 1921 | // Next, do a 2nd try with surface_format_count being set too high: |
| 1922 | surface_present_mode_count += 5; |
| 1923 | m_errorMonitor->SetDesiredFailureMsg( |
| 1924 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1925 | "that is greater than the value"); |
| 1926 | vkGetPhysicalDeviceSurfacePresentModesKHR(gpu(), surface, |
| 1927 | &surface_present_mode_count, |
| 1928 | surface_present_modes); |
| 1929 | pass = (err == VK_SUCCESS); |
| 1930 | ASSERT_TRUE(pass); |
| 1931 | m_errorMonitor->VerifyFound(); |
| 1932 | |
| 1933 | // Finally, do a correct 1st and 2nd try: |
| 1934 | vkGetPhysicalDeviceSurfacePresentModesKHR(gpu(), surface, |
| 1935 | &surface_present_mode_count, |
| 1936 | NULL); |
| 1937 | pass = (err == VK_SUCCESS); |
| 1938 | ASSERT_TRUE(pass); |
| 1939 | vkGetPhysicalDeviceSurfacePresentModesKHR(gpu(), surface, |
| 1940 | &surface_present_mode_count, |
| 1941 | surface_present_modes); |
| 1942 | pass = (err == VK_SUCCESS); |
| 1943 | ASSERT_TRUE(pass); |
| 1944 | |
| 1945 | |
| 1946 | |
| 1947 | // Create a swapchain: |
| 1948 | |
| 1949 | // First, try without a pointer to swapchain_create_info: |
| 1950 | m_errorMonitor->SetDesiredFailureMsg( |
| 1951 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1952 | "called with NULL pointer"); |
| 1953 | err = vkCreateSwapchainKHR(m_device->device(), NULL, NULL, &swapchain); |
| 1954 | pass = (err != VK_SUCCESS); |
| 1955 | ASSERT_TRUE(pass); |
| 1956 | m_errorMonitor->VerifyFound(); |
| 1957 | |
| 1958 | // Next, call with a non-NULL swapchain_create_info, that has the wrong |
| 1959 | // sType: |
| 1960 | swapchain_create_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; |
| 1961 | m_errorMonitor->SetDesiredFailureMsg( |
| 1962 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1963 | "called with the wrong value for"); |
| 1964 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, |
| 1965 | NULL, &swapchain); |
| 1966 | pass = (err != VK_SUCCESS); |
| 1967 | ASSERT_TRUE(pass); |
| 1968 | m_errorMonitor->VerifyFound(); |
| 1969 | |
| 1970 | // Next, call with a NULL swapchain pointer: |
| 1971 | swapchain_create_info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR; |
| 1972 | swapchain_create_info.pNext = NULL; |
| 1973 | swapchain_create_info.flags = 0; |
| 1974 | m_errorMonitor->SetDesiredFailureMsg( |
| 1975 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1976 | "called with NULL pointer"); |
| 1977 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, |
| 1978 | NULL, NULL); |
| 1979 | pass = (err != VK_SUCCESS); |
| 1980 | ASSERT_TRUE(pass); |
| 1981 | m_errorMonitor->VerifyFound(); |
| 1982 | |
| 1983 | // TODO: Enhance swapchain layer so that |
| 1984 | // swapchain_create_info.queueFamilyIndexCount is checked against something? |
| 1985 | |
| 1986 | // Next, call with a queue family index that's too large: |
| 1987 | uint32_t queueFamilyIndex[2] = {100000, 0}; |
| 1988 | swapchain_create_info.imageSharingMode = VK_SHARING_MODE_CONCURRENT; |
| 1989 | swapchain_create_info.queueFamilyIndexCount = 2; |
| 1990 | swapchain_create_info.pQueueFamilyIndices = queueFamilyIndex; |
| 1991 | m_errorMonitor->SetDesiredFailureMsg( |
| 1992 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1993 | "called with a queueFamilyIndex that is too large"); |
| 1994 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, |
| 1995 | NULL, &swapchain); |
| 1996 | pass = (err != VK_SUCCESS); |
| 1997 | ASSERT_TRUE(pass); |
| 1998 | m_errorMonitor->VerifyFound(); |
| 1999 | |
| 2000 | // Next, call a queueFamilyIndexCount that's too small for CONCURRENT: |
| 2001 | swapchain_create_info.imageSharingMode = VK_SHARING_MODE_CONCURRENT; |
| 2002 | swapchain_create_info.queueFamilyIndexCount = 1; |
| 2003 | m_errorMonitor->SetDesiredFailureMsg( |
| 2004 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2005 | "but with a bad value(s) for pCreateInfo->queueFamilyIndexCount or " |
| 2006 | "pCreateInfo->pQueueFamilyIndices)."); |
| 2007 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, |
| 2008 | NULL, &swapchain); |
| 2009 | pass = (err != VK_SUCCESS); |
| 2010 | ASSERT_TRUE(pass); |
| 2011 | m_errorMonitor->VerifyFound(); |
| 2012 | |
| 2013 | // Next, call with an invalid imageSharingMode: |
| 2014 | swapchain_create_info.imageSharingMode = VK_SHARING_MODE_MAX_ENUM; |
| 2015 | swapchain_create_info.queueFamilyIndexCount = 1; |
| 2016 | m_errorMonitor->SetDesiredFailureMsg( |
| 2017 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2018 | "called with a non-supported pCreateInfo->imageSharingMode (i.e."); |
| 2019 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, |
| 2020 | NULL, &swapchain); |
| 2021 | pass = (err != VK_SUCCESS); |
| 2022 | ASSERT_TRUE(pass); |
| 2023 | m_errorMonitor->VerifyFound(); |
| 2024 | // Fix for the future: |
| 2025 | // FIXME: THIS ISN'T CORRECT--MUST QUERY UNTIL WE FIND A QUEUE FAMILY THAT'S SUPPORTED |
| 2026 | swapchain_create_info.queueFamilyIndexCount = 0; |
| 2027 | queueFamilyIndex[0] = 0; |
| 2028 | swapchain_create_info.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 2029 | |
| 2030 | // TODO: CONTINUE TESTING VALIDATION OF vkCreateSwapchainKHR() ... |
| 2031 | |
| 2032 | |
| 2033 | |
| 2034 | // Get the images from a swapchain: |
| 2035 | |
| 2036 | |
| 2037 | |
| 2038 | // Acquire an image from a swapchain: |
| 2039 | |
| 2040 | |
| 2041 | |
| 2042 | // Present an image to a swapchain: |
| 2043 | |
| 2044 | |
| 2045 | |
| 2046 | // Destroy the swapchain: |
| 2047 | |
| 2048 | |
| 2049 | |
| 2050 | // TODOs: |
| 2051 | // |
| 2052 | // - Try destroying the device without first destroying the swapchain |
| 2053 | // |
| 2054 | // - Try destroying the device without first destroying the surface |
| 2055 | // |
| 2056 | // - Try destroying the surface without first destroying the swapchain |
| 2057 | |
| 2058 | |
| 2059 | // Destroy the surface: |
| 2060 | vkDestroySurfaceKHR(instance(), surface, NULL); |
| 2061 | |
| 2062 | |
| 2063 | // Tear down the window: |
| 2064 | xcb_destroy_window(connection, xcb_window); |
| 2065 | xcb_disconnect(connection); |
| 2066 | |
| 2067 | #else // VK_USE_PLATFORM_XCB_KHR |
| 2068 | err = (surface == VK_NULL_HANDLE) ? VK_SUCCESS : VK_SUCCESS; |
| 2069 | pass = (err != VK_SUCCESS); |
| 2070 | ASSERT_TRUE(pass); |
| 2071 | #endif // VK_USE_PLATFORM_XCB_KHR |
| 2072 | } |
| 2073 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2074 | TEST_F(VkLayerTest, MapMemWithoutHostVisibleBit) { |
| 2075 | VkResult err; |
| 2076 | bool pass; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2077 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2078 | m_errorMonitor->SetDesiredFailureMsg( |
| 2079 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2080 | "Mapping Memory without VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT"); |
| 2081 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2082 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2083 | |
| 2084 | // 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] | 2085 | VkImage image; |
| 2086 | VkDeviceMemory mem; |
| 2087 | VkMemoryRequirements mem_reqs; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2088 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2089 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2090 | const int32_t tex_width = 32; |
| 2091 | const int32_t tex_height = 32; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2092 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2093 | VkImageCreateInfo image_create_info = {}; |
| 2094 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2095 | image_create_info.pNext = NULL; |
| 2096 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2097 | image_create_info.format = tex_format; |
| 2098 | image_create_info.extent.width = tex_width; |
| 2099 | image_create_info.extent.height = tex_height; |
| 2100 | image_create_info.extent.depth = 1; |
| 2101 | image_create_info.mipLevels = 1; |
| 2102 | image_create_info.arrayLayers = 1; |
| 2103 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 2104 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 2105 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 2106 | image_create_info.flags = 0; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2107 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2108 | VkMemoryAllocateInfo mem_alloc = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2109 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2110 | mem_alloc.pNext = NULL; |
| 2111 | mem_alloc.allocationSize = 0; |
| 2112 | // Introduce failure, do NOT set memProps to |
| 2113 | // VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
| 2114 | mem_alloc.memoryTypeIndex = 1; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2115 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2116 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2117 | ASSERT_VK_SUCCESS(err); |
| 2118 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2119 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2120 | |
Mark Lobodzinski | 2306535 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 2121 | mem_alloc.allocationSize = mem_reqs.size; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2122 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2123 | pass = |
| 2124 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0, |
| 2125 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 2126 | if (!pass) { // If we can't find any unmappable memory this test doesn't |
| 2127 | // make sense |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2128 | vkDestroyImage(m_device->device(), image, NULL); |
Tony Barbour | 02fdc7d | 2015-08-04 16:13:01 -0600 | [diff] [blame] | 2129 | return; |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2130 | } |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 2131 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2132 | // allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2133 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2134 | ASSERT_VK_SUCCESS(err); |
| 2135 | |
| 2136 | // Try to bind free memory that has been freed |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 2137 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2138 | ASSERT_VK_SUCCESS(err); |
| 2139 | |
| 2140 | // Map memory as if to initialize the image |
| 2141 | void *mappedAddress = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2142 | err = vkMapMemory(m_device->device(), mem, 0, VK_WHOLE_SIZE, 0, |
| 2143 | &mappedAddress); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2144 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2145 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2146 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2147 | vkDestroyImage(m_device->device(), image, NULL); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2148 | } |
| 2149 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2150 | TEST_F(VkLayerTest, RebindMemory) { |
| 2151 | VkResult err; |
| 2152 | bool pass; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2153 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2154 | m_errorMonitor->SetDesiredFailureMsg( |
| 2155 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2156 | "which has already been bound to mem object"); |
| 2157 | |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2158 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2159 | |
| 2160 | // 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] | 2161 | VkImage image; |
| 2162 | VkDeviceMemory mem1; |
| 2163 | VkDeviceMemory mem2; |
| 2164 | VkMemoryRequirements mem_reqs; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2165 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2166 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2167 | const int32_t tex_width = 32; |
| 2168 | const int32_t tex_height = 32; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2169 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2170 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2171 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 2172 | image_create_info.pNext = NULL; |
| 2173 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2174 | image_create_info.format = tex_format; |
| 2175 | image_create_info.extent.width = tex_width; |
| 2176 | image_create_info.extent.height = tex_height; |
| 2177 | image_create_info.extent.depth = 1; |
| 2178 | image_create_info.mipLevels = 1; |
| 2179 | image_create_info.arrayLayers = 1; |
| 2180 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 2181 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 2182 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 2183 | image_create_info.flags = 0; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2184 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2185 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2186 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 2187 | mem_alloc.pNext = NULL; |
| 2188 | mem_alloc.allocationSize = 0; |
| 2189 | mem_alloc.memoryTypeIndex = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2190 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2191 | // Introduce failure, do NOT set memProps to |
| 2192 | // VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2193 | mem_alloc.memoryTypeIndex = 1; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2194 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2195 | ASSERT_VK_SUCCESS(err); |
| 2196 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2197 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2198 | |
| 2199 | mem_alloc.allocationSize = mem_reqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2200 | pass = |
| 2201 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 2202 | ASSERT_TRUE(pass); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2203 | |
| 2204 | // allocate 2 memory objects |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2205 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem1); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2206 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2207 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem2); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2208 | ASSERT_VK_SUCCESS(err); |
| 2209 | |
| 2210 | // Bind first memory object to Image object |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 2211 | err = vkBindImageMemory(m_device->device(), image, mem1, 0); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2212 | ASSERT_VK_SUCCESS(err); |
| 2213 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2214 | // Introduce validation failure, try to bind a different memory object to |
| 2215 | // the same image object |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 2216 | err = vkBindImageMemory(m_device->device(), image, mem2, 0); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2217 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2218 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2219 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2220 | vkDestroyImage(m_device->device(), image, NULL); |
| 2221 | vkFreeMemory(m_device->device(), mem1, NULL); |
| 2222 | vkFreeMemory(m_device->device(), mem2, NULL); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2223 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2224 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2225 | TEST_F(VkLayerTest, SubmitSignaledFence) { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2226 | vk_testing::Fence testFence; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2227 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2228 | m_errorMonitor->SetDesiredFailureMsg( |
| 2229 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "submitted in SIGNALED state. Fences " |
| 2230 | "must be reset before being submitted"); |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2231 | |
| 2232 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2233 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2234 | fenceInfo.pNext = NULL; |
| 2235 | fenceInfo.flags = VK_FENCE_CREATE_SIGNALED_BIT; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2236 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2237 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2238 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 2239 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2240 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 2241 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2242 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 2243 | m_stencil_clear_color, NULL); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 2244 | EndCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2245 | |
| 2246 | testFence.init(*m_device, fenceInfo); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2247 | |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2248 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 2249 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2250 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2251 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2252 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 2253 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2254 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2255 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2256 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2257 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 2258 | |
| 2259 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2260 | vkQueueWaitIdle(m_device->m_queue); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2261 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2262 | m_errorMonitor->VerifyFound(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2263 | } |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 2264 | // This is a positive test. We used to expect error in this case but spec now |
| 2265 | // allows it |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2266 | TEST_F(VkLayerTest, ResetUnsignaledFence) { |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 2267 | m_errorMonitor->ExpectSuccess(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2268 | vk_testing::Fence testFence; |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2269 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2270 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2271 | fenceInfo.pNext = NULL; |
| 2272 | |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2273 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2274 | testFence.init(*m_device, fenceInfo); |
Chia-I Wu | d9e8e82 | 2015-07-03 11:45:55 +0800 | [diff] [blame] | 2275 | VkFence fences[1] = {testFence.handle()}; |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 2276 | VkResult result = vkResetFences(m_device->device(), 1, fences); |
| 2277 | ASSERT_VK_SUCCESS(result); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2278 | |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 2279 | m_errorMonitor->VerifyNotFound(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2280 | } |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2281 | |
| 2282 | TEST_F(VkLayerTest, InvalidUsageBits) |
| 2283 | { |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2284 | TEST_DESCRIPTION( |
Karl Schultz | b5bc11e | 2016-05-04 08:36:08 -0600 | [diff] [blame] | 2285 | "Specify wrong usage for image then create conflicting view of image " |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2286 | "Initialize buffer with wrong usage then perform copy expecting errors " |
| 2287 | "from both the image and the buffer (2 calls)"); |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2288 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2289 | "Invalid usage flag for image "); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2290 | |
| 2291 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2292 | VkImageObj image(m_device); |
| 2293 | // Initialize image with USAGE_INPUT_ATTACHMENT |
| 2294 | image.init(128, 128, VK_FORMAT_D32_SFLOAT_S8_UINT, |
Karl Schultz | b5bc11e | 2016-05-04 08:36:08 -0600 | [diff] [blame] | 2295 | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
| 2296 | ASSERT_TRUE(image.initialized()); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2297 | |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2298 | VkImageView dsv; |
| 2299 | VkImageViewCreateInfo dsvci = {}; |
| 2300 | dsvci.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 2301 | dsvci.image = image.handle(); |
| 2302 | dsvci.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 2303 | dsvci.format = VK_FORMAT_D32_SFLOAT_S8_UINT; |
| 2304 | dsvci.subresourceRange.layerCount = 1; |
| 2305 | dsvci.subresourceRange.baseMipLevel = 0; |
| 2306 | dsvci.subresourceRange.levelCount = 1; |
| 2307 | dsvci.subresourceRange.aspectMask = |
| 2308 | VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2309 | |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2310 | // Create a view with depth / stencil aspect for image with different usage |
| 2311 | vkCreateImageView(m_device->device(), &dsvci, NULL, &dsv); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2312 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2313 | m_errorMonitor->VerifyFound(); |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2314 | |
| 2315 | // Initialize buffer with TRANSFER_DST usage |
| 2316 | vk_testing::Buffer buffer; |
| 2317 | VkMemoryPropertyFlags reqs = 0; |
| 2318 | buffer.init_as_dst(*m_device, 128 * 128, reqs); |
| 2319 | VkBufferImageCopy region = {}; |
| 2320 | region.bufferRowLength = 128; |
| 2321 | region.bufferImageHeight = 128; |
| 2322 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 2323 | region.imageSubresource.layerCount = 1; |
| 2324 | region.imageExtent.height = 16; |
| 2325 | region.imageExtent.width = 16; |
| 2326 | region.imageExtent.depth = 1; |
| 2327 | |
| 2328 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2329 | "Invalid usage flag for buffer "); |
| 2330 | // Buffer usage not set to TRANSFER_SRC and image usage not set to |
| 2331 | // TRANSFER_DST |
| 2332 | BeginCommandBuffer(); |
| 2333 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 2334 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 2335 | 1, ®ion); |
| 2336 | m_errorMonitor->VerifyFound(); |
| 2337 | |
| 2338 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2339 | "Invalid usage flag for image "); |
| 2340 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 2341 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 2342 | 1, ®ion); |
| 2343 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2344 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 2345 | #endif // MEM_TRACKER_TESTS |
| 2346 | |
Tobin Ehlis | 4bf96d1 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 2347 | #if OBJ_TRACKER_TESTS |
Mark Lobodzinski | fc5cc66 | 2016-05-02 17:17:41 -0600 | [diff] [blame] | 2348 | |
| 2349 | TEST_F(VkLayerTest, LeakAnObject) { |
| 2350 | VkResult err; |
| 2351 | |
| 2352 | TEST_DESCRIPTION( |
| 2353 | "Create a fence and destroy its device without first destroying the fence."); |
| 2354 | |
| 2355 | // Note that we have to create a new device since destroying the |
| 2356 | // framework's device causes Teardown() to fail and just calling Teardown |
| 2357 | // will destroy the errorMonitor. |
| 2358 | |
| 2359 | m_errorMonitor->SetDesiredFailureMsg( |
| 2360 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2361 | "OBJ ERROR : VK_DEBUG_REPORT_OBJECT_TYPE_FENCE_EXT object"); |
| 2362 | |
| 2363 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2364 | |
| 2365 | const std::vector<VkQueueFamilyProperties> queue_props = |
| 2366 | m_device->queue_props; |
| 2367 | std::vector<VkDeviceQueueCreateInfo> queue_info; |
| 2368 | queue_info.reserve(queue_props.size()); |
| 2369 | std::vector<std::vector<float>> queue_priorities; |
| 2370 | for (uint32_t i = 0; i < (uint32_t)queue_props.size(); i++) { |
| 2371 | VkDeviceQueueCreateInfo qi = {}; |
| 2372 | qi.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO; |
| 2373 | qi.pNext = NULL; |
| 2374 | qi.queueFamilyIndex = i; |
| 2375 | qi.queueCount = queue_props[i].queueCount; |
| 2376 | queue_priorities.emplace_back(qi.queueCount, 0.0f); |
| 2377 | qi.pQueuePriorities = queue_priorities[i].data(); |
| 2378 | queue_info.push_back(qi); |
| 2379 | } |
| 2380 | |
| 2381 | std::vector<const char *> device_layer_names; |
| 2382 | std::vector<const char *> device_extension_names; |
| 2383 | device_layer_names.push_back("VK_LAYER_GOOGLE_threading"); |
| 2384 | device_layer_names.push_back("VK_LAYER_LUNARG_parameter_validation"); |
| 2385 | device_layer_names.push_back("VK_LAYER_LUNARG_object_tracker"); |
| 2386 | device_layer_names.push_back("VK_LAYER_LUNARG_core_validation"); |
| 2387 | device_layer_names.push_back("VK_LAYER_LUNARG_device_limits"); |
| 2388 | device_layer_names.push_back("VK_LAYER_LUNARG_image"); |
| 2389 | device_layer_names.push_back("VK_LAYER_GOOGLE_unique_objects"); |
| 2390 | |
| 2391 | // The sacrificial device object |
| 2392 | VkDevice testDevice; |
| 2393 | VkDeviceCreateInfo device_create_info = {}; |
| 2394 | auto features = m_device->phy().features(); |
| 2395 | device_create_info.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO; |
| 2396 | device_create_info.pNext = NULL; |
| 2397 | device_create_info.queueCreateInfoCount = queue_info.size(); |
| 2398 | device_create_info.pQueueCreateInfos = queue_info.data(); |
| 2399 | device_create_info.enabledLayerCount = device_layer_names.size(); |
| 2400 | device_create_info.ppEnabledLayerNames = device_layer_names.data(); |
| 2401 | device_create_info.pEnabledFeatures = &features; |
| 2402 | err = vkCreateDevice(gpu(), &device_create_info, NULL, &testDevice); |
| 2403 | ASSERT_VK_SUCCESS(err); |
| 2404 | |
| 2405 | VkFence fence; |
| 2406 | VkFenceCreateInfo fence_create_info = {}; |
| 2407 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2408 | fence_create_info.pNext = NULL; |
| 2409 | fence_create_info.flags = 0; |
| 2410 | err = vkCreateFence(testDevice, &fence_create_info, NULL, &fence); |
| 2411 | ASSERT_VK_SUCCESS(err); |
| 2412 | |
| 2413 | // Induce failure by not calling vkDestroyFence |
| 2414 | vkDestroyDevice(testDevice, NULL); |
| 2415 | m_errorMonitor->VerifyFound(); |
| 2416 | } |
| 2417 | |
| 2418 | TEST_F(VkLayerTest, InvalidCommandPoolConsistency) { |
| 2419 | |
| 2420 | TEST_DESCRIPTION("Allocate command buffers from one command pool and " |
| 2421 | "attempt to delete them from another."); |
| 2422 | |
| 2423 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2424 | "FreeCommandBuffers is attempting to free Command Buffer"); |
| 2425 | |
| 2426 | VkCommandPool command_pool_one; |
| 2427 | VkCommandPool command_pool_two; |
| 2428 | |
| 2429 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2430 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2431 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2432 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2433 | |
| 2434 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2435 | &command_pool_one); |
| 2436 | |
| 2437 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2438 | &command_pool_two); |
| 2439 | |
| 2440 | VkCommandBuffer command_buffer[9]; |
| 2441 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2442 | command_buffer_allocate_info.sType = |
| 2443 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2444 | command_buffer_allocate_info.commandPool = command_pool_one; |
| 2445 | command_buffer_allocate_info.commandBufferCount = 9; |
| 2446 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2447 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2448 | command_buffer); |
| 2449 | |
| 2450 | vkFreeCommandBuffers(m_device->device(), command_pool_two, 4, |
| 2451 | &command_buffer[3]); |
| 2452 | |
| 2453 | m_errorMonitor->VerifyFound(); |
| 2454 | |
| 2455 | vkDestroyCommandPool(m_device->device(), command_pool_one, NULL); |
| 2456 | vkDestroyCommandPool(m_device->device(), command_pool_two, NULL); |
| 2457 | } |
| 2458 | |
| 2459 | TEST_F(VkLayerTest, InvalidDescriptorPoolConsistency) { |
| 2460 | VkResult err; |
| 2461 | |
| 2462 | TEST_DESCRIPTION("Allocate descriptor sets from one DS pool and " |
| 2463 | "attempt to delete them from another."); |
| 2464 | |
| 2465 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2466 | "FreeDescriptorSets is attempting to free descriptorSet"); |
| 2467 | |
| 2468 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2469 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2470 | |
| 2471 | VkDescriptorPoolSize ds_type_count = {}; |
| 2472 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 2473 | ds_type_count.descriptorCount = 1; |
| 2474 | |
| 2475 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2476 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2477 | ds_pool_ci.pNext = NULL; |
| 2478 | ds_pool_ci.flags = 0; |
| 2479 | ds_pool_ci.maxSets = 1; |
| 2480 | ds_pool_ci.poolSizeCount = 1; |
| 2481 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 2482 | |
| 2483 | VkDescriptorPool ds_pool_one; |
| 2484 | err = |
| 2485 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool_one); |
| 2486 | ASSERT_VK_SUCCESS(err); |
| 2487 | |
| 2488 | // Create a second descriptor pool |
| 2489 | VkDescriptorPool ds_pool_two; |
| 2490 | err = |
| 2491 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool_two); |
| 2492 | ASSERT_VK_SUCCESS(err); |
| 2493 | |
| 2494 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 2495 | dsl_binding.binding = 0; |
| 2496 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 2497 | dsl_binding.descriptorCount = 1; |
| 2498 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2499 | dsl_binding.pImmutableSamplers = NULL; |
| 2500 | |
| 2501 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2502 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2503 | ds_layout_ci.pNext = NULL; |
| 2504 | ds_layout_ci.bindingCount = 1; |
| 2505 | ds_layout_ci.pBindings = &dsl_binding; |
| 2506 | |
| 2507 | VkDescriptorSetLayout ds_layout; |
| 2508 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2509 | &ds_layout); |
| 2510 | ASSERT_VK_SUCCESS(err); |
| 2511 | |
| 2512 | VkDescriptorSet descriptorSet; |
| 2513 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 2514 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 2515 | alloc_info.descriptorSetCount = 1; |
| 2516 | alloc_info.descriptorPool = ds_pool_one; |
| 2517 | alloc_info.pSetLayouts = &ds_layout; |
| 2518 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 2519 | &descriptorSet); |
| 2520 | ASSERT_VK_SUCCESS(err); |
| 2521 | |
| 2522 | err = vkFreeDescriptorSets(m_device->device(), ds_pool_two, 1, &descriptorSet); |
| 2523 | |
| 2524 | m_errorMonitor->VerifyFound(); |
| 2525 | |
| 2526 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2527 | vkDestroyDescriptorPool(m_device->device(), ds_pool_one, NULL); |
| 2528 | vkDestroyDescriptorPool(m_device->device(), ds_pool_two, NULL); |
| 2529 | } |
| 2530 | |
| 2531 | TEST_F(VkLayerTest, CreateUnknownObject) { |
| 2532 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2533 | "Invalid VkImage Object "); |
| 2534 | |
| 2535 | TEST_DESCRIPTION( |
| 2536 | "Pass an invalid image object handle into a Vulkan API call."); |
| 2537 | |
| 2538 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2539 | |
| 2540 | // Pass bogus handle into GetImageMemoryRequirements |
| 2541 | VkMemoryRequirements mem_reqs; |
| 2542 | uint64_t fakeImageHandle = 0xCADECADE; |
| 2543 | VkImage fauxImage = reinterpret_cast<VkImage &>(fakeImageHandle); |
| 2544 | |
| 2545 | vkGetImageMemoryRequirements(m_device->device(), fauxImage, &mem_reqs); |
| 2546 | |
| 2547 | m_errorMonitor->VerifyFound(); |
| 2548 | } |
| 2549 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2550 | TEST_F(VkLayerTest, PipelineNotBound) { |
| 2551 | VkResult err; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2552 | |
Mark Lobodzinski | fc5cc66 | 2016-05-02 17:17:41 -0600 | [diff] [blame] | 2553 | TEST_DESCRIPTION( |
| 2554 | "Pass in an invalid pipeline object handle into a Vulkan API call."); |
| 2555 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2556 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2557 | "Invalid VkPipeline Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2558 | |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2559 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2560 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2561 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2562 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2563 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2564 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2565 | |
| 2566 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2567 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2568 | ds_pool_ci.pNext = NULL; |
| 2569 | ds_pool_ci.maxSets = 1; |
| 2570 | ds_pool_ci.poolSizeCount = 1; |
| 2571 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2572 | |
| 2573 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2574 | err = |
| 2575 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2576 | ASSERT_VK_SUCCESS(err); |
| 2577 | |
| 2578 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2579 | dsl_binding.binding = 0; |
| 2580 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2581 | dsl_binding.descriptorCount = 1; |
| 2582 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2583 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2584 | |
| 2585 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2586 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2587 | ds_layout_ci.pNext = NULL; |
| 2588 | ds_layout_ci.bindingCount = 1; |
| 2589 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2590 | |
| 2591 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2592 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2593 | &ds_layout); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2594 | ASSERT_VK_SUCCESS(err); |
| 2595 | |
| 2596 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2597 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2598 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2599 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2600 | alloc_info.descriptorPool = ds_pool; |
| 2601 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2602 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 2603 | &descriptorSet); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2604 | ASSERT_VK_SUCCESS(err); |
| 2605 | |
| 2606 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2607 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 2608 | pipeline_layout_ci.pNext = NULL; |
| 2609 | pipeline_layout_ci.setLayoutCount = 1; |
| 2610 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2611 | |
| 2612 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2613 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2614 | &pipeline_layout); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2615 | ASSERT_VK_SUCCESS(err); |
| 2616 | |
Mark Young | ad77905 | 2016-01-06 14:26:04 -0700 | [diff] [blame] | 2617 | VkPipeline badPipeline = (VkPipeline)((size_t)0xbaadb1be); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2618 | |
| 2619 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2620 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 2621 | VK_PIPELINE_BIND_POINT_GRAPHICS, badPipeline); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2622 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2623 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2624 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2625 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2626 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2627 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2628 | } |
| 2629 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2630 | TEST_F(VkLayerTest, BindInvalidMemory) { |
| 2631 | VkResult err; |
| 2632 | bool pass; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2633 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2634 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2635 | "Invalid VkDeviceMemory Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2636 | |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2637 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2638 | |
| 2639 | // 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] | 2640 | VkImage image; |
| 2641 | VkDeviceMemory mem; |
| 2642 | VkMemoryRequirements mem_reqs; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2643 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2644 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2645 | const int32_t tex_width = 32; |
| 2646 | const int32_t tex_height = 32; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2647 | |
| 2648 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2649 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 2650 | image_create_info.pNext = NULL; |
| 2651 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2652 | image_create_info.format = tex_format; |
| 2653 | image_create_info.extent.width = tex_width; |
| 2654 | image_create_info.extent.height = tex_height; |
| 2655 | image_create_info.extent.depth = 1; |
| 2656 | image_create_info.mipLevels = 1; |
| 2657 | image_create_info.arrayLayers = 1; |
| 2658 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 2659 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 2660 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 2661 | image_create_info.flags = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2662 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2663 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2664 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 2665 | mem_alloc.pNext = NULL; |
| 2666 | mem_alloc.allocationSize = 0; |
| 2667 | mem_alloc.memoryTypeIndex = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2668 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2669 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2670 | ASSERT_VK_SUCCESS(err); |
| 2671 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2672 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2673 | |
| 2674 | mem_alloc.allocationSize = mem_reqs.size; |
| 2675 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2676 | pass = |
| 2677 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 2678 | ASSERT_TRUE(pass); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2679 | |
| 2680 | // allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2681 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2682 | ASSERT_VK_SUCCESS(err); |
| 2683 | |
| 2684 | // Introduce validation failure, free memory before binding |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2685 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2686 | |
| 2687 | // Try to bind free memory that has been freed |
| 2688 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 2689 | // This may very well return an error. |
| 2690 | (void)err; |
| 2691 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2692 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2693 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2694 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2695 | } |
| 2696 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2697 | TEST_F(VkLayerTest, BindMemoryToDestroyedObject) { |
| 2698 | VkResult err; |
| 2699 | bool pass; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2700 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2701 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2702 | "Invalid VkImage Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2703 | |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2704 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2705 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2706 | // Create an image object, allocate memory, destroy the object and then try |
| 2707 | // to bind it |
| 2708 | VkImage image; |
| 2709 | VkDeviceMemory mem; |
| 2710 | VkMemoryRequirements mem_reqs; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2711 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2712 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2713 | const int32_t tex_width = 32; |
| 2714 | const int32_t tex_height = 32; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2715 | |
| 2716 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2717 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 2718 | image_create_info.pNext = NULL; |
| 2719 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2720 | image_create_info.format = tex_format; |
| 2721 | image_create_info.extent.width = tex_width; |
| 2722 | image_create_info.extent.height = tex_height; |
| 2723 | image_create_info.extent.depth = 1; |
| 2724 | image_create_info.mipLevels = 1; |
| 2725 | image_create_info.arrayLayers = 1; |
| 2726 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 2727 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 2728 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 2729 | image_create_info.flags = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2730 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2731 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2732 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 2733 | mem_alloc.pNext = NULL; |
| 2734 | mem_alloc.allocationSize = 0; |
| 2735 | mem_alloc.memoryTypeIndex = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2736 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2737 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2738 | ASSERT_VK_SUCCESS(err); |
| 2739 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2740 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2741 | |
| 2742 | mem_alloc.allocationSize = mem_reqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2743 | pass = |
| 2744 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 2745 | ASSERT_TRUE(pass); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2746 | |
| 2747 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2748 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2749 | ASSERT_VK_SUCCESS(err); |
| 2750 | |
| 2751 | // Introduce validation failure, destroy Image object before binding |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2752 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2753 | ASSERT_VK_SUCCESS(err); |
| 2754 | |
| 2755 | // Now Try to bind memory to this destroyed object |
| 2756 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 2757 | // This may very well return an error. |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2758 | (void)err; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2759 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2760 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2761 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2762 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2763 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 2764 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 2765 | #endif // OBJ_TRACKER_TESTS |
| 2766 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 2767 | #if DRAW_STATE_TESTS |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 2768 | |
| 2769 | // This is a positive test. No errors should be generated. |
| 2770 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceQWI) { |
| 2771 | |
| 2772 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 2773 | "submitted on separate queues followed by a QueueWaitIdle."); |
| 2774 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 2775 | if ((m_device->queue_props.empty()) || |
| 2776 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 2777 | return; |
| 2778 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 2779 | m_errorMonitor->ExpectSuccess(); |
| 2780 | |
| 2781 | VkSemaphore semaphore; |
| 2782 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 2783 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 2784 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 2785 | &semaphore); |
| 2786 | |
| 2787 | VkCommandPool command_pool; |
| 2788 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2789 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2790 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2791 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2792 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2793 | &command_pool); |
| 2794 | |
| 2795 | VkCommandBuffer command_buffer[2]; |
| 2796 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2797 | command_buffer_allocate_info.sType = |
| 2798 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2799 | command_buffer_allocate_info.commandPool = command_pool; |
| 2800 | command_buffer_allocate_info.commandBufferCount = 2; |
| 2801 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2802 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2803 | command_buffer); |
| 2804 | |
| 2805 | VkQueue queue = VK_NULL_HANDLE; |
| 2806 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 2807 | 1, &queue); |
| 2808 | |
| 2809 | { |
| 2810 | VkCommandBufferBeginInfo begin_info{}; |
| 2811 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2812 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2813 | |
| 2814 | vkCmdPipelineBarrier(command_buffer[0], |
| 2815 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2816 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 2817 | 0, nullptr, 0, nullptr); |
| 2818 | |
| 2819 | VkViewport viewport{}; |
| 2820 | viewport.maxDepth = 1.0f; |
| 2821 | viewport.minDepth = 0.0f; |
| 2822 | viewport.width = 512; |
| 2823 | viewport.height = 512; |
| 2824 | viewport.x = 0; |
| 2825 | viewport.y = 0; |
| 2826 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 2827 | vkEndCommandBuffer(command_buffer[0]); |
| 2828 | } |
| 2829 | { |
| 2830 | VkCommandBufferBeginInfo begin_info{}; |
| 2831 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2832 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 2833 | |
| 2834 | VkViewport viewport{}; |
| 2835 | viewport.maxDepth = 1.0f; |
| 2836 | viewport.minDepth = 0.0f; |
| 2837 | viewport.width = 512; |
| 2838 | viewport.height = 512; |
| 2839 | viewport.x = 0; |
| 2840 | viewport.y = 0; |
| 2841 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 2842 | vkEndCommandBuffer(command_buffer[1]); |
| 2843 | } |
| 2844 | { |
| 2845 | VkSubmitInfo submit_info{}; |
| 2846 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2847 | submit_info.commandBufferCount = 1; |
| 2848 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 2849 | submit_info.signalSemaphoreCount = 1; |
| 2850 | submit_info.pSignalSemaphores = &semaphore; |
| 2851 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2852 | } |
| 2853 | { |
| 2854 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 2855 | VkSubmitInfo submit_info{}; |
| 2856 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2857 | submit_info.commandBufferCount = 1; |
| 2858 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 2859 | submit_info.waitSemaphoreCount = 1; |
| 2860 | submit_info.pWaitSemaphores = &semaphore; |
| 2861 | submit_info.pWaitDstStageMask = flags; |
| 2862 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2863 | } |
| 2864 | |
| 2865 | vkQueueWaitIdle(m_device->m_queue); |
| 2866 | |
| 2867 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 2868 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 2869 | &command_buffer[0]); |
| 2870 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2871 | |
| 2872 | m_errorMonitor->VerifyNotFound(); |
| 2873 | } |
| 2874 | |
| 2875 | // This is a positive test. No errors should be generated. |
| 2876 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceQWIFence) { |
| 2877 | |
| 2878 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 2879 | "submitted on separate queues, the second having a fence" |
| 2880 | "followed by a QueueWaitIdle."); |
| 2881 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 2882 | if ((m_device->queue_props.empty()) || |
| 2883 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 2884 | return; |
| 2885 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 2886 | m_errorMonitor->ExpectSuccess(); |
| 2887 | |
| 2888 | VkFence fence; |
| 2889 | VkFenceCreateInfo fence_create_info{}; |
| 2890 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2891 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 2892 | |
| 2893 | VkSemaphore semaphore; |
| 2894 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 2895 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 2896 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 2897 | &semaphore); |
| 2898 | |
| 2899 | VkCommandPool command_pool; |
| 2900 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2901 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2902 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2903 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2904 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2905 | &command_pool); |
| 2906 | |
| 2907 | VkCommandBuffer command_buffer[2]; |
| 2908 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2909 | command_buffer_allocate_info.sType = |
| 2910 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2911 | command_buffer_allocate_info.commandPool = command_pool; |
| 2912 | command_buffer_allocate_info.commandBufferCount = 2; |
| 2913 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2914 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2915 | command_buffer); |
| 2916 | |
| 2917 | VkQueue queue = VK_NULL_HANDLE; |
| 2918 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 2919 | 1, &queue); |
| 2920 | |
| 2921 | { |
| 2922 | VkCommandBufferBeginInfo begin_info{}; |
| 2923 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2924 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2925 | |
| 2926 | vkCmdPipelineBarrier(command_buffer[0], |
| 2927 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2928 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 2929 | 0, nullptr, 0, nullptr); |
| 2930 | |
| 2931 | VkViewport viewport{}; |
| 2932 | viewport.maxDepth = 1.0f; |
| 2933 | viewport.minDepth = 0.0f; |
| 2934 | viewport.width = 512; |
| 2935 | viewport.height = 512; |
| 2936 | viewport.x = 0; |
| 2937 | viewport.y = 0; |
| 2938 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 2939 | vkEndCommandBuffer(command_buffer[0]); |
| 2940 | } |
| 2941 | { |
| 2942 | VkCommandBufferBeginInfo begin_info{}; |
| 2943 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2944 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 2945 | |
| 2946 | VkViewport viewport{}; |
| 2947 | viewport.maxDepth = 1.0f; |
| 2948 | viewport.minDepth = 0.0f; |
| 2949 | viewport.width = 512; |
| 2950 | viewport.height = 512; |
| 2951 | viewport.x = 0; |
| 2952 | viewport.y = 0; |
| 2953 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 2954 | vkEndCommandBuffer(command_buffer[1]); |
| 2955 | } |
| 2956 | { |
| 2957 | VkSubmitInfo submit_info{}; |
| 2958 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2959 | submit_info.commandBufferCount = 1; |
| 2960 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 2961 | submit_info.signalSemaphoreCount = 1; |
| 2962 | submit_info.pSignalSemaphores = &semaphore; |
| 2963 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2964 | } |
| 2965 | { |
| 2966 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 2967 | VkSubmitInfo submit_info{}; |
| 2968 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2969 | submit_info.commandBufferCount = 1; |
| 2970 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 2971 | submit_info.waitSemaphoreCount = 1; |
| 2972 | submit_info.pWaitSemaphores = &semaphore; |
| 2973 | submit_info.pWaitDstStageMask = flags; |
| 2974 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 2975 | } |
| 2976 | |
| 2977 | vkQueueWaitIdle(m_device->m_queue); |
| 2978 | |
| 2979 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 2980 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 2981 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 2982 | &command_buffer[0]); |
| 2983 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2984 | |
| 2985 | m_errorMonitor->VerifyNotFound(); |
| 2986 | } |
| 2987 | |
| 2988 | // This is a positive test. No errors should be generated. |
| 2989 | TEST_F(VkLayerTest, |
| 2990 | TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceTwoWFF) { |
| 2991 | |
| 2992 | TEST_DESCRIPTION( |
| 2993 | "Two command buffers, each in a separate QueueSubmit call " |
| 2994 | "submitted on separate queues, the second having a fence" |
| 2995 | "followed by two consecutive WaitForFences calls on the same fence."); |
| 2996 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 2997 | if ((m_device->queue_props.empty()) || |
| 2998 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 2999 | return; |
| 3000 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3001 | m_errorMonitor->ExpectSuccess(); |
| 3002 | |
| 3003 | VkFence fence; |
| 3004 | VkFenceCreateInfo fence_create_info{}; |
| 3005 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3006 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3007 | |
| 3008 | VkSemaphore semaphore; |
| 3009 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 3010 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 3011 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 3012 | &semaphore); |
| 3013 | |
| 3014 | VkCommandPool command_pool; |
| 3015 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3016 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3017 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3018 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3019 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3020 | &command_pool); |
| 3021 | |
| 3022 | VkCommandBuffer command_buffer[2]; |
| 3023 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3024 | command_buffer_allocate_info.sType = |
| 3025 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3026 | command_buffer_allocate_info.commandPool = command_pool; |
| 3027 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3028 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3029 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3030 | command_buffer); |
| 3031 | |
| 3032 | VkQueue queue = VK_NULL_HANDLE; |
| 3033 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 3034 | 1, &queue); |
| 3035 | |
| 3036 | { |
| 3037 | VkCommandBufferBeginInfo begin_info{}; |
| 3038 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3039 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3040 | |
| 3041 | vkCmdPipelineBarrier(command_buffer[0], |
| 3042 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3043 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3044 | 0, nullptr, 0, nullptr); |
| 3045 | |
| 3046 | VkViewport viewport{}; |
| 3047 | viewport.maxDepth = 1.0f; |
| 3048 | viewport.minDepth = 0.0f; |
| 3049 | viewport.width = 512; |
| 3050 | viewport.height = 512; |
| 3051 | viewport.x = 0; |
| 3052 | viewport.y = 0; |
| 3053 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3054 | vkEndCommandBuffer(command_buffer[0]); |
| 3055 | } |
| 3056 | { |
| 3057 | VkCommandBufferBeginInfo begin_info{}; |
| 3058 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3059 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3060 | |
| 3061 | VkViewport viewport{}; |
| 3062 | viewport.maxDepth = 1.0f; |
| 3063 | viewport.minDepth = 0.0f; |
| 3064 | viewport.width = 512; |
| 3065 | viewport.height = 512; |
| 3066 | viewport.x = 0; |
| 3067 | viewport.y = 0; |
| 3068 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3069 | vkEndCommandBuffer(command_buffer[1]); |
| 3070 | } |
| 3071 | { |
| 3072 | VkSubmitInfo submit_info{}; |
| 3073 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3074 | submit_info.commandBufferCount = 1; |
| 3075 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3076 | submit_info.signalSemaphoreCount = 1; |
| 3077 | submit_info.pSignalSemaphores = &semaphore; |
| 3078 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3079 | } |
| 3080 | { |
| 3081 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3082 | VkSubmitInfo submit_info{}; |
| 3083 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3084 | submit_info.commandBufferCount = 1; |
| 3085 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3086 | submit_info.waitSemaphoreCount = 1; |
| 3087 | submit_info.pWaitSemaphores = &semaphore; |
| 3088 | submit_info.pWaitDstStageMask = flags; |
| 3089 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 3090 | } |
| 3091 | |
| 3092 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3093 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3094 | |
| 3095 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3096 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 3097 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3098 | &command_buffer[0]); |
| 3099 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3100 | |
| 3101 | m_errorMonitor->VerifyNotFound(); |
| 3102 | } |
| 3103 | |
| 3104 | // This is a positive test. No errors should be generated. |
| 3105 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFence) { |
| 3106 | |
| 3107 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 3108 | "submitted on separate queues, the second having a fence, " |
| 3109 | "followed by a WaitForFences call."); |
| 3110 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 3111 | if ((m_device->queue_props.empty()) || |
| 3112 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 3113 | return; |
| 3114 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3115 | m_errorMonitor->ExpectSuccess(); |
| 3116 | |
| 3117 | VkFence fence; |
| 3118 | VkFenceCreateInfo fence_create_info{}; |
| 3119 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3120 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3121 | |
| 3122 | VkSemaphore semaphore; |
| 3123 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 3124 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 3125 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 3126 | &semaphore); |
| 3127 | |
| 3128 | VkCommandPool command_pool; |
| 3129 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3130 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3131 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3132 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3133 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3134 | &command_pool); |
| 3135 | |
| 3136 | VkCommandBuffer command_buffer[2]; |
| 3137 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3138 | command_buffer_allocate_info.sType = |
| 3139 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3140 | command_buffer_allocate_info.commandPool = command_pool; |
| 3141 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3142 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3143 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3144 | command_buffer); |
| 3145 | |
| 3146 | VkQueue queue = VK_NULL_HANDLE; |
| 3147 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 3148 | 1, &queue); |
| 3149 | |
| 3150 | |
| 3151 | { |
| 3152 | VkCommandBufferBeginInfo begin_info{}; |
| 3153 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3154 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3155 | |
| 3156 | vkCmdPipelineBarrier(command_buffer[0], |
| 3157 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3158 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3159 | 0, nullptr, 0, nullptr); |
| 3160 | |
| 3161 | VkViewport viewport{}; |
| 3162 | viewport.maxDepth = 1.0f; |
| 3163 | viewport.minDepth = 0.0f; |
| 3164 | viewport.width = 512; |
| 3165 | viewport.height = 512; |
| 3166 | viewport.x = 0; |
| 3167 | viewport.y = 0; |
| 3168 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3169 | vkEndCommandBuffer(command_buffer[0]); |
| 3170 | } |
| 3171 | { |
| 3172 | VkCommandBufferBeginInfo begin_info{}; |
| 3173 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3174 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3175 | |
| 3176 | VkViewport viewport{}; |
| 3177 | viewport.maxDepth = 1.0f; |
| 3178 | viewport.minDepth = 0.0f; |
| 3179 | viewport.width = 512; |
| 3180 | viewport.height = 512; |
| 3181 | viewport.x = 0; |
| 3182 | viewport.y = 0; |
| 3183 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3184 | vkEndCommandBuffer(command_buffer[1]); |
| 3185 | } |
| 3186 | { |
| 3187 | VkSubmitInfo submit_info{}; |
| 3188 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3189 | submit_info.commandBufferCount = 1; |
| 3190 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3191 | submit_info.signalSemaphoreCount = 1; |
| 3192 | submit_info.pSignalSemaphores = &semaphore; |
| 3193 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3194 | } |
| 3195 | { |
| 3196 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3197 | VkSubmitInfo submit_info{}; |
| 3198 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3199 | submit_info.commandBufferCount = 1; |
| 3200 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3201 | submit_info.waitSemaphoreCount = 1; |
| 3202 | submit_info.pWaitSemaphores = &semaphore; |
| 3203 | submit_info.pWaitDstStageMask = flags; |
| 3204 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 3205 | } |
| 3206 | |
| 3207 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3208 | |
| 3209 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3210 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 3211 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3212 | &command_buffer[0]); |
| 3213 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3214 | |
| 3215 | m_errorMonitor->VerifyNotFound(); |
| 3216 | } |
| 3217 | |
| 3218 | // This is a positive test. No errors should be generated. |
| 3219 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueWithSemaphoreAndOneFence) { |
| 3220 | |
| 3221 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 3222 | "on the same queue, sharing a signal/wait semaphore, the " |
| 3223 | "second having a fence, " |
| 3224 | "followed by a WaitForFences call."); |
| 3225 | |
| 3226 | m_errorMonitor->ExpectSuccess(); |
| 3227 | |
| 3228 | VkFence fence; |
| 3229 | VkFenceCreateInfo fence_create_info{}; |
| 3230 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3231 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3232 | |
| 3233 | VkSemaphore semaphore; |
| 3234 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 3235 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 3236 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 3237 | &semaphore); |
| 3238 | |
| 3239 | VkCommandPool command_pool; |
| 3240 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3241 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3242 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3243 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3244 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3245 | &command_pool); |
| 3246 | |
| 3247 | VkCommandBuffer command_buffer[2]; |
| 3248 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3249 | command_buffer_allocate_info.sType = |
| 3250 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3251 | command_buffer_allocate_info.commandPool = command_pool; |
| 3252 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3253 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3254 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3255 | command_buffer); |
| 3256 | |
| 3257 | { |
| 3258 | VkCommandBufferBeginInfo begin_info{}; |
| 3259 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3260 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3261 | |
| 3262 | vkCmdPipelineBarrier(command_buffer[0], |
| 3263 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3264 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3265 | 0, nullptr, 0, nullptr); |
| 3266 | |
| 3267 | VkViewport viewport{}; |
| 3268 | viewport.maxDepth = 1.0f; |
| 3269 | viewport.minDepth = 0.0f; |
| 3270 | viewport.width = 512; |
| 3271 | viewport.height = 512; |
| 3272 | viewport.x = 0; |
| 3273 | viewport.y = 0; |
| 3274 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3275 | vkEndCommandBuffer(command_buffer[0]); |
| 3276 | } |
| 3277 | { |
| 3278 | VkCommandBufferBeginInfo begin_info{}; |
| 3279 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3280 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3281 | |
| 3282 | VkViewport viewport{}; |
| 3283 | viewport.maxDepth = 1.0f; |
| 3284 | viewport.minDepth = 0.0f; |
| 3285 | viewport.width = 512; |
| 3286 | viewport.height = 512; |
| 3287 | viewport.x = 0; |
| 3288 | viewport.y = 0; |
| 3289 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3290 | vkEndCommandBuffer(command_buffer[1]); |
| 3291 | } |
| 3292 | { |
| 3293 | VkSubmitInfo submit_info{}; |
| 3294 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3295 | submit_info.commandBufferCount = 1; |
| 3296 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3297 | submit_info.signalSemaphoreCount = 1; |
| 3298 | submit_info.pSignalSemaphores = &semaphore; |
| 3299 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3300 | } |
| 3301 | { |
| 3302 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3303 | VkSubmitInfo submit_info{}; |
| 3304 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3305 | submit_info.commandBufferCount = 1; |
| 3306 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3307 | submit_info.waitSemaphoreCount = 1; |
| 3308 | submit_info.pWaitSemaphores = &semaphore; |
| 3309 | submit_info.pWaitDstStageMask = flags; |
| 3310 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 3311 | } |
| 3312 | |
| 3313 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3314 | |
| 3315 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3316 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 3317 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3318 | &command_buffer[0]); |
| 3319 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3320 | |
| 3321 | m_errorMonitor->VerifyNotFound(); |
| 3322 | } |
| 3323 | |
| 3324 | // This is a positive test. No errors should be generated. |
| 3325 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueNullQueueSubmitWithFence) { |
| 3326 | |
| 3327 | TEST_DESCRIPTION( |
| 3328 | "Two command buffers, each in a separate QueueSubmit call " |
| 3329 | "on the same queue, no fences, followed by a third QueueSubmit with NO " |
| 3330 | "SubmitInfos but with a fence, followed by a WaitForFences call."); |
| 3331 | |
| 3332 | m_errorMonitor->ExpectSuccess(); |
| 3333 | |
| 3334 | VkFence fence; |
| 3335 | VkFenceCreateInfo fence_create_info{}; |
| 3336 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3337 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3338 | |
| 3339 | VkCommandPool command_pool; |
| 3340 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3341 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3342 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3343 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3344 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3345 | &command_pool); |
| 3346 | |
| 3347 | VkCommandBuffer command_buffer[2]; |
| 3348 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3349 | command_buffer_allocate_info.sType = |
| 3350 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3351 | command_buffer_allocate_info.commandPool = command_pool; |
| 3352 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3353 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3354 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3355 | command_buffer); |
| 3356 | |
| 3357 | { |
| 3358 | VkCommandBufferBeginInfo begin_info{}; |
| 3359 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3360 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3361 | |
| 3362 | vkCmdPipelineBarrier(command_buffer[0], |
| 3363 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3364 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3365 | 0, nullptr, 0, nullptr); |
| 3366 | |
| 3367 | VkViewport viewport{}; |
| 3368 | viewport.maxDepth = 1.0f; |
| 3369 | viewport.minDepth = 0.0f; |
| 3370 | viewport.width = 512; |
| 3371 | viewport.height = 512; |
| 3372 | viewport.x = 0; |
| 3373 | viewport.y = 0; |
| 3374 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3375 | vkEndCommandBuffer(command_buffer[0]); |
| 3376 | } |
| 3377 | { |
| 3378 | VkCommandBufferBeginInfo begin_info{}; |
| 3379 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3380 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3381 | |
| 3382 | VkViewport viewport{}; |
| 3383 | viewport.maxDepth = 1.0f; |
| 3384 | viewport.minDepth = 0.0f; |
| 3385 | viewport.width = 512; |
| 3386 | viewport.height = 512; |
| 3387 | viewport.x = 0; |
| 3388 | viewport.y = 0; |
| 3389 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3390 | vkEndCommandBuffer(command_buffer[1]); |
| 3391 | } |
| 3392 | { |
| 3393 | VkSubmitInfo submit_info{}; |
| 3394 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3395 | submit_info.commandBufferCount = 1; |
| 3396 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3397 | submit_info.signalSemaphoreCount = 0; |
| 3398 | submit_info.pSignalSemaphores = VK_NULL_HANDLE; |
| 3399 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3400 | } |
| 3401 | { |
| 3402 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3403 | VkSubmitInfo submit_info{}; |
| 3404 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3405 | submit_info.commandBufferCount = 1; |
| 3406 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3407 | submit_info.waitSemaphoreCount = 0; |
| 3408 | submit_info.pWaitSemaphores = VK_NULL_HANDLE; |
| 3409 | submit_info.pWaitDstStageMask = flags; |
| 3410 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3411 | } |
| 3412 | |
| 3413 | vkQueueSubmit(m_device->m_queue, 0, NULL, fence); |
| 3414 | |
| 3415 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3416 | |
| 3417 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3418 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3419 | &command_buffer[0]); |
| 3420 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3421 | |
| 3422 | m_errorMonitor->VerifyNotFound(); |
| 3423 | } |
| 3424 | |
| 3425 | // This is a positive test. No errors should be generated. |
| 3426 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueOneFence) { |
| 3427 | |
| 3428 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 3429 | "on the same queue, the second having a fence, followed " |
| 3430 | "by a WaitForFences call."); |
| 3431 | |
| 3432 | m_errorMonitor->ExpectSuccess(); |
| 3433 | |
| 3434 | VkFence fence; |
| 3435 | VkFenceCreateInfo fence_create_info{}; |
| 3436 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3437 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3438 | |
| 3439 | VkCommandPool command_pool; |
| 3440 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3441 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3442 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3443 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3444 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3445 | &command_pool); |
| 3446 | |
| 3447 | VkCommandBuffer command_buffer[2]; |
| 3448 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3449 | command_buffer_allocate_info.sType = |
| 3450 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3451 | command_buffer_allocate_info.commandPool = command_pool; |
| 3452 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3453 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3454 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3455 | command_buffer); |
| 3456 | |
| 3457 | { |
| 3458 | VkCommandBufferBeginInfo begin_info{}; |
| 3459 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3460 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3461 | |
| 3462 | vkCmdPipelineBarrier(command_buffer[0], |
| 3463 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3464 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3465 | 0, nullptr, 0, nullptr); |
| 3466 | |
| 3467 | VkViewport viewport{}; |
| 3468 | viewport.maxDepth = 1.0f; |
| 3469 | viewport.minDepth = 0.0f; |
| 3470 | viewport.width = 512; |
| 3471 | viewport.height = 512; |
| 3472 | viewport.x = 0; |
| 3473 | viewport.y = 0; |
| 3474 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3475 | vkEndCommandBuffer(command_buffer[0]); |
| 3476 | } |
| 3477 | { |
| 3478 | VkCommandBufferBeginInfo begin_info{}; |
| 3479 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3480 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3481 | |
| 3482 | VkViewport viewport{}; |
| 3483 | viewport.maxDepth = 1.0f; |
| 3484 | viewport.minDepth = 0.0f; |
| 3485 | viewport.width = 512; |
| 3486 | viewport.height = 512; |
| 3487 | viewport.x = 0; |
| 3488 | viewport.y = 0; |
| 3489 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3490 | vkEndCommandBuffer(command_buffer[1]); |
| 3491 | } |
| 3492 | { |
| 3493 | VkSubmitInfo submit_info{}; |
| 3494 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3495 | submit_info.commandBufferCount = 1; |
| 3496 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3497 | submit_info.signalSemaphoreCount = 0; |
| 3498 | submit_info.pSignalSemaphores = VK_NULL_HANDLE; |
| 3499 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3500 | } |
| 3501 | { |
| 3502 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3503 | VkSubmitInfo submit_info{}; |
| 3504 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3505 | submit_info.commandBufferCount = 1; |
| 3506 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3507 | submit_info.waitSemaphoreCount = 0; |
| 3508 | submit_info.pWaitSemaphores = VK_NULL_HANDLE; |
| 3509 | submit_info.pWaitDstStageMask = flags; |
| 3510 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 3511 | } |
| 3512 | |
| 3513 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3514 | |
| 3515 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3516 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3517 | &command_buffer[0]); |
| 3518 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3519 | |
| 3520 | m_errorMonitor->VerifyNotFound(); |
| 3521 | } |
| 3522 | |
| 3523 | // This is a positive test. No errors should be generated. |
| 3524 | TEST_F(VkLayerTest, TwoSubmitInfosWithSemaphoreOneQueueSubmitsOneFence) { |
| 3525 | |
| 3526 | TEST_DESCRIPTION( |
| 3527 | "Two command buffers each in a separate SubmitInfo sent in a single " |
| 3528 | "QueueSubmit call followed by a WaitForFences call."); |
| 3529 | |
| 3530 | m_errorMonitor->ExpectSuccess(); |
| 3531 | |
| 3532 | VkFence fence; |
| 3533 | VkFenceCreateInfo fence_create_info{}; |
| 3534 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3535 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3536 | |
| 3537 | VkSemaphore semaphore; |
| 3538 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 3539 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 3540 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 3541 | &semaphore); |
| 3542 | |
| 3543 | VkCommandPool command_pool; |
| 3544 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3545 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3546 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3547 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3548 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3549 | &command_pool); |
| 3550 | |
| 3551 | VkCommandBuffer command_buffer[2]; |
| 3552 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3553 | command_buffer_allocate_info.sType = |
| 3554 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3555 | command_buffer_allocate_info.commandPool = command_pool; |
| 3556 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3557 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3558 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3559 | command_buffer); |
| 3560 | |
| 3561 | { |
| 3562 | VkCommandBufferBeginInfo begin_info{}; |
| 3563 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3564 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3565 | |
| 3566 | vkCmdPipelineBarrier(command_buffer[0], |
| 3567 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3568 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3569 | 0, nullptr, 0, nullptr); |
| 3570 | |
| 3571 | VkViewport viewport{}; |
| 3572 | viewport.maxDepth = 1.0f; |
| 3573 | viewport.minDepth = 0.0f; |
| 3574 | viewport.width = 512; |
| 3575 | viewport.height = 512; |
| 3576 | viewport.x = 0; |
| 3577 | viewport.y = 0; |
| 3578 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3579 | vkEndCommandBuffer(command_buffer[0]); |
| 3580 | } |
| 3581 | { |
| 3582 | VkCommandBufferBeginInfo begin_info{}; |
| 3583 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3584 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3585 | |
| 3586 | VkViewport viewport{}; |
| 3587 | viewport.maxDepth = 1.0f; |
| 3588 | viewport.minDepth = 0.0f; |
| 3589 | viewport.width = 512; |
| 3590 | viewport.height = 512; |
| 3591 | viewport.x = 0; |
| 3592 | viewport.y = 0; |
| 3593 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3594 | vkEndCommandBuffer(command_buffer[1]); |
| 3595 | } |
| 3596 | { |
| 3597 | VkSubmitInfo submit_info[2]; |
| 3598 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3599 | |
| 3600 | submit_info[0].sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3601 | submit_info[0].pNext = NULL; |
| 3602 | submit_info[0].commandBufferCount = 1; |
| 3603 | submit_info[0].pCommandBuffers = &command_buffer[0]; |
| 3604 | submit_info[0].signalSemaphoreCount = 1; |
| 3605 | submit_info[0].pSignalSemaphores = &semaphore; |
| 3606 | submit_info[0].waitSemaphoreCount = 0; |
| 3607 | submit_info[0].pWaitSemaphores = NULL; |
| 3608 | submit_info[0].pWaitDstStageMask = 0; |
| 3609 | |
| 3610 | submit_info[1].sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3611 | submit_info[1].pNext = NULL; |
| 3612 | submit_info[1].commandBufferCount = 1; |
| 3613 | submit_info[1].pCommandBuffers = &command_buffer[1]; |
| 3614 | submit_info[1].waitSemaphoreCount = 1; |
| 3615 | submit_info[1].pWaitSemaphores = &semaphore; |
| 3616 | submit_info[1].pWaitDstStageMask = flags; |
| 3617 | submit_info[1].signalSemaphoreCount = 0; |
| 3618 | submit_info[1].pSignalSemaphores = NULL; |
| 3619 | vkQueueSubmit(m_device->m_queue, 2, &submit_info[0], fence); |
| 3620 | } |
| 3621 | |
| 3622 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3623 | |
| 3624 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3625 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3626 | &command_buffer[0]); |
| 3627 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3628 | |
| 3629 | m_errorMonitor->VerifyNotFound(); |
| 3630 | } |
| 3631 | |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 3632 | TEST_F(VkLayerTest, DynamicStatesNotBound) { |
| 3633 | TEST_DESCRIPTION( |
| 3634 | "Run a series of simple draw calls to validate all the different " |
| 3635 | "failure cases that can occur when dynamic state is required but not " |
| 3636 | "correctly bound." |
| 3637 | "Here are the different dynamic state cases verified by this test:\n" |
| 3638 | "-Line Width\n-Depth Bias\n-Viewport State\n-Scissor State\n-Blend " |
| 3639 | "State\n-Depth Bounds\n-Stencil Read Mask\n-Stencil Write " |
| 3640 | "Mask\n-Stencil Reference"); |
| 3641 | |
| 3642 | // Dynamic line width |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3643 | m_errorMonitor->SetDesiredFailureMsg( |
| 3644 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3645 | "Dynamic line width state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3646 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 3647 | BsoFailLineWidth); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3648 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 3649 | // Dynamic depth bias |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3650 | m_errorMonitor->SetDesiredFailureMsg( |
| 3651 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3652 | "Dynamic depth bias state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3653 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 3654 | BsoFailDepthBias); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3655 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 3656 | // Dynamic viewport state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3657 | m_errorMonitor->SetDesiredFailureMsg( |
| 3658 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3659 | "Dynamic viewport state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3660 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 3661 | BsoFailViewport); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3662 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 3663 | // Dynamic scissor state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3664 | m_errorMonitor->SetDesiredFailureMsg( |
| 3665 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3666 | "Dynamic scissor state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3667 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 3668 | BsoFailScissor); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3669 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 3670 | // Dynamic blend state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3671 | m_errorMonitor->SetDesiredFailureMsg( |
| 3672 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3673 | "Dynamic depth bounds state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3674 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 3675 | BsoFailDepthBounds); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3676 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 3677 | // Dynamic stencil read mask |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3678 | m_errorMonitor->SetDesiredFailureMsg( |
| 3679 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3680 | "Dynamic stencil read mask state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3681 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 3682 | BsoFailStencilReadMask); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3683 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 3684 | // Dynamic stencil write mask |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3685 | m_errorMonitor->SetDesiredFailureMsg( |
| 3686 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3687 | "Dynamic stencil write mask state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3688 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 3689 | BsoFailStencilWriteMask); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3690 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 3691 | // Dynamic stencil reference |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3692 | m_errorMonitor->SetDesiredFailureMsg( |
| 3693 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3694 | "Dynamic stencil reference state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3695 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 3696 | BsoFailStencilReference); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3697 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 3698 | } |
| 3699 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3700 | TEST_F(VkLayerTest, CommandBufferTwoSubmits) { |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 3701 | vk_testing::Fence testFence; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3702 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3703 | m_errorMonitor->SetDesiredFailureMsg( |
| 3704 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3705 | "was begun w/ VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set, but has " |
| 3706 | "been submitted"); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 3707 | |
| 3708 | VkFenceCreateInfo fenceInfo = {}; |
| 3709 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3710 | fenceInfo.pNext = NULL; |
| 3711 | fenceInfo.flags = 0; |
| 3712 | |
| 3713 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3714 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 3715 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3716 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3717 | // We luck out b/c by default the framework creates CB w/ the |
| 3718 | // VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 3719 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3720 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 3721 | m_stencil_clear_color, NULL); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 3722 | EndCommandBuffer(); |
| 3723 | |
| 3724 | testFence.init(*m_device, fenceInfo); |
| 3725 | |
| 3726 | // Bypass framework since it does the waits automatically |
| 3727 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 3728 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 3729 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3730 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3731 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 3732 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 3733 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3734 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3735 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3736 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 3737 | submit_info.pSignalSemaphores = NULL; |
| 3738 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3739 | err = vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
| 3740 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 3741 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3742 | // Cause validation error by re-submitting cmd buffer that should only be |
| 3743 | // submitted once |
| 3744 | err = vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 3745 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3746 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 3747 | } |
| 3748 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3749 | TEST_F(VkLayerTest, AllocDescriptorFromEmptyPool) { |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 3750 | // Initiate Draw w/o a PSO bound |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3751 | VkResult err; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 3752 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3753 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3754 | "Unable to allocate 1 descriptors of " |
| 3755 | "type " |
| 3756 | "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3757 | |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 3758 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3759 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 3760 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3761 | // Create Pool w/ 1 Sampler descriptor, but try to alloc Uniform Buffer |
| 3762 | // descriptor from it |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3763 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3764 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 3765 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 3766 | |
| 3767 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3768 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3769 | ds_pool_ci.pNext = NULL; |
| 3770 | ds_pool_ci.flags = 0; |
| 3771 | ds_pool_ci.maxSets = 1; |
| 3772 | ds_pool_ci.poolSizeCount = 1; |
| 3773 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 3774 | |
| 3775 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3776 | err = |
| 3777 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 3778 | ASSERT_VK_SUCCESS(err); |
| 3779 | |
| 3780 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3781 | dsl_binding.binding = 0; |
| 3782 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3783 | dsl_binding.descriptorCount = 1; |
| 3784 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3785 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 3786 | |
| 3787 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3788 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3789 | ds_layout_ci.pNext = NULL; |
| 3790 | ds_layout_ci.bindingCount = 1; |
| 3791 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 3792 | |
| 3793 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3794 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3795 | &ds_layout); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 3796 | ASSERT_VK_SUCCESS(err); |
| 3797 | |
| 3798 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3799 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3800 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3801 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3802 | alloc_info.descriptorPool = ds_pool; |
| 3803 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3804 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3805 | &descriptorSet); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 3806 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3807 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 3808 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3809 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3810 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 3811 | } |
| 3812 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3813 | TEST_F(VkLayerTest, FreeDescriptorFromOneShotPool) { |
| 3814 | VkResult err; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3815 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3816 | m_errorMonitor->SetDesiredFailureMsg( |
| 3817 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3818 | "It is invalid to call vkFreeDescriptorSets() with a pool created " |
| 3819 | "without setting VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3820 | |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3821 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3822 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3823 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3824 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3825 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3826 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3827 | |
| 3828 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3829 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3830 | ds_pool_ci.pNext = NULL; |
| 3831 | ds_pool_ci.maxSets = 1; |
| 3832 | ds_pool_ci.poolSizeCount = 1; |
| 3833 | ds_pool_ci.flags = 0; |
| 3834 | // Not specifying VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT means |
| 3835 | // app can only call vkResetDescriptorPool on this pool.; |
| 3836 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3837 | |
| 3838 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3839 | err = |
| 3840 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3841 | ASSERT_VK_SUCCESS(err); |
| 3842 | |
| 3843 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3844 | dsl_binding.binding = 0; |
| 3845 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3846 | dsl_binding.descriptorCount = 1; |
| 3847 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3848 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3849 | |
| 3850 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3851 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3852 | ds_layout_ci.pNext = NULL; |
| 3853 | ds_layout_ci.bindingCount = 1; |
| 3854 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3855 | |
| 3856 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3857 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3858 | &ds_layout); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3859 | ASSERT_VK_SUCCESS(err); |
| 3860 | |
| 3861 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3862 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3863 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3864 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3865 | alloc_info.descriptorPool = ds_pool; |
| 3866 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3867 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3868 | &descriptorSet); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3869 | ASSERT_VK_SUCCESS(err); |
| 3870 | |
| 3871 | err = vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptorSet); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3872 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3873 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3874 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3875 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3876 | } |
| 3877 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3878 | TEST_F(VkLayerTest, InvalidDescriptorPool) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3879 | // Attempt to clear Descriptor Pool with bad object. |
| 3880 | // ObjectTracker should catch this. |
| 3881 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3882 | "Invalid VkDescriptorPool Object 0xbaad6001"); |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 3883 | uint64_t fake_pool_handle = 0xbaad6001; |
| 3884 | VkDescriptorPool bad_pool = reinterpret_cast<VkDescriptorPool &>(fake_pool_handle); |
| 3885 | vkResetDescriptorPool(device(), bad_pool, 0); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3886 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3887 | } |
| 3888 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3889 | TEST_F(VkLayerTest, InvalidDescriptorSet) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3890 | // Attempt to bind an invalid Descriptor Set to a valid Command Buffer |
| 3891 | // ObjectTracker should catch this. |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3892 | // Create a valid cmd buffer |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3893 | // call vkCmdBindDescriptorSets w/ false Descriptor Set |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 3894 | |
| 3895 | uint64_t fake_set_handle = 0xbaad6001; |
| 3896 | VkDescriptorSet bad_set = reinterpret_cast<VkDescriptorSet &>(fake_set_handle); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3897 | VkResult err; |
| 3898 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3899 | "Invalid VkDescriptorSet Object 0xbaad6001"); |
| 3900 | |
| 3901 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3902 | |
| 3903 | VkDescriptorSetLayoutBinding layout_bindings[1] = {}; |
| 3904 | layout_bindings[0].binding = 0; |
| 3905 | layout_bindings[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3906 | layout_bindings[0].descriptorCount = 1; |
| 3907 | layout_bindings[0].stageFlags = VK_SHADER_STAGE_VERTEX_BIT; |
| 3908 | layout_bindings[0].pImmutableSamplers = NULL; |
| 3909 | |
| 3910 | VkDescriptorSetLayout descriptor_set_layout; |
| 3911 | VkDescriptorSetLayoutCreateInfo dslci = {}; |
| 3912 | dslci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3913 | dslci.pNext = NULL; |
| 3914 | dslci.bindingCount = 1; |
| 3915 | dslci.pBindings = layout_bindings; |
| 3916 | err = vkCreateDescriptorSetLayout(device(), &dslci, NULL, &descriptor_set_layout); |
Karl Schultz | 5cb2111 | 2016-04-21 17:17:40 -0600 | [diff] [blame] | 3917 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3918 | |
| 3919 | VkPipelineLayout pipeline_layout; |
| 3920 | VkPipelineLayoutCreateInfo plci = {}; |
| 3921 | plci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3922 | plci.pNext = NULL; |
| 3923 | plci.setLayoutCount = 1; |
| 3924 | plci.pSetLayouts = &descriptor_set_layout; |
| 3925 | err = vkCreatePipelineLayout(device(), &plci, NULL, &pipeline_layout); |
Karl Schultz | 5cb2111 | 2016-04-21 17:17:40 -0600 | [diff] [blame] | 3926 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3927 | |
| 3928 | BeginCommandBuffer(); |
| 3929 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 3930 | pipeline_layout, 0, 1, &bad_set, 0, NULL); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3931 | m_errorMonitor->VerifyFound(); |
| 3932 | EndCommandBuffer(); |
| 3933 | vkDestroyPipelineLayout(device(), pipeline_layout, NULL); |
| 3934 | vkDestroyDescriptorSetLayout(device(), descriptor_set_layout, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3935 | } |
| 3936 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3937 | TEST_F(VkLayerTest, InvalidDescriptorSetLayout) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3938 | // Attempt to create a Pipeline Layout with an invalid Descriptor Set Layout. |
| 3939 | // ObjectTracker should catch this. |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 3940 | uint64_t fake_layout_handle = 0xbaad6001; |
| 3941 | VkDescriptorSetLayout bad_layout = reinterpret_cast<VkDescriptorSetLayout &>(fake_layout_handle); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3942 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3943 | "Invalid VkDescriptorSetLayout Object 0xbaad6001"); |
| 3944 | |
| 3945 | VkPipelineLayout pipeline_layout; |
| 3946 | VkPipelineLayoutCreateInfo plci = {}; |
| 3947 | plci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3948 | plci.pNext = NULL; |
| 3949 | plci.setLayoutCount = 1; |
| 3950 | plci.pSetLayouts = &bad_layout; |
| 3951 | vkCreatePipelineLayout(device(), &plci, NULL, &pipeline_layout); |
| 3952 | |
| 3953 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3954 | } |
| 3955 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3956 | TEST_F(VkLayerTest, InvalidPipeline) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3957 | // Attempt to bind an invalid Pipeline to a valid Command Buffer |
| 3958 | // ObjectTracker should catch this. |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3959 | // Create a valid cmd buffer |
| 3960 | // call vkCmdBindPipeline w/ false Pipeline |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 3961 | uint64_t fake_pipeline_handle = 0xbaad6001; |
| 3962 | VkPipeline bad_pipeline = reinterpret_cast<VkPipeline &>(fake_pipeline_handle); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3963 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3964 | "Invalid VkPipeline Object 0xbaad6001"); |
| 3965 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3966 | BeginCommandBuffer(); |
| 3967 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 3968 | VK_PIPELINE_BIND_POINT_GRAPHICS, bad_pipeline); |
| 3969 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b8b6b27 | 2016-05-02 13:26:06 -0600 | [diff] [blame] | 3970 | |
| 3971 | // Now issue a draw call with no pipeline bound |
| 3972 | m_errorMonitor->SetDesiredFailureMsg( |
| 3973 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3974 | "At Draw/Dispatch time no valid VkPipeline is bound!"); |
| 3975 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3976 | BeginCommandBuffer(); |
| 3977 | Draw(1, 0, 0, 0); |
| 3978 | m_errorMonitor->VerifyFound(); |
| 3979 | // Finally same check once more but with Dispatch/Compute |
| 3980 | m_errorMonitor->SetDesiredFailureMsg( |
| 3981 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3982 | "At Draw/Dispatch time no valid VkPipeline is bound!"); |
| 3983 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3984 | BeginCommandBuffer(); |
| 3985 | vkCmdDispatch(m_commandBuffer->GetBufferHandle(), 0, 0, 0); |
| 3986 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3987 | } |
| 3988 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3989 | TEST_F(VkLayerTest, DescriptorSetNotUpdated) { |
| 3990 | // Create and update CommandBuffer then call QueueSubmit w/o calling End on |
| 3991 | // CommandBuffer |
| 3992 | VkResult err; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3993 | |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 3994 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3995 | " bound but it was never updated. "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3996 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3997 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 3998 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 3999 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4000 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4001 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4002 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4003 | |
| 4004 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4005 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4006 | ds_pool_ci.pNext = NULL; |
| 4007 | ds_pool_ci.maxSets = 1; |
| 4008 | ds_pool_ci.poolSizeCount = 1; |
| 4009 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 4010 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4011 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4012 | err = |
| 4013 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4014 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4015 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4016 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4017 | dsl_binding.binding = 0; |
| 4018 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4019 | dsl_binding.descriptorCount = 1; |
| 4020 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4021 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4022 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4023 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4024 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4025 | ds_layout_ci.pNext = NULL; |
| 4026 | ds_layout_ci.bindingCount = 1; |
| 4027 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4028 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4029 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4030 | &ds_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4031 | ASSERT_VK_SUCCESS(err); |
| 4032 | |
| 4033 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4034 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4035 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4036 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4037 | alloc_info.descriptorPool = ds_pool; |
| 4038 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4039 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4040 | &descriptorSet); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4041 | ASSERT_VK_SUCCESS(err); |
| 4042 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4043 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4044 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4045 | pipeline_layout_ci.pNext = NULL; |
| 4046 | pipeline_layout_ci.setLayoutCount = 1; |
| 4047 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4048 | |
| 4049 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4050 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4051 | &pipeline_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4052 | ASSERT_VK_SUCCESS(err); |
| 4053 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4054 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4055 | VK_SHADER_STAGE_VERTEX_BIT, this); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4056 | // 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] | 4057 | // on more devices |
| 4058 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4059 | VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4060 | |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 4061 | VkPipelineObj pipe(m_device); |
| 4062 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 4063 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 4064 | pipe.AddColorAttachment(); |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 4065 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4066 | |
| 4067 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4068 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4069 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 4070 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 4071 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 4072 | 1, &descriptorSet, 0, NULL); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4073 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4074 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 4075 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4076 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4077 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4078 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4079 | } |
| 4080 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4081 | TEST_F(VkLayerTest, InvalidBufferViewObject) { |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4082 | // Create a single TEXEL_BUFFER descriptor and send it an invalid bufferView |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4083 | VkResult err; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4084 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4085 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4086 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Attempted write update to texel buffer " |
| 4087 | "descriptor with invalid buffer view"); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4088 | |
| 4089 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4090 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4091 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 4092 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4093 | |
| 4094 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4095 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4096 | ds_pool_ci.pNext = NULL; |
| 4097 | ds_pool_ci.maxSets = 1; |
| 4098 | ds_pool_ci.poolSizeCount = 1; |
| 4099 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4100 | |
| 4101 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4102 | err = |
| 4103 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4104 | ASSERT_VK_SUCCESS(err); |
| 4105 | |
| 4106 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4107 | dsl_binding.binding = 0; |
| 4108 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 4109 | dsl_binding.descriptorCount = 1; |
| 4110 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4111 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4112 | |
| 4113 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4114 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4115 | ds_layout_ci.pNext = NULL; |
| 4116 | ds_layout_ci.bindingCount = 1; |
| 4117 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4118 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4119 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4120 | &ds_layout); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4121 | ASSERT_VK_SUCCESS(err); |
| 4122 | |
| 4123 | VkDescriptorSet descriptorSet; |
| 4124 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4125 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4126 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4127 | alloc_info.descriptorPool = ds_pool; |
| 4128 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4129 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4130 | &descriptorSet); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4131 | ASSERT_VK_SUCCESS(err); |
| 4132 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4133 | VkBufferView view = |
| 4134 | (VkBufferView)((size_t)0xbaadbeef); // invalid bufferView object |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4135 | VkWriteDescriptorSet descriptor_write; |
| 4136 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 4137 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 4138 | descriptor_write.dstSet = descriptorSet; |
| 4139 | descriptor_write.dstBinding = 0; |
| 4140 | descriptor_write.descriptorCount = 1; |
| 4141 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 4142 | descriptor_write.pTexelBufferView = &view; |
| 4143 | |
| 4144 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 4145 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4146 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4147 | |
| 4148 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4149 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 4150 | } |
| 4151 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4152 | TEST_F(VkLayerTest, InvalidDynamicOffsetCases) { |
| 4153 | // Create a descriptorSet w/ dynamic descriptor and then hit 3 offset error |
| 4154 | // cases: |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4155 | // 1. No dynamicOffset supplied |
| 4156 | // 2. Too many dynamicOffsets supplied |
| 4157 | // 3. Dynamic offset oversteps buffer being updated |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4158 | VkResult err; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4159 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4160 | " requires 1 dynamicOffsets, but only " |
| 4161 | "0 dynamicOffsets are left in " |
| 4162 | "pDynamicOffsets "); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4163 | |
| 4164 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4165 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 4166 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4167 | |
| 4168 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4169 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 4170 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4171 | |
| 4172 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4173 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4174 | ds_pool_ci.pNext = NULL; |
| 4175 | ds_pool_ci.maxSets = 1; |
| 4176 | ds_pool_ci.poolSizeCount = 1; |
| 4177 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4178 | |
| 4179 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4180 | err = |
| 4181 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4182 | ASSERT_VK_SUCCESS(err); |
| 4183 | |
| 4184 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4185 | dsl_binding.binding = 0; |
| 4186 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 4187 | dsl_binding.descriptorCount = 1; |
| 4188 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4189 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4190 | |
| 4191 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4192 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4193 | ds_layout_ci.pNext = NULL; |
| 4194 | ds_layout_ci.bindingCount = 1; |
| 4195 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4196 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4197 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4198 | &ds_layout); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4199 | ASSERT_VK_SUCCESS(err); |
| 4200 | |
| 4201 | VkDescriptorSet descriptorSet; |
| 4202 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4203 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4204 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4205 | alloc_info.descriptorPool = ds_pool; |
| 4206 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4207 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4208 | &descriptorSet); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4209 | ASSERT_VK_SUCCESS(err); |
| 4210 | |
| 4211 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4212 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4213 | pipeline_layout_ci.pNext = NULL; |
| 4214 | pipeline_layout_ci.setLayoutCount = 1; |
| 4215 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4216 | |
| 4217 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4218 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4219 | &pipeline_layout); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4220 | ASSERT_VK_SUCCESS(err); |
| 4221 | |
| 4222 | // Create a buffer to update the descriptor with |
| 4223 | uint32_t qfi = 0; |
| 4224 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4225 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 4226 | buffCI.size = 1024; |
| 4227 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 4228 | buffCI.queueFamilyIndexCount = 1; |
| 4229 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4230 | |
| 4231 | VkBuffer dyub; |
| 4232 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 4233 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4234 | // Allocate memory and bind to buffer so we can make it to the appropriate |
| 4235 | // error |
| 4236 | VkMemoryAllocateInfo mem_alloc = {}; |
| 4237 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 4238 | mem_alloc.pNext = NULL; |
| 4239 | mem_alloc.allocationSize = 1024; |
Chris Forbes | b6116cc | 2016-05-08 11:39:59 +1200 | [diff] [blame] | 4240 | mem_alloc.memoryTypeIndex = 0; |
| 4241 | |
| 4242 | VkMemoryRequirements memReqs; |
| 4243 | vkGetBufferMemoryRequirements(m_device->device(), dyub, &memReqs); |
| 4244 | bool pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &mem_alloc, |
| 4245 | 0); |
| 4246 | if (!pass) { |
| 4247 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
| 4248 | return; |
| 4249 | } |
| 4250 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4251 | VkDeviceMemory mem; |
| 4252 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
| 4253 | ASSERT_VK_SUCCESS(err); |
| 4254 | err = vkBindBufferMemory(m_device->device(), dyub, mem, 0); |
| 4255 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4256 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 4257 | VkDescriptorBufferInfo buffInfo = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4258 | buffInfo.buffer = dyub; |
| 4259 | buffInfo.offset = 0; |
| 4260 | buffInfo.range = 1024; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4261 | |
| 4262 | VkWriteDescriptorSet descriptor_write; |
| 4263 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 4264 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 4265 | descriptor_write.dstSet = descriptorSet; |
| 4266 | descriptor_write.dstBinding = 0; |
| 4267 | descriptor_write.descriptorCount = 1; |
| 4268 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 4269 | descriptor_write.pBufferInfo = &buffInfo; |
| 4270 | |
| 4271 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 4272 | |
| 4273 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4274 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 4275 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 4276 | 1, &descriptorSet, 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4277 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4278 | uint32_t pDynOff[2] = {512, 756}; |
| 4279 | // 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] | 4280 | m_errorMonitor->SetDesiredFailureMsg( |
| 4281 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4282 | "Attempting to bind 1 descriptorSets with 1 dynamic descriptors, but "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4283 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 4284 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 4285 | 1, &descriptorSet, 2, pDynOff); |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 4286 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4287 | // Finally cause error due to dynamicOffset being too big |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4288 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4289 | " dynamic offset 512 combined with " |
| 4290 | "offset 0 and range 1024 that " |
| 4291 | "oversteps the buffer size of 1024"); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4292 | // Create PSO to be used for draw-time errors below |
| 4293 | char const *vsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 4294 | "#version 450\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4295 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 4296 | "out gl_PerVertex { \n" |
| 4297 | " vec4 gl_Position;\n" |
| 4298 | "};\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4299 | "void main(){\n" |
| 4300 | " gl_Position = vec4(1);\n" |
| 4301 | "}\n"; |
| 4302 | char const *fsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 4303 | "#version 450\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4304 | "\n" |
| 4305 | "layout(location=0) out vec4 x;\n" |
| 4306 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 4307 | "void main(){\n" |
| 4308 | " x = vec4(bar.y);\n" |
| 4309 | "}\n"; |
| 4310 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4311 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 4312 | VkPipelineObj pipe(m_device); |
| 4313 | pipe.AddShader(&vs); |
| 4314 | pipe.AddShader(&fs); |
| 4315 | pipe.AddColorAttachment(); |
| 4316 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 4317 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4318 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4319 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 4320 | // This update should succeed, but offset size of 512 will overstep buffer |
| 4321 | // /w range 1024 & size 1024 |
| 4322 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 4323 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 4324 | 1, &descriptorSet, 1, pDynOff); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4325 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4326 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4327 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4328 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
Tobin Ehlis | 512098e | 2016-05-05 09:06:12 -0600 | [diff] [blame] | 4329 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4330 | |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4331 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4332 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 4333 | } |
| 4334 | |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4335 | TEST_F(VkLayerTest, InvalidPushConstants) { |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4336 | VkResult err; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4337 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4338 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 4339 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4340 | |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4341 | VkPipelineLayout pipeline_layout; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4342 | VkPushConstantRange pc_range = {}; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4343 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 4344 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4345 | pipeline_layout_ci.pushConstantRangeCount = 1; |
| 4346 | pipeline_layout_ci.pPushConstantRanges = &pc_range; |
| 4347 | |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4348 | // |
| 4349 | // Check for invalid push constant ranges in pipeline layouts. |
| 4350 | // |
| 4351 | struct PipelineLayoutTestCase { |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4352 | VkPushConstantRange const range; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4353 | char const *msg; |
| 4354 | }; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4355 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4356 | const uint32_t too_big = m_device->props.limits.maxPushConstantsSize + 0x4; |
| 4357 | const std::array<PipelineLayoutTestCase, 10> range_tests = {{ |
| 4358 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 0}, |
| 4359 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 4360 | "size 0."}, |
| 4361 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 1}, |
| 4362 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 4363 | "size 1."}, |
| 4364 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 1}, |
| 4365 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 4366 | "size 1."}, |
| 4367 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 0}, |
| 4368 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 4369 | "size 0."}, |
| 4370 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 4}, |
| 4371 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 4372 | "offset 1. Offset must"}, |
| 4373 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, too_big}, |
| 4374 | "vkCreatePipelineLayout() call has push constants index 0 " |
| 4375 | "with offset "}, |
| 4376 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, too_big}, |
| 4377 | "vkCreatePipelineLayout() call has push constants " |
| 4378 | "index 0 with offset "}, |
| 4379 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, 0}, |
| 4380 | "vkCreatePipelineLayout() call has push constants index 0 " |
| 4381 | "with offset "}, |
| 4382 | {{VK_SHADER_STAGE_VERTEX_BIT, 0xFFFFFFF0, 0x00000020}, |
| 4383 | "vkCreatePipelineLayout() call has push " |
| 4384 | "constants index 0 with offset "}, |
| 4385 | {{VK_SHADER_STAGE_VERTEX_BIT, 0x00000020, 0xFFFFFFF0}, |
| 4386 | "vkCreatePipelineLayout() call has push " |
| 4387 | "constants index 0 with offset "}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4388 | }}; |
| 4389 | |
| 4390 | // Check for invalid offset and size |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4391 | for (const auto &iter : range_tests) { |
| 4392 | pc_range = iter.range; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4393 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4394 | iter.msg); |
| 4395 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, |
| 4396 | NULL, &pipeline_layout); |
| 4397 | m_errorMonitor->VerifyFound(); |
| 4398 | if (VK_SUCCESS == err) { |
| 4399 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4400 | } |
| 4401 | } |
| 4402 | |
| 4403 | // Check for invalid stage flag |
| 4404 | pc_range.offset = 0; |
| 4405 | pc_range.size = 16; |
| 4406 | pc_range.stageFlags = 0; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4407 | m_errorMonitor->SetDesiredFailureMsg( |
| 4408 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4409 | "vkCreatePipelineLayout() call has no stageFlags set."); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4410 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4411 | &pipeline_layout); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4412 | m_errorMonitor->VerifyFound(); |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4413 | if (VK_SUCCESS == err) { |
| 4414 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4415 | } |
| 4416 | |
| 4417 | // Check for overlapping ranges |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4418 | const uint32_t ranges_per_test = 5; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4419 | struct OverlappingRangeTestCase { |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4420 | VkPushConstantRange const ranges[ranges_per_test]; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4421 | char const *msg; |
| 4422 | }; |
| 4423 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4424 | const std::array<OverlappingRangeTestCase, 5> overlapping_range_tests = { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4425 | {{{{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4426 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4427 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4428 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4429 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, |
| 4430 | "vkCreatePipelineLayout() call has push constants with overlapping " |
| 4431 | "ranges: 0:[0, 4), 1:[0, 4)"}, |
| 4432 | { |
| 4433 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4434 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, |
| 4435 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, |
| 4436 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 8}, |
| 4437 | {VK_SHADER_STAGE_VERTEX_BIT, 16, 4}}, |
| 4438 | "vkCreatePipelineLayout() call has push constants with " |
| 4439 | "overlapping " |
| 4440 | "ranges: 3:[12, 20), 4:[16, 20)", |
| 4441 | }, |
| 4442 | { |
| 4443 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, |
| 4444 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 8}, |
| 4445 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, |
| 4446 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, |
| 4447 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, |
| 4448 | "vkCreatePipelineLayout() call has push constants with " |
| 4449 | "overlapping " |
| 4450 | "ranges: 0:[16, 20), 1:[12, 20)", |
| 4451 | }, |
| 4452 | { |
| 4453 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, |
| 4454 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, |
| 4455 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, |
| 4456 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 8}, |
| 4457 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, |
| 4458 | "vkCreatePipelineLayout() call has push constants with " |
| 4459 | "overlapping " |
| 4460 | "ranges: 0:[16, 20), 3:[12, 20)", |
| 4461 | }, |
| 4462 | { |
| 4463 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, |
| 4464 | {VK_SHADER_STAGE_VERTEX_BIT, 32, 4}, |
| 4465 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 96}, |
| 4466 | {VK_SHADER_STAGE_VERTEX_BIT, 40, 8}, |
| 4467 | {VK_SHADER_STAGE_VERTEX_BIT, 52, 4}}, |
| 4468 | "vkCreatePipelineLayout() call has push constants with " |
| 4469 | "overlapping " |
| 4470 | "ranges: 0:[16, 20), 2:[4, 100)", |
| 4471 | }}}; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4472 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4473 | for (const auto &iter : overlapping_range_tests) { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4474 | pipeline_layout_ci.pPushConstantRanges = iter.ranges; |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4475 | pipeline_layout_ci.pushConstantRangeCount = ranges_per_test; |
| 4476 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4477 | iter.msg); |
| 4478 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, |
| 4479 | NULL, &pipeline_layout); |
| 4480 | m_errorMonitor->VerifyFound(); |
| 4481 | if (VK_SUCCESS == err) { |
| 4482 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4483 | } |
| 4484 | } |
| 4485 | |
| 4486 | // 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] | 4487 | const std::array<OverlappingRangeTestCase, 2> overlapping_range_tests_pos = |
| 4488 | {{{{{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4489 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, |
| 4490 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, |
| 4491 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 4}, |
| 4492 | {VK_SHADER_STAGE_VERTEX_BIT, 16, 4}}, |
| 4493 | ""}, |
| 4494 | {{{VK_SHADER_STAGE_VERTEX_BIT, 92, 24}, |
| 4495 | {VK_SHADER_STAGE_VERTEX_BIT, 80, 4}, |
| 4496 | {VK_SHADER_STAGE_VERTEX_BIT, 64, 8}, |
| 4497 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 16}, |
| 4498 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, |
| 4499 | ""}}}; |
| 4500 | for (const auto &iter : overlapping_range_tests_pos) { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4501 | pipeline_layout_ci.pPushConstantRanges = iter.ranges; |
| 4502 | m_errorMonitor->ExpectSuccess(); |
| 4503 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, |
| 4504 | NULL, &pipeline_layout); |
| 4505 | m_errorMonitor->VerifyNotFound(); |
| 4506 | if (VK_SUCCESS == err) { |
| 4507 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4508 | } |
| 4509 | } |
| 4510 | |
| 4511 | // |
| 4512 | // CmdPushConstants tests |
| 4513 | // |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4514 | const uint8_t dummy_values[100] = {}; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4515 | |
| 4516 | // 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] | 4517 | const std::array<PipelineLayoutTestCase, 16> cmd_range_tests = {{ |
| 4518 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 0}, |
| 4519 | "vkCmdPushConstants() call has push constants with size 0. Size " |
| 4520 | "must be greater than zero and a multiple of 4."}, |
| 4521 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 1}, |
| 4522 | "vkCmdPushConstants() call has push constants with size 1. Size " |
| 4523 | "must be greater than zero and a multiple of 4."}, |
| 4524 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 1}, |
| 4525 | "vkCmdPushConstants() call has push constants with size 1. Size " |
| 4526 | "must be greater than zero and a multiple of 4."}, |
| 4527 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 0}, |
| 4528 | "vkCmdPushConstants() call has push constants with offset 1. " |
| 4529 | "Offset must be a multiple of 4."}, |
| 4530 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 4}, |
| 4531 | "vkCmdPushConstants() call has push constants with offset 1. " |
| 4532 | "Offset must be a multiple of 4."}, |
| 4533 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 20}, |
| 4534 | "vkCmdPushConstants() Push constant range [0, 20) with stageFlags = " |
| 4535 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4536 | {{VK_SHADER_STAGE_VERTEX_BIT, 60, 8}, |
| 4537 | "vkCmdPushConstants() Push constant range [60, 68) with stageFlags = " |
| 4538 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4539 | {{VK_SHADER_STAGE_VERTEX_BIT, 76, 8}, |
| 4540 | "vkCmdPushConstants() Push constant range [76, 84) with stageFlags = " |
| 4541 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4542 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 80}, |
| 4543 | "vkCmdPushConstants() Push constant range [0, 80) with stageFlags = " |
| 4544 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4545 | {{VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, 0, 4}, |
| 4546 | "vkCmdPushConstants() stageFlags = 0x2 do not match the stageFlags in " |
| 4547 | "any of the ranges in pipeline layout"}, |
| 4548 | {{VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, |
| 4549 | 0, 16}, |
| 4550 | "vkCmdPushConstants() stageFlags = 0x3 do not match the stageFlags in " |
| 4551 | "any of the ranges in pipeline layout"}, |
| 4552 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, too_big}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4553 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4554 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, too_big}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4555 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4556 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, 0}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4557 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4558 | {{VK_SHADER_STAGE_VERTEX_BIT, 0xFFFFFFF0, 0x00000020}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4559 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4560 | {{VK_SHADER_STAGE_VERTEX_BIT, 0x00000020, 0xFFFFFFF0}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4561 | "vkCmdPushConstants() call has push constants with offset "}, |
| 4562 | }}; |
| 4563 | |
| 4564 | // Two ranges for testing robustness |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4565 | const VkPushConstantRange pc_range2[] = { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4566 | {VK_SHADER_STAGE_VERTEX_BIT, 64, 16}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4567 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4568 | }; |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4569 | pipeline_layout_ci.pushConstantRangeCount = |
| 4570 | sizeof(pc_range2) / sizeof(VkPushConstantRange); |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4571 | pipeline_layout_ci.pPushConstantRanges = pc_range2; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4572 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4573 | &pipeline_layout); |
| 4574 | ASSERT_VK_SUCCESS(err); |
| 4575 | BeginCommandBuffer(); |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4576 | for (const auto &iter : cmd_range_tests) { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4577 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4578 | iter.msg); |
| 4579 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4580 | iter.range.stageFlags, iter.range.offset, |
| 4581 | iter.range.size, dummy_values); |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4582 | m_errorMonitor->VerifyFound(); |
| 4583 | } |
| 4584 | |
| 4585 | // Check for invalid stage flag |
| 4586 | m_errorMonitor->SetDesiredFailureMsg( |
| 4587 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4588 | "vkCmdPushConstants() call has no stageFlags set."); |
| 4589 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, 0, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4590 | 0, 16, dummy_values); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4591 | m_errorMonitor->VerifyFound(); |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4592 | EndCommandBuffer(); |
| 4593 | vkResetCommandBuffer(m_commandBuffer->GetBufferHandle(), 0); |
| 4594 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4595 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4596 | // overlapping range tests with cmd |
| 4597 | const std::array<PipelineLayoutTestCase, 3> cmd_overlap_tests = {{ |
| 4598 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 20}, |
| 4599 | "vkCmdPushConstants() Push constant range [0, 20) with stageFlags = " |
| 4600 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4601 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, |
| 4602 | "vkCmdPushConstants() Push constant range [16, 20) with stageFlags = " |
| 4603 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4604 | {{VK_SHADER_STAGE_VERTEX_BIT, 40, 16}, |
| 4605 | "vkCmdPushConstants() Push constant range [40, 56) with stageFlags = " |
| 4606 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4607 | }}; |
| 4608 | const VkPushConstantRange pc_range3[] = { |
| 4609 | {VK_SHADER_STAGE_VERTEX_BIT, 20, 16}, |
| 4610 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, |
| 4611 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4612 | {VK_SHADER_STAGE_VERTEX_BIT, 44, 8}, |
| 4613 | {VK_SHADER_STAGE_VERTEX_BIT, 80, 12}, |
| 4614 | {VK_SHADER_STAGE_VERTEX_BIT, 36, 8}, |
| 4615 | {VK_SHADER_STAGE_VERTEX_BIT, 56, 28}, |
| 4616 | }; |
| 4617 | pipeline_layout_ci.pushConstantRangeCount = |
| 4618 | sizeof(pc_range3) / sizeof(VkPushConstantRange); |
| 4619 | pipeline_layout_ci.pPushConstantRanges = pc_range3; |
| 4620 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4621 | &pipeline_layout); |
| 4622 | ASSERT_VK_SUCCESS(err); |
| 4623 | BeginCommandBuffer(); |
| 4624 | for (const auto &iter : cmd_overlap_tests) { |
| 4625 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4626 | iter.msg); |
| 4627 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, |
| 4628 | iter.range.stageFlags, iter.range.offset, |
| 4629 | iter.range.size, dummy_values); |
| 4630 | m_errorMonitor->VerifyFound(); |
| 4631 | } |
| 4632 | EndCommandBuffer(); |
| 4633 | vkResetCommandBuffer(m_commandBuffer->GetBufferHandle(), 0); |
| 4634 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4635 | |
| 4636 | // positive overlapping range tests with cmd |
| 4637 | const std::array<PipelineLayoutTestCase, 4> cmd_overlap_tests_pos = {{ |
| 4638 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, ""}, |
| 4639 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, ""}, |
| 4640 | {{VK_SHADER_STAGE_VERTEX_BIT, 20, 12}, ""}, |
| 4641 | {{VK_SHADER_STAGE_VERTEX_BIT, 56, 36}, ""}, |
| 4642 | }}; |
| 4643 | const VkPushConstantRange pc_range4[] = { |
| 4644 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 64}, |
| 4645 | {VK_SHADER_STAGE_VERTEX_BIT, 20, 16}, |
| 4646 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, |
| 4647 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4648 | {VK_SHADER_STAGE_VERTEX_BIT, 44, 8}, |
| 4649 | {VK_SHADER_STAGE_VERTEX_BIT, 80, 12}, |
| 4650 | {VK_SHADER_STAGE_VERTEX_BIT, 36, 8}, |
| 4651 | {VK_SHADER_STAGE_VERTEX_BIT, 56, 28}, |
| 4652 | }; |
| 4653 | pipeline_layout_ci.pushConstantRangeCount = |
| 4654 | sizeof(pc_range4) / sizeof(VkPushConstantRange); |
| 4655 | pipeline_layout_ci.pPushConstantRanges = pc_range4; |
| 4656 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4657 | &pipeline_layout); |
| 4658 | ASSERT_VK_SUCCESS(err); |
| 4659 | BeginCommandBuffer(); |
| 4660 | for (const auto &iter : cmd_overlap_tests_pos) { |
| 4661 | m_errorMonitor->ExpectSuccess(); |
| 4662 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, |
| 4663 | iter.range.stageFlags, iter.range.offset, |
| 4664 | iter.range.size, dummy_values); |
| 4665 | m_errorMonitor->VerifyNotFound(); |
| 4666 | } |
| 4667 | EndCommandBuffer(); |
| 4668 | vkResetCommandBuffer(m_commandBuffer->GetBufferHandle(), 0); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4669 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4670 | } |
| 4671 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4672 | TEST_F(VkLayerTest, DescriptorSetCompatibility) { |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4673 | // Test various desriptorSet errors with bad binding combinations |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4674 | VkResult err; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4675 | |
| 4676 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4677 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 4678 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4679 | |
| 4680 | static const uint32_t NUM_DESCRIPTOR_TYPES = 5; |
| 4681 | VkDescriptorPoolSize ds_type_count[NUM_DESCRIPTOR_TYPES] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4682 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4683 | ds_type_count[0].descriptorCount = 10; |
| 4684 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 4685 | ds_type_count[1].descriptorCount = 2; |
| 4686 | ds_type_count[2].type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 4687 | ds_type_count[2].descriptorCount = 2; |
| 4688 | ds_type_count[3].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 4689 | ds_type_count[3].descriptorCount = 5; |
| 4690 | // TODO : LunarG ILO driver currently asserts in desc.c w/ INPUT_ATTACHMENT |
| 4691 | // type |
| 4692 | // ds_type_count[4].type = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; |
| 4693 | ds_type_count[4].type = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
| 4694 | ds_type_count[4].descriptorCount = 2; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4695 | |
| 4696 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4697 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4698 | ds_pool_ci.pNext = NULL; |
| 4699 | ds_pool_ci.maxSets = 5; |
| 4700 | ds_pool_ci.poolSizeCount = NUM_DESCRIPTOR_TYPES; |
| 4701 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4702 | |
| 4703 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4704 | err = |
| 4705 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4706 | ASSERT_VK_SUCCESS(err); |
| 4707 | |
| 4708 | static const uint32_t MAX_DS_TYPES_IN_LAYOUT = 2; |
| 4709 | VkDescriptorSetLayoutBinding dsl_binding[MAX_DS_TYPES_IN_LAYOUT] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4710 | dsl_binding[0].binding = 0; |
| 4711 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4712 | dsl_binding[0].descriptorCount = 5; |
| 4713 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 4714 | dsl_binding[0].pImmutableSamplers = NULL; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4715 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4716 | // Create layout identical to set0 layout but w/ different stageFlags |
| 4717 | VkDescriptorSetLayoutBinding dsl_fs_stage_only = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4718 | dsl_fs_stage_only.binding = 0; |
| 4719 | dsl_fs_stage_only.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4720 | dsl_fs_stage_only.descriptorCount = 5; |
| 4721 | dsl_fs_stage_only.stageFlags = |
| 4722 | VK_SHADER_STAGE_FRAGMENT_BIT; // Different stageFlags to cause error at |
| 4723 | // bind time |
| 4724 | dsl_fs_stage_only.pImmutableSamplers = NULL; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4725 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4726 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4727 | ds_layout_ci.pNext = NULL; |
| 4728 | ds_layout_ci.bindingCount = 1; |
| 4729 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4730 | static const uint32_t NUM_LAYOUTS = 4; |
| 4731 | VkDescriptorSetLayout ds_layout[NUM_LAYOUTS] = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4732 | VkDescriptorSetLayout ds_layout_fs_only = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4733 | // Create 4 unique layouts for full pipelineLayout, and 1 special fs-only |
| 4734 | // layout for error case |
| 4735 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4736 | &ds_layout[0]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4737 | ASSERT_VK_SUCCESS(err); |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 4738 | ds_layout_ci.pBindings = &dsl_fs_stage_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4739 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4740 | &ds_layout_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4741 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4742 | dsl_binding[0].binding = 0; |
| 4743 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4744 | dsl_binding[0].descriptorCount = 2; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 4745 | dsl_binding[1].binding = 1; |
| 4746 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 4747 | dsl_binding[1].descriptorCount = 2; |
| 4748 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 4749 | dsl_binding[1].pImmutableSamplers = NULL; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 4750 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4751 | ds_layout_ci.bindingCount = 2; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4752 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4753 | &ds_layout[1]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4754 | ASSERT_VK_SUCCESS(err); |
| 4755 | dsl_binding[0].binding = 0; |
| 4756 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4757 | dsl_binding[0].descriptorCount = 5; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4758 | ds_layout_ci.bindingCount = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4759 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4760 | &ds_layout[2]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4761 | ASSERT_VK_SUCCESS(err); |
| 4762 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4763 | dsl_binding[0].descriptorCount = 2; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4764 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4765 | &ds_layout[3]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4766 | ASSERT_VK_SUCCESS(err); |
| 4767 | |
| 4768 | static const uint32_t NUM_SETS = 4; |
| 4769 | VkDescriptorSet descriptorSet[NUM_SETS] = {}; |
| 4770 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4771 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4772 | alloc_info.descriptorSetCount = NUM_LAYOUTS; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4773 | alloc_info.descriptorPool = ds_pool; |
| 4774 | alloc_info.pSetLayouts = ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4775 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4776 | descriptorSet); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4777 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4778 | VkDescriptorSet ds0_fs_only = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4779 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4780 | alloc_info.pSetLayouts = &ds_layout_fs_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4781 | err = |
| 4782 | vkAllocateDescriptorSets(m_device->device(), &alloc_info, &ds0_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4783 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4784 | |
| 4785 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4786 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4787 | pipeline_layout_ci.pNext = NULL; |
| 4788 | pipeline_layout_ci.setLayoutCount = NUM_LAYOUTS; |
| 4789 | pipeline_layout_ci.pSetLayouts = ds_layout; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4790 | |
| 4791 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4792 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4793 | &pipeline_layout); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4794 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4795 | // Create pipelineLayout with only one setLayout |
| 4796 | pipeline_layout_ci.setLayoutCount = 1; |
| 4797 | VkPipelineLayout single_pipe_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4798 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4799 | &single_pipe_layout); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4800 | ASSERT_VK_SUCCESS(err); |
| 4801 | // Create pipelineLayout with 2 descriptor setLayout at index 0 |
| 4802 | pipeline_layout_ci.pSetLayouts = &ds_layout[3]; |
| 4803 | VkPipelineLayout pipe_layout_one_desc; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4804 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4805 | &pipe_layout_one_desc); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4806 | ASSERT_VK_SUCCESS(err); |
| 4807 | // Create pipelineLayout with 5 SAMPLER descriptor setLayout at index 0 |
| 4808 | pipeline_layout_ci.pSetLayouts = &ds_layout[2]; |
| 4809 | VkPipelineLayout pipe_layout_five_samp; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4810 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4811 | &pipe_layout_five_samp); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4812 | ASSERT_VK_SUCCESS(err); |
| 4813 | // Create pipelineLayout with UB type, but stageFlags for FS only |
| 4814 | pipeline_layout_ci.pSetLayouts = &ds_layout_fs_only; |
| 4815 | VkPipelineLayout pipe_layout_fs_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4816 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4817 | &pipe_layout_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4818 | ASSERT_VK_SUCCESS(err); |
| 4819 | // Create pipelineLayout w/ incompatible set0 layout, but set1 is fine |
| 4820 | VkDescriptorSetLayout pl_bad_s0[2] = {}; |
| 4821 | pl_bad_s0[0] = ds_layout_fs_only; |
| 4822 | pl_bad_s0[1] = ds_layout[1]; |
| 4823 | pipeline_layout_ci.setLayoutCount = 2; |
| 4824 | pipeline_layout_ci.pSetLayouts = pl_bad_s0; |
| 4825 | VkPipelineLayout pipe_layout_bad_set0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4826 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4827 | &pipe_layout_bad_set0); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4828 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4829 | |
| 4830 | // Create a buffer to update the descriptor with |
| 4831 | uint32_t qfi = 0; |
| 4832 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4833 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 4834 | buffCI.size = 1024; |
| 4835 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 4836 | buffCI.queueFamilyIndexCount = 1; |
| 4837 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4838 | |
| 4839 | VkBuffer dyub; |
| 4840 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 4841 | ASSERT_VK_SUCCESS(err); |
| 4842 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 4843 | static const uint32_t NUM_BUFFS = 5; |
| 4844 | VkDescriptorBufferInfo buffInfo[NUM_BUFFS] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4845 | for (uint32_t i = 0; i < NUM_BUFFS; ++i) { |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4846 | buffInfo[i].buffer = dyub; |
| 4847 | buffInfo[i].offset = 0; |
| 4848 | buffInfo[i].range = 1024; |
| 4849 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4850 | VkImage image; |
| 4851 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 4852 | const int32_t tex_width = 32; |
| 4853 | const int32_t tex_height = 32; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4854 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4855 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4856 | image_create_info.pNext = NULL; |
| 4857 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4858 | image_create_info.format = tex_format; |
| 4859 | image_create_info.extent.width = tex_width; |
| 4860 | image_create_info.extent.height = tex_height; |
| 4861 | image_create_info.extent.depth = 1; |
| 4862 | image_create_info.mipLevels = 1; |
| 4863 | image_create_info.arrayLayers = 1; |
| 4864 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 4865 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 4866 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 4867 | image_create_info.flags = 0; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4868 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 4869 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4870 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4871 | VkMemoryRequirements memReqs; |
| 4872 | VkDeviceMemory imageMem; |
| 4873 | bool pass; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 4874 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4875 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 4876 | memAlloc.pNext = NULL; |
| 4877 | memAlloc.allocationSize = 0; |
| 4878 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 4879 | vkGetImageMemoryRequirements(m_device->device(), image, &memReqs); |
| 4880 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4881 | pass = |
| 4882 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 4883 | ASSERT_TRUE(pass); |
| 4884 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &imageMem); |
| 4885 | ASSERT_VK_SUCCESS(err); |
| 4886 | err = vkBindImageMemory(m_device->device(), image, imageMem, 0); |
| 4887 | ASSERT_VK_SUCCESS(err); |
| 4888 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4889 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4890 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 4891 | image_view_create_info.image = image; |
| 4892 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 4893 | image_view_create_info.format = tex_format; |
| 4894 | image_view_create_info.subresourceRange.layerCount = 1; |
| 4895 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 4896 | image_view_create_info.subresourceRange.levelCount = 1; |
| 4897 | image_view_create_info.subresourceRange.aspectMask = |
| 4898 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4899 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4900 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4901 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 4902 | &view); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4903 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 4904 | VkDescriptorImageInfo imageInfo[4] = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4905 | imageInfo[0].imageView = view; |
| 4906 | imageInfo[0].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 4907 | imageInfo[1].imageView = view; |
| 4908 | imageInfo[1].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 4909 | imageInfo[2].imageView = view; |
| 4910 | imageInfo[2].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 4911 | imageInfo[3].imageView = view; |
| 4912 | imageInfo[3].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4913 | |
| 4914 | static const uint32_t NUM_SET_UPDATES = 3; |
| 4915 | VkWriteDescriptorSet descriptor_write[NUM_SET_UPDATES] = {}; |
| 4916 | descriptor_write[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 4917 | descriptor_write[0].dstSet = descriptorSet[0]; |
| 4918 | descriptor_write[0].dstBinding = 0; |
| 4919 | descriptor_write[0].descriptorCount = 5; |
| 4920 | descriptor_write[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4921 | descriptor_write[0].pBufferInfo = buffInfo; |
| 4922 | descriptor_write[1].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 4923 | descriptor_write[1].dstSet = descriptorSet[1]; |
| 4924 | descriptor_write[1].dstBinding = 0; |
| 4925 | descriptor_write[1].descriptorCount = 2; |
| 4926 | descriptor_write[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 4927 | descriptor_write[1].pImageInfo = imageInfo; |
| 4928 | descriptor_write[2].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 4929 | descriptor_write[2].dstSet = descriptorSet[1]; |
| 4930 | descriptor_write[2].dstBinding = 1; |
| 4931 | descriptor_write[2].descriptorCount = 2; |
| 4932 | descriptor_write[2].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 4933 | descriptor_write[2].pImageInfo = &imageInfo[2]; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4934 | |
| 4935 | vkUpdateDescriptorSets(m_device->device(), 3, descriptor_write, 0, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4936 | |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 4937 | // Create PSO to be used for draw-time errors below |
| 4938 | char const *vsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 4939 | "#version 450\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 4940 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 4941 | "out gl_PerVertex {\n" |
| 4942 | " vec4 gl_Position;\n" |
| 4943 | "};\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 4944 | "void main(){\n" |
| 4945 | " gl_Position = vec4(1);\n" |
| 4946 | "}\n"; |
| 4947 | char const *fsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 4948 | "#version 450\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 4949 | "\n" |
| 4950 | "layout(location=0) out vec4 x;\n" |
| 4951 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 4952 | "void main(){\n" |
| 4953 | " x = vec4(bar.y);\n" |
| 4954 | "}\n"; |
| 4955 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4956 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4957 | VkPipelineObj pipe(m_device); |
| 4958 | pipe.AddShader(&vs); |
| 4959 | pipe.AddShader(&fs); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 4960 | pipe.AddColorAttachment(); |
| 4961 | pipe.CreateVKPipeline(pipe_layout_fs_only, renderPass()); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4962 | |
| 4963 | BeginCommandBuffer(); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 4964 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4965 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4966 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 4967 | // NOTE : I believe LunarG ilo driver has bug (LX#189) that requires binding |
| 4968 | // of PSO |
| 4969 | // here before binding DSs. Otherwise we assert in cmd_copy_dset_data() of |
| 4970 | // cmd_pipeline.c |
| 4971 | // due to the fact that cmd_alloc_dset_data() has not been called in |
| 4972 | // cmd_bind_graphics_pipeline() |
| 4973 | // TODO : Want to cause various binding incompatibility issues here to test |
| 4974 | // DrawState |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4975 | // First cause various verify_layout_compatibility() fails |
| 4976 | // Second disturb early and late sets and verify INFO msgs |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4977 | // verify_set_layout_compatibility fail cases: |
| 4978 | // 1. invalid VkPipelineLayout (layout) passed into vkCmdBindDescriptorSets |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4979 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4980 | " due to: invalid VkPipelineLayout "); |
| 4981 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 4982 | VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 4983 | (VkPipelineLayout)((size_t)0xbaadb1be), 0, 1, |
| 4984 | &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4985 | m_errorMonitor->VerifyFound(); |
| 4986 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4987 | // 2. layoutIndex exceeds # of layouts in layout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4988 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4989 | " attempting to bind set to index 1"); |
| 4990 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 4991 | VK_PIPELINE_BIND_POINT_GRAPHICS, single_pipe_layout, |
| 4992 | 0, 2, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4993 | m_errorMonitor->VerifyFound(); |
| 4994 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4995 | vkDestroyPipelineLayout(m_device->device(), single_pipe_layout, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4996 | // 3. Pipeline setLayout[0] has 2 descriptors, but set being bound has 5 |
| 4997 | // descriptors |
| 4998 | m_errorMonitor->SetDesiredFailureMsg( |
| 4999 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 5000 | " has 2 descriptors, but DescriptorSetLayout "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5001 | vkCmdBindDescriptorSets( |
| 5002 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5003 | pipe_layout_one_desc, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5004 | m_errorMonitor->VerifyFound(); |
| 5005 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5006 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_one_desc, NULL); |
| 5007 | // 4. same # of descriptors but mismatch in type |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5008 | m_errorMonitor->SetDesiredFailureMsg( |
| 5009 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 5010 | " is type 'VK_DESCRIPTOR_TYPE_SAMPLER' but binding "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5011 | vkCmdBindDescriptorSets( |
| 5012 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5013 | pipe_layout_five_samp, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5014 | m_errorMonitor->VerifyFound(); |
| 5015 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5016 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_five_samp, NULL); |
| 5017 | // 5. same # of descriptors but mismatch in stageFlags |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5018 | m_errorMonitor->SetDesiredFailureMsg( |
| 5019 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 5020 | " has stageFlags 16 but binding 0 for DescriptorSetLayout "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5021 | vkCmdBindDescriptorSets( |
| 5022 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5023 | pipe_layout_fs_only, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5024 | m_errorMonitor->VerifyFound(); |
| 5025 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5026 | // Cause INFO messages due to disturbing previously bound Sets |
| 5027 | // First bind sets 0 & 1 |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5028 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5029 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 5030 | 2, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5031 | // 1. Disturb bound set0 by re-binding set1 w/ updated pipelineLayout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5032 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 5033 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5034 | " previously bound as set #0 was disturbed "); |
| 5035 | vkCmdBindDescriptorSets( |
| 5036 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5037 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5038 | m_errorMonitor->VerifyFound(); |
| 5039 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5040 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5041 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 5042 | 2, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5043 | // 2. Disturb set after last bound set |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 5044 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5045 | " newly bound as set #0 so set #1 and " |
| 5046 | "any subsequent sets were disturbed "); |
| 5047 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5048 | VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5049 | pipe_layout_fs_only, 0, 1, &ds0_fs_only, 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5050 | m_errorMonitor->VerifyFound(); |
| 5051 | |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5052 | // Cause draw-time errors due to PSO incompatibilities |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5053 | // 1. Error due to not binding required set (we actually use same code as |
| 5054 | // above to disturb set0) |
| 5055 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5056 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 5057 | 2, &descriptorSet[0], 0, NULL); |
| 5058 | vkCmdBindDescriptorSets( |
| 5059 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5060 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
| 5061 | m_errorMonitor->SetDesiredFailureMsg( |
| 5062 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5063 | " uses set #0 but that set is not bound."); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5064 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5065 | m_errorMonitor->VerifyFound(); |
| 5066 | |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 5067 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_bad_set0, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5068 | // 2. Error due to bound set not being compatible with PSO's |
| 5069 | // VkPipelineLayout (diff stageFlags in this case) |
| 5070 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5071 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 5072 | 2, &descriptorSet[0], 0, NULL); |
| 5073 | m_errorMonitor->SetDesiredFailureMsg( |
| 5074 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5075 | " bound as set #0 is not compatible with "); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5076 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5077 | m_errorMonitor->VerifyFound(); |
| 5078 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5079 | // Remaining clean-up |
| 5080 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_fs_only, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5081 | for (uint32_t i = 0; i < NUM_LAYOUTS; ++i) { |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5082 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout[i], NULL); |
| 5083 | } |
| 5084 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout_fs_only, NULL); |
Tobin Ehlis | 9bfd449 | 2016-05-05 15:09:11 -0600 | [diff] [blame] | 5085 | vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &ds0_fs_only); |
| 5086 | vkFreeDescriptorSets(m_device->device(), ds_pool, NUM_SETS, descriptorSet); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5087 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5088 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5089 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 5090 | } |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5091 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5092 | TEST_F(VkLayerTest, NoBeginCommandBuffer) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5093 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5094 | m_errorMonitor->SetDesiredFailureMsg( |
| 5095 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5096 | "You must call vkBeginCommandBuffer() before this call to "); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5097 | |
| 5098 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5099 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5100 | // Call EndCommandBuffer() w/o calling BeginCommandBuffer() |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5101 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5102 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5103 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5104 | } |
| 5105 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5106 | TEST_F(VkLayerTest, SecondaryCommandBufferNullRenderpass) { |
| 5107 | VkResult err; |
| 5108 | VkCommandBuffer draw_cmd; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5109 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5110 | m_errorMonitor->SetDesiredFailureMsg( |
| 5111 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 61b36f3 | 2015-12-16 08:19:42 -0700 | [diff] [blame] | 5112 | " must specify a valid renderpass parameter."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5113 | |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 5114 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 5115 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5116 | VkCommandBufferAllocateInfo cmd = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5117 | cmd.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 5118 | cmd.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5119 | cmd.commandPool = m_commandPool; |
| 5120 | cmd.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5121 | cmd.commandBufferCount = 1; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 5122 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5123 | err = vkAllocateCommandBuffers(m_device->device(), &cmd, &draw_cmd); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5124 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 5125 | |
| 5126 | // Force the failure by not setting the Renderpass and Framebuffer fields |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5127 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5128 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5129 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 5130 | cmd_buf_info.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5131 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT | |
| 5132 | VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5133 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 5134 | |
| 5135 | // The error should be caught by validation of the BeginCommandBuffer call |
| 5136 | vkBeginCommandBuffer(draw_cmd, &cmd_buf_info); |
| 5137 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5138 | m_errorMonitor->VerifyFound(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5139 | vkFreeCommandBuffers(m_device->device(), m_commandPool, 1, &draw_cmd); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 5140 | } |
| 5141 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5142 | TEST_F(VkLayerTest, CommandBufferResetErrors) { |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5143 | // Cause error due to Begin while recording CB |
| 5144 | // Then cause 2 errors for attempting to reset CB w/o having |
| 5145 | // VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT set for the pool from |
| 5146 | // which CBs were allocated. Note that this bit is off by default. |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5147 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5148 | "Cannot call Begin on CB"); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5149 | |
| 5150 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5151 | |
| 5152 | // Calls AllocateCommandBuffers |
| 5153 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
| 5154 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5155 | // Force the failure by setting the Renderpass and Framebuffer fields with |
| 5156 | // (fake) data |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5157 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5158 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5159 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 5160 | cmd_buf_info.pNext = NULL; |
| 5161 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5162 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5163 | |
| 5164 | // Begin CB to transition to recording state |
| 5165 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
| 5166 | // Can't re-begin. This should trigger error |
| 5167 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5168 | m_errorMonitor->VerifyFound(); |
| 5169 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5170 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5171 | "Attempt to reset command buffer "); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5172 | VkCommandBufferResetFlags flags = 0; // Don't care about flags for this test |
| 5173 | // Reset attempt will trigger error due to incorrect CommandPool state |
| 5174 | vkResetCommandBuffer(commandBuffer.GetBufferHandle(), flags); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5175 | m_errorMonitor->VerifyFound(); |
| 5176 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5177 | m_errorMonitor->SetDesiredFailureMsg( |
| 5178 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5179 | " attempts to implicitly reset cmdBuffer created from "); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5180 | // Transition CB to RECORDED state |
| 5181 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
| 5182 | // Now attempting to Begin will implicitly reset, which triggers error |
| 5183 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5184 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5185 | } |
| 5186 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5187 | TEST_F(VkLayerTest, InvalidPipelineCreateState) { |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5188 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5189 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5190 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5191 | m_errorMonitor->SetDesiredFailureMsg( |
| 5192 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5193 | "Invalid Pipeline CreateInfo State: Vtx Shader required"); |
| 5194 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5195 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 5196 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 5197 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5198 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5199 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5200 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5201 | |
| 5202 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5203 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5204 | ds_pool_ci.pNext = NULL; |
| 5205 | ds_pool_ci.maxSets = 1; |
| 5206 | ds_pool_ci.poolSizeCount = 1; |
| 5207 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 5208 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5209 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5210 | err = |
| 5211 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5212 | ASSERT_VK_SUCCESS(err); |
| 5213 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5214 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5215 | dsl_binding.binding = 0; |
| 5216 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5217 | dsl_binding.descriptorCount = 1; |
| 5218 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5219 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5220 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5221 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5222 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5223 | ds_layout_ci.pNext = NULL; |
| 5224 | ds_layout_ci.bindingCount = 1; |
| 5225 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5226 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5227 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5228 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5229 | &ds_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5230 | ASSERT_VK_SUCCESS(err); |
| 5231 | |
| 5232 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5233 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5234 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5235 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5236 | alloc_info.descriptorPool = ds_pool; |
| 5237 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5238 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5239 | &descriptorSet); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5240 | ASSERT_VK_SUCCESS(err); |
| 5241 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5242 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5243 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5244 | pipeline_layout_ci.setLayoutCount = 1; |
| 5245 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5246 | |
| 5247 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5248 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5249 | &pipeline_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5250 | ASSERT_VK_SUCCESS(err); |
| 5251 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5252 | VkViewport vp = {}; // Just need dummy vp to point to |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5253 | VkRect2D sc = {}; // dummy scissor to point to |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5254 | |
| 5255 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5256 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 5257 | vp_state_ci.scissorCount = 1; |
| 5258 | vp_state_ci.pScissors = ≻ |
| 5259 | vp_state_ci.viewportCount = 1; |
| 5260 | vp_state_ci.pViewports = &vp; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5261 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 5262 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 5263 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 5264 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 5265 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 5266 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 5267 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 5268 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 5269 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 5270 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5271 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5272 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 5273 | gp_ci.pViewportState = &vp_state_ci; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 5274 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5275 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 5276 | gp_ci.layout = pipeline_layout; |
| 5277 | gp_ci.renderPass = renderPass(); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5278 | |
| 5279 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5280 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 5281 | pc_ci.initialDataSize = 0; |
| 5282 | pc_ci.pInitialData = 0; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5283 | |
| 5284 | VkPipeline pipeline; |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 5285 | VkPipelineCache pipelineCache; |
| 5286 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5287 | err = |
| 5288 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 5289 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5290 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 5291 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 5292 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5293 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5294 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5295 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 5296 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5297 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5298 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5299 | } |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5300 | /*// TODO : This test should be good, but needs Tess support in compiler to run |
| 5301 | TEST_F(VkLayerTest, InvalidPatchControlPoints) |
| 5302 | { |
| 5303 | // Attempt to Create Gfx Pipeline w/o a VS |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5304 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5305 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5306 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5307 | "Invalid Pipeline CreateInfo State: VK_PRIMITIVE_TOPOLOGY_PATCH |
| 5308 | primitive "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5309 | |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5310 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5311 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5312 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5313 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5314 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5315 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5316 | |
| 5317 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 5318 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5319 | ds_pool_ci.pNext = NULL; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5320 | ds_pool_ci.poolSizeCount = 1; |
| 5321 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5322 | |
| 5323 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5324 | err = vkCreateDescriptorPool(m_device->device(), |
| 5325 | 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] | 5326 | ASSERT_VK_SUCCESS(err); |
| 5327 | |
| 5328 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5329 | dsl_binding.binding = 0; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5330 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 5331 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5332 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5333 | dsl_binding.pImmutableSamplers = NULL; |
| 5334 | |
| 5335 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5336 | ds_layout_ci.sType = |
| 5337 | VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5338 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5339 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 5340 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5341 | |
| 5342 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5343 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5344 | &ds_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5345 | ASSERT_VK_SUCCESS(err); |
| 5346 | |
| 5347 | VkDescriptorSet descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5348 | err = vkAllocateDescriptorSets(m_device->device(), ds_pool, |
| 5349 | VK_DESCRIPTOR_SET_USAGE_NON_FREE, 1, &ds_layout, &descriptorSet); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5350 | ASSERT_VK_SUCCESS(err); |
| 5351 | |
| 5352 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5353 | pipeline_layout_ci.sType = |
| 5354 | VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5355 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5356 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5357 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 5358 | |
| 5359 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5360 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5361 | &pipeline_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5362 | ASSERT_VK_SUCCESS(err); |
| 5363 | |
| 5364 | VkPipelineShaderStageCreateInfo shaderStages[3]; |
| 5365 | memset(&shaderStages, 0, 3 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 5366 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5367 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, |
| 5368 | this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5369 | // 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] | 5370 | VkShaderObj |
| 5371 | tc(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, |
| 5372 | this); |
| 5373 | VkShaderObj |
| 5374 | te(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, |
| 5375 | this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5376 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5377 | shaderStages[0].sType = |
| 5378 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5379 | shaderStages[0].stage = VK_SHADER_STAGE_VERTEX_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5380 | shaderStages[0].shader = vs.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5381 | shaderStages[1].sType = |
| 5382 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5383 | shaderStages[1].stage = VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5384 | shaderStages[1].shader = tc.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5385 | shaderStages[2].sType = |
| 5386 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5387 | shaderStages[2].stage = VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5388 | shaderStages[2].shader = te.handle(); |
| 5389 | |
| 5390 | VkPipelineInputAssemblyStateCreateInfo iaCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5391 | iaCI.sType = |
| 5392 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
Chia-I Wu | 515eb8f | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5393 | iaCI.topology = VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5394 | |
| 5395 | VkPipelineTessellationStateCreateInfo tsCI = {}; |
| 5396 | tsCI.sType = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO; |
| 5397 | tsCI.patchControlPoints = 0; // This will cause an error |
| 5398 | |
| 5399 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 5400 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 5401 | gp_ci.pNext = NULL; |
| 5402 | gp_ci.stageCount = 3; |
| 5403 | gp_ci.pStages = shaderStages; |
| 5404 | gp_ci.pVertexInputState = NULL; |
| 5405 | gp_ci.pInputAssemblyState = &iaCI; |
| 5406 | gp_ci.pTessellationState = &tsCI; |
| 5407 | gp_ci.pViewportState = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5408 | gp_ci.pRasterizationState = NULL; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5409 | gp_ci.pMultisampleState = NULL; |
| 5410 | gp_ci.pDepthStencilState = NULL; |
| 5411 | gp_ci.pColorBlendState = NULL; |
| 5412 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 5413 | gp_ci.layout = pipeline_layout; |
| 5414 | gp_ci.renderPass = renderPass(); |
| 5415 | |
| 5416 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 5417 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 5418 | pc_ci.pNext = NULL; |
| 5419 | pc_ci.initialSize = 0; |
| 5420 | pc_ci.initialData = 0; |
| 5421 | pc_ci.maxSize = 0; |
| 5422 | |
| 5423 | VkPipeline pipeline; |
| 5424 | VkPipelineCache pipelineCache; |
| 5425 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5426 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, |
| 5427 | &pipelineCache); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5428 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5429 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 5430 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5431 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5432 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5433 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5434 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 5435 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5436 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5437 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5438 | } |
| 5439 | */ |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5440 | // Set scissor and viewport counts to different numbers |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5441 | TEST_F(VkLayerTest, PSOViewportScissorCountMismatch) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5442 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5443 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5444 | m_errorMonitor->SetDesiredFailureMsg( |
| 5445 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5446 | "Gfx Pipeline viewport count (1) must match scissor count (0)."); |
| 5447 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5448 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5449 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5450 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5451 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5452 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5453 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5454 | |
| 5455 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5456 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5457 | ds_pool_ci.maxSets = 1; |
| 5458 | ds_pool_ci.poolSizeCount = 1; |
| 5459 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5460 | |
| 5461 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5462 | err = |
| 5463 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5464 | ASSERT_VK_SUCCESS(err); |
| 5465 | |
| 5466 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5467 | dsl_binding.binding = 0; |
| 5468 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5469 | dsl_binding.descriptorCount = 1; |
| 5470 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5471 | |
| 5472 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5473 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5474 | ds_layout_ci.bindingCount = 1; |
| 5475 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5476 | |
| 5477 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5478 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5479 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5480 | ASSERT_VK_SUCCESS(err); |
| 5481 | |
| 5482 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5483 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5484 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5485 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5486 | alloc_info.descriptorPool = ds_pool; |
| 5487 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5488 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5489 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5490 | ASSERT_VK_SUCCESS(err); |
| 5491 | |
| 5492 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5493 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5494 | pipeline_layout_ci.setLayoutCount = 1; |
| 5495 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5496 | |
| 5497 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5498 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5499 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5500 | ASSERT_VK_SUCCESS(err); |
| 5501 | |
| 5502 | VkViewport vp = {}; // Just need dummy vp to point to |
| 5503 | |
| 5504 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5505 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 5506 | vp_state_ci.scissorCount = 0; |
| 5507 | vp_state_ci.viewportCount = 1; // Count mismatch should cause error |
| 5508 | vp_state_ci.pViewports = &vp; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5509 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 5510 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 5511 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 5512 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 5513 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 5514 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 5515 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 5516 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 5517 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 5518 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 5519 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5520 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5521 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5522 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 5523 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5524 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 5525 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 5526 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5527 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5528 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 5529 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5530 | |
| 5531 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5532 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 5533 | gp_ci.stageCount = 2; |
| 5534 | gp_ci.pStages = shaderStages; |
| 5535 | gp_ci.pViewportState = &vp_state_ci; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 5536 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5537 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 5538 | gp_ci.layout = pipeline_layout; |
| 5539 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5540 | |
| 5541 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5542 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5543 | |
| 5544 | VkPipeline pipeline; |
| 5545 | VkPipelineCache pipelineCache; |
| 5546 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5547 | err = |
| 5548 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5549 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5550 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 5551 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5552 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5553 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5554 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5555 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 5556 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5557 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5558 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5559 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5560 | // Don't set viewport state in PSO. This is an error b/c we always need this |
| 5561 | // state |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 5562 | // 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] | 5563 | TEST_F(VkLayerTest, PSOViewportStateNotSet) { |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5564 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5565 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5566 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5567 | m_errorMonitor->SetDesiredFailureMsg( |
| 5568 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5569 | "Gfx Pipeline pViewportState is null. Even if "); |
| 5570 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5571 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5572 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5573 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5574 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5575 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5576 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5577 | |
| 5578 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5579 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5580 | ds_pool_ci.maxSets = 1; |
| 5581 | ds_pool_ci.poolSizeCount = 1; |
| 5582 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5583 | |
| 5584 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5585 | err = |
| 5586 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5587 | ASSERT_VK_SUCCESS(err); |
| 5588 | |
| 5589 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5590 | dsl_binding.binding = 0; |
| 5591 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5592 | dsl_binding.descriptorCount = 1; |
| 5593 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5594 | |
| 5595 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5596 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5597 | ds_layout_ci.bindingCount = 1; |
| 5598 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5599 | |
| 5600 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5601 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5602 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5603 | ASSERT_VK_SUCCESS(err); |
| 5604 | |
| 5605 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5606 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5607 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5608 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5609 | alloc_info.descriptorPool = ds_pool; |
| 5610 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5611 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5612 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5613 | ASSERT_VK_SUCCESS(err); |
| 5614 | |
| 5615 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5616 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5617 | pipeline_layout_ci.setLayoutCount = 1; |
| 5618 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5619 | |
| 5620 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5621 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5622 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5623 | ASSERT_VK_SUCCESS(err); |
| 5624 | |
| 5625 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 5626 | // Set scissor as dynamic to avoid second error |
| 5627 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5628 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 5629 | dyn_state_ci.dynamicStateCount = 1; |
| 5630 | dyn_state_ci.pDynamicStates = &sc_state; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5631 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 5632 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5633 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5634 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5635 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 5636 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5637 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 5638 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 5639 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5640 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5641 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 5642 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5643 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 5644 | |
| 5645 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 5646 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 5647 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 5648 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 5649 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 5650 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 5651 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 5652 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 5653 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5654 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5655 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 5656 | gp_ci.stageCount = 2; |
| 5657 | gp_ci.pStages = shaderStages; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 5658 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5659 | gp_ci.pViewportState = NULL; // Not setting VP state w/o dynamic vp state |
| 5660 | // should cause validation error |
| 5661 | gp_ci.pDynamicState = &dyn_state_ci; |
| 5662 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 5663 | gp_ci.layout = pipeline_layout; |
| 5664 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5665 | |
| 5666 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5667 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5668 | |
| 5669 | VkPipeline pipeline; |
| 5670 | VkPipelineCache pipelineCache; |
| 5671 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5672 | err = |
| 5673 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5674 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5675 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 5676 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5677 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5678 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5679 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5680 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 5681 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5682 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5683 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5684 | } |
| 5685 | // Create PSO w/o non-zero viewportCount but no viewport data |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5686 | // Then run second test where dynamic scissor count doesn't match PSO scissor |
| 5687 | // count |
| 5688 | TEST_F(VkLayerTest, PSOViewportCountWithoutDataAndDynScissorMismatch) { |
| 5689 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5690 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5691 | m_errorMonitor->SetDesiredFailureMsg( |
| 5692 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5693 | "Gfx Pipeline viewportCount is 1, but pViewports is NULL. "); |
| 5694 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5695 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5696 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5697 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5698 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5699 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5700 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5701 | |
| 5702 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5703 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5704 | ds_pool_ci.maxSets = 1; |
| 5705 | ds_pool_ci.poolSizeCount = 1; |
| 5706 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5707 | |
| 5708 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5709 | err = |
| 5710 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5711 | ASSERT_VK_SUCCESS(err); |
| 5712 | |
| 5713 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5714 | dsl_binding.binding = 0; |
| 5715 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5716 | dsl_binding.descriptorCount = 1; |
| 5717 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5718 | |
| 5719 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5720 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5721 | ds_layout_ci.bindingCount = 1; |
| 5722 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5723 | |
| 5724 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5725 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5726 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5727 | ASSERT_VK_SUCCESS(err); |
| 5728 | |
| 5729 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5730 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5731 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5732 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5733 | alloc_info.descriptorPool = ds_pool; |
| 5734 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5735 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5736 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5737 | ASSERT_VK_SUCCESS(err); |
| 5738 | |
| 5739 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5740 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5741 | pipeline_layout_ci.setLayoutCount = 1; |
| 5742 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5743 | |
| 5744 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5745 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5746 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5747 | ASSERT_VK_SUCCESS(err); |
| 5748 | |
| 5749 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5750 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 5751 | vp_state_ci.viewportCount = 1; |
| 5752 | vp_state_ci.pViewports = NULL; // Null vp w/ count of 1 should cause error |
| 5753 | vp_state_ci.scissorCount = 1; |
| 5754 | vp_state_ci.pScissors = |
| 5755 | NULL; // Scissor is dynamic (below) so this won't cause error |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5756 | |
| 5757 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 5758 | // Set scissor as dynamic to avoid that error |
| 5759 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5760 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 5761 | dyn_state_ci.dynamicStateCount = 1; |
| 5762 | dyn_state_ci.pDynamicStates = &sc_state; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5763 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 5764 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5765 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5766 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5767 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 5768 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5769 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 5770 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 5771 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5772 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5773 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 5774 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5775 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 5776 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 5777 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 5778 | vi_ci.pNext = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5779 | vi_ci.vertexBindingDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 5780 | vi_ci.pVertexBindingDescriptions = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5781 | vi_ci.vertexAttributeDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 5782 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 5783 | |
| 5784 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 5785 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 5786 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 5787 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5788 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5789 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 5790 | rs_ci.pNext = nullptr; |
| 5791 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 5792 | VkPipelineColorBlendAttachmentState att = {}; |
| 5793 | att.blendEnable = VK_FALSE; |
| 5794 | att.colorWriteMask = 0xf; |
| 5795 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 5796 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 5797 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 5798 | cb_ci.pNext = nullptr; |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 5799 | cb_ci.attachmentCount = 1; |
| 5800 | cb_ci.pAttachments = &att; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 5801 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5802 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5803 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 5804 | gp_ci.stageCount = 2; |
| 5805 | gp_ci.pStages = shaderStages; |
| 5806 | gp_ci.pVertexInputState = &vi_ci; |
| 5807 | gp_ci.pInputAssemblyState = &ia_ci; |
| 5808 | gp_ci.pViewportState = &vp_state_ci; |
| 5809 | gp_ci.pRasterizationState = &rs_ci; |
| 5810 | gp_ci.pColorBlendState = &cb_ci; |
| 5811 | gp_ci.pDynamicState = &dyn_state_ci; |
| 5812 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 5813 | gp_ci.layout = pipeline_layout; |
| 5814 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5815 | |
| 5816 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5817 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5818 | |
| 5819 | VkPipeline pipeline; |
| 5820 | VkPipelineCache pipelineCache; |
| 5821 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5822 | err = |
| 5823 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5824 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5825 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 5826 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5827 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5828 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5829 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 5830 | // 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] | 5831 | // First need to successfully create the PSO from above by setting |
| 5832 | // pViewports |
| 5833 | m_errorMonitor->SetDesiredFailureMsg( |
| 5834 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5835 | "Dynamic scissorCount from vkCmdSetScissor() is 2, but PSO " |
| 5836 | "scissorCount is 1. These counts must match."); |
| 5837 | |
| 5838 | VkViewport vp = {}; // Just need dummy vp to point to |
| 5839 | vp_state_ci.pViewports = &vp; |
| 5840 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 5841 | &gp_ci, NULL, &pipeline); |
| 5842 | ASSERT_VK_SUCCESS(err); |
| 5843 | BeginCommandBuffer(); |
| 5844 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 5845 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
| 5846 | VkRect2D scissors[2] = {}; // don't care about data |
| 5847 | // Count of 2 doesn't match PSO count of 1 |
| 5848 | vkCmdSetScissor(m_commandBuffer->GetBufferHandle(), 0, 2, scissors); |
| 5849 | Draw(1, 0, 0, 0); |
| 5850 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5851 | m_errorMonitor->VerifyFound(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5852 | |
| 5853 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 5854 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5855 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5856 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 5857 | } |
| 5858 | // Create PSO w/o non-zero scissorCount but no scissor data |
| 5859 | // Then run second test where dynamic viewportCount doesn't match PSO |
| 5860 | // viewportCount |
| 5861 | TEST_F(VkLayerTest, PSOScissorCountWithoutDataAndDynViewportMismatch) { |
| 5862 | VkResult err; |
| 5863 | |
| 5864 | m_errorMonitor->SetDesiredFailureMsg( |
| 5865 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5866 | "Gfx Pipeline scissorCount is 1, but pScissors is NULL. "); |
| 5867 | |
| 5868 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5869 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5870 | |
| 5871 | VkDescriptorPoolSize ds_type_count = {}; |
| 5872 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5873 | ds_type_count.descriptorCount = 1; |
| 5874 | |
| 5875 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 5876 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5877 | ds_pool_ci.maxSets = 1; |
| 5878 | ds_pool_ci.poolSizeCount = 1; |
| 5879 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 5880 | |
| 5881 | VkDescriptorPool ds_pool; |
| 5882 | err = |
| 5883 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 5884 | ASSERT_VK_SUCCESS(err); |
| 5885 | |
| 5886 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 5887 | dsl_binding.binding = 0; |
| 5888 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5889 | dsl_binding.descriptorCount = 1; |
| 5890 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5891 | |
| 5892 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 5893 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5894 | ds_layout_ci.bindingCount = 1; |
| 5895 | ds_layout_ci.pBindings = &dsl_binding; |
| 5896 | |
| 5897 | VkDescriptorSetLayout ds_layout; |
| 5898 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5899 | &ds_layout); |
| 5900 | ASSERT_VK_SUCCESS(err); |
| 5901 | |
| 5902 | VkDescriptorSet descriptorSet; |
| 5903 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 5904 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 5905 | alloc_info.descriptorSetCount = 1; |
| 5906 | alloc_info.descriptorPool = ds_pool; |
| 5907 | alloc_info.pSetLayouts = &ds_layout; |
| 5908 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5909 | &descriptorSet); |
| 5910 | ASSERT_VK_SUCCESS(err); |
| 5911 | |
| 5912 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 5913 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5914 | pipeline_layout_ci.setLayoutCount = 1; |
| 5915 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 5916 | |
| 5917 | VkPipelineLayout pipeline_layout; |
| 5918 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5919 | &pipeline_layout); |
| 5920 | ASSERT_VK_SUCCESS(err); |
| 5921 | |
| 5922 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 5923 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 5924 | vp_state_ci.scissorCount = 1; |
| 5925 | vp_state_ci.pScissors = |
| 5926 | NULL; // Null scissor w/ count of 1 should cause error |
| 5927 | vp_state_ci.viewportCount = 1; |
| 5928 | vp_state_ci.pViewports = |
| 5929 | NULL; // vp is dynamic (below) so this won't cause error |
| 5930 | |
| 5931 | VkDynamicState vp_state = VK_DYNAMIC_STATE_VIEWPORT; |
| 5932 | // Set scissor as dynamic to avoid that error |
| 5933 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 5934 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 5935 | dyn_state_ci.dynamicStateCount = 1; |
| 5936 | dyn_state_ci.pDynamicStates = &vp_state; |
| 5937 | |
| 5938 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 5939 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 5940 | |
| 5941 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 5942 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5943 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 5944 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 5945 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5946 | // but add it to be able to run on more devices |
| 5947 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 5948 | shaderStages[1] = fs.GetStageCreateInfo(); |
| 5949 | |
| 5950 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 5951 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 5952 | vi_ci.pNext = nullptr; |
| 5953 | vi_ci.vertexBindingDescriptionCount = 0; |
| 5954 | vi_ci.pVertexBindingDescriptions = nullptr; |
| 5955 | vi_ci.vertexAttributeDescriptionCount = 0; |
| 5956 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 5957 | |
| 5958 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 5959 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 5960 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 5961 | |
| 5962 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
| 5963 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 5964 | rs_ci.pNext = nullptr; |
| 5965 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 5966 | VkPipelineColorBlendAttachmentState att = {}; |
| 5967 | att.blendEnable = VK_FALSE; |
| 5968 | att.colorWriteMask = 0xf; |
| 5969 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5970 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 5971 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 5972 | cb_ci.pNext = nullptr; |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 5973 | cb_ci.attachmentCount = 1; |
| 5974 | cb_ci.pAttachments = &att; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5975 | |
| 5976 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 5977 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 5978 | gp_ci.stageCount = 2; |
| 5979 | gp_ci.pStages = shaderStages; |
| 5980 | gp_ci.pVertexInputState = &vi_ci; |
| 5981 | gp_ci.pInputAssemblyState = &ia_ci; |
| 5982 | gp_ci.pViewportState = &vp_state_ci; |
| 5983 | gp_ci.pRasterizationState = &rs_ci; |
| 5984 | gp_ci.pColorBlendState = &cb_ci; |
| 5985 | gp_ci.pDynamicState = &dyn_state_ci; |
| 5986 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 5987 | gp_ci.layout = pipeline_layout; |
| 5988 | gp_ci.renderPass = renderPass(); |
| 5989 | |
| 5990 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 5991 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 5992 | |
| 5993 | VkPipeline pipeline; |
| 5994 | VkPipelineCache pipelineCache; |
| 5995 | |
| 5996 | err = |
| 5997 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 5998 | ASSERT_VK_SUCCESS(err); |
| 5999 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6000 | &gp_ci, NULL, &pipeline); |
| 6001 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6002 | m_errorMonitor->VerifyFound(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6003 | |
| 6004 | // Now hit second fail case where we set scissor w/ different count than PSO |
| 6005 | // First need to successfully create the PSO from above by setting |
| 6006 | // pViewports |
| 6007 | m_errorMonitor->SetDesiredFailureMsg( |
| 6008 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6009 | "Dynamic viewportCount from vkCmdSetViewport() is 2, but PSO " |
| 6010 | "viewportCount is 1. These counts must match."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6011 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6012 | VkRect2D sc = {}; // Just need dummy vp to point to |
| 6013 | vp_state_ci.pScissors = ≻ |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6014 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6015 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6016 | ASSERT_VK_SUCCESS(err); |
| 6017 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6018 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 6019 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6020 | VkViewport viewports[2] = {}; // don't care about data |
| 6021 | // Count of 2 doesn't match PSO count of 1 |
Jon Ashburn | 19d3bf1 | 2015-12-30 14:06:55 -0700 | [diff] [blame] | 6022 | vkCmdSetViewport(m_commandBuffer->GetBufferHandle(), 0, 2, viewports); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6023 | Draw(1, 0, 0, 0); |
| 6024 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6025 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6026 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6027 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 6028 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6029 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6030 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6031 | } |
| 6032 | |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6033 | TEST_F(VkLayerTest, PSOLineWidthInvalid) { |
| 6034 | VkResult err; |
| 6035 | |
| 6036 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 6037 | "Attempt to set lineWidth to -1"); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6038 | |
| 6039 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6040 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6041 | |
| 6042 | VkDescriptorPoolSize ds_type_count = {}; |
| 6043 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6044 | ds_type_count.descriptorCount = 1; |
| 6045 | |
| 6046 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 6047 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6048 | ds_pool_ci.maxSets = 1; |
| 6049 | ds_pool_ci.poolSizeCount = 1; |
| 6050 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 6051 | |
| 6052 | VkDescriptorPool ds_pool; |
| 6053 | err = |
| 6054 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 6055 | ASSERT_VK_SUCCESS(err); |
| 6056 | |
| 6057 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 6058 | dsl_binding.binding = 0; |
| 6059 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6060 | dsl_binding.descriptorCount = 1; |
| 6061 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6062 | |
| 6063 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 6064 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6065 | ds_layout_ci.bindingCount = 1; |
| 6066 | ds_layout_ci.pBindings = &dsl_binding; |
| 6067 | |
| 6068 | VkDescriptorSetLayout ds_layout; |
| 6069 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6070 | &ds_layout); |
| 6071 | ASSERT_VK_SUCCESS(err); |
| 6072 | |
| 6073 | VkDescriptorSet descriptorSet; |
| 6074 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 6075 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 6076 | alloc_info.descriptorSetCount = 1; |
| 6077 | alloc_info.descriptorPool = ds_pool; |
| 6078 | alloc_info.pSetLayouts = &ds_layout; |
| 6079 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6080 | &descriptorSet); |
| 6081 | ASSERT_VK_SUCCESS(err); |
| 6082 | |
| 6083 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 6084 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6085 | pipeline_layout_ci.setLayoutCount = 1; |
| 6086 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 6087 | |
| 6088 | VkPipelineLayout pipeline_layout; |
| 6089 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6090 | &pipeline_layout); |
| 6091 | ASSERT_VK_SUCCESS(err); |
| 6092 | |
| 6093 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 6094 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 6095 | vp_state_ci.scissorCount = 1; |
| 6096 | vp_state_ci.pScissors = NULL; |
| 6097 | vp_state_ci.viewportCount = 1; |
| 6098 | vp_state_ci.pViewports = NULL; |
| 6099 | |
| 6100 | VkDynamicState dynamic_states[3] = {VK_DYNAMIC_STATE_VIEWPORT, |
| 6101 | VK_DYNAMIC_STATE_SCISSOR, |
| 6102 | VK_DYNAMIC_STATE_LINE_WIDTH}; |
| 6103 | // Set scissor as dynamic to avoid that error |
| 6104 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 6105 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 6106 | dyn_state_ci.dynamicStateCount = 2; |
| 6107 | dyn_state_ci.pDynamicStates = dynamic_states; |
| 6108 | |
| 6109 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 6110 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 6111 | |
| 6112 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6113 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6114 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6115 | VK_SHADER_STAGE_FRAGMENT_BIT, |
| 6116 | this); // TODO - We shouldn't need a fragment shader |
| 6117 | // but add it to be able to run on more devices |
| 6118 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 6119 | shaderStages[1] = fs.GetStageCreateInfo(); |
| 6120 | |
| 6121 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 6122 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 6123 | vi_ci.pNext = nullptr; |
| 6124 | vi_ci.vertexBindingDescriptionCount = 0; |
| 6125 | vi_ci.pVertexBindingDescriptions = nullptr; |
| 6126 | vi_ci.vertexAttributeDescriptionCount = 0; |
| 6127 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 6128 | |
| 6129 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 6130 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 6131 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 6132 | |
| 6133 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
| 6134 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 6135 | rs_ci.pNext = nullptr; |
| 6136 | |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 6137 | // Check too low (line width of -1.0f). |
| 6138 | rs_ci.lineWidth = -1.0f; |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6139 | |
| 6140 | VkPipelineColorBlendAttachmentState att = {}; |
| 6141 | att.blendEnable = VK_FALSE; |
| 6142 | att.colorWriteMask = 0xf; |
| 6143 | |
| 6144 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 6145 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 6146 | cb_ci.pNext = nullptr; |
| 6147 | cb_ci.attachmentCount = 1; |
| 6148 | cb_ci.pAttachments = &att; |
| 6149 | |
| 6150 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 6151 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 6152 | gp_ci.stageCount = 2; |
| 6153 | gp_ci.pStages = shaderStages; |
| 6154 | gp_ci.pVertexInputState = &vi_ci; |
| 6155 | gp_ci.pInputAssemblyState = &ia_ci; |
| 6156 | gp_ci.pViewportState = &vp_state_ci; |
| 6157 | gp_ci.pRasterizationState = &rs_ci; |
| 6158 | gp_ci.pColorBlendState = &cb_ci; |
| 6159 | gp_ci.pDynamicState = &dyn_state_ci; |
| 6160 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 6161 | gp_ci.layout = pipeline_layout; |
| 6162 | gp_ci.renderPass = renderPass(); |
| 6163 | |
| 6164 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 6165 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 6166 | |
| 6167 | VkPipeline pipeline; |
| 6168 | VkPipelineCache pipelineCache; |
| 6169 | |
| 6170 | err = |
| 6171 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 6172 | ASSERT_VK_SUCCESS(err); |
| 6173 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6174 | &gp_ci, NULL, &pipeline); |
| 6175 | |
| 6176 | m_errorMonitor->VerifyFound(); |
| 6177 | |
| 6178 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6179 | "Attempt to set lineWidth to 65536"); |
| 6180 | |
| 6181 | // Check too high (line width of 65536.0f). |
| 6182 | rs_ci.lineWidth = 65536.0f; |
| 6183 | |
| 6184 | err = |
| 6185 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 6186 | ASSERT_VK_SUCCESS(err); |
| 6187 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6188 | &gp_ci, NULL, &pipeline); |
| 6189 | |
| 6190 | m_errorMonitor->VerifyFound(); |
| 6191 | |
| 6192 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 6193 | "Attempt to set lineWidth to -1"); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6194 | |
| 6195 | dyn_state_ci.dynamicStateCount = 3; |
| 6196 | |
| 6197 | rs_ci.lineWidth = 1.0f; |
| 6198 | |
| 6199 | err = |
| 6200 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 6201 | ASSERT_VK_SUCCESS(err); |
| 6202 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6203 | &gp_ci, NULL, &pipeline); |
| 6204 | BeginCommandBuffer(); |
| 6205 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 6206 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
| 6207 | |
| 6208 | // Check too low with dynamic setting. |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 6209 | vkCmdSetLineWidth(m_commandBuffer->GetBufferHandle(), -1.0f); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6210 | m_errorMonitor->VerifyFound(); |
| 6211 | |
| 6212 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6213 | "Attempt to set lineWidth to 65536"); |
| 6214 | |
| 6215 | // Check too high with dynamic setting. |
| 6216 | vkCmdSetLineWidth(m_commandBuffer->GetBufferHandle(), 65536.0f); |
| 6217 | m_errorMonitor->VerifyFound(); |
| 6218 | EndCommandBuffer(); |
| 6219 | |
| 6220 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 6221 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6222 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6223 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 6224 | } |
| 6225 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6226 | TEST_F(VkLayerTest, NullRenderPass) { |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 6227 | // Bind a NULL RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6228 | m_errorMonitor->SetDesiredFailureMsg( |
| 6229 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6230 | "You cannot use a NULL RenderPass object in vkCmdBeginRenderPass()"); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 6231 | |
| 6232 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6233 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 6234 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 6235 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6236 | // Don't care about RenderPass handle b/c error should be flagged before |
| 6237 | // that |
| 6238 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), NULL, |
| 6239 | VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 6240 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6241 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 6242 | } |
| 6243 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6244 | TEST_F(VkLayerTest, RenderPassWithinRenderPass) { |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6245 | // Bind a BeginRenderPass within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6246 | m_errorMonitor->SetDesiredFailureMsg( |
| 6247 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6248 | "It is invalid to issue this call inside an active render pass"); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6249 | |
| 6250 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6251 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6252 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 6253 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6254 | // Just create a dummy Renderpass that's non-NULL so we can get to the |
| 6255 | // proper error |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6256 | VkRenderPassBeginInfo rp_begin = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6257 | rp_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; |
| 6258 | rp_begin.pNext = NULL; |
| 6259 | rp_begin.renderPass = renderPass(); |
| 6260 | rp_begin.framebuffer = framebuffer(); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6261 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6262 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &rp_begin, |
| 6263 | VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6264 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6265 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 6266 | } |
| 6267 | |
Cody Northrop | 3bb4d96 | 2016-05-09 16:15:57 -0600 | [diff] [blame] | 6268 | TEST_F(VkLayerTest, EndCommandBufferWithinRenderPass) { |
| 6269 | |
| 6270 | TEST_DESCRIPTION("End a command buffer with an active render pass"); |
| 6271 | |
| 6272 | m_errorMonitor->SetDesiredFailureMsg( |
| 6273 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6274 | "It is invalid to issue this call inside an active render pass"); |
| 6275 | |
| 6276 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6277 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6278 | |
| 6279 | // The framework's BeginCommandBuffer calls CreateRenderPass |
| 6280 | BeginCommandBuffer(); |
| 6281 | |
| 6282 | // Call directly into vkEndCommandBuffer instead of the |
| 6283 | // the framework's EndCommandBuffer, which inserts a |
| 6284 | // vkEndRenderPass |
| 6285 | vkEndCommandBuffer(m_commandBuffer->GetBufferHandle()); |
| 6286 | |
| 6287 | m_errorMonitor->VerifyFound(); |
| 6288 | |
| 6289 | // TODO: Add test for VK_COMMAND_BUFFER_LEVEL_SECONDARY |
| 6290 | // TODO: Add test for VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT |
| 6291 | } |
| 6292 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6293 | TEST_F(VkLayerTest, FillBufferWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6294 | // Call CmdFillBuffer within an active renderpass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6295 | m_errorMonitor->SetDesiredFailureMsg( |
| 6296 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6297 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6298 | |
| 6299 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6300 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6301 | |
| 6302 | // Renderpass is started here |
| 6303 | BeginCommandBuffer(); |
| 6304 | |
| 6305 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6306 | vk_testing::Buffer dstBuffer; |
| 6307 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6308 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6309 | m_commandBuffer->FillBuffer(dstBuffer.handle(), 0, 4, 0x11111111); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6310 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6311 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6312 | } |
| 6313 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6314 | TEST_F(VkLayerTest, UpdateBufferWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6315 | // Call CmdUpdateBuffer within an active renderpass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6316 | m_errorMonitor->SetDesiredFailureMsg( |
| 6317 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6318 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6319 | |
| 6320 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6321 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6322 | |
| 6323 | // Renderpass is started here |
| 6324 | BeginCommandBuffer(); |
| 6325 | |
| 6326 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6327 | vk_testing::Buffer dstBuffer; |
| 6328 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6329 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6330 | VkDeviceSize dstOffset = 0; |
| 6331 | VkDeviceSize dataSize = 1024; |
| 6332 | const uint32_t *pData = NULL; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6333 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6334 | vkCmdUpdateBuffer(m_commandBuffer->GetBufferHandle(), dstBuffer.handle(), |
| 6335 | dstOffset, dataSize, pData); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6336 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6337 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6338 | } |
| 6339 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6340 | TEST_F(VkLayerTest, ClearColorImageWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6341 | // Call CmdClearColorImage within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6342 | m_errorMonitor->SetDesiredFailureMsg( |
| 6343 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6344 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6345 | |
| 6346 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6347 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6348 | |
| 6349 | // Renderpass is started here |
| 6350 | BeginCommandBuffer(); |
| 6351 | |
Michael Lentine | 0a369f6 | 2016-02-03 16:51:46 -0600 | [diff] [blame] | 6352 | VkClearColorValue clear_color; |
| 6353 | memset(clear_color.uint32, 0, sizeof(uint32_t) * 4); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6354 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 6355 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6356 | const int32_t tex_width = 32; |
| 6357 | const int32_t tex_height = 32; |
| 6358 | VkImageCreateInfo image_create_info = {}; |
| 6359 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6360 | image_create_info.pNext = NULL; |
| 6361 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6362 | image_create_info.format = tex_format; |
| 6363 | image_create_info.extent.width = tex_width; |
| 6364 | image_create_info.extent.height = tex_height; |
| 6365 | image_create_info.extent.depth = 1; |
| 6366 | image_create_info.mipLevels = 1; |
| 6367 | image_create_info.arrayLayers = 1; |
| 6368 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 6369 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 6370 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6371 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6372 | vk_testing::Image dstImage; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6373 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 6374 | reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6375 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6376 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
| 6377 | image_create_info, VK_IMAGE_ASPECT_COLOR_BIT); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6378 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6379 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), dstImage.handle(), |
| 6380 | VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1, &range); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6381 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6382 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6383 | } |
| 6384 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6385 | TEST_F(VkLayerTest, ClearDepthStencilImageWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6386 | // Call CmdClearDepthStencilImage within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6387 | m_errorMonitor->SetDesiredFailureMsg( |
| 6388 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6389 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6390 | |
| 6391 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6392 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6393 | |
| 6394 | // Renderpass is started here |
| 6395 | BeginCommandBuffer(); |
| 6396 | |
| 6397 | VkClearDepthStencilValue clear_value = {0}; |
Dustin Graves | a2e5c94 | 2016-02-11 18:28:06 -0700 | [diff] [blame] | 6398 | VkMemoryPropertyFlags reqs = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6399 | VkImageCreateInfo image_create_info = vk_testing::Image::create_info(); |
| 6400 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6401 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 6402 | image_create_info.extent.width = 64; |
| 6403 | image_create_info.extent.height = 64; |
| 6404 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 6405 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6406 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6407 | vk_testing::Image dstImage; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6408 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 6409 | reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6410 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6411 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
| 6412 | image_create_info, VK_IMAGE_ASPECT_DEPTH_BIT); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6413 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6414 | vkCmdClearDepthStencilImage( |
| 6415 | m_commandBuffer->GetBufferHandle(), dstImage.handle(), |
| 6416 | VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, &clear_value, 1, |
| 6417 | &range); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6418 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6419 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6420 | } |
| 6421 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6422 | TEST_F(VkLayerTest, ClearColorAttachmentsOutsideRenderPass) { |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 6423 | // Call CmdClearAttachmentss outside of an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6424 | VkResult err; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6425 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6426 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6427 | "vkCmdClearAttachments: This call " |
| 6428 | "must be issued inside an active " |
| 6429 | "render pass"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6430 | |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6431 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6432 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6433 | |
| 6434 | // Start no RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6435 | err = m_commandBuffer->BeginCommandBuffer(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6436 | ASSERT_VK_SUCCESS(err); |
| 6437 | |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 6438 | VkClearAttachment color_attachment; |
| 6439 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 6440 | color_attachment.clearValue.color.float32[0] = 0; |
| 6441 | color_attachment.clearValue.color.float32[1] = 0; |
| 6442 | color_attachment.clearValue.color.float32[2] = 0; |
| 6443 | color_attachment.clearValue.color.float32[3] = 0; |
| 6444 | color_attachment.colorAttachment = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6445 | VkClearRect clear_rect = {{{0, 0}, {32, 32}}}; |
| 6446 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
| 6447 | &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6448 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6449 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6450 | } |
| 6451 | |
Karl Schultz | 9e66a29 | 2016-04-21 15:57:51 -0600 | [diff] [blame] | 6452 | TEST_F(VkLayerTest, BufferMemoryBarrierNoBuffer) { |
| 6453 | // Try to add a buffer memory barrier with no buffer. |
| 6454 | m_errorMonitor->SetDesiredFailureMsg( |
| 6455 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6456 | "required parameter pBufferMemoryBarriers[i].buffer specified as VK_NULL_HANDLE"); |
| 6457 | |
| 6458 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6459 | BeginCommandBuffer(); |
| 6460 | |
| 6461 | VkBufferMemoryBarrier buf_barrier = {}; |
| 6462 | buf_barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; |
| 6463 | buf_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 6464 | buf_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 6465 | buf_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 6466 | buf_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 6467 | buf_barrier.buffer = VK_NULL_HANDLE; |
| 6468 | buf_barrier.offset = 0; |
| 6469 | buf_barrier.size = VK_WHOLE_SIZE; |
| 6470 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6471 | VK_PIPELINE_STAGE_HOST_BIT, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, |
| 6472 | 0, 0, nullptr, 1, &buf_barrier, 0, nullptr); |
| 6473 | |
| 6474 | m_errorMonitor->VerifyFound(); |
| 6475 | } |
| 6476 | |
Tony Barbour | 7fd5c0f | 2016-05-03 16:11:53 -0600 | [diff] [blame] | 6477 | TEST_F(VkLayerTest, InvalidBarriers) { |
| 6478 | TEST_DESCRIPTION("A variety of ways to get VK_INVALID_BARRIER "); |
| 6479 | |
| 6480 | m_errorMonitor->SetDesiredFailureMsg( |
| 6481 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Barriers cannot be set during subpass"); |
| 6482 | |
| 6483 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6484 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6485 | |
| 6486 | VkMemoryBarrier mem_barrier = {}; |
| 6487 | mem_barrier.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER; |
| 6488 | mem_barrier.pNext = NULL; |
| 6489 | mem_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 6490 | mem_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 6491 | BeginCommandBuffer(); |
| 6492 | // BeginCommandBuffer() starts a render pass |
| 6493 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6494 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6495 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 1, |
| 6496 | &mem_barrier, 0, nullptr, 0, nullptr); |
| 6497 | m_errorMonitor->VerifyFound(); |
| 6498 | |
| 6499 | m_errorMonitor->SetDesiredFailureMsg( |
| 6500 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6501 | "Image Layout cannot be transitioned to UNDEFINED"); |
| 6502 | VkImageObj image(m_device); |
| 6503 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 6504 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
| 6505 | ASSERT_TRUE(image.initialized()); |
| 6506 | VkImageMemoryBarrier img_barrier = {}; |
| 6507 | img_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; |
| 6508 | img_barrier.pNext = NULL; |
| 6509 | img_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 6510 | img_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 6511 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 6512 | // New layout can't be UNDEFINED |
| 6513 | img_barrier.newLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 6514 | img_barrier.image = image.handle(); |
| 6515 | img_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 6516 | img_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 6517 | img_barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 6518 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 6519 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 6520 | img_barrier.subresourceRange.layerCount = 1; |
| 6521 | img_barrier.subresourceRange.levelCount = 1; |
| 6522 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6523 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6524 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 6525 | nullptr, 1, &img_barrier); |
| 6526 | m_errorMonitor->VerifyFound(); |
| 6527 | img_barrier.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 6528 | |
| 6529 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6530 | "Subresource must have the sum of the " |
| 6531 | "baseArrayLayer"); |
| 6532 | // baseArrayLayer + layerCount must be <= image's arrayLayers |
| 6533 | img_barrier.subresourceRange.baseArrayLayer = 1; |
| 6534 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6535 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6536 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 6537 | nullptr, 1, &img_barrier); |
| 6538 | m_errorMonitor->VerifyFound(); |
| 6539 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 6540 | |
| 6541 | m_errorMonitor->SetDesiredFailureMsg( |
| 6542 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6543 | "Subresource must have the sum of the baseMipLevel"); |
| 6544 | // baseMipLevel + levelCount must be <= image's mipLevels |
| 6545 | img_barrier.subresourceRange.baseMipLevel = 1; |
| 6546 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6547 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6548 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 6549 | nullptr, 1, &img_barrier); |
| 6550 | m_errorMonitor->VerifyFound(); |
| 6551 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 6552 | |
| 6553 | m_errorMonitor->SetDesiredFailureMsg( |
| 6554 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6555 | "Buffer Barriers cannot be used during a render pass"); |
| 6556 | vk_testing::Buffer buffer; |
| 6557 | buffer.init(*m_device, 256); |
| 6558 | VkBufferMemoryBarrier buf_barrier = {}; |
| 6559 | buf_barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; |
| 6560 | buf_barrier.pNext = NULL; |
| 6561 | buf_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 6562 | buf_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 6563 | buf_barrier.buffer = buffer.handle(); |
| 6564 | buf_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 6565 | buf_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 6566 | buf_barrier.offset = 0; |
| 6567 | buf_barrier.size = VK_WHOLE_SIZE; |
| 6568 | // Can't send buffer barrier during a render pass |
| 6569 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6570 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6571 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 6572 | &buf_barrier, 0, nullptr); |
| 6573 | m_errorMonitor->VerifyFound(); |
| 6574 | vkCmdEndRenderPass(m_commandBuffer->GetBufferHandle()); |
| 6575 | |
| 6576 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6577 | "which is not less than total size"); |
| 6578 | buf_barrier.offset = 257; |
| 6579 | // Offset greater than total size |
| 6580 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6581 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6582 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 6583 | &buf_barrier, 0, nullptr); |
| 6584 | m_errorMonitor->VerifyFound(); |
| 6585 | buf_barrier.offset = 0; |
| 6586 | |
| 6587 | m_errorMonitor->SetDesiredFailureMsg( |
| 6588 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "whose sum is greater than total size"); |
| 6589 | buf_barrier.size = 257; |
| 6590 | // Size greater than total size |
| 6591 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6592 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6593 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 6594 | &buf_barrier, 0, nullptr); |
| 6595 | m_errorMonitor->VerifyFound(); |
| 6596 | buf_barrier.size = VK_WHOLE_SIZE; |
| 6597 | |
| 6598 | m_errorMonitor->SetDesiredFailureMsg( |
| 6599 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6600 | "Image is a depth and stencil format and thus must " |
| 6601 | "have both VK_IMAGE_ASPECT_DEPTH_BIT and " |
| 6602 | "VK_IMAGE_ASPECT_STENCIL_BIT set."); |
| 6603 | VkDepthStencilObj ds_image(m_device); |
| 6604 | ds_image.Init(m_device, 128, 128, VK_FORMAT_D24_UNORM_S8_UINT); |
| 6605 | ASSERT_TRUE(ds_image.initialized()); |
| 6606 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 6607 | img_barrier.newLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; |
| 6608 | img_barrier.image = ds_image.handle(); |
| 6609 | // Leave aspectMask at COLOR on purpose |
| 6610 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6611 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6612 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 6613 | nullptr, 1, &img_barrier); |
| 6614 | m_errorMonitor->VerifyFound(); |
| 6615 | } |
| 6616 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6617 | TEST_F(VkLayerTest, IdxBufferAlignmentError) { |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 6618 | // Bind a BeginRenderPass within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6619 | VkResult err; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 6620 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6621 | m_errorMonitor->SetDesiredFailureMsg( |
| 6622 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6623 | "vkCmdBindIndexBuffer() offset (0x7) does not fall on "); |
| 6624 | |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 6625 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6626 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 6627 | uint32_t qfi = 0; |
| 6628 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6629 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 6630 | buffCI.size = 1024; |
| 6631 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
| 6632 | buffCI.queueFamilyIndexCount = 1; |
| 6633 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 6634 | |
| 6635 | VkBuffer ib; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6636 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 6637 | ASSERT_VK_SUCCESS(err); |
| 6638 | |
| 6639 | BeginCommandBuffer(); |
| 6640 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6641 | // vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 6642 | // VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 6643 | // 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] | 6644 | vkCmdBindIndexBuffer(m_commandBuffer->GetBufferHandle(), ib, 7, |
| 6645 | VK_INDEX_TYPE_UINT16); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 6646 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6647 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 6648 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6649 | vkDestroyBuffer(m_device->device(), ib, NULL); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 6650 | } |
| 6651 | |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 6652 | TEST_F(VkLayerTest, InvalidQueueFamilyIndex) { |
| 6653 | // Create an out-of-range queueFamilyIndex |
| 6654 | m_errorMonitor->SetDesiredFailureMsg( |
| 6655 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Dustin Graves | de62853 | 2016-04-21 16:30:17 -0600 | [diff] [blame] | 6656 | "vkCreateBuffer: pCreateInfo->pQueueFamilyIndices[0] (777) must be one " |
| 6657 | "of the indices specified when the device was created, via the " |
| 6658 | "VkDeviceQueueCreateInfo structure."); |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 6659 | |
| 6660 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6661 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6662 | VkBufferCreateInfo buffCI = {}; |
| 6663 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 6664 | buffCI.size = 1024; |
| 6665 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
| 6666 | buffCI.queueFamilyIndexCount = 1; |
| 6667 | // Introduce failure by specifying invalid queue_family_index |
| 6668 | uint32_t qfi = 777; |
| 6669 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 6670 | buffCI.sharingMode = VK_SHARING_MODE_CONCURRENT; // qfi only matters in CONCURRENT mode |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 6671 | |
| 6672 | VkBuffer ib; |
| 6673 | vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
| 6674 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6675 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 6676 | } |
| 6677 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6678 | TEST_F(VkLayerTest, ExecuteCommandsPrimaryCB) { |
| 6679 | // Attempt vkCmdExecuteCommands w/ a primary cmd buffer (should only be |
| 6680 | // secondary) |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6681 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6682 | m_errorMonitor->SetDesiredFailureMsg( |
| 6683 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6684 | "vkCmdExecuteCommands() called w/ Primary Cmd Buffer "); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 6685 | |
| 6686 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6687 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 6688 | |
| 6689 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6690 | // ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6691 | VkCommandBuffer primCB = m_commandBuffer->GetBufferHandle(); |
| 6692 | vkCmdExecuteCommands(m_commandBuffer->GetBufferHandle(), 1, &primCB); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 6693 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6694 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 6695 | } |
| 6696 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6697 | TEST_F(VkLayerTest, DSTypeMismatch) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 6698 | // 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] | 6699 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6700 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6701 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 6702 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6703 | " binding #0 with type VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER but update " |
| 6704 | "type is VK_DESCRIPTOR_TYPE_SAMPLER"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6705 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6706 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6707 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6708 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6709 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6710 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6711 | |
| 6712 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6713 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6714 | ds_pool_ci.pNext = NULL; |
| 6715 | ds_pool_ci.maxSets = 1; |
| 6716 | ds_pool_ci.poolSizeCount = 1; |
| 6717 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6718 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6719 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6720 | err = |
| 6721 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6722 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6723 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6724 | dsl_binding.binding = 0; |
| 6725 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6726 | dsl_binding.descriptorCount = 1; |
| 6727 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6728 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6729 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6730 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6731 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6732 | ds_layout_ci.pNext = NULL; |
| 6733 | ds_layout_ci.bindingCount = 1; |
| 6734 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6735 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6736 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6737 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6738 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6739 | ASSERT_VK_SUCCESS(err); |
| 6740 | |
| 6741 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6742 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6743 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6744 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 6745 | alloc_info.descriptorPool = ds_pool; |
| 6746 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6747 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6748 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6749 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6750 | |
Tobin Ehlis | 30db8f8 | 2016-05-05 08:19:48 -0600 | [diff] [blame] | 6751 | VkSamplerCreateInfo sampler_ci = {}; |
| 6752 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 6753 | sampler_ci.pNext = NULL; |
| 6754 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 6755 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 6756 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 6757 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 6758 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 6759 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 6760 | sampler_ci.mipLodBias = 1.0; |
| 6761 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 6762 | sampler_ci.maxAnisotropy = 1; |
| 6763 | sampler_ci.compareEnable = VK_FALSE; |
| 6764 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 6765 | sampler_ci.minLod = 1.0; |
| 6766 | sampler_ci.maxLod = 1.0; |
| 6767 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 6768 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
| 6769 | VkSampler sampler; |
| 6770 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
| 6771 | ASSERT_VK_SUCCESS(err); |
| 6772 | |
| 6773 | VkDescriptorImageInfo info = {}; |
| 6774 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 6775 | |
| 6776 | VkWriteDescriptorSet descriptor_write; |
| 6777 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 6778 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6779 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6780 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6781 | // This is a mismatched type for the layout which expects BUFFER |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 6782 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 6783 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 6784 | |
| 6785 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 6786 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6787 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 6788 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6789 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 6790 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6791 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 6792 | } |
| 6793 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6794 | TEST_F(VkLayerTest, DSUpdateOutOfBounds) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 6795 | // For overlapping Update, have arrayIndex exceed that of layout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6796 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6797 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6798 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 6799 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6800 | " binding #0 with 1 total descriptors but update of 1 descriptors " |
| 6801 | "starting at binding offset of 0 combined with update array element " |
| 6802 | "offset of 1 oversteps the size of this descriptor set."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6803 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6804 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6805 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6806 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6807 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6808 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6809 | |
| 6810 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6811 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6812 | ds_pool_ci.pNext = NULL; |
| 6813 | ds_pool_ci.maxSets = 1; |
| 6814 | ds_pool_ci.poolSizeCount = 1; |
| 6815 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6816 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6817 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6818 | err = |
| 6819 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6820 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6821 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6822 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6823 | dsl_binding.binding = 0; |
| 6824 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6825 | dsl_binding.descriptorCount = 1; |
| 6826 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6827 | dsl_binding.pImmutableSamplers = NULL; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6828 | |
| 6829 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6830 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6831 | ds_layout_ci.pNext = NULL; |
| 6832 | ds_layout_ci.bindingCount = 1; |
| 6833 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6834 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6835 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6836 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6837 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6838 | ASSERT_VK_SUCCESS(err); |
| 6839 | |
| 6840 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6841 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6842 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6843 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 6844 | alloc_info.descriptorPool = ds_pool; |
| 6845 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6846 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6847 | &descriptorSet); |
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 | |
Tobin Ehlis | 30db8f8 | 2016-05-05 08:19:48 -0600 | [diff] [blame] | 6850 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 6851 | VkDescriptorBufferInfo buff_info = {}; |
| 6852 | buff_info.buffer = |
| 6853 | VkBuffer(0); // Don't care about buffer handle for this test |
| 6854 | buff_info.offset = 0; |
| 6855 | buff_info.range = 1024; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 6856 | |
| 6857 | VkWriteDescriptorSet descriptor_write; |
| 6858 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 6859 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6860 | descriptor_write.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6861 | descriptor_write.dstArrayElement = |
| 6862 | 1; /* This index out of bounds for the update */ |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6863 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 6864 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6865 | descriptor_write.pBufferInfo = &buff_info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 6866 | |
| 6867 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 6868 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6869 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 6870 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6871 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6872 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 6873 | } |
| 6874 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6875 | TEST_F(VkLayerTest, InvalidDSUpdateIndex) { |
| 6876 | // Create layout w/ count of 1 and attempt update to that layout w/ binding |
| 6877 | // index 2 |
| 6878 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6879 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 6880 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6881 | " does not have binding 2."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6882 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6883 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6884 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6885 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6886 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6887 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6888 | |
| 6889 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6890 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6891 | ds_pool_ci.pNext = NULL; |
| 6892 | ds_pool_ci.maxSets = 1; |
| 6893 | ds_pool_ci.poolSizeCount = 1; |
| 6894 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 6895 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6896 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6897 | err = |
| 6898 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6899 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6900 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6901 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6902 | dsl_binding.binding = 0; |
| 6903 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6904 | dsl_binding.descriptorCount = 1; |
| 6905 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6906 | dsl_binding.pImmutableSamplers = NULL; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6907 | |
| 6908 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6909 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6910 | ds_layout_ci.pNext = NULL; |
| 6911 | ds_layout_ci.bindingCount = 1; |
| 6912 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6913 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6914 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6915 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6916 | ASSERT_VK_SUCCESS(err); |
| 6917 | |
| 6918 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6919 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6920 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6921 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 6922 | alloc_info.descriptorPool = ds_pool; |
| 6923 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6924 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6925 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6926 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6927 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6928 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6929 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 6930 | sampler_ci.pNext = NULL; |
| 6931 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 6932 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 6933 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 6934 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 6935 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 6936 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 6937 | sampler_ci.mipLodBias = 1.0; |
| 6938 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 6939 | sampler_ci.maxAnisotropy = 1; |
| 6940 | sampler_ci.compareEnable = VK_FALSE; |
| 6941 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 6942 | sampler_ci.minLod = 1.0; |
| 6943 | sampler_ci.maxLod = 1.0; |
| 6944 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 6945 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6946 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6947 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6948 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6949 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 6950 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 6951 | VkDescriptorImageInfo info = {}; |
| 6952 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 6953 | |
| 6954 | VkWriteDescriptorSet descriptor_write; |
| 6955 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 6956 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6957 | descriptor_write.dstSet = descriptorSet; |
| 6958 | descriptor_write.dstBinding = 2; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6959 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6960 | // 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] | 6961 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 6962 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 6963 | |
| 6964 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 6965 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6966 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 6967 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6968 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 6969 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6970 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 6971 | } |
| 6972 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6973 | TEST_F(VkLayerTest, InvalidDSUpdateStruct) { |
| 6974 | // Call UpdateDS w/ struct type other than valid VK_STRUCTUR_TYPE_UPDATE_* |
| 6975 | // types |
| 6976 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6977 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6978 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6979 | "Unexpected UPDATE struct of type "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6980 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6981 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6982 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6983 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6984 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6985 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6986 | |
| 6987 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6988 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6989 | ds_pool_ci.pNext = NULL; |
| 6990 | ds_pool_ci.maxSets = 1; |
| 6991 | ds_pool_ci.poolSizeCount = 1; |
| 6992 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 6993 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6994 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6995 | err = |
| 6996 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6997 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6998 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6999 | dsl_binding.binding = 0; |
| 7000 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7001 | dsl_binding.descriptorCount = 1; |
| 7002 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7003 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7004 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7005 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7006 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7007 | ds_layout_ci.pNext = NULL; |
| 7008 | ds_layout_ci.bindingCount = 1; |
| 7009 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7010 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7011 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7012 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7013 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7014 | ASSERT_VK_SUCCESS(err); |
| 7015 | |
| 7016 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7017 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7018 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7019 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 7020 | alloc_info.descriptorPool = ds_pool; |
| 7021 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7022 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7023 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7024 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7025 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7026 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7027 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 7028 | sampler_ci.pNext = NULL; |
| 7029 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 7030 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 7031 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 7032 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7033 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7034 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7035 | sampler_ci.mipLodBias = 1.0; |
| 7036 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 7037 | sampler_ci.maxAnisotropy = 1; |
| 7038 | sampler_ci.compareEnable = VK_FALSE; |
| 7039 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 7040 | sampler_ci.minLod = 1.0; |
| 7041 | sampler_ci.maxLod = 1.0; |
| 7042 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 7043 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7044 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7045 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7046 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7047 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 7048 | VkDescriptorImageInfo info = {}; |
| 7049 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7050 | |
| 7051 | VkWriteDescriptorSet descriptor_write; |
| 7052 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7053 | descriptor_write.sType = |
| 7054 | (VkStructureType)0x99999999; /* Intentionally broken struct type */ |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7055 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7056 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7057 | // 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] | 7058 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 7059 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7060 | |
| 7061 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 7062 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7063 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7064 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7065 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 7066 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7067 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 7068 | } |
| 7069 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7070 | TEST_F(VkLayerTest, SampleDescriptorUpdateError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7071 | // Create a single Sampler descriptor and send it an invalid Sampler |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7072 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7073 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7074 | m_errorMonitor->SetDesiredFailureMsg( |
| 7075 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7076 | "Attempted write update to sampler descriptor with invalid sampler"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7077 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7078 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7079 | // TODO : Farm Descriptor setup code to helper function(s) to reduce copied |
| 7080 | // code |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7081 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7082 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 7083 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7084 | |
| 7085 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7086 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7087 | ds_pool_ci.pNext = NULL; |
| 7088 | ds_pool_ci.maxSets = 1; |
| 7089 | ds_pool_ci.poolSizeCount = 1; |
| 7090 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7091 | |
| 7092 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7093 | err = |
| 7094 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7095 | ASSERT_VK_SUCCESS(err); |
| 7096 | |
| 7097 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7098 | dsl_binding.binding = 0; |
| 7099 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 7100 | dsl_binding.descriptorCount = 1; |
| 7101 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7102 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7103 | |
| 7104 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7105 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7106 | ds_layout_ci.pNext = NULL; |
| 7107 | ds_layout_ci.bindingCount = 1; |
| 7108 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7109 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7110 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7111 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7112 | ASSERT_VK_SUCCESS(err); |
| 7113 | |
| 7114 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7115 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7116 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7117 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7118 | alloc_info.descriptorPool = ds_pool; |
| 7119 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7120 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7121 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7122 | ASSERT_VK_SUCCESS(err); |
| 7123 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7124 | VkSampler sampler = |
| 7125 | (VkSampler)((size_t)0xbaadbeef); // Sampler with invalid handle |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7126 | |
| 7127 | VkDescriptorImageInfo descriptor_info; |
| 7128 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 7129 | descriptor_info.sampler = sampler; |
| 7130 | |
| 7131 | VkWriteDescriptorSet descriptor_write; |
| 7132 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 7133 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7134 | descriptor_write.dstSet = descriptorSet; |
| 7135 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7136 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7137 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 7138 | descriptor_write.pImageInfo = &descriptor_info; |
| 7139 | |
| 7140 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 7141 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7142 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7143 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7144 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7145 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7146 | } |
| 7147 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7148 | TEST_F(VkLayerTest, ImageViewDescriptorUpdateError) { |
| 7149 | // Create a single combined Image/Sampler descriptor and send it an invalid |
| 7150 | // imageView |
| 7151 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7152 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7153 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7154 | "Attempted write update to combined " |
| 7155 | "image sampler descriptor failed due " |
Tobin Ehlis | 63c4b8a | 2016-05-09 10:29:34 -0600 | [diff] [blame] | 7156 | "to: Invalid VkImageView:"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7157 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7158 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7159 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7160 | ds_type_count.type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 7161 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7162 | |
| 7163 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7164 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7165 | ds_pool_ci.pNext = NULL; |
| 7166 | ds_pool_ci.maxSets = 1; |
| 7167 | ds_pool_ci.poolSizeCount = 1; |
| 7168 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7169 | |
| 7170 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7171 | err = |
| 7172 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7173 | ASSERT_VK_SUCCESS(err); |
| 7174 | |
| 7175 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7176 | dsl_binding.binding = 0; |
| 7177 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 7178 | dsl_binding.descriptorCount = 1; |
| 7179 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7180 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7181 | |
| 7182 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7183 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7184 | ds_layout_ci.pNext = NULL; |
| 7185 | ds_layout_ci.bindingCount = 1; |
| 7186 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7187 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7188 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7189 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7190 | ASSERT_VK_SUCCESS(err); |
| 7191 | |
| 7192 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7193 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7194 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7195 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7196 | alloc_info.descriptorPool = ds_pool; |
| 7197 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7198 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7199 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7200 | ASSERT_VK_SUCCESS(err); |
| 7201 | |
| 7202 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7203 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 7204 | sampler_ci.pNext = NULL; |
| 7205 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 7206 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 7207 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 7208 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7209 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7210 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7211 | sampler_ci.mipLodBias = 1.0; |
| 7212 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 7213 | sampler_ci.maxAnisotropy = 1; |
| 7214 | sampler_ci.compareEnable = VK_FALSE; |
| 7215 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 7216 | sampler_ci.minLod = 1.0; |
| 7217 | sampler_ci.maxLod = 1.0; |
| 7218 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 7219 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7220 | |
| 7221 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7222 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7223 | ASSERT_VK_SUCCESS(err); |
| 7224 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7225 | VkImageView view = |
| 7226 | (VkImageView)((size_t)0xbaadbeef); // invalid imageView object |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7227 | |
| 7228 | VkDescriptorImageInfo descriptor_info; |
| 7229 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 7230 | descriptor_info.sampler = sampler; |
| 7231 | descriptor_info.imageView = view; |
| 7232 | |
| 7233 | VkWriteDescriptorSet descriptor_write; |
| 7234 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 7235 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7236 | descriptor_write.dstSet = descriptorSet; |
| 7237 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7238 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7239 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 7240 | descriptor_write.pImageInfo = &descriptor_info; |
| 7241 | |
| 7242 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 7243 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7244 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7245 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7246 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 7247 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7248 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7249 | } |
| 7250 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7251 | TEST_F(VkLayerTest, CopyDescriptorUpdateErrors) { |
| 7252 | // Create DS w/ layout of 2 types, write update 1 and attempt to copy-update |
| 7253 | // into the other |
| 7254 | VkResult err; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7255 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7256 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7257 | " binding #1 with type " |
| 7258 | "VK_DESCRIPTOR_TYPE_SAMPLER. Types do " |
| 7259 | "not match."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7260 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7261 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7262 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7263 | VkDescriptorPoolSize ds_type_count[2] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7264 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7265 | ds_type_count[0].descriptorCount = 1; |
| 7266 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 7267 | ds_type_count[1].descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7268 | |
| 7269 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7270 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7271 | ds_pool_ci.pNext = NULL; |
| 7272 | ds_pool_ci.maxSets = 1; |
| 7273 | ds_pool_ci.poolSizeCount = 2; |
| 7274 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7275 | |
| 7276 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7277 | err = |
| 7278 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7279 | ASSERT_VK_SUCCESS(err); |
| 7280 | VkDescriptorSetLayoutBinding dsl_binding[2] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7281 | dsl_binding[0].binding = 0; |
| 7282 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7283 | dsl_binding[0].descriptorCount = 1; |
| 7284 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 7285 | dsl_binding[0].pImmutableSamplers = NULL; |
| 7286 | dsl_binding[1].binding = 1; |
| 7287 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 7288 | dsl_binding[1].descriptorCount = 1; |
| 7289 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 7290 | dsl_binding[1].pImmutableSamplers = NULL; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7291 | |
| 7292 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7293 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7294 | ds_layout_ci.pNext = NULL; |
| 7295 | ds_layout_ci.bindingCount = 2; |
| 7296 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7297 | |
| 7298 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7299 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7300 | &ds_layout); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7301 | ASSERT_VK_SUCCESS(err); |
| 7302 | |
| 7303 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7304 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7305 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7306 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7307 | alloc_info.descriptorPool = ds_pool; |
| 7308 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7309 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7310 | &descriptorSet); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7311 | ASSERT_VK_SUCCESS(err); |
| 7312 | |
| 7313 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7314 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 7315 | sampler_ci.pNext = NULL; |
| 7316 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 7317 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 7318 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 7319 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7320 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7321 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7322 | sampler_ci.mipLodBias = 1.0; |
| 7323 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 7324 | sampler_ci.maxAnisotropy = 1; |
| 7325 | sampler_ci.compareEnable = VK_FALSE; |
| 7326 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 7327 | sampler_ci.minLod = 1.0; |
| 7328 | sampler_ci.maxLod = 1.0; |
| 7329 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 7330 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7331 | |
| 7332 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7333 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7334 | ASSERT_VK_SUCCESS(err); |
| 7335 | |
| 7336 | VkDescriptorImageInfo info = {}; |
| 7337 | info.sampler = sampler; |
| 7338 | |
| 7339 | VkWriteDescriptorSet descriptor_write; |
| 7340 | memset(&descriptor_write, 0, sizeof(VkWriteDescriptorSet)); |
| 7341 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7342 | descriptor_write.dstSet = descriptorSet; |
| 7343 | descriptor_write.dstBinding = 1; // SAMPLER binding from layout above |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7344 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7345 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 7346 | descriptor_write.pImageInfo = &info; |
| 7347 | // This write update should succeed |
| 7348 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 7349 | // Now perform a copy update that fails due to type mismatch |
| 7350 | VkCopyDescriptorSet copy_ds_update; |
| 7351 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 7352 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 7353 | copy_ds_update.srcSet = descriptorSet; |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 7354 | copy_ds_update.srcBinding = 1; // Copy from SAMPLER binding |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7355 | copy_ds_update.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7356 | copy_ds_update.dstBinding = 0; // ERROR : copy to UNIFORM binding |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7357 | copy_ds_update.descriptorCount = 1; // copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7358 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 7359 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7360 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7361 | // 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] | 7362 | m_errorMonitor->SetDesiredFailureMsg( |
| 7363 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7364 | " does not have copy update src binding of 3."); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7365 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 7366 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 7367 | copy_ds_update.srcSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7368 | copy_ds_update.srcBinding = |
| 7369 | 3; // ERROR : Invalid binding for matching layout |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7370 | copy_ds_update.dstSet = descriptorSet; |
| 7371 | copy_ds_update.dstBinding = 0; |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 7372 | copy_ds_update.descriptorCount = 1; // Copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7373 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 7374 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7375 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7376 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7377 | // 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] | 7378 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7379 | VK_DEBUG_REPORT_ERROR_BIT_EXT, " binding#1 with offset index of 1 plus " |
| 7380 | "update array offset of 0 and update of " |
| 7381 | "5 descriptors oversteps total number " |
| 7382 | "of descriptors in set: 2."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7383 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7384 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 7385 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 7386 | copy_ds_update.srcSet = descriptorSet; |
| 7387 | copy_ds_update.srcBinding = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7388 | copy_ds_update.dstSet = descriptorSet; |
| 7389 | copy_ds_update.dstBinding = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7390 | copy_ds_update.descriptorCount = |
| 7391 | 5; // ERROR copy 5 descriptors (out of bounds for layout) |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7392 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 7393 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7394 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7395 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7396 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 7397 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7398 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7399 | } |
| 7400 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7401 | TEST_F(VkLayerTest, NumSamplesMismatch) { |
| 7402 | // Create CommandBuffer where MSAA samples doesn't match RenderPass |
| 7403 | // sampleCount |
| 7404 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7405 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7406 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7407 | "Num samples mismatch! "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7408 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7409 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7410 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7411 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7412 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7413 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7414 | |
| 7415 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7416 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7417 | ds_pool_ci.pNext = NULL; |
| 7418 | ds_pool_ci.maxSets = 1; |
| 7419 | ds_pool_ci.poolSizeCount = 1; |
| 7420 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 7421 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7422 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7423 | err = |
| 7424 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7425 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7426 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7427 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 7428 | dsl_binding.binding = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7429 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 7430 | dsl_binding.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7431 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7432 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7433 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7434 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 7435 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7436 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7437 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 7438 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7439 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7440 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7441 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7442 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7443 | ASSERT_VK_SUCCESS(err); |
| 7444 | |
| 7445 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7446 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7447 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7448 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 7449 | alloc_info.descriptorPool = ds_pool; |
| 7450 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7451 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7452 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7453 | ASSERT_VK_SUCCESS(err); |
| 7454 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7455 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7456 | pipe_ms_state_ci.sType = |
| 7457 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 7458 | pipe_ms_state_ci.pNext = NULL; |
| 7459 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
| 7460 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 7461 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 7462 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7463 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7464 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7465 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 7466 | pipeline_layout_ci.pNext = NULL; |
| 7467 | pipeline_layout_ci.setLayoutCount = 1; |
| 7468 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7469 | |
| 7470 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7471 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 7472 | &pipeline_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7473 | ASSERT_VK_SUCCESS(err); |
| 7474 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7475 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 7476 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7477 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 7478 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 7479 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7480 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 7481 | VkPipelineObj pipe(m_device); |
| 7482 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 7483 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 7484 | pipe.AddColorAttachment(); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 7485 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 7486 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7487 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 7488 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7489 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 7490 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7491 | |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 7492 | // Render triangle (the error should trigger on the attempt to draw). |
| 7493 | Draw(3, 1, 0, 0); |
| 7494 | |
| 7495 | // Finalize recording of the command buffer |
| 7496 | EndCommandBuffer(); |
| 7497 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7498 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7499 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7500 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 7501 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7502 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 7503 | } |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 7504 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 7505 | TEST_F(VkLayerTest, NumBlendAttachMismatch) { |
| 7506 | // Create Pipeline where the number of blend attachments doesn't match the |
| 7507 | // number of color attachments. In this case, we don't add any color |
| 7508 | // blend attachments even though we have a color attachment. |
| 7509 | VkResult err; |
| 7510 | |
| 7511 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 7512 | "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] | 7513 | |
| 7514 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7515 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7516 | VkDescriptorPoolSize ds_type_count = {}; |
| 7517 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7518 | ds_type_count.descriptorCount = 1; |
| 7519 | |
| 7520 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 7521 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7522 | ds_pool_ci.pNext = NULL; |
| 7523 | ds_pool_ci.maxSets = 1; |
| 7524 | ds_pool_ci.poolSizeCount = 1; |
| 7525 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 7526 | |
| 7527 | VkDescriptorPool ds_pool; |
| 7528 | err = |
| 7529 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 7530 | ASSERT_VK_SUCCESS(err); |
| 7531 | |
| 7532 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 7533 | dsl_binding.binding = 0; |
| 7534 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7535 | dsl_binding.descriptorCount = 1; |
| 7536 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7537 | dsl_binding.pImmutableSamplers = NULL; |
| 7538 | |
| 7539 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 7540 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7541 | ds_layout_ci.pNext = NULL; |
| 7542 | ds_layout_ci.bindingCount = 1; |
| 7543 | ds_layout_ci.pBindings = &dsl_binding; |
| 7544 | |
| 7545 | VkDescriptorSetLayout ds_layout; |
| 7546 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7547 | &ds_layout); |
| 7548 | ASSERT_VK_SUCCESS(err); |
| 7549 | |
| 7550 | VkDescriptorSet descriptorSet; |
| 7551 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 7552 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 7553 | alloc_info.descriptorSetCount = 1; |
| 7554 | alloc_info.descriptorPool = ds_pool; |
| 7555 | alloc_info.pSetLayouts = &ds_layout; |
| 7556 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7557 | &descriptorSet); |
| 7558 | ASSERT_VK_SUCCESS(err); |
| 7559 | |
| 7560 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 7561 | pipe_ms_state_ci.sType = |
| 7562 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 7563 | pipe_ms_state_ci.pNext = NULL; |
| 7564 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 7565 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 7566 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 7567 | pipe_ms_state_ci.pSampleMask = NULL; |
| 7568 | |
| 7569 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 7570 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 7571 | pipeline_layout_ci.pNext = NULL; |
| 7572 | pipeline_layout_ci.setLayoutCount = 1; |
| 7573 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 7574 | |
| 7575 | VkPipelineLayout pipeline_layout; |
| 7576 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 7577 | &pipeline_layout); |
| 7578 | ASSERT_VK_SUCCESS(err); |
| 7579 | |
| 7580 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 7581 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7582 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 7583 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 7584 | this); // We shouldn't need a fragment shader |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 7585 | // but add it to be able to run on more devices |
| 7586 | VkPipelineObj pipe(m_device); |
| 7587 | pipe.AddShader(&vs); |
| 7588 | pipe.AddShader(&fs); |
| 7589 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 7590 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 7591 | |
| 7592 | BeginCommandBuffer(); |
| 7593 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 7594 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 7595 | |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 7596 | // Render triangle (the error should trigger on the attempt to draw). |
| 7597 | Draw(3, 1, 0, 0); |
| 7598 | |
| 7599 | // Finalize recording of the command buffer |
| 7600 | EndCommandBuffer(); |
| 7601 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7602 | m_errorMonitor->VerifyFound(); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 7603 | |
| 7604 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 7605 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7606 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 7607 | } |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 7608 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7609 | TEST_F(VkLayerTest, ClearCmdNoDraw) { |
| 7610 | // Create CommandBuffer where we add ClearCmd for FB Color attachment prior |
| 7611 | // to issuing a Draw |
| 7612 | VkResult err; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7613 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7614 | m_errorMonitor->SetDesiredFailureMsg( |
Tony Barbour | 7e56d30 | 2016-03-02 15:12:01 -0700 | [diff] [blame] | 7615 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7616 | "vkCmdClearAttachments() issued on CB object "); |
| 7617 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7618 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7619 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7620 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7621 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7622 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7623 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7624 | |
| 7625 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7626 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7627 | ds_pool_ci.pNext = NULL; |
| 7628 | ds_pool_ci.maxSets = 1; |
| 7629 | ds_pool_ci.poolSizeCount = 1; |
| 7630 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7631 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7632 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7633 | err = |
| 7634 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7635 | ASSERT_VK_SUCCESS(err); |
| 7636 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7637 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7638 | dsl_binding.binding = 0; |
| 7639 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7640 | dsl_binding.descriptorCount = 1; |
| 7641 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7642 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7643 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7644 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7645 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7646 | ds_layout_ci.pNext = NULL; |
| 7647 | ds_layout_ci.bindingCount = 1; |
| 7648 | ds_layout_ci.pBindings = &dsl_binding; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 7649 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7650 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7651 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7652 | &ds_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7653 | ASSERT_VK_SUCCESS(err); |
| 7654 | |
| 7655 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7656 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7657 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7658 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 7659 | alloc_info.descriptorPool = ds_pool; |
| 7660 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7661 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7662 | &descriptorSet); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7663 | ASSERT_VK_SUCCESS(err); |
| 7664 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7665 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7666 | pipe_ms_state_ci.sType = |
| 7667 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 7668 | pipe_ms_state_ci.pNext = NULL; |
| 7669 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
| 7670 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 7671 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 7672 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7673 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7674 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7675 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 7676 | pipeline_layout_ci.pNext = NULL; |
| 7677 | pipeline_layout_ci.setLayoutCount = 1; |
| 7678 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7679 | |
| 7680 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7681 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 7682 | &pipeline_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7683 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 7684 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7685 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 7686 | VK_SHADER_STAGE_VERTEX_BIT, this); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 7687 | // 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] | 7688 | // on more devices |
| 7689 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 7690 | VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7691 | |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 7692 | VkPipelineObj pipe(m_device); |
| 7693 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 7694 | pipe.AddShader(&fs); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 7695 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 7696 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 7697 | |
| 7698 | BeginCommandBuffer(); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7699 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7700 | // Main thing we care about for this test is that the VkImage obj we're |
| 7701 | // clearing matches Color Attachment of FB |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7702 | // Also pass down other dummy params to keep driver and paramchecker happy |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 7703 | VkClearAttachment color_attachment; |
| 7704 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 7705 | color_attachment.clearValue.color.float32[0] = 1.0; |
| 7706 | color_attachment.clearValue.color.float32[1] = 1.0; |
| 7707 | color_attachment.clearValue.color.float32[2] = 1.0; |
| 7708 | color_attachment.clearValue.color.float32[3] = 1.0; |
| 7709 | color_attachment.colorAttachment = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7710 | VkClearRect clear_rect = { |
| 7711 | {{0, 0}, {(uint32_t)m_width, (uint32_t)m_height}}}; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7712 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7713 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
| 7714 | &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7715 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7716 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7717 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7718 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 7719 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7720 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7721 | } |
| 7722 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7723 | TEST_F(VkLayerTest, VtxBufferBadIndex) { |
| 7724 | VkResult err; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 7725 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7726 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 7727 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | dfcd9b6 | 2015-12-14 15:14:10 -0700 | [diff] [blame] | 7728 | "but no vertex buffers are attached to this Pipeline State Object"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7729 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 7730 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 7731 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 7732 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7733 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7734 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7735 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7736 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7737 | |
| 7738 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7739 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7740 | ds_pool_ci.pNext = NULL; |
| 7741 | ds_pool_ci.maxSets = 1; |
| 7742 | ds_pool_ci.poolSizeCount = 1; |
| 7743 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7744 | |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 7745 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7746 | err = |
| 7747 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 7748 | ASSERT_VK_SUCCESS(err); |
| 7749 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7750 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7751 | dsl_binding.binding = 0; |
| 7752 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7753 | dsl_binding.descriptorCount = 1; |
| 7754 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7755 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 7756 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7757 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7758 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7759 | ds_layout_ci.pNext = NULL; |
| 7760 | ds_layout_ci.bindingCount = 1; |
| 7761 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7762 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 7763 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7764 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7765 | &ds_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 7766 | ASSERT_VK_SUCCESS(err); |
| 7767 | |
| 7768 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7769 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7770 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7771 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 7772 | alloc_info.descriptorPool = ds_pool; |
| 7773 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7774 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7775 | &descriptorSet); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 7776 | ASSERT_VK_SUCCESS(err); |
| 7777 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7778 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7779 | pipe_ms_state_ci.sType = |
| 7780 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 7781 | pipe_ms_state_ci.pNext = NULL; |
| 7782 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 7783 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 7784 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 7785 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 7786 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7787 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7788 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 7789 | pipeline_layout_ci.pNext = NULL; |
| 7790 | pipeline_layout_ci.setLayoutCount = 1; |
| 7791 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 7792 | VkPipelineLayout pipeline_layout; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 7793 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7794 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 7795 | &pipeline_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 7796 | ASSERT_VK_SUCCESS(err); |
| 7797 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7798 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 7799 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7800 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 7801 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 7802 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7803 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 7804 | VkPipelineObj pipe(m_device); |
| 7805 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 7806 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 7807 | pipe.AddColorAttachment(); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 7808 | pipe.SetMSAA(&pipe_ms_state_ci); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 7809 | pipe.SetViewport(m_viewports); |
| 7810 | pipe.SetScissor(m_scissors); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 7811 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 7812 | |
| 7813 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7814 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 7815 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 7816 | // Don't care about actual data, just need to get to draw to flag error |
| 7817 | static const float vbo_data[3] = {1.f, 0.f, 1.f}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7818 | VkConstantBufferObj vbo(m_device, sizeof(vbo_data), sizeof(float), |
| 7819 | (const void *)&vbo_data); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 7820 | 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] | 7821 | Draw(1, 0, 0, 0); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 7822 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7823 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7824 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7825 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 7826 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7827 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 7828 | } |
Tobin Ehlis | c555a3c | 2016-05-04 14:08:34 -0600 | [diff] [blame] | 7829 | // INVALID_IMAGE_LAYOUT tests (one other case is hit by MapMemWithoutHostVisibleBit and not here) |
| 7830 | TEST_F(VkLayerTest, InvalidImageLayout) { |
| 7831 | TEST_DESCRIPTION("Hit all possible validation checks associated with the " |
| 7832 | "DRAWSTATE_INVALID_IMAGE_LAYOUT enum. Generally these involve having" |
| 7833 | "images in the wrong layout when they're copied or transitioned."); |
| 7834 | // 3 in ValidateCmdBufImageLayouts |
| 7835 | // * -1 Attempt to submit cmd buf w/ deleted image |
| 7836 | // * -2 Cmd buf submit of image w/ layout not matching first use w/ subresource |
| 7837 | // * -3 Cmd buf submit of image w/ layout not matching first use w/o subresource |
| 7838 | m_errorMonitor->SetDesiredFailureMsg( |
| 7839 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 7840 | "Layout for input image should be TRANSFER_SRC_OPTIMAL instead of GENERAL."); |
| 7841 | |
| 7842 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7843 | // Create src & dst images to use for copy operations |
| 7844 | VkImage src_image; |
| 7845 | VkImage dst_image; |
| 7846 | |
| 7847 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 7848 | const int32_t tex_width = 32; |
| 7849 | const int32_t tex_height = 32; |
| 7850 | |
| 7851 | VkImageCreateInfo image_create_info = {}; |
| 7852 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 7853 | image_create_info.pNext = NULL; |
| 7854 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 7855 | image_create_info.format = tex_format; |
| 7856 | image_create_info.extent.width = tex_width; |
| 7857 | image_create_info.extent.height = tex_height; |
| 7858 | image_create_info.extent.depth = 1; |
| 7859 | image_create_info.mipLevels = 1; |
| 7860 | image_create_info.arrayLayers = 4; |
| 7861 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 7862 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 7863 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 7864 | image_create_info.flags = 0; |
| 7865 | |
| 7866 | VkResult err = vkCreateImage(m_device->device(), &image_create_info, NULL, &src_image); |
| 7867 | ASSERT_VK_SUCCESS(err); |
| 7868 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dst_image); |
| 7869 | ASSERT_VK_SUCCESS(err); |
| 7870 | |
| 7871 | BeginCommandBuffer(); |
| 7872 | VkImageCopy copyRegion; |
| 7873 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 7874 | copyRegion.srcSubresource.mipLevel = 0; |
| 7875 | copyRegion.srcSubresource.baseArrayLayer = 0; |
| 7876 | copyRegion.srcSubresource.layerCount = 1; |
| 7877 | copyRegion.srcOffset.x = 0; |
| 7878 | copyRegion.srcOffset.y = 0; |
| 7879 | copyRegion.srcOffset.z = 0; |
| 7880 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 7881 | copyRegion.dstSubresource.mipLevel = 0; |
| 7882 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 7883 | copyRegion.dstSubresource.layerCount = 1; |
| 7884 | copyRegion.dstOffset.x = 0; |
| 7885 | copyRegion.dstOffset.y = 0; |
| 7886 | copyRegion.dstOffset.z = 0; |
| 7887 | copyRegion.extent.width = 1; |
| 7888 | copyRegion.extent.height = 1; |
| 7889 | copyRegion.extent.depth = 1; |
| 7890 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 7891 | m_errorMonitor->VerifyFound(); |
| 7892 | // Now cause error due to src image layout changing |
| 7893 | m_errorMonitor->SetDesiredFailureMsg( |
| 7894 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7895 | "Cannot copy from an image whose source layout is VK_IMAGE_LAYOUT_UNDEFINED and doesn't match the current layout VK_IMAGE_LAYOUT_GENERAL."); |
| 7896 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_UNDEFINED, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 7897 | m_errorMonitor->VerifyFound(); |
| 7898 | // Final src error is due to bad layout type |
| 7899 | m_errorMonitor->SetDesiredFailureMsg( |
| 7900 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7901 | "Layout for input image is VK_IMAGE_LAYOUT_UNDEFINED but can only be TRANSFER_SRC_OPTIMAL or GENERAL."); |
| 7902 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_UNDEFINED, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 7903 | m_errorMonitor->VerifyFound(); |
| 7904 | // Now verify same checks for dst |
| 7905 | m_errorMonitor->SetDesiredFailureMsg( |
| 7906 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 7907 | "Layout for output image should be TRANSFER_DST_OPTIMAL instead of GENERAL."); |
| 7908 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 7909 | m_errorMonitor->VerifyFound(); |
| 7910 | // Now cause error due to src image layout changing |
| 7911 | m_errorMonitor->SetDesiredFailureMsg( |
| 7912 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7913 | "Cannot copy from an image whose dest layout is VK_IMAGE_LAYOUT_UNDEFINED and doesn't match the current layout VK_IMAGE_LAYOUT_GENERAL."); |
| 7914 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_UNDEFINED, 1, ©Region); |
| 7915 | m_errorMonitor->VerifyFound(); |
| 7916 | m_errorMonitor->SetDesiredFailureMsg( |
| 7917 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7918 | "Layout for output image is VK_IMAGE_LAYOUT_UNDEFINED but can only be TRANSFER_DST_OPTIMAL or GENERAL."); |
| 7919 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_UNDEFINED, 1, ©Region); |
| 7920 | m_errorMonitor->VerifyFound(); |
| 7921 | // Now cause error due to bad image layout transition in PipelineBarrier |
| 7922 | VkImageMemoryBarrier image_barrier[1] = {}; |
| 7923 | image_barrier[0].oldLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; |
| 7924 | image_barrier[0].image = src_image; |
| 7925 | image_barrier[0].subresourceRange.layerCount = 2; |
| 7926 | image_barrier[0].subresourceRange.levelCount = 2; |
| 7927 | image_barrier[0].subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 7928 | m_errorMonitor->SetDesiredFailureMsg( |
| 7929 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7930 | "You cannot transition the layout from VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL when current layout is VK_IMAGE_LAYOUT_GENERAL."); |
| 7931 | vkCmdPipelineBarrier(m_commandBuffer->handle(), VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, NULL, 0, NULL, 1, image_barrier); |
| 7932 | m_errorMonitor->VerifyFound(); |
| 7933 | |
| 7934 | // Finally some layout errors at RenderPass create time |
| 7935 | // Just hacking in specific state to get to the errors we want so don't copy this unless you know what you're doing. |
| 7936 | VkAttachmentReference attach = {}; |
| 7937 | // perf warning for GENERAL layout w/ non-DS input attachment |
| 7938 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 7939 | VkSubpassDescription subpass = {}; |
| 7940 | subpass.inputAttachmentCount = 1; |
| 7941 | subpass.pInputAttachments = &attach; |
| 7942 | VkRenderPassCreateInfo rpci = {}; |
| 7943 | rpci.subpassCount = 1; |
| 7944 | rpci.pSubpasses = &subpass; |
| 7945 | rpci.attachmentCount = 1; |
| 7946 | VkAttachmentDescription attach_desc = {}; |
| 7947 | attach_desc.format = VK_FORMAT_UNDEFINED; |
| 7948 | rpci.pAttachments = &attach_desc; |
Tobin Ehlis | 1efce02 | 2016-05-11 10:40:34 -0600 | [diff] [blame] | 7949 | rpci.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; |
Tobin Ehlis | c555a3c | 2016-05-04 14:08:34 -0600 | [diff] [blame] | 7950 | VkRenderPass rp; |
| 7951 | m_errorMonitor->SetDesiredFailureMsg( |
| 7952 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 7953 | "Layout for input attachment is GENERAL but should be READ_ONLY_OPTIMAL."); |
| 7954 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 7955 | m_errorMonitor->VerifyFound(); |
| 7956 | // error w/ non-general layout |
| 7957 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; |
| 7958 | |
| 7959 | m_errorMonitor->SetDesiredFailureMsg( |
| 7960 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7961 | "Layout for input attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be READ_ONLY_OPTIMAL or GENERAL."); |
| 7962 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 7963 | m_errorMonitor->VerifyFound(); |
| 7964 | subpass.inputAttachmentCount = 0; |
| 7965 | subpass.colorAttachmentCount = 1; |
| 7966 | subpass.pColorAttachments = &attach; |
| 7967 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 7968 | // perf warning for GENERAL layout on color attachment |
| 7969 | m_errorMonitor->SetDesiredFailureMsg( |
| 7970 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 7971 | "Layout for color attachment is GENERAL but should be COLOR_ATTACHMENT_OPTIMAL."); |
| 7972 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 7973 | m_errorMonitor->VerifyFound(); |
| 7974 | // error w/ non-color opt or GENERAL layout for color attachment |
| 7975 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; |
| 7976 | m_errorMonitor->SetDesiredFailureMsg( |
| 7977 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7978 | "Layout for color attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be COLOR_ATTACHMENT_OPTIMAL or GENERAL."); |
| 7979 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 7980 | m_errorMonitor->VerifyFound(); |
| 7981 | subpass.colorAttachmentCount = 0; |
| 7982 | subpass.pDepthStencilAttachment = &attach; |
| 7983 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 7984 | // perf warning for GENERAL layout on DS attachment |
| 7985 | m_errorMonitor->SetDesiredFailureMsg( |
| 7986 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 7987 | "Layout for depth attachment is GENERAL but should be DEPTH_STENCIL_ATTACHMENT_OPTIMAL."); |
| 7988 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 7989 | m_errorMonitor->VerifyFound(); |
| 7990 | // error w/ non-ds opt or GENERAL layout for color attachment |
| 7991 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; |
| 7992 | m_errorMonitor->SetDesiredFailureMsg( |
| 7993 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7994 | "Layout for depth attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be DEPTH_STENCIL_ATTACHMENT_OPTIMAL or GENERAL."); |
| 7995 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 7996 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 1efce02 | 2016-05-11 10:40:34 -0600 | [diff] [blame] | 7997 | // For this error we need a valid renderpass so create default one |
| 7998 | attach.layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; |
| 7999 | attach.attachment = 0; |
| 8000 | attach_desc.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 8001 | attach_desc.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8002 | attach_desc.storeOp = VK_ATTACHMENT_STORE_OP_STORE; |
| 8003 | attach_desc.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; |
| 8004 | attach_desc.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; |
| 8005 | // Can't do a CLEAR load on READ_ONLY initialLayout |
| 8006 | attach_desc.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; |
| 8007 | attach_desc.initialLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; |
| 8008 | attach_desc.finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 8009 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8010 | " with invalid first layout " |
| 8011 | "VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_" |
| 8012 | "ONLY_OPTIMAL"); |
| 8013 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 8014 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | c555a3c | 2016-05-04 14:08:34 -0600 | [diff] [blame] | 8015 | |
| 8016 | vkDestroyImage(m_device->device(), src_image, NULL); |
| 8017 | vkDestroyImage(m_device->device(), dst_image, NULL); |
| 8018 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 8019 | #endif // DRAW_STATE_TESTS |
| 8020 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 8021 | #if THREADING_TESTS |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8022 | #if GTEST_IS_THREADSAFE |
| 8023 | struct thread_data_struct { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8024 | VkCommandBuffer commandBuffer; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8025 | VkEvent event; |
| 8026 | bool bailout; |
| 8027 | }; |
| 8028 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8029 | extern "C" void *AddToCommandBuffer(void *arg) { |
| 8030 | struct thread_data_struct *data = (struct thread_data_struct *)arg; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8031 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8032 | for (int i = 0; i < 10000; i++) { |
| 8033 | vkCmdSetEvent(data->commandBuffer, data->event, |
| 8034 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8035 | if (data->bailout) { |
| 8036 | break; |
| 8037 | } |
| 8038 | } |
| 8039 | return NULL; |
| 8040 | } |
| 8041 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8042 | TEST_F(VkLayerTest, ThreadCommandBufferCollision) { |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 8043 | test_platform_thread thread; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8044 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8045 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8046 | "THREADING ERROR"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8047 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8048 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8049 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 8050 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8051 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8052 | // Calls AllocateCommandBuffers |
| 8053 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 8054 | |
| 8055 | // Avoid creating RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8056 | commandBuffer.BeginCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8057 | |
| 8058 | VkEventCreateInfo event_info; |
| 8059 | VkEvent event; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8060 | VkResult err; |
| 8061 | |
| 8062 | memset(&event_info, 0, sizeof(event_info)); |
| 8063 | event_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 8064 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8065 | err = vkCreateEvent(device(), &event_info, NULL, &event); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8066 | ASSERT_VK_SUCCESS(err); |
| 8067 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8068 | err = vkResetEvent(device(), event); |
| 8069 | ASSERT_VK_SUCCESS(err); |
| 8070 | |
| 8071 | struct thread_data_struct data; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8072 | data.commandBuffer = commandBuffer.GetBufferHandle(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8073 | data.event = event; |
| 8074 | data.bailout = false; |
| 8075 | m_errorMonitor->SetBailout(&data.bailout); |
| 8076 | // Add many entries to command buffer from another thread. |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 8077 | test_platform_thread_create(&thread, AddToCommandBuffer, (void *)&data); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8078 | // Add many entries to command buffer from this thread at the same time. |
| 8079 | AddToCommandBuffer(&data); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 8080 | |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 8081 | test_platform_thread_join(thread, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8082 | commandBuffer.EndCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8083 | |
Mike Stroyan | 10b8cb7 | 2016-01-22 15:22:03 -0700 | [diff] [blame] | 8084 | m_errorMonitor->SetBailout(NULL); |
| 8085 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8086 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8087 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8088 | vkDestroyEvent(device(), event, NULL); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8089 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 8090 | #endif // GTEST_IS_THREADSAFE |
| 8091 | #endif // THREADING_TESTS |
| 8092 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8093 | #if SHADER_CHECKER_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8094 | TEST_F(VkLayerTest, InvalidSPIRVCodeSize) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8095 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 8096 | "Invalid SPIR-V header"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8097 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8098 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8099 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8100 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8101 | VkShaderModule module; |
| 8102 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 8103 | struct icd_spv_header spv; |
| 8104 | |
| 8105 | spv.magic = ICD_SPV_MAGIC; |
| 8106 | spv.version = ICD_SPV_VERSION; |
| 8107 | spv.gen_magic = 0; |
| 8108 | |
| 8109 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 8110 | moduleCreateInfo.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8111 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8112 | moduleCreateInfo.codeSize = 4; |
| 8113 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8114 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8115 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8116 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8117 | } |
| 8118 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8119 | TEST_F(VkLayerTest, InvalidSPIRVMagic) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8120 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 8121 | "Invalid SPIR-V magic number"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8122 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8123 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8124 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8125 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8126 | VkShaderModule module; |
| 8127 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 8128 | struct icd_spv_header spv; |
| 8129 | |
| 8130 | spv.magic = ~ICD_SPV_MAGIC; |
| 8131 | spv.version = ICD_SPV_VERSION; |
| 8132 | spv.gen_magic = 0; |
| 8133 | |
| 8134 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 8135 | moduleCreateInfo.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8136 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8137 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 8138 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8139 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8140 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8141 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8142 | } |
| 8143 | |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 8144 | #if 0 |
| 8145 | // Not currently covered by SPIRV-Tools validator |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8146 | TEST_F(VkLayerTest, InvalidSPIRVVersion) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8147 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 8148 | "Invalid SPIR-V header"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8149 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8150 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8151 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8152 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8153 | VkShaderModule module; |
| 8154 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 8155 | struct icd_spv_header spv; |
| 8156 | |
| 8157 | spv.magic = ICD_SPV_MAGIC; |
| 8158 | spv.version = ~ICD_SPV_VERSION; |
| 8159 | spv.gen_magic = 0; |
| 8160 | |
| 8161 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 8162 | moduleCreateInfo.pNext = NULL; |
| 8163 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8164 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8165 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 8166 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8167 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8168 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8169 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8170 | } |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 8171 | #endif |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8172 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8173 | TEST_F(VkLayerTest, CreatePipelineVertexOutputNotConsumed) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 8174 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8175 | "not consumed by fragment shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8176 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8177 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 8178 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8179 | |
| 8180 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8181 | "#version 450\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8182 | "\n" |
| 8183 | "layout(location=0) out float x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8184 | "out gl_PerVertex {\n" |
| 8185 | " vec4 gl_Position;\n" |
| 8186 | "};\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8187 | "void main(){\n" |
| 8188 | " gl_Position = vec4(1);\n" |
| 8189 | " x = 0;\n" |
| 8190 | "}\n"; |
| 8191 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8192 | "#version 450\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8193 | "\n" |
| 8194 | "layout(location=0) out vec4 color;\n" |
| 8195 | "void main(){\n" |
| 8196 | " color = vec4(1);\n" |
| 8197 | "}\n"; |
| 8198 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8199 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8200 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8201 | |
| 8202 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 8203 | pipe.AddColorAttachment(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8204 | pipe.AddShader(&vs); |
| 8205 | pipe.AddShader(&fs); |
| 8206 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8207 | VkDescriptorSetObj descriptorSet(m_device); |
| 8208 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8209 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8210 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 8211 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8212 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8213 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8214 | } |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8215 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8216 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvided) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8217 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8218 | "not written by vertex shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8219 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8220 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 8221 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8222 | |
| 8223 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8224 | "#version 450\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8225 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8226 | "out gl_PerVertex {\n" |
| 8227 | " vec4 gl_Position;\n" |
| 8228 | "};\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8229 | "void main(){\n" |
| 8230 | " gl_Position = vec4(1);\n" |
| 8231 | "}\n"; |
| 8232 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8233 | "#version 450\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8234 | "\n" |
| 8235 | "layout(location=0) in float x;\n" |
| 8236 | "layout(location=0) out vec4 color;\n" |
| 8237 | "void main(){\n" |
| 8238 | " color = vec4(x);\n" |
| 8239 | "}\n"; |
| 8240 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8241 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8242 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8243 | |
| 8244 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 8245 | pipe.AddColorAttachment(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8246 | pipe.AddShader(&vs); |
| 8247 | pipe.AddShader(&fs); |
| 8248 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8249 | VkDescriptorSetObj descriptorSet(m_device); |
| 8250 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8251 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8252 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 8253 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8254 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8255 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8256 | } |
| 8257 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8258 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvidedInBlock) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8259 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8260 | "not written by vertex shader"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8261 | |
| 8262 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8263 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8264 | |
| 8265 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8266 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8267 | "\n" |
| 8268 | "out gl_PerVertex {\n" |
| 8269 | " vec4 gl_Position;\n" |
| 8270 | "};\n" |
| 8271 | "void main(){\n" |
| 8272 | " gl_Position = vec4(1);\n" |
| 8273 | "}\n"; |
| 8274 | char const *fsSource = |
| 8275 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8276 | "\n" |
| 8277 | "in block { layout(location=0) float x; } ins;\n" |
| 8278 | "layout(location=0) out vec4 color;\n" |
| 8279 | "void main(){\n" |
| 8280 | " color = vec4(ins.x);\n" |
| 8281 | "}\n"; |
| 8282 | |
| 8283 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8284 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8285 | |
| 8286 | VkPipelineObj pipe(m_device); |
| 8287 | pipe.AddColorAttachment(); |
| 8288 | pipe.AddShader(&vs); |
| 8289 | pipe.AddShader(&fs); |
| 8290 | |
| 8291 | VkDescriptorSetObj descriptorSet(m_device); |
| 8292 | descriptorSet.AppendDummy(); |
| 8293 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8294 | |
| 8295 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8296 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8297 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8298 | } |
| 8299 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8300 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchArraySize) { |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 8301 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 8302 | "Type mismatch on location 0.0: 'ptr to " |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8303 | "output arr[2] of float32' vs 'ptr to " |
| 8304 | "input arr[3] of float32'"); |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 8305 | |
| 8306 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8307 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8308 | |
| 8309 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8310 | "#version 450\n" |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 8311 | "\n" |
| 8312 | "layout(location=0) out float x[2];\n" |
| 8313 | "out gl_PerVertex {\n" |
| 8314 | " vec4 gl_Position;\n" |
| 8315 | "};\n" |
| 8316 | "void main(){\n" |
| 8317 | " x[0] = 0; x[1] = 0;\n" |
| 8318 | " gl_Position = vec4(1);\n" |
| 8319 | "}\n"; |
| 8320 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8321 | "#version 450\n" |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 8322 | "\n" |
| 8323 | "layout(location=0) in float x[3];\n" |
| 8324 | "layout(location=0) out vec4 color;\n" |
| 8325 | "void main(){\n" |
| 8326 | " color = vec4(x[0] + x[1] + x[2]);\n" |
| 8327 | "}\n"; |
| 8328 | |
| 8329 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8330 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8331 | |
| 8332 | VkPipelineObj pipe(m_device); |
| 8333 | pipe.AddColorAttachment(); |
| 8334 | pipe.AddShader(&vs); |
| 8335 | pipe.AddShader(&fs); |
| 8336 | |
| 8337 | VkDescriptorSetObj descriptorSet(m_device); |
| 8338 | descriptorSet.AppendDummy(); |
| 8339 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8340 | |
| 8341 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8342 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8343 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 8344 | } |
| 8345 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8346 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatch) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8347 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8348 | "Type mismatch on location 0"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8349 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8350 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 8351 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8352 | |
| 8353 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8354 | "#version 450\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8355 | "\n" |
| 8356 | "layout(location=0) out int x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8357 | "out gl_PerVertex {\n" |
| 8358 | " vec4 gl_Position;\n" |
| 8359 | "};\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8360 | "void main(){\n" |
| 8361 | " x = 0;\n" |
| 8362 | " gl_Position = vec4(1);\n" |
| 8363 | "}\n"; |
| 8364 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8365 | "#version 450\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8366 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8367 | "layout(location=0) in float x;\n" /* VS writes int */ |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8368 | "layout(location=0) out vec4 color;\n" |
| 8369 | "void main(){\n" |
| 8370 | " color = vec4(x);\n" |
| 8371 | "}\n"; |
| 8372 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8373 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8374 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8375 | |
| 8376 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 8377 | pipe.AddColorAttachment(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8378 | pipe.AddShader(&vs); |
| 8379 | pipe.AddShader(&fs); |
| 8380 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8381 | VkDescriptorSetObj descriptorSet(m_device); |
| 8382 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8383 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8384 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 8385 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8386 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8387 | m_errorMonitor->VerifyFound(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8388 | } |
| 8389 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8390 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchInBlock) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8391 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8392 | "Type mismatch on location 0"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8393 | |
| 8394 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8395 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8396 | |
| 8397 | char const *vsSource = |
| 8398 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8399 | "\n" |
| 8400 | "out block { layout(location=0) int x; } outs;\n" |
| 8401 | "out gl_PerVertex {\n" |
| 8402 | " vec4 gl_Position;\n" |
| 8403 | "};\n" |
| 8404 | "void main(){\n" |
| 8405 | " outs.x = 0;\n" |
| 8406 | " gl_Position = vec4(1);\n" |
| 8407 | "}\n"; |
| 8408 | char const *fsSource = |
| 8409 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8410 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8411 | "in block { layout(location=0) float x; } ins;\n" /* VS writes int */ |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8412 | "layout(location=0) out vec4 color;\n" |
| 8413 | "void main(){\n" |
| 8414 | " color = vec4(ins.x);\n" |
| 8415 | "}\n"; |
| 8416 | |
| 8417 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8418 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8419 | |
| 8420 | VkPipelineObj pipe(m_device); |
| 8421 | pipe.AddColorAttachment(); |
| 8422 | pipe.AddShader(&vs); |
| 8423 | pipe.AddShader(&fs); |
| 8424 | |
| 8425 | VkDescriptorSetObj descriptorSet(m_device); |
| 8426 | descriptorSet.AppendDummy(); |
| 8427 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8428 | |
| 8429 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8430 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8431 | m_errorMonitor->VerifyFound(); |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 8432 | } |
| 8433 | |
| 8434 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByLocation) { |
| 8435 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8436 | "location 0.0 which is not written by vertex shader"); |
| 8437 | |
| 8438 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8439 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8440 | |
| 8441 | char const *vsSource = |
| 8442 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 8443 | "\n" |
| 8444 | "out block { layout(location=1) float x; } outs;\n" |
| 8445 | "out gl_PerVertex {\n" |
| 8446 | " vec4 gl_Position;\n" |
| 8447 | "};\n" |
| 8448 | "void main(){\n" |
| 8449 | " outs.x = 0;\n" |
| 8450 | " gl_Position = vec4(1);\n" |
| 8451 | "}\n"; |
| 8452 | char const *fsSource = |
| 8453 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 8454 | "\n" |
| 8455 | "in block { layout(location=0) float x; } ins;\n" |
| 8456 | "layout(location=0) out vec4 color;\n" |
| 8457 | "void main(){\n" |
| 8458 | " color = vec4(ins.x);\n" |
| 8459 | "}\n"; |
| 8460 | |
| 8461 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8462 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8463 | |
| 8464 | VkPipelineObj pipe(m_device); |
| 8465 | pipe.AddColorAttachment(); |
| 8466 | pipe.AddShader(&vs); |
| 8467 | pipe.AddShader(&fs); |
| 8468 | |
| 8469 | VkDescriptorSetObj descriptorSet(m_device); |
| 8470 | descriptorSet.AppendDummy(); |
| 8471 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8472 | |
| 8473 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8474 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8475 | m_errorMonitor->VerifyFound(); |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 8476 | } |
| 8477 | |
| 8478 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByComponent) { |
| 8479 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8480 | "location 0.1 which is not written by vertex shader"); |
| 8481 | |
| 8482 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8483 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8484 | |
| 8485 | char const *vsSource = |
| 8486 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 8487 | "\n" |
| 8488 | "out block { layout(location=0, component=0) float x; } outs;\n" |
| 8489 | "out gl_PerVertex {\n" |
| 8490 | " vec4 gl_Position;\n" |
| 8491 | "};\n" |
| 8492 | "void main(){\n" |
| 8493 | " outs.x = 0;\n" |
| 8494 | " gl_Position = vec4(1);\n" |
| 8495 | "}\n"; |
| 8496 | char const *fsSource = |
| 8497 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 8498 | "\n" |
| 8499 | "in block { layout(location=0, component=1) float x; } ins;\n" |
| 8500 | "layout(location=0) out vec4 color;\n" |
| 8501 | "void main(){\n" |
| 8502 | " color = vec4(ins.x);\n" |
| 8503 | "}\n"; |
| 8504 | |
| 8505 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8506 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8507 | |
| 8508 | VkPipelineObj pipe(m_device); |
| 8509 | pipe.AddColorAttachment(); |
| 8510 | pipe.AddShader(&vs); |
| 8511 | pipe.AddShader(&fs); |
| 8512 | |
| 8513 | VkDescriptorSetObj descriptorSet(m_device); |
| 8514 | descriptorSet.AppendDummy(); |
| 8515 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8516 | |
| 8517 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8518 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8519 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8520 | } |
| 8521 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8522 | TEST_F(VkLayerTest, CreatePipelineAttribNotConsumed) { |
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"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8525 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8526 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 8527 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 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 | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8538 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8539 | "out gl_PerVertex {\n" |
| 8540 | " vec4 gl_Position;\n" |
| 8541 | "};\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8542 | "void main(){\n" |
| 8543 | " gl_Position = vec4(1);\n" |
| 8544 | "}\n"; |
| 8545 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8546 | "#version 450\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8547 | "\n" |
| 8548 | "layout(location=0) out vec4 color;\n" |
| 8549 | "void main(){\n" |
| 8550 | " color = vec4(1);\n" |
| 8551 | "}\n"; |
| 8552 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8553 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8554 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8555 | |
| 8556 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 8557 | pipe.AddColorAttachment(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8558 | pipe.AddShader(&vs); |
| 8559 | pipe.AddShader(&fs); |
| 8560 | |
| 8561 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 8562 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 8563 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8564 | VkDescriptorSetObj descriptorSet(m_device); |
| 8565 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8566 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8567 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 8568 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8569 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8570 | m_errorMonitor->VerifyFound(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8571 | } |
| 8572 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8573 | TEST_F(VkLayerTest, CreatePipelineAttribLocationMismatch) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 8574 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8575 | "location 0 not consumed by VS"); |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 8576 | |
| 8577 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8578 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8579 | |
| 8580 | VkVertexInputBindingDescription input_binding; |
| 8581 | memset(&input_binding, 0, sizeof(input_binding)); |
| 8582 | |
| 8583 | VkVertexInputAttributeDescription input_attrib; |
| 8584 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 8585 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 8586 | |
| 8587 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8588 | "#version 450\n" |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 8589 | "\n" |
| 8590 | "layout(location=1) in float x;\n" |
| 8591 | "out gl_PerVertex {\n" |
| 8592 | " vec4 gl_Position;\n" |
| 8593 | "};\n" |
| 8594 | "void main(){\n" |
| 8595 | " gl_Position = vec4(x);\n" |
| 8596 | "}\n"; |
| 8597 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8598 | "#version 450\n" |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 8599 | "\n" |
| 8600 | "layout(location=0) out vec4 color;\n" |
| 8601 | "void main(){\n" |
| 8602 | " color = vec4(1);\n" |
| 8603 | "}\n"; |
| 8604 | |
| 8605 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8606 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8607 | |
| 8608 | VkPipelineObj pipe(m_device); |
| 8609 | pipe.AddColorAttachment(); |
| 8610 | pipe.AddShader(&vs); |
| 8611 | pipe.AddShader(&fs); |
| 8612 | |
| 8613 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 8614 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 8615 | |
| 8616 | VkDescriptorSetObj descriptorSet(m_device); |
| 8617 | descriptorSet.AppendDummy(); |
| 8618 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8619 | |
| 8620 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8621 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8622 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 8623 | } |
| 8624 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8625 | TEST_F(VkLayerTest, CreatePipelineAttribNotProvided) { |
| 8626 | m_errorMonitor->SetDesiredFailureMsg( |
| 8627 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8628 | "VS consumes input at location 0 but not provided"); |
| 8629 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8630 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 8631 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8632 | |
| 8633 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8634 | "#version 450\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8635 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8636 | "layout(location=0) in vec4 x;\n" /* not provided */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8637 | "out gl_PerVertex {\n" |
| 8638 | " vec4 gl_Position;\n" |
| 8639 | "};\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8640 | "void main(){\n" |
| 8641 | " gl_Position = x;\n" |
| 8642 | "}\n"; |
| 8643 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8644 | "#version 450\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8645 | "\n" |
| 8646 | "layout(location=0) out vec4 color;\n" |
| 8647 | "void main(){\n" |
| 8648 | " color = vec4(1);\n" |
| 8649 | "}\n"; |
| 8650 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8651 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8652 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8653 | |
| 8654 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 8655 | pipe.AddColorAttachment(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8656 | pipe.AddShader(&vs); |
| 8657 | pipe.AddShader(&fs); |
| 8658 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8659 | VkDescriptorSetObj descriptorSet(m_device); |
| 8660 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8661 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8662 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 8663 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8664 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8665 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8666 | } |
| 8667 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8668 | TEST_F(VkLayerTest, CreatePipelineAttribTypeMismatch) { |
| 8669 | m_errorMonitor->SetDesiredFailureMsg( |
| 8670 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8671 | "location 0 does not match VS input type"); |
| 8672 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 8673 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 8674 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 8675 | |
| 8676 | VkVertexInputBindingDescription input_binding; |
| 8677 | memset(&input_binding, 0, sizeof(input_binding)); |
| 8678 | |
| 8679 | VkVertexInputAttributeDescription input_attrib; |
| 8680 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 8681 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 8682 | |
| 8683 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8684 | "#version 450\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 8685 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8686 | "layout(location=0) in int x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8687 | "out gl_PerVertex {\n" |
| 8688 | " vec4 gl_Position;\n" |
| 8689 | "};\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 8690 | "void main(){\n" |
| 8691 | " gl_Position = vec4(x);\n" |
| 8692 | "}\n"; |
| 8693 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8694 | "#version 450\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 8695 | "\n" |
| 8696 | "layout(location=0) out vec4 color;\n" |
| 8697 | "void main(){\n" |
| 8698 | " color = vec4(1);\n" |
| 8699 | "}\n"; |
| 8700 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8701 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8702 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 8703 | |
| 8704 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 8705 | pipe.AddColorAttachment(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 8706 | pipe.AddShader(&vs); |
| 8707 | pipe.AddShader(&fs); |
| 8708 | |
| 8709 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 8710 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 8711 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 8712 | VkDescriptorSetObj descriptorSet(m_device); |
| 8713 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8714 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 8715 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 8716 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 8717 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8718 | m_errorMonitor->VerifyFound(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 8719 | } |
| 8720 | |
Chris Forbes | c68b43c | 2016-04-06 11:18:47 +1200 | [diff] [blame] | 8721 | TEST_F(VkLayerTest, CreatePipelineDuplicateStage) { |
| 8722 | m_errorMonitor->SetDesiredFailureMsg( |
| 8723 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8724 | "Multiple shaders provided for stage VK_SHADER_STAGE_VERTEX_BIT"); |
| 8725 | |
| 8726 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8727 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8728 | |
| 8729 | char const *vsSource = |
| 8730 | "#version 450\n" |
| 8731 | "\n" |
| 8732 | "out gl_PerVertex {\n" |
| 8733 | " vec4 gl_Position;\n" |
| 8734 | "};\n" |
| 8735 | "void main(){\n" |
| 8736 | " gl_Position = vec4(1);\n" |
| 8737 | "}\n"; |
| 8738 | char const *fsSource = |
| 8739 | "#version 450\n" |
| 8740 | "\n" |
| 8741 | "layout(location=0) out vec4 color;\n" |
| 8742 | "void main(){\n" |
| 8743 | " color = vec4(1);\n" |
| 8744 | "}\n"; |
| 8745 | |
| 8746 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8747 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8748 | |
| 8749 | VkPipelineObj pipe(m_device); |
| 8750 | pipe.AddColorAttachment(); |
| 8751 | pipe.AddShader(&vs); |
| 8752 | pipe.AddShader(&vs); |
| 8753 | pipe.AddShader(&fs); |
| 8754 | |
| 8755 | VkDescriptorSetObj descriptorSet(m_device); |
| 8756 | descriptorSet.AppendDummy(); |
| 8757 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8758 | |
| 8759 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8760 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8761 | m_errorMonitor->VerifyFound(); |
Chris Forbes | c68b43c | 2016-04-06 11:18:47 +1200 | [diff] [blame] | 8762 | } |
| 8763 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8764 | TEST_F(VkLayerTest, CreatePipelineAttribMatrixType) { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8765 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 8766 | |
| 8767 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8768 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8769 | |
| 8770 | VkVertexInputBindingDescription input_binding; |
| 8771 | memset(&input_binding, 0, sizeof(input_binding)); |
| 8772 | |
| 8773 | VkVertexInputAttributeDescription input_attribs[2]; |
| 8774 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 8775 | |
| 8776 | for (int i = 0; i < 2; i++) { |
| 8777 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 8778 | input_attribs[i].location = i; |
| 8779 | } |
| 8780 | |
| 8781 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8782 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 8783 | "\n" |
| 8784 | "layout(location=0) in mat2x4 x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8785 | "out gl_PerVertex {\n" |
| 8786 | " vec4 gl_Position;\n" |
| 8787 | "};\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 8788 | "void main(){\n" |
| 8789 | " gl_Position = x[0] + x[1];\n" |
| 8790 | "}\n"; |
| 8791 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8792 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 8793 | "\n" |
| 8794 | "layout(location=0) out vec4 color;\n" |
| 8795 | "void main(){\n" |
| 8796 | " color = vec4(1);\n" |
| 8797 | "}\n"; |
| 8798 | |
| 8799 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8800 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8801 | |
| 8802 | VkPipelineObj pipe(m_device); |
| 8803 | pipe.AddColorAttachment(); |
| 8804 | pipe.AddShader(&vs); |
| 8805 | pipe.AddShader(&fs); |
| 8806 | |
| 8807 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 8808 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 8809 | |
| 8810 | VkDescriptorSetObj descriptorSet(m_device); |
| 8811 | descriptorSet.AppendDummy(); |
| 8812 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8813 | |
| 8814 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8815 | |
| 8816 | /* expect success */ |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8817 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 8818 | } |
| 8819 | |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 8820 | TEST_F(VkLayerTest, CreatePipelineAttribArrayType) |
| 8821 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8822 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 8823 | |
| 8824 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8825 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8826 | |
| 8827 | VkVertexInputBindingDescription input_binding; |
| 8828 | memset(&input_binding, 0, sizeof(input_binding)); |
| 8829 | |
| 8830 | VkVertexInputAttributeDescription input_attribs[2]; |
| 8831 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 8832 | |
| 8833 | for (int i = 0; i < 2; i++) { |
| 8834 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 8835 | input_attribs[i].location = i; |
| 8836 | } |
| 8837 | |
| 8838 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8839 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 8840 | "\n" |
| 8841 | "layout(location=0) in vec4 x[2];\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8842 | "out gl_PerVertex {\n" |
| 8843 | " vec4 gl_Position;\n" |
| 8844 | "};\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 8845 | "void main(){\n" |
| 8846 | " gl_Position = x[0] + x[1];\n" |
| 8847 | "}\n"; |
| 8848 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8849 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 8850 | "\n" |
| 8851 | "layout(location=0) out vec4 color;\n" |
| 8852 | "void main(){\n" |
| 8853 | " color = vec4(1);\n" |
| 8854 | "}\n"; |
| 8855 | |
| 8856 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8857 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8858 | |
| 8859 | VkPipelineObj pipe(m_device); |
| 8860 | pipe.AddColorAttachment(); |
| 8861 | pipe.AddShader(&vs); |
| 8862 | pipe.AddShader(&fs); |
| 8863 | |
| 8864 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 8865 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 8866 | |
| 8867 | VkDescriptorSetObj descriptorSet(m_device); |
| 8868 | descriptorSet.AppendDummy(); |
| 8869 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8870 | |
| 8871 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8872 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8873 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 8874 | } |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 8875 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 8876 | TEST_F(VkLayerTest, CreatePipelineSimplePositive) |
| 8877 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8878 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 8879 | |
| 8880 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8881 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8882 | |
| 8883 | char const *vsSource = |
| 8884 | "#version 450\n" |
| 8885 | "out gl_PerVertex {\n" |
| 8886 | " vec4 gl_Position;\n" |
| 8887 | "};\n" |
| 8888 | "void main(){\n" |
| 8889 | " gl_Position = vec4(0);\n" |
| 8890 | "}\n"; |
| 8891 | char const *fsSource = |
| 8892 | "#version 450\n" |
| 8893 | "\n" |
| 8894 | "layout(location=0) out vec4 color;\n" |
| 8895 | "void main(){\n" |
| 8896 | " color = vec4(1);\n" |
| 8897 | "}\n"; |
| 8898 | |
| 8899 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8900 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8901 | |
| 8902 | VkPipelineObj pipe(m_device); |
| 8903 | pipe.AddColorAttachment(); |
| 8904 | pipe.AddShader(&vs); |
| 8905 | pipe.AddShader(&fs); |
| 8906 | |
| 8907 | VkDescriptorSetObj descriptorSet(m_device); |
| 8908 | descriptorSet.AppendDummy(); |
| 8909 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8910 | |
| 8911 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8912 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8913 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 8914 | } |
| 8915 | |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 8916 | TEST_F(VkLayerTest, CreatePipelineRelaxedTypeMatch) |
| 8917 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8918 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 8919 | |
| 8920 | // VK 1.0.8 Specification, 14.1.3 "Additionally,..." block |
| 8921 | |
| 8922 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8923 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8924 | |
| 8925 | char const *vsSource = |
| 8926 | "#version 450\n" |
| 8927 | "out gl_PerVertex {\n" |
| 8928 | " vec4 gl_Position;\n" |
| 8929 | "};\n" |
| 8930 | "layout(location=0) out vec3 x;\n" |
| 8931 | "layout(location=1) out ivec3 y;\n" |
| 8932 | "layout(location=2) out vec3 z;\n" |
| 8933 | "void main(){\n" |
| 8934 | " gl_Position = vec4(0);\n" |
| 8935 | " x = vec3(0); y = ivec3(0); z = vec3(0);\n" |
| 8936 | "}\n"; |
| 8937 | char const *fsSource = |
| 8938 | "#version 450\n" |
| 8939 | "\n" |
| 8940 | "layout(location=0) out vec4 color;\n" |
| 8941 | "layout(location=0) in float x;\n" |
| 8942 | "layout(location=1) flat in int y;\n" |
| 8943 | "layout(location=2) in vec2 z;\n" |
| 8944 | "void main(){\n" |
| 8945 | " color = vec4(1 + x + y + z.x);\n" |
| 8946 | "}\n"; |
| 8947 | |
| 8948 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8949 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8950 | |
| 8951 | VkPipelineObj pipe(m_device); |
| 8952 | pipe.AddColorAttachment(); |
| 8953 | pipe.AddShader(&vs); |
| 8954 | pipe.AddShader(&fs); |
| 8955 | |
| 8956 | VkDescriptorSetObj descriptorSet(m_device); |
| 8957 | descriptorSet.AppendDummy(); |
| 8958 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8959 | |
| 8960 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8961 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8962 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 8963 | } |
| 8964 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 8965 | TEST_F(VkLayerTest, CreatePipelineTessPerVertex) |
| 8966 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8967 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 8968 | |
| 8969 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8970 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8971 | |
Chris Forbes | c1e852d | 2016-04-04 19:26:42 +1200 | [diff] [blame] | 8972 | if (!m_device->phy().features().tessellationShader) { |
| 8973 | printf("Device does not support tessellation shaders; skipped.\n"); |
| 8974 | return; |
| 8975 | } |
| 8976 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 8977 | char const *vsSource = |
| 8978 | "#version 450\n" |
| 8979 | "void main(){}\n"; |
| 8980 | char const *tcsSource = |
| 8981 | "#version 450\n" |
| 8982 | "layout(location=0) out int x[];\n" |
| 8983 | "layout(vertices=3) out;\n" |
| 8984 | "void main(){\n" |
| 8985 | " gl_TessLevelOuter[0] = gl_TessLevelOuter[1] = gl_TessLevelOuter[2] = 1;\n" |
| 8986 | " gl_TessLevelInner[0] = 1;\n" |
| 8987 | " x[gl_InvocationID] = gl_InvocationID;\n" |
| 8988 | "}\n"; |
| 8989 | char const *tesSource = |
| 8990 | "#version 450\n" |
| 8991 | "layout(triangles, equal_spacing, cw) in;\n" |
| 8992 | "layout(location=0) in int x[];\n" |
| 8993 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 8994 | "void main(){\n" |
| 8995 | " gl_Position.xyz = gl_TessCoord;\n" |
| 8996 | " gl_Position.w = x[0] + x[1] + x[2];\n" |
| 8997 | "}\n"; |
| 8998 | char const *fsSource = |
| 8999 | "#version 450\n" |
| 9000 | "layout(location=0) out vec4 color;\n" |
| 9001 | "void main(){\n" |
| 9002 | " color = vec4(1);\n" |
| 9003 | "}\n"; |
| 9004 | |
| 9005 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9006 | VkShaderObj tcs(m_device, tcsSource, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 9007 | VkShaderObj tes(m_device, tesSource, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
| 9008 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9009 | |
| 9010 | VkPipelineInputAssemblyStateCreateInfo iasci{ |
| 9011 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, |
| 9012 | nullptr, |
| 9013 | 0, |
| 9014 | VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, |
| 9015 | VK_FALSE}; |
| 9016 | |
Chris Forbes | b4cacb6 | 2016-04-04 19:15:00 +1200 | [diff] [blame] | 9017 | VkPipelineTessellationStateCreateInfo tsci{ |
| 9018 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, |
| 9019 | nullptr, |
| 9020 | 0, |
| 9021 | 3}; |
| 9022 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9023 | VkPipelineObj pipe(m_device); |
| 9024 | pipe.SetInputAssembly(&iasci); |
Chris Forbes | b4cacb6 | 2016-04-04 19:15:00 +1200 | [diff] [blame] | 9025 | pipe.SetTessellation(&tsci); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9026 | pipe.AddColorAttachment(); |
| 9027 | pipe.AddShader(&vs); |
| 9028 | pipe.AddShader(&tcs); |
| 9029 | pipe.AddShader(&tes); |
| 9030 | pipe.AddShader(&fs); |
| 9031 | |
| 9032 | VkDescriptorSetObj descriptorSet(m_device); |
| 9033 | descriptorSet.AppendDummy(); |
| 9034 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9035 | |
| 9036 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9037 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9038 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9039 | } |
| 9040 | |
Chris Forbes | a0ab815 | 2016-04-20 13:34:27 +1200 | [diff] [blame] | 9041 | TEST_F(VkLayerTest, CreatePipelineGeometryInputBlockPositive) |
| 9042 | { |
| 9043 | m_errorMonitor->ExpectSuccess(); |
| 9044 | |
| 9045 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9046 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9047 | |
| 9048 | if (!m_device->phy().features().geometryShader) { |
| 9049 | printf("Device does not support geometry shaders; skipped.\n"); |
| 9050 | return; |
| 9051 | } |
| 9052 | |
| 9053 | char const *vsSource = |
| 9054 | "#version 450\n" |
| 9055 | "layout(location=0) out VertexData { vec4 x; } vs_out;\n" |
| 9056 | "void main(){\n" |
| 9057 | " vs_out.x = vec4(1);\n" |
| 9058 | "}\n"; |
| 9059 | char const *gsSource = |
| 9060 | "#version 450\n" |
| 9061 | "layout(triangles) in;\n" |
| 9062 | "layout(triangle_strip, max_vertices=3) out;\n" |
| 9063 | "layout(location=0) in VertexData { vec4 x; } gs_in[];\n" |
| 9064 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 9065 | "void main() {\n" |
| 9066 | " gl_Position = gs_in[0].x;\n" |
| 9067 | " EmitVertex();\n" |
| 9068 | "}\n"; |
| 9069 | char const *fsSource = |
| 9070 | "#version 450\n" |
| 9071 | "layout(location=0) out vec4 color;\n" |
| 9072 | "void main(){\n" |
| 9073 | " color = vec4(1);\n" |
| 9074 | "}\n"; |
| 9075 | |
| 9076 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9077 | VkShaderObj gs(m_device, gsSource, VK_SHADER_STAGE_GEOMETRY_BIT, this); |
| 9078 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9079 | |
| 9080 | VkPipelineObj pipe(m_device); |
| 9081 | pipe.AddColorAttachment(); |
| 9082 | pipe.AddShader(&vs); |
| 9083 | pipe.AddShader(&gs); |
| 9084 | pipe.AddShader(&fs); |
| 9085 | |
| 9086 | VkDescriptorSetObj descriptorSet(m_device); |
| 9087 | descriptorSet.AppendDummy(); |
| 9088 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9089 | |
| 9090 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9091 | |
| 9092 | m_errorMonitor->VerifyNotFound(); |
| 9093 | } |
| 9094 | |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 9095 | TEST_F(VkLayerTest, CreatePipelineTessPatchDecorationMismatch) |
| 9096 | { |
| 9097 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9098 | "is per-vertex in tessellation control shader stage " |
| 9099 | "but per-patch in tessellation evaluation shader stage"); |
| 9100 | |
| 9101 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9102 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9103 | |
Chris Forbes | c1e852d | 2016-04-04 19:26:42 +1200 | [diff] [blame] | 9104 | if (!m_device->phy().features().tessellationShader) { |
| 9105 | printf("Device does not support tessellation shaders; skipped.\n"); |
| 9106 | return; |
| 9107 | } |
| 9108 | |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 9109 | char const *vsSource = |
| 9110 | "#version 450\n" |
| 9111 | "void main(){}\n"; |
| 9112 | char const *tcsSource = |
| 9113 | "#version 450\n" |
| 9114 | "layout(location=0) out int x[];\n" |
| 9115 | "layout(vertices=3) out;\n" |
| 9116 | "void main(){\n" |
| 9117 | " gl_TessLevelOuter[0] = gl_TessLevelOuter[1] = gl_TessLevelOuter[2] = 1;\n" |
| 9118 | " gl_TessLevelInner[0] = 1;\n" |
| 9119 | " x[gl_InvocationID] = gl_InvocationID;\n" |
| 9120 | "}\n"; |
| 9121 | char const *tesSource = |
| 9122 | "#version 450\n" |
| 9123 | "layout(triangles, equal_spacing, cw) in;\n" |
| 9124 | "layout(location=0) patch in int x;\n" |
| 9125 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 9126 | "void main(){\n" |
| 9127 | " gl_Position.xyz = gl_TessCoord;\n" |
| 9128 | " gl_Position.w = x;\n" |
| 9129 | "}\n"; |
| 9130 | char const *fsSource = |
| 9131 | "#version 450\n" |
| 9132 | "layout(location=0) out vec4 color;\n" |
| 9133 | "void main(){\n" |
| 9134 | " color = vec4(1);\n" |
| 9135 | "}\n"; |
| 9136 | |
| 9137 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9138 | VkShaderObj tcs(m_device, tcsSource, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 9139 | VkShaderObj tes(m_device, tesSource, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
| 9140 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9141 | |
| 9142 | VkPipelineInputAssemblyStateCreateInfo iasci{ |
| 9143 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, |
| 9144 | nullptr, |
| 9145 | 0, |
| 9146 | VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, |
| 9147 | VK_FALSE}; |
| 9148 | |
| 9149 | VkPipelineTessellationStateCreateInfo tsci{ |
| 9150 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, |
| 9151 | nullptr, |
| 9152 | 0, |
| 9153 | 3}; |
| 9154 | |
| 9155 | VkPipelineObj pipe(m_device); |
| 9156 | pipe.SetInputAssembly(&iasci); |
| 9157 | pipe.SetTessellation(&tsci); |
| 9158 | pipe.AddColorAttachment(); |
| 9159 | pipe.AddShader(&vs); |
| 9160 | pipe.AddShader(&tcs); |
| 9161 | pipe.AddShader(&tes); |
| 9162 | pipe.AddShader(&fs); |
| 9163 | |
| 9164 | VkDescriptorSetObj descriptorSet(m_device); |
| 9165 | descriptorSet.AppendDummy(); |
| 9166 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9167 | |
| 9168 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9169 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9170 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 9171 | } |
| 9172 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9173 | TEST_F(VkLayerTest, CreatePipelineAttribBindingConflict) { |
| 9174 | m_errorMonitor->SetDesiredFailureMsg( |
| 9175 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9176 | "Duplicate vertex input binding descriptions for binding 0"); |
| 9177 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9178 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 9179 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9180 | |
| 9181 | /* Two binding descriptions for binding 0 */ |
| 9182 | VkVertexInputBindingDescription input_bindings[2]; |
| 9183 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 9184 | |
| 9185 | VkVertexInputAttributeDescription input_attrib; |
| 9186 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 9187 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 9188 | |
| 9189 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9190 | "#version 450\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9191 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9192 | "layout(location=0) in float x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9193 | "out gl_PerVertex {\n" |
| 9194 | " vec4 gl_Position;\n" |
| 9195 | "};\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9196 | "void main(){\n" |
| 9197 | " gl_Position = vec4(x);\n" |
| 9198 | "}\n"; |
| 9199 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9200 | "#version 450\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9201 | "\n" |
| 9202 | "layout(location=0) out vec4 color;\n" |
| 9203 | "void main(){\n" |
| 9204 | " color = vec4(1);\n" |
| 9205 | "}\n"; |
| 9206 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9207 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9208 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9209 | |
| 9210 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9211 | pipe.AddColorAttachment(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9212 | pipe.AddShader(&vs); |
| 9213 | pipe.AddShader(&fs); |
| 9214 | |
| 9215 | pipe.AddVertexInputBindings(input_bindings, 2); |
| 9216 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 9217 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9218 | VkDescriptorSetObj descriptorSet(m_device); |
| 9219 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9220 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9221 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9222 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9223 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9224 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9225 | } |
Chris Forbes | 8f68b56 | 2015-05-25 11:13:32 +1200 | [diff] [blame] | 9226 | |
Chris Forbes | 35efec7 | 2016-04-21 14:32:08 +1200 | [diff] [blame] | 9227 | TEST_F(VkLayerTest, CreatePipeline64BitAttributesPositive) { |
| 9228 | m_errorMonitor->ExpectSuccess(); |
| 9229 | |
| 9230 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9231 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9232 | |
| 9233 | if (!m_device->phy().features().tessellationShader) { |
| 9234 | printf("Device does not support 64bit vertex attributes; skipped.\n"); |
| 9235 | return; |
| 9236 | } |
| 9237 | |
| 9238 | VkVertexInputBindingDescription input_bindings[1]; |
| 9239 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 9240 | |
| 9241 | VkVertexInputAttributeDescription input_attribs[4]; |
| 9242 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 9243 | input_attribs[0].location = 0; |
| 9244 | input_attribs[0].offset = 0; |
| 9245 | input_attribs[0].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 9246 | input_attribs[1].location = 2; |
| 9247 | input_attribs[1].offset = 32; |
| 9248 | input_attribs[1].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 9249 | input_attribs[2].location = 4; |
| 9250 | input_attribs[2].offset = 64; |
| 9251 | input_attribs[2].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 9252 | input_attribs[3].location = 6; |
| 9253 | input_attribs[3].offset = 96; |
| 9254 | input_attribs[3].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 9255 | |
| 9256 | char const *vsSource = |
| 9257 | "#version 450\n" |
| 9258 | "\n" |
| 9259 | "layout(location=0) in dmat4 x;\n" |
| 9260 | "out gl_PerVertex {\n" |
| 9261 | " vec4 gl_Position;\n" |
| 9262 | "};\n" |
| 9263 | "void main(){\n" |
| 9264 | " gl_Position = vec4(x[0][0]);\n" |
| 9265 | "}\n"; |
| 9266 | char const *fsSource = |
| 9267 | "#version 450\n" |
| 9268 | "\n" |
| 9269 | "layout(location=0) out vec4 color;\n" |
| 9270 | "void main(){\n" |
| 9271 | " color = vec4(1);\n" |
| 9272 | "}\n"; |
| 9273 | |
| 9274 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9275 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9276 | |
| 9277 | VkPipelineObj pipe(m_device); |
| 9278 | pipe.AddColorAttachment(); |
| 9279 | pipe.AddShader(&vs); |
| 9280 | pipe.AddShader(&fs); |
| 9281 | |
| 9282 | pipe.AddVertexInputBindings(input_bindings, 1); |
| 9283 | pipe.AddVertexInputAttribs(input_attribs, 4); |
| 9284 | |
| 9285 | VkDescriptorSetObj descriptorSet(m_device); |
| 9286 | descriptorSet.AppendDummy(); |
| 9287 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9288 | |
| 9289 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9290 | |
| 9291 | m_errorMonitor->VerifyNotFound(); |
| 9292 | } |
| 9293 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9294 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotWritten) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9295 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9296 | "Attachment 0 not written by FS"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9297 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9298 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9299 | |
| 9300 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9301 | "#version 450\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9302 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9303 | "out gl_PerVertex {\n" |
| 9304 | " vec4 gl_Position;\n" |
| 9305 | "};\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9306 | "void main(){\n" |
| 9307 | " gl_Position = vec4(1);\n" |
| 9308 | "}\n"; |
| 9309 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9310 | "#version 450\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9311 | "\n" |
| 9312 | "void main(){\n" |
| 9313 | "}\n"; |
| 9314 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9315 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9316 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9317 | |
| 9318 | VkPipelineObj pipe(m_device); |
| 9319 | pipe.AddShader(&vs); |
| 9320 | pipe.AddShader(&fs); |
| 9321 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9322 | /* set up CB 0, not written */ |
| 9323 | pipe.AddColorAttachment(); |
| 9324 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9325 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9326 | VkDescriptorSetObj descriptorSet(m_device); |
| 9327 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9328 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9329 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9330 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9331 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9332 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9333 | } |
| 9334 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9335 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotConsumed) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9336 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 9337 | VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9338 | "FS writes to output location 1 with no matching attachment"); |
| 9339 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9340 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9341 | |
| 9342 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9343 | "#version 450\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9344 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9345 | "out gl_PerVertex {\n" |
| 9346 | " vec4 gl_Position;\n" |
| 9347 | "};\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9348 | "void main(){\n" |
| 9349 | " gl_Position = vec4(1);\n" |
| 9350 | "}\n"; |
| 9351 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9352 | "#version 450\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9353 | "\n" |
| 9354 | "layout(location=0) out vec4 x;\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9355 | "layout(location=1) out vec4 y;\n" /* no matching attachment for this */ |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9356 | "void main(){\n" |
| 9357 | " x = vec4(1);\n" |
| 9358 | " y = vec4(1);\n" |
| 9359 | "}\n"; |
| 9360 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9361 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9362 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9363 | |
| 9364 | VkPipelineObj pipe(m_device); |
| 9365 | pipe.AddShader(&vs); |
| 9366 | pipe.AddShader(&fs); |
| 9367 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9368 | /* set up CB 0, not written */ |
| 9369 | pipe.AddColorAttachment(); |
| 9370 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9371 | /* FS writes CB 1, but we don't configure it */ |
| 9372 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9373 | VkDescriptorSetObj descriptorSet(m_device); |
| 9374 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9375 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9376 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9377 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9378 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9379 | m_errorMonitor->VerifyFound(); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9380 | } |
| 9381 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9382 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputTypeMismatch) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9383 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9384 | "does not match FS output type"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9385 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9386 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9387 | |
| 9388 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9389 | "#version 450\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9390 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9391 | "out gl_PerVertex {\n" |
| 9392 | " vec4 gl_Position;\n" |
| 9393 | "};\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9394 | "void main(){\n" |
| 9395 | " gl_Position = vec4(1);\n" |
| 9396 | "}\n"; |
| 9397 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9398 | "#version 450\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9399 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9400 | "layout(location=0) out ivec4 x;\n" /* not UNORM */ |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9401 | "void main(){\n" |
| 9402 | " x = ivec4(1);\n" |
| 9403 | "}\n"; |
| 9404 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9405 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9406 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9407 | |
| 9408 | VkPipelineObj pipe(m_device); |
| 9409 | pipe.AddShader(&vs); |
| 9410 | pipe.AddShader(&fs); |
| 9411 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9412 | /* set up CB 0; type is UNORM by default */ |
| 9413 | pipe.AddColorAttachment(); |
| 9414 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9415 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9416 | VkDescriptorSetObj descriptorSet(m_device); |
| 9417 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9418 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9419 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9420 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9421 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9422 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9423 | } |
Chris Forbes | 7b1b893 | 2015-06-05 14:43:36 +1200 | [diff] [blame] | 9424 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9425 | TEST_F(VkLayerTest, CreatePipelineUniformBlockNotProvided) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9426 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9427 | "not declared in pipeline layout"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9428 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 9429 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 9430 | |
| 9431 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9432 | "#version 450\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 9433 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9434 | "out gl_PerVertex {\n" |
| 9435 | " vec4 gl_Position;\n" |
| 9436 | "};\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 9437 | "void main(){\n" |
| 9438 | " gl_Position = vec4(1);\n" |
| 9439 | "}\n"; |
| 9440 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9441 | "#version 450\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 9442 | "\n" |
| 9443 | "layout(location=0) out vec4 x;\n" |
| 9444 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 9445 | "void main(){\n" |
| 9446 | " x = vec4(bar.y);\n" |
| 9447 | "}\n"; |
| 9448 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9449 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9450 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 9451 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 9452 | VkPipelineObj pipe(m_device); |
| 9453 | pipe.AddShader(&vs); |
| 9454 | pipe.AddShader(&fs); |
| 9455 | |
| 9456 | /* set up CB 0; type is UNORM by default */ |
| 9457 | pipe.AddColorAttachment(); |
| 9458 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9459 | |
| 9460 | VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9461 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 9462 | |
| 9463 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9464 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9465 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 9466 | } |
| 9467 | |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 9468 | TEST_F(VkLayerTest, CreatePipelinePushConstantsNotInLayout) { |
| 9469 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9470 | "not declared in layout"); |
| 9471 | |
| 9472 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9473 | |
| 9474 | char const *vsSource = |
| 9475 | "#version 450\n" |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 9476 | "\n" |
| 9477 | "layout(push_constant, std430) uniform foo { float x; } consts;\n" |
| 9478 | "out gl_PerVertex {\n" |
| 9479 | " vec4 gl_Position;\n" |
| 9480 | "};\n" |
| 9481 | "void main(){\n" |
| 9482 | " gl_Position = vec4(consts.x);\n" |
| 9483 | "}\n"; |
| 9484 | char const *fsSource = |
| 9485 | "#version 450\n" |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 9486 | "\n" |
| 9487 | "layout(location=0) out vec4 x;\n" |
| 9488 | "void main(){\n" |
| 9489 | " x = vec4(1);\n" |
| 9490 | "}\n"; |
| 9491 | |
| 9492 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9493 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9494 | |
| 9495 | VkPipelineObj pipe(m_device); |
| 9496 | pipe.AddShader(&vs); |
| 9497 | pipe.AddShader(&fs); |
| 9498 | |
| 9499 | /* set up CB 0; type is UNORM by default */ |
| 9500 | pipe.AddColorAttachment(); |
| 9501 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9502 | |
| 9503 | VkDescriptorSetObj descriptorSet(m_device); |
| 9504 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9505 | |
| 9506 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9507 | |
| 9508 | /* should have generated an error -- no push constant ranges provided! */ |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9509 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 9510 | } |
| 9511 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 9512 | #endif // SHADER_CHECKER_TESTS |
| 9513 | |
| 9514 | #if DEVICE_LIMITS_TESTS |
Mark Young | c48c4c1 | 2016-04-11 14:26:49 -0600 | [diff] [blame] | 9515 | TEST_F(VkLayerTest, CreateImageLimitsViolationMaxWidth) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9516 | m_errorMonitor->SetDesiredFailureMsg( |
| 9517 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9518 | "CreateImage extents exceed allowable limits for format"); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 9519 | |
| 9520 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 9521 | |
| 9522 | // Create an image |
| 9523 | VkImage image; |
| 9524 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9525 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 9526 | const int32_t tex_width = 32; |
| 9527 | const int32_t tex_height = 32; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 9528 | |
| 9529 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9530 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9531 | image_create_info.pNext = NULL; |
| 9532 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 9533 | image_create_info.format = tex_format; |
| 9534 | image_create_info.extent.width = tex_width; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 9535 | image_create_info.extent.height = tex_height; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9536 | image_create_info.extent.depth = 1; |
| 9537 | image_create_info.mipLevels = 1; |
| 9538 | image_create_info.arrayLayers = 1; |
| 9539 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 9540 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 9541 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 9542 | image_create_info.flags = 0; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 9543 | |
| 9544 | // Introduce error by sending down a bogus width extent |
| 9545 | image_create_info.extent.width = 65536; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9546 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 9547 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9548 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 9549 | } |
| 9550 | |
Mark Young | c48c4c1 | 2016-04-11 14:26:49 -0600 | [diff] [blame] | 9551 | TEST_F(VkLayerTest, CreateImageLimitsViolationMinWidth) { |
| 9552 | m_errorMonitor->SetDesiredFailureMsg( |
| 9553 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9554 | "CreateImage extents is 0 for at least one required dimension"); |
| 9555 | |
| 9556 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9557 | |
| 9558 | // Create an image |
| 9559 | VkImage image; |
| 9560 | |
| 9561 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 9562 | const int32_t tex_width = 32; |
| 9563 | const int32_t tex_height = 32; |
| 9564 | |
| 9565 | VkImageCreateInfo image_create_info = {}; |
| 9566 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9567 | image_create_info.pNext = NULL; |
| 9568 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 9569 | image_create_info.format = tex_format; |
| 9570 | image_create_info.extent.width = tex_width; |
| 9571 | image_create_info.extent.height = tex_height; |
| 9572 | image_create_info.extent.depth = 1; |
| 9573 | image_create_info.mipLevels = 1; |
| 9574 | image_create_info.arrayLayers = 1; |
| 9575 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 9576 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 9577 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 9578 | image_create_info.flags = 0; |
| 9579 | |
| 9580 | // Introduce error by sending down a bogus width extent |
| 9581 | image_create_info.extent.width = 0; |
| 9582 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 9583 | |
| 9584 | m_errorMonitor->VerifyFound(); |
| 9585 | } |
| 9586 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9587 | TEST_F(VkLayerTest, UpdateBufferAlignment) { |
| 9588 | uint32_t updateData[] = {1, 2, 3, 4, 5, 6, 7, 8}; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9589 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9590 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9591 | "dstOffset, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9592 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9593 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9594 | |
| 9595 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 9596 | vk_testing::Buffer buffer; |
| 9597 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 9598 | |
| 9599 | BeginCommandBuffer(); |
| 9600 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9601 | m_commandBuffer->UpdateBuffer(buffer.handle(), 1, 4, updateData); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9602 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9603 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9604 | // Introduce failure by using size that is not multiple of 4 |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9605 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9606 | "dataSize, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9607 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9608 | m_commandBuffer->UpdateBuffer(buffer.handle(), 0, 6, updateData); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9609 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9610 | EndCommandBuffer(); |
| 9611 | } |
| 9612 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9613 | TEST_F(VkLayerTest, FillBufferAlignment) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9614 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9615 | "dstOffset, is not a multiple of 4"); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9616 | |
| 9617 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9618 | |
| 9619 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 9620 | vk_testing::Buffer buffer; |
| 9621 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 9622 | |
| 9623 | BeginCommandBuffer(); |
| 9624 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9625 | m_commandBuffer->FillBuffer(buffer.handle(), 1, 4, 0x11111111); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9626 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9627 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9628 | // Introduce failure by using size that is not multiple of 4 |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9629 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9630 | "size, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9631 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9632 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 6, 0x11111111); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9633 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9634 | m_errorMonitor->VerifyFound(); |
| 9635 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9636 | EndCommandBuffer(); |
| 9637 | } |
| 9638 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 9639 | #endif // DEVICE_LIMITS_TESTS |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9640 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 9641 | #if IMAGE_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9642 | TEST_F(VkLayerTest, InvalidImageView) { |
| 9643 | VkResult err; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 9644 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9645 | m_errorMonitor->SetDesiredFailureMsg( |
| 9646 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9647 | "vkCreateImageView called with baseMipLevel 10 "); |
| 9648 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 9649 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 9650 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9651 | // Create an image and try to create a view with bad baseMipLevel |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9652 | VkImage image; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 9653 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9654 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 9655 | const int32_t tex_width = 32; |
| 9656 | const int32_t tex_height = 32; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 9657 | |
| 9658 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9659 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9660 | image_create_info.pNext = NULL; |
| 9661 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 9662 | image_create_info.format = tex_format; |
| 9663 | image_create_info.extent.width = tex_width; |
| 9664 | image_create_info.extent.height = tex_height; |
| 9665 | image_create_info.extent.depth = 1; |
| 9666 | image_create_info.mipLevels = 1; |
| 9667 | image_create_info.arrayLayers = 1; |
| 9668 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 9669 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 9670 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 9671 | image_create_info.flags = 0; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 9672 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9673 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 9674 | ASSERT_VK_SUCCESS(err); |
| 9675 | |
| 9676 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9677 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9678 | image_view_create_info.image = image; |
| 9679 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 9680 | image_view_create_info.format = tex_format; |
| 9681 | image_view_create_info.subresourceRange.layerCount = 1; |
| 9682 | image_view_create_info.subresourceRange.baseMipLevel = 10; // cause an error |
| 9683 | image_view_create_info.subresourceRange.levelCount = 1; |
| 9684 | image_view_create_info.subresourceRange.aspectMask = |
| 9685 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 9686 | |
| 9687 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9688 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 9689 | &view); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 9690 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9691 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 9692 | } |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9693 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9694 | TEST_F(VkLayerTest, InvalidImageViewAspect) { |
| 9695 | VkResult err; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 9696 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9697 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9698 | "vkCreateImageView: Color image " |
| 9699 | "formats must have ONLY the " |
| 9700 | "VK_IMAGE_ASPECT_COLOR_BIT set"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9701 | |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 9702 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 9703 | |
| 9704 | // 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] | 9705 | VkImage image; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 9706 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9707 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 9708 | const int32_t tex_width = 32; |
| 9709 | const int32_t tex_height = 32; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 9710 | |
| 9711 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9712 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9713 | image_create_info.pNext = NULL; |
| 9714 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 9715 | image_create_info.format = tex_format; |
| 9716 | image_create_info.extent.width = tex_width; |
| 9717 | image_create_info.extent.height = tex_height; |
| 9718 | image_create_info.extent.depth = 1; |
| 9719 | image_create_info.mipLevels = 1; |
| 9720 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 9721 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 9722 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 9723 | image_create_info.flags = 0; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 9724 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9725 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 9726 | ASSERT_VK_SUCCESS(err); |
| 9727 | |
| 9728 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9729 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9730 | image_view_create_info.image = image; |
| 9731 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 9732 | image_view_create_info.format = tex_format; |
| 9733 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 9734 | image_view_create_info.subresourceRange.levelCount = 1; |
| 9735 | // Cause an error by setting an invalid image aspect |
| 9736 | image_view_create_info.subresourceRange.aspectMask = |
| 9737 | VK_IMAGE_ASPECT_METADATA_BIT; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 9738 | |
| 9739 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9740 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 9741 | &view); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 9742 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9743 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 9744 | } |
| 9745 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 9746 | TEST_F(VkLayerTest, CopyImageLayerCountMismatch) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9747 | VkResult err; |
| 9748 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9749 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9750 | m_errorMonitor->SetDesiredFailureMsg( |
| 9751 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 9752 | "vkCmdCopyImage: number of layers in source and destination subresources for pRegions"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9753 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9754 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9755 | |
| 9756 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9757 | VkImage srcImage; |
| 9758 | VkImage dstImage; |
| 9759 | VkDeviceMemory srcMem; |
| 9760 | VkDeviceMemory destMem; |
| 9761 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9762 | |
| 9763 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9764 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9765 | image_create_info.pNext = NULL; |
| 9766 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 9767 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 9768 | image_create_info.extent.width = 32; |
| 9769 | image_create_info.extent.height = 32; |
| 9770 | image_create_info.extent.depth = 1; |
| 9771 | image_create_info.mipLevels = 1; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 9772 | image_create_info.arrayLayers = 4; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9773 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 9774 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 9775 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 9776 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9777 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9778 | err = |
| 9779 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9780 | ASSERT_VK_SUCCESS(err); |
| 9781 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9782 | err = |
| 9783 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9784 | ASSERT_VK_SUCCESS(err); |
| 9785 | |
| 9786 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9787 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9788 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 9789 | memAlloc.pNext = NULL; |
| 9790 | memAlloc.allocationSize = 0; |
| 9791 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9792 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 9793 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9794 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9795 | pass = |
| 9796 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 9797 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9798 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9799 | ASSERT_VK_SUCCESS(err); |
| 9800 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9801 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9802 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9803 | pass = |
| 9804 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9805 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9806 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9807 | ASSERT_VK_SUCCESS(err); |
| 9808 | |
| 9809 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 9810 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9811 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9812 | ASSERT_VK_SUCCESS(err); |
| 9813 | |
| 9814 | BeginCommandBuffer(); |
| 9815 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 9816 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9817 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 9818 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 9819 | copyRegion.srcSubresource.layerCount = 1; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9820 | copyRegion.srcOffset.x = 0; |
| 9821 | copyRegion.srcOffset.y = 0; |
| 9822 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 9823 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9824 | copyRegion.dstSubresource.mipLevel = 0; |
| 9825 | copyRegion.dstSubresource.baseArrayLayer = 0; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 9826 | // Introduce failure by forcing the dst layerCount to differ from src |
| 9827 | copyRegion.dstSubresource.layerCount = 3; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9828 | copyRegion.dstOffset.x = 0; |
| 9829 | copyRegion.dstOffset.y = 0; |
| 9830 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9831 | copyRegion.extent.width = 1; |
| 9832 | copyRegion.extent.height = 1; |
| 9833 | copyRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9834 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 9835 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9836 | EndCommandBuffer(); |
| 9837 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9838 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9839 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9840 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9841 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9842 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 9843 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9844 | } |
| 9845 | |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 9846 | TEST_F(VkLayerTest, ImageLayerUnsupportedFormat) { |
| 9847 | |
| 9848 | TEST_DESCRIPTION("Creating images with unsuported formats "); |
| 9849 | |
| 9850 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9851 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9852 | VkImageObj image(m_device); |
| 9853 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 9854 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 9855 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 9856 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 9857 | ASSERT_TRUE(image.initialized()); |
| 9858 | |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 9859 | // Create image with unsupported format - Expect FORMAT_UNSUPPORTED |
| 9860 | VkImageCreateInfo image_create_info; |
| 9861 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9862 | image_create_info.pNext = NULL; |
| 9863 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 9864 | image_create_info.format = VK_FORMAT_UNDEFINED; |
| 9865 | image_create_info.extent.width = 32; |
| 9866 | image_create_info.extent.height = 32; |
| 9867 | image_create_info.extent.depth = 1; |
| 9868 | image_create_info.mipLevels = 1; |
| 9869 | image_create_info.arrayLayers = 1; |
| 9870 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 9871 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 9872 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 9873 | image_create_info.flags = 0; |
| 9874 | |
| 9875 | m_errorMonitor->SetDesiredFailureMsg( |
| 9876 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9877 | "vkCreateImage: VkFormat for image must not be VK_FORMAT_UNDEFINED"); |
| 9878 | |
| 9879 | VkImage localImage; |
| 9880 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &localImage); |
| 9881 | m_errorMonitor->VerifyFound(); |
| 9882 | |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 9883 | VkFormat unsupported = VK_FORMAT_UNDEFINED; |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 9884 | // Look for a format that is COMPLETELY unsupported with this hardware |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 9885 | for (int f = VK_FORMAT_BEGIN_RANGE; f <= VK_FORMAT_END_RANGE; f++) { |
| 9886 | VkFormat format = static_cast<VkFormat>(f); |
| 9887 | VkFormatProperties fProps = m_device->format_properties(format); |
| 9888 | if (format != VK_FORMAT_UNDEFINED && fProps.linearTilingFeatures == 0 && |
| 9889 | fProps.optimalTilingFeatures == 0) { |
| 9890 | unsupported = format; |
| 9891 | break; |
| 9892 | } |
| 9893 | } |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 9894 | |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 9895 | if (unsupported != VK_FORMAT_UNDEFINED) { |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 9896 | image_create_info.format = unsupported; |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 9897 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 9898 | "is an unsupported format"); |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 9899 | |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 9900 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &localImage); |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 9901 | m_errorMonitor->VerifyFound(); |
| 9902 | } |
| 9903 | } |
| 9904 | |
| 9905 | TEST_F(VkLayerTest, ImageLayerViewTests) { |
| 9906 | VkResult ret; |
| 9907 | TEST_DESCRIPTION("Passing bad parameters to CreateImageView"); |
| 9908 | |
| 9909 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9910 | |
| 9911 | VkImageObj image(m_device); |
| 9912 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 9913 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 9914 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 9915 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 9916 | ASSERT_TRUE(image.initialized()); |
| 9917 | |
| 9918 | VkImageView imgView; |
| 9919 | VkImageViewCreateInfo imgViewInfo = {}; |
| 9920 | imgViewInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 9921 | imgViewInfo.image = image.handle(); |
| 9922 | imgViewInfo.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 9923 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 9924 | imgViewInfo.subresourceRange.layerCount = 1; |
| 9925 | imgViewInfo.subresourceRange.baseMipLevel = 0; |
| 9926 | imgViewInfo.subresourceRange.levelCount = 1; |
| 9927 | imgViewInfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 9928 | |
| 9929 | m_errorMonitor->SetDesiredFailureMsg( |
| 9930 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9931 | "vkCreateImageView called with baseMipLevel"); |
| 9932 | // View can't have baseMipLevel >= image's mipLevels - Expect |
| 9933 | // VIEW_CREATE_ERROR |
| 9934 | imgViewInfo.subresourceRange.baseMipLevel = 1; |
| 9935 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 9936 | m_errorMonitor->VerifyFound(); |
| 9937 | imgViewInfo.subresourceRange.baseMipLevel = 0; |
| 9938 | |
| 9939 | m_errorMonitor->SetDesiredFailureMsg( |
| 9940 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9941 | "vkCreateImageView called with baseArrayLayer"); |
| 9942 | // View can't have baseArrayLayer >= image's arraySize - Expect |
| 9943 | // VIEW_CREATE_ERROR |
| 9944 | imgViewInfo.subresourceRange.baseArrayLayer = 1; |
| 9945 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 9946 | m_errorMonitor->VerifyFound(); |
| 9947 | imgViewInfo.subresourceRange.baseArrayLayer = 0; |
| 9948 | |
| 9949 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9950 | "vkCreateImageView called with 0 in " |
| 9951 | "pCreateInfo->subresourceRange." |
| 9952 | "levelCount"); |
| 9953 | // View's levelCount can't be 0 - Expect VIEW_CREATE_ERROR |
| 9954 | imgViewInfo.subresourceRange.levelCount = 0; |
| 9955 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 9956 | m_errorMonitor->VerifyFound(); |
| 9957 | imgViewInfo.subresourceRange.levelCount = 1; |
| 9958 | |
| 9959 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9960 | "vkCreateImageView called with 0 in " |
| 9961 | "pCreateInfo->subresourceRange." |
| 9962 | "layerCount"); |
| 9963 | // View's layerCount can't be 0 - Expect VIEW_CREATE_ERROR |
| 9964 | imgViewInfo.subresourceRange.layerCount = 0; |
| 9965 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 9966 | m_errorMonitor->VerifyFound(); |
| 9967 | imgViewInfo.subresourceRange.layerCount = 1; |
| 9968 | |
| 9969 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9970 | "but both must be color formats"); |
| 9971 | // Can't use depth format for view into color image - Expect INVALID_FORMAT |
| 9972 | imgViewInfo.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 9973 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 9974 | m_errorMonitor->VerifyFound(); |
| 9975 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 9976 | |
| 9977 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9978 | "Formats MUST be IDENTICAL unless " |
| 9979 | "VK_IMAGE_CREATE_MUTABLE_FORMAT BIT " |
| 9980 | "was set on image creation."); |
| 9981 | // Same compatibility class but no MUTABLE_FORMAT bit - Expect |
| 9982 | // VIEW_CREATE_ERROR |
| 9983 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UINT; |
| 9984 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 9985 | m_errorMonitor->VerifyFound(); |
| 9986 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 9987 | |
| 9988 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9989 | "can support ImageViews with " |
| 9990 | "differing formats but they must be " |
| 9991 | "in the same compatibility class."); |
| 9992 | // Have MUTABLE_FORMAT bit but not in same compatibility class - Expect |
| 9993 | // VIEW_CREATE_ERROR |
| 9994 | VkImageCreateInfo mutImgInfo = image.create_info(); |
| 9995 | VkImage mutImage; |
| 9996 | mutImgInfo.format = VK_FORMAT_R8_UINT; |
| 9997 | assert( |
| 9998 | m_device->format_properties(VK_FORMAT_R8_UINT).optimalTilingFeatures & |
| 9999 | VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT); |
| 10000 | mutImgInfo.flags = VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT; |
| 10001 | mutImgInfo.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 10002 | ret = vkCreateImage(m_device->handle(), &mutImgInfo, NULL, &mutImage); |
| 10003 | ASSERT_VK_SUCCESS(ret); |
| 10004 | imgViewInfo.image = mutImage; |
| 10005 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 10006 | m_errorMonitor->VerifyFound(); |
| 10007 | imgViewInfo.image = image.handle(); |
| 10008 | vkDestroyImage(m_device->handle(), mutImage, NULL); |
| 10009 | } |
| 10010 | |
| 10011 | TEST_F(VkLayerTest, MiscImageLayerTests) { |
| 10012 | |
| 10013 | TEST_DESCRIPTION("Image layer tests that don't belong elsewhare"); |
| 10014 | |
| 10015 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10016 | |
| 10017 | VkImageObj image(m_device); |
| 10018 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 10019 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 10020 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 10021 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 10022 | ASSERT_TRUE(image.initialized()); |
| 10023 | |
| 10024 | m_errorMonitor->SetDesiredFailureMsg( |
| 10025 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10026 | "number of layers in image subresource is zero"); |
| 10027 | vk_testing::Buffer buffer; |
| 10028 | VkMemoryPropertyFlags reqs = 0; |
| 10029 | buffer.init_as_src(*m_device, 128 * 128 * 4, reqs); |
| 10030 | VkBufferImageCopy region = {}; |
| 10031 | region.bufferRowLength = 128; |
| 10032 | region.bufferImageHeight = 128; |
| 10033 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10034 | // layerCount can't be 0 - Expect MISMATCHED_IMAGE_ASPECT |
| 10035 | region.imageSubresource.layerCount = 0; |
| 10036 | region.imageExtent.height = 4; |
| 10037 | region.imageExtent.width = 4; |
| 10038 | region.imageExtent.depth = 1; |
| 10039 | m_commandBuffer->BeginCommandBuffer(); |
| 10040 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 10041 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 10042 | 1, ®ion); |
| 10043 | m_errorMonitor->VerifyFound(); |
| 10044 | region.imageSubresource.layerCount = 1; |
| 10045 | |
| 10046 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10047 | "aspectMasks for each region must " |
| 10048 | "specify only COLOR or DEPTH or " |
| 10049 | "STENCIL"); |
| 10050 | // Expect MISMATCHED_IMAGE_ASPECT |
| 10051 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_METADATA_BIT; |
| 10052 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 10053 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 10054 | 1, ®ion); |
| 10055 | m_errorMonitor->VerifyFound(); |
| 10056 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10057 | |
| 10058 | m_errorMonitor->SetDesiredFailureMsg( |
| 10059 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10060 | "If the format of srcImage is a depth, stencil, depth stencil or " |
| 10061 | "integer-based format then filter must be VK_FILTER_NEAREST"); |
| 10062 | // Expect INVALID_FILTER |
| 10063 | VkImageObj intImage1(m_device); |
| 10064 | intImage1.init(128, 128, VK_FORMAT_R8_UINT, |
| 10065 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, |
| 10066 | 0); |
| 10067 | VkImageObj intImage2(m_device); |
| 10068 | intImage2.init(128, 128, VK_FORMAT_R8_UINT, |
| 10069 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, |
| 10070 | 0); |
| 10071 | VkImageBlit blitRegion = {}; |
| 10072 | blitRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10073 | blitRegion.srcSubresource.baseArrayLayer = 0; |
| 10074 | blitRegion.srcSubresource.layerCount = 1; |
| 10075 | blitRegion.srcSubresource.mipLevel = 0; |
| 10076 | blitRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10077 | blitRegion.dstSubresource.baseArrayLayer = 0; |
| 10078 | blitRegion.dstSubresource.layerCount = 1; |
| 10079 | blitRegion.dstSubresource.mipLevel = 0; |
| 10080 | |
| 10081 | vkCmdBlitImage(m_commandBuffer->GetBufferHandle(), intImage1.handle(), |
| 10082 | intImage1.layout(), intImage2.handle(), intImage2.layout(), |
| 10083 | 16, &blitRegion, VK_FILTER_LINEAR); |
| 10084 | m_errorMonitor->VerifyFound(); |
| 10085 | |
| 10086 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10087 | "called with 0 in ppMemoryBarriers"); |
| 10088 | VkImageMemoryBarrier img_barrier; |
| 10089 | img_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; |
| 10090 | img_barrier.pNext = NULL; |
| 10091 | img_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 10092 | img_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 10093 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 10094 | img_barrier.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 10095 | img_barrier.image = image.handle(); |
| 10096 | img_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 10097 | img_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 10098 | img_barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10099 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 10100 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 10101 | // layerCount should not be 0 - Expect INVALID_IMAGE_RESOURCE |
| 10102 | img_barrier.subresourceRange.layerCount = 0; |
| 10103 | img_barrier.subresourceRange.levelCount = 1; |
| 10104 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 10105 | VK_PIPELINE_STAGE_HOST_BIT, |
| 10106 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 10107 | nullptr, 1, &img_barrier); |
| 10108 | m_errorMonitor->VerifyFound(); |
| 10109 | img_barrier.subresourceRange.layerCount = 1; |
| 10110 | } |
| 10111 | |
| 10112 | TEST_F(VkLayerTest, ImageFormatLimits) { |
| 10113 | |
| 10114 | TEST_DESCRIPTION("Exceed the limits of image format "); |
| 10115 | |
| 10116 | m_errorMonitor->SetDesiredFailureMsg( |
| 10117 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10118 | "CreateImage extents exceed allowable limits for format"); |
| 10119 | VkImageCreateInfo image_create_info = {}; |
| 10120 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10121 | image_create_info.pNext = NULL; |
| 10122 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10123 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10124 | image_create_info.extent.width = 32; |
| 10125 | image_create_info.extent.height = 32; |
| 10126 | image_create_info.extent.depth = 1; |
| 10127 | image_create_info.mipLevels = 1; |
| 10128 | image_create_info.arrayLayers = 1; |
| 10129 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10130 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 10131 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 10132 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 10133 | image_create_info.flags = 0; |
| 10134 | |
| 10135 | VkImage nullImg; |
| 10136 | VkImageFormatProperties imgFmtProps; |
| 10137 | vkGetPhysicalDeviceImageFormatProperties( |
| 10138 | gpu(), image_create_info.format, image_create_info.imageType, |
| 10139 | image_create_info.tiling, image_create_info.usage, |
| 10140 | image_create_info.flags, &imgFmtProps); |
| 10141 | image_create_info.extent.depth = imgFmtProps.maxExtent.depth + 1; |
| 10142 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 10143 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 10144 | m_errorMonitor->VerifyFound(); |
| 10145 | image_create_info.extent.depth = 1; |
| 10146 | |
| 10147 | m_errorMonitor->SetDesiredFailureMsg( |
| 10148 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10149 | "exceeds allowable maximum supported by format of"); |
| 10150 | image_create_info.mipLevels = imgFmtProps.maxMipLevels + 1; |
| 10151 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 10152 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 10153 | m_errorMonitor->VerifyFound(); |
| 10154 | image_create_info.mipLevels = 1; |
| 10155 | |
| 10156 | m_errorMonitor->SetDesiredFailureMsg( |
| 10157 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10158 | "exceeds allowable maximum supported by format of"); |
| 10159 | image_create_info.arrayLayers = imgFmtProps.maxArrayLayers + 1; |
| 10160 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 10161 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 10162 | m_errorMonitor->VerifyFound(); |
| 10163 | image_create_info.arrayLayers = 1; |
| 10164 | |
| 10165 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10166 | "is not supported by format"); |
| 10167 | int samples = imgFmtProps.sampleCounts >> 1; |
| 10168 | image_create_info.samples = (VkSampleCountFlagBits)samples; |
| 10169 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 10170 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 10171 | m_errorMonitor->VerifyFound(); |
| 10172 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10173 | |
| 10174 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10175 | "pCreateInfo->initialLayout, must be " |
| 10176 | "VK_IMAGE_LAYOUT_UNDEFINED or " |
| 10177 | "VK_IMAGE_LAYOUT_PREINITIALIZED"); |
| 10178 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 10179 | // Expect INVALID_LAYOUT |
| 10180 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 10181 | m_errorMonitor->VerifyFound(); |
| 10182 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 10183 | } |
| 10184 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10185 | TEST_F(VkLayerTest, CopyImageFormatSizeMismatch) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 10186 | VkResult err; |
| 10187 | bool pass; |
| 10188 | |
| 10189 | // Create color images with different format sizes and try to copy between them |
| 10190 | m_errorMonitor->SetDesiredFailureMsg( |
| 10191 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10192 | "vkCmdCopyImage called with unmatched source and dest image format sizes"); |
| 10193 | |
| 10194 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10195 | |
| 10196 | // Create two images of different types and try to copy between them |
| 10197 | VkImage srcImage; |
| 10198 | VkImage dstImage; |
| 10199 | VkDeviceMemory srcMem; |
| 10200 | VkDeviceMemory destMem; |
| 10201 | VkMemoryRequirements memReqs; |
| 10202 | |
| 10203 | VkImageCreateInfo image_create_info = {}; |
| 10204 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10205 | image_create_info.pNext = NULL; |
| 10206 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10207 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10208 | image_create_info.extent.width = 32; |
| 10209 | image_create_info.extent.height = 32; |
| 10210 | image_create_info.extent.depth = 1; |
| 10211 | image_create_info.mipLevels = 1; |
| 10212 | image_create_info.arrayLayers = 1; |
| 10213 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10214 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 10215 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 10216 | image_create_info.flags = 0; |
| 10217 | |
| 10218 | err = |
| 10219 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
| 10220 | ASSERT_VK_SUCCESS(err); |
| 10221 | |
| 10222 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 10223 | // Introduce failure by creating second image with a different-sized format. |
| 10224 | image_create_info.format = VK_FORMAT_R5G5B5A1_UNORM_PACK16; |
| 10225 | |
| 10226 | err = |
| 10227 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
| 10228 | ASSERT_VK_SUCCESS(err); |
| 10229 | |
| 10230 | // Allocate memory |
| 10231 | VkMemoryAllocateInfo memAlloc = {}; |
| 10232 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 10233 | memAlloc.pNext = NULL; |
| 10234 | memAlloc.allocationSize = 0; |
| 10235 | memAlloc.memoryTypeIndex = 0; |
| 10236 | |
| 10237 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
| 10238 | memAlloc.allocationSize = memReqs.size; |
| 10239 | pass = |
| 10240 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 10241 | ASSERT_TRUE(pass); |
| 10242 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
| 10243 | ASSERT_VK_SUCCESS(err); |
| 10244 | |
| 10245 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
| 10246 | memAlloc.allocationSize = memReqs.size; |
| 10247 | pass = |
| 10248 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 10249 | ASSERT_TRUE(pass); |
| 10250 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
| 10251 | ASSERT_VK_SUCCESS(err); |
| 10252 | |
| 10253 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 10254 | ASSERT_VK_SUCCESS(err); |
| 10255 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
| 10256 | ASSERT_VK_SUCCESS(err); |
| 10257 | |
| 10258 | BeginCommandBuffer(); |
| 10259 | VkImageCopy copyRegion; |
| 10260 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10261 | copyRegion.srcSubresource.mipLevel = 0; |
| 10262 | copyRegion.srcSubresource.baseArrayLayer = 0; |
| 10263 | copyRegion.srcSubresource.layerCount = 0; |
| 10264 | copyRegion.srcOffset.x = 0; |
| 10265 | copyRegion.srcOffset.y = 0; |
| 10266 | copyRegion.srcOffset.z = 0; |
| 10267 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10268 | copyRegion.dstSubresource.mipLevel = 0; |
| 10269 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 10270 | copyRegion.dstSubresource.layerCount = 0; |
| 10271 | copyRegion.dstOffset.x = 0; |
| 10272 | copyRegion.dstOffset.y = 0; |
| 10273 | copyRegion.dstOffset.z = 0; |
| 10274 | copyRegion.extent.width = 1; |
| 10275 | copyRegion.extent.height = 1; |
| 10276 | copyRegion.extent.depth = 1; |
| 10277 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 10278 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 10279 | EndCommandBuffer(); |
| 10280 | |
| 10281 | m_errorMonitor->VerifyFound(); |
| 10282 | |
| 10283 | vkDestroyImage(m_device->device(), srcImage, NULL); |
| 10284 | vkDestroyImage(m_device->device(), dstImage, NULL); |
| 10285 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 10286 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10287 | } |
| 10288 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10289 | TEST_F(VkLayerTest, CopyImageDepthStencilFormatMismatch) { |
| 10290 | VkResult err; |
| 10291 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10292 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10293 | // 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] | 10294 | m_errorMonitor->SetDesiredFailureMsg( |
| 10295 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10296 | "vkCmdCopyImage called with unmatched source and dest image depth"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10297 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10298 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10299 | |
| 10300 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10301 | VkImage srcImage; |
| 10302 | VkImage dstImage; |
| 10303 | VkDeviceMemory srcMem; |
| 10304 | VkDeviceMemory destMem; |
| 10305 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10306 | |
| 10307 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10308 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10309 | image_create_info.pNext = NULL; |
| 10310 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10311 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10312 | image_create_info.extent.width = 32; |
| 10313 | image_create_info.extent.height = 32; |
| 10314 | image_create_info.extent.depth = 1; |
| 10315 | image_create_info.mipLevels = 1; |
| 10316 | image_create_info.arrayLayers = 1; |
| 10317 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10318 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 10319 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 10320 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10321 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10322 | err = |
| 10323 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10324 | ASSERT_VK_SUCCESS(err); |
| 10325 | |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 10326 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 10327 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10328 | // Introduce failure by creating second image with a depth/stencil format |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10329 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10330 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 10331 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10332 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10333 | err = |
| 10334 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10335 | ASSERT_VK_SUCCESS(err); |
| 10336 | |
| 10337 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10338 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10339 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 10340 | memAlloc.pNext = NULL; |
| 10341 | memAlloc.allocationSize = 0; |
| 10342 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10343 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 10344 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10345 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10346 | pass = |
| 10347 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10348 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10349 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10350 | ASSERT_VK_SUCCESS(err); |
| 10351 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10352 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10353 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10354 | pass = |
| 10355 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10356 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10357 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10358 | ASSERT_VK_SUCCESS(err); |
| 10359 | |
| 10360 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 10361 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10362 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10363 | ASSERT_VK_SUCCESS(err); |
| 10364 | |
| 10365 | BeginCommandBuffer(); |
| 10366 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10367 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10368 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 10369 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10370 | copyRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10371 | copyRegion.srcOffset.x = 0; |
| 10372 | copyRegion.srcOffset.y = 0; |
| 10373 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10374 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10375 | copyRegion.dstSubresource.mipLevel = 0; |
| 10376 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 10377 | copyRegion.dstSubresource.layerCount = 0; |
| 10378 | copyRegion.dstOffset.x = 0; |
| 10379 | copyRegion.dstOffset.y = 0; |
| 10380 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10381 | copyRegion.extent.width = 1; |
| 10382 | copyRegion.extent.height = 1; |
| 10383 | copyRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10384 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 10385 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10386 | EndCommandBuffer(); |
| 10387 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10388 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10389 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10390 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10391 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10392 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 10393 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10394 | } |
| 10395 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10396 | TEST_F(VkLayerTest, ResolveImageLowSampleCount) { |
| 10397 | VkResult err; |
| 10398 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10399 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10400 | m_errorMonitor->SetDesiredFailureMsg( |
| 10401 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10402 | "vkCmdResolveImage called with source sample count less than 2."); |
| 10403 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10404 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10405 | |
| 10406 | // 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] | 10407 | VkImage srcImage; |
| 10408 | VkImage dstImage; |
| 10409 | VkDeviceMemory srcMem; |
| 10410 | VkDeviceMemory destMem; |
| 10411 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10412 | |
| 10413 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10414 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10415 | image_create_info.pNext = NULL; |
| 10416 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10417 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10418 | image_create_info.extent.width = 32; |
| 10419 | image_create_info.extent.height = 1; |
| 10420 | image_create_info.extent.depth = 1; |
| 10421 | image_create_info.mipLevels = 1; |
| 10422 | image_create_info.arrayLayers = 1; |
| 10423 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10424 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 10425 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 10426 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10427 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10428 | err = |
| 10429 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10430 | ASSERT_VK_SUCCESS(err); |
| 10431 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10432 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10433 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10434 | err = |
| 10435 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10436 | ASSERT_VK_SUCCESS(err); |
| 10437 | |
| 10438 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10439 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10440 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 10441 | memAlloc.pNext = NULL; |
| 10442 | memAlloc.allocationSize = 0; |
| 10443 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10444 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 10445 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10446 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10447 | pass = |
| 10448 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10449 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10450 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10451 | ASSERT_VK_SUCCESS(err); |
| 10452 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10453 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10454 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10455 | pass = |
| 10456 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10457 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10458 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10459 | ASSERT_VK_SUCCESS(err); |
| 10460 | |
| 10461 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 10462 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10463 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10464 | ASSERT_VK_SUCCESS(err); |
| 10465 | |
| 10466 | BeginCommandBuffer(); |
| 10467 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10468 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 10469 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10470 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10471 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10472 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 10473 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10474 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10475 | resolveRegion.srcOffset.x = 0; |
| 10476 | resolveRegion.srcOffset.y = 0; |
| 10477 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10478 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10479 | resolveRegion.dstSubresource.mipLevel = 0; |
| 10480 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 10481 | resolveRegion.dstSubresource.layerCount = 0; |
| 10482 | resolveRegion.dstOffset.x = 0; |
| 10483 | resolveRegion.dstOffset.y = 0; |
| 10484 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10485 | resolveRegion.extent.width = 1; |
| 10486 | resolveRegion.extent.height = 1; |
| 10487 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10488 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 10489 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10490 | EndCommandBuffer(); |
| 10491 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10492 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10493 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10494 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10495 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10496 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 10497 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10498 | } |
| 10499 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10500 | TEST_F(VkLayerTest, ResolveImageHighSampleCount) { |
| 10501 | VkResult err; |
| 10502 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10503 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10504 | m_errorMonitor->SetDesiredFailureMsg( |
| 10505 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10506 | "vkCmdResolveImage called with dest sample count greater than 1."); |
| 10507 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10508 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10509 | |
Chris Forbes | a753069 | 2016-05-08 12:35:39 +1200 | [diff] [blame] | 10510 | // 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] | 10511 | VkImage srcImage; |
| 10512 | VkImage dstImage; |
| 10513 | VkDeviceMemory srcMem; |
| 10514 | VkDeviceMemory destMem; |
| 10515 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10516 | |
| 10517 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10518 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10519 | image_create_info.pNext = NULL; |
| 10520 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10521 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10522 | image_create_info.extent.width = 32; |
| 10523 | image_create_info.extent.height = 1; |
| 10524 | image_create_info.extent.depth = 1; |
| 10525 | image_create_info.mipLevels = 1; |
| 10526 | image_create_info.arrayLayers = 1; |
Chris Forbes | a753069 | 2016-05-08 12:35:39 +1200 | [diff] [blame] | 10527 | image_create_info.samples = VK_SAMPLE_COUNT_4_BIT; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10528 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 10529 | // Note: Some implementations expect color attachment usage for any |
| 10530 | // multisample surface |
| 10531 | image_create_info.usage = |
| 10532 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 10533 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10534 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10535 | err = |
| 10536 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10537 | ASSERT_VK_SUCCESS(err); |
| 10538 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10539 | // Note: Some implementations expect color attachment usage for any |
| 10540 | // multisample surface |
| 10541 | image_create_info.usage = |
| 10542 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10543 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10544 | err = |
| 10545 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10546 | ASSERT_VK_SUCCESS(err); |
| 10547 | |
| 10548 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10549 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10550 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 10551 | memAlloc.pNext = NULL; |
| 10552 | memAlloc.allocationSize = 0; |
| 10553 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10554 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 10555 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10556 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10557 | pass = |
| 10558 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10559 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10560 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10561 | ASSERT_VK_SUCCESS(err); |
| 10562 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10563 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10564 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10565 | pass = |
| 10566 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10567 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10568 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10569 | ASSERT_VK_SUCCESS(err); |
| 10570 | |
| 10571 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 10572 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10573 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10574 | ASSERT_VK_SUCCESS(err); |
| 10575 | |
| 10576 | BeginCommandBuffer(); |
| 10577 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10578 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 10579 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10580 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10581 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10582 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 10583 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10584 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10585 | resolveRegion.srcOffset.x = 0; |
| 10586 | resolveRegion.srcOffset.y = 0; |
| 10587 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10588 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10589 | resolveRegion.dstSubresource.mipLevel = 0; |
| 10590 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 10591 | resolveRegion.dstSubresource.layerCount = 0; |
| 10592 | resolveRegion.dstOffset.x = 0; |
| 10593 | resolveRegion.dstOffset.y = 0; |
| 10594 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10595 | resolveRegion.extent.width = 1; |
| 10596 | resolveRegion.extent.height = 1; |
| 10597 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10598 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 10599 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10600 | EndCommandBuffer(); |
| 10601 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10602 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10603 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10604 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10605 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10606 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 10607 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10608 | } |
| 10609 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10610 | TEST_F(VkLayerTest, ResolveImageFormatMismatch) { |
| 10611 | VkResult err; |
| 10612 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10613 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10614 | m_errorMonitor->SetDesiredFailureMsg( |
| 10615 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10616 | "vkCmdResolveImage called with unmatched source and dest formats."); |
| 10617 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10618 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10619 | |
| 10620 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10621 | VkImage srcImage; |
| 10622 | VkImage dstImage; |
| 10623 | VkDeviceMemory srcMem; |
| 10624 | VkDeviceMemory destMem; |
| 10625 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10626 | |
| 10627 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10628 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10629 | image_create_info.pNext = NULL; |
| 10630 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10631 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10632 | image_create_info.extent.width = 32; |
| 10633 | image_create_info.extent.height = 1; |
| 10634 | image_create_info.extent.depth = 1; |
| 10635 | image_create_info.mipLevels = 1; |
| 10636 | image_create_info.arrayLayers = 1; |
| 10637 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 10638 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 10639 | // Note: Some implementations expect color attachment usage for any |
| 10640 | // multisample surface |
| 10641 | image_create_info.usage = |
| 10642 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 10643 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10644 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10645 | err = |
| 10646 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10647 | ASSERT_VK_SUCCESS(err); |
| 10648 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10649 | // Set format to something other than source image |
| 10650 | image_create_info.format = VK_FORMAT_R32_SFLOAT; |
| 10651 | // Note: Some implementations expect color attachment usage for any |
| 10652 | // multisample surface |
| 10653 | image_create_info.usage = |
| 10654 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 10655 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10656 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10657 | err = |
| 10658 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10659 | ASSERT_VK_SUCCESS(err); |
| 10660 | |
| 10661 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10662 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10663 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 10664 | memAlloc.pNext = NULL; |
| 10665 | memAlloc.allocationSize = 0; |
| 10666 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10667 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 10668 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10669 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10670 | pass = |
| 10671 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10672 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10673 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10674 | ASSERT_VK_SUCCESS(err); |
| 10675 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10676 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10677 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10678 | pass = |
| 10679 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10680 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10681 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10682 | ASSERT_VK_SUCCESS(err); |
| 10683 | |
| 10684 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 10685 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10686 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10687 | ASSERT_VK_SUCCESS(err); |
| 10688 | |
| 10689 | BeginCommandBuffer(); |
| 10690 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10691 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 10692 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10693 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10694 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10695 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 10696 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10697 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10698 | resolveRegion.srcOffset.x = 0; |
| 10699 | resolveRegion.srcOffset.y = 0; |
| 10700 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10701 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10702 | resolveRegion.dstSubresource.mipLevel = 0; |
| 10703 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 10704 | resolveRegion.dstSubresource.layerCount = 0; |
| 10705 | resolveRegion.dstOffset.x = 0; |
| 10706 | resolveRegion.dstOffset.y = 0; |
| 10707 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10708 | resolveRegion.extent.width = 1; |
| 10709 | resolveRegion.extent.height = 1; |
| 10710 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10711 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 10712 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10713 | EndCommandBuffer(); |
| 10714 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10715 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10716 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10717 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10718 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10719 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 10720 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10721 | } |
| 10722 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10723 | TEST_F(VkLayerTest, ResolveImageTypeMismatch) { |
| 10724 | VkResult err; |
| 10725 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10726 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10727 | m_errorMonitor->SetDesiredFailureMsg( |
| 10728 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10729 | "vkCmdResolveImage called with unmatched source and dest image types."); |
| 10730 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10731 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10732 | |
| 10733 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10734 | VkImage srcImage; |
| 10735 | VkImage dstImage; |
| 10736 | VkDeviceMemory srcMem; |
| 10737 | VkDeviceMemory destMem; |
| 10738 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10739 | |
| 10740 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10741 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10742 | image_create_info.pNext = NULL; |
| 10743 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10744 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10745 | image_create_info.extent.width = 32; |
| 10746 | image_create_info.extent.height = 1; |
| 10747 | image_create_info.extent.depth = 1; |
| 10748 | image_create_info.mipLevels = 1; |
| 10749 | image_create_info.arrayLayers = 1; |
| 10750 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 10751 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 10752 | // Note: Some implementations expect color attachment usage for any |
| 10753 | // multisample surface |
| 10754 | image_create_info.usage = |
| 10755 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 10756 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10757 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10758 | err = |
| 10759 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10760 | ASSERT_VK_SUCCESS(err); |
| 10761 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10762 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 10763 | // Note: Some implementations expect color attachment usage for any |
| 10764 | // multisample surface |
| 10765 | image_create_info.usage = |
| 10766 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 10767 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10768 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10769 | err = |
| 10770 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10771 | ASSERT_VK_SUCCESS(err); |
| 10772 | |
| 10773 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10774 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10775 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 10776 | memAlloc.pNext = NULL; |
| 10777 | memAlloc.allocationSize = 0; |
| 10778 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10779 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 10780 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10781 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10782 | pass = |
| 10783 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10784 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10785 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10786 | ASSERT_VK_SUCCESS(err); |
| 10787 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10788 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10789 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10790 | pass = |
| 10791 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10792 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10793 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10794 | ASSERT_VK_SUCCESS(err); |
| 10795 | |
| 10796 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 10797 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10798 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10799 | ASSERT_VK_SUCCESS(err); |
| 10800 | |
| 10801 | BeginCommandBuffer(); |
| 10802 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10803 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 10804 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10805 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10806 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10807 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 10808 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10809 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10810 | resolveRegion.srcOffset.x = 0; |
| 10811 | resolveRegion.srcOffset.y = 0; |
| 10812 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10813 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10814 | resolveRegion.dstSubresource.mipLevel = 0; |
| 10815 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 10816 | resolveRegion.dstSubresource.layerCount = 0; |
| 10817 | resolveRegion.dstOffset.x = 0; |
| 10818 | resolveRegion.dstOffset.y = 0; |
| 10819 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10820 | resolveRegion.extent.width = 1; |
| 10821 | resolveRegion.extent.height = 1; |
| 10822 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10823 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 10824 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10825 | EndCommandBuffer(); |
| 10826 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10827 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10828 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10829 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10830 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10831 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 10832 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10833 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10834 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10835 | TEST_F(VkLayerTest, DepthStencilImageViewWithColorAspectBitError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10836 | // 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] | 10837 | // to using a DS format, then cause it to hit error due to COLOR_BIT not |
| 10838 | // set in aspect |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10839 | // The image format check comes 2nd in validation so we trigger it first, |
| 10840 | // 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] | 10841 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10842 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10843 | m_errorMonitor->SetDesiredFailureMsg( |
| 10844 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10845 | "Combination depth/stencil image formats can have only the "); |
| 10846 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10847 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10848 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 10849 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10850 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 10851 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10852 | |
| 10853 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10854 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 10855 | ds_pool_ci.pNext = NULL; |
| 10856 | ds_pool_ci.maxSets = 1; |
| 10857 | ds_pool_ci.poolSizeCount = 1; |
| 10858 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10859 | |
| 10860 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10861 | err = |
| 10862 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10863 | ASSERT_VK_SUCCESS(err); |
| 10864 | |
| 10865 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10866 | dsl_binding.binding = 0; |
| 10867 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 10868 | dsl_binding.descriptorCount = 1; |
| 10869 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 10870 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10871 | |
| 10872 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10873 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 10874 | ds_layout_ci.pNext = NULL; |
| 10875 | ds_layout_ci.bindingCount = 1; |
| 10876 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10877 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10878 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 10879 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10880 | ASSERT_VK_SUCCESS(err); |
| 10881 | |
| 10882 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10883 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 10884 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 10885 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10886 | alloc_info.descriptorPool = ds_pool; |
| 10887 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10888 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 10889 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10890 | ASSERT_VK_SUCCESS(err); |
| 10891 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10892 | VkImage image_bad; |
| 10893 | VkImage image_good; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10894 | // One bad format and one good format for Color attachment |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10895 | const VkFormat tex_format_bad = VK_FORMAT_D32_SFLOAT_S8_UINT; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10896 | const VkFormat tex_format_good = VK_FORMAT_B8G8R8A8_UNORM; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10897 | const int32_t tex_width = 32; |
| 10898 | const int32_t tex_height = 32; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10899 | |
| 10900 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10901 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10902 | image_create_info.pNext = NULL; |
| 10903 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10904 | image_create_info.format = tex_format_bad; |
| 10905 | image_create_info.extent.width = tex_width; |
| 10906 | image_create_info.extent.height = tex_height; |
| 10907 | image_create_info.extent.depth = 1; |
| 10908 | image_create_info.mipLevels = 1; |
| 10909 | image_create_info.arrayLayers = 1; |
| 10910 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10911 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 10912 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT | |
| 10913 | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 10914 | image_create_info.flags = 0; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10915 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10916 | err = |
| 10917 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image_bad); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10918 | ASSERT_VK_SUCCESS(err); |
| 10919 | image_create_info.format = tex_format_good; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10920 | image_create_info.usage = |
| 10921 | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 10922 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, |
| 10923 | &image_good); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10924 | ASSERT_VK_SUCCESS(err); |
| 10925 | |
| 10926 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10927 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10928 | image_view_create_info.image = image_bad; |
| 10929 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 10930 | image_view_create_info.format = tex_format_bad; |
| 10931 | image_view_create_info.subresourceRange.baseArrayLayer = 0; |
| 10932 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 10933 | image_view_create_info.subresourceRange.layerCount = 1; |
| 10934 | image_view_create_info.subresourceRange.levelCount = 1; |
| 10935 | image_view_create_info.subresourceRange.aspectMask = |
| 10936 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10937 | |
| 10938 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10939 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 10940 | &view); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10941 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10942 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10943 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10944 | vkDestroyImage(m_device->device(), image_bad, NULL); |
| 10945 | vkDestroyImage(m_device->device(), image_good, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10946 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 10947 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10948 | } |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10949 | #endif // IMAGE_TESTS |
| 10950 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 10951 | int main(int argc, char **argv) { |
| 10952 | int result; |
| 10953 | |
Cody Northrop | 8e54a40 | 2016-03-08 22:25:52 -0700 | [diff] [blame] | 10954 | #ifdef ANDROID |
| 10955 | int vulkanSupport = InitVulkan(); |
| 10956 | if (vulkanSupport == 0) |
| 10957 | return 1; |
| 10958 | #endif |
| 10959 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 10960 | ::testing::InitGoogleTest(&argc, argv); |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 10961 | VkTestFramework::InitArgs(&argc, argv); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 10962 | |
| 10963 | ::testing::AddGlobalTestEnvironment(new TestEnvironment); |
| 10964 | |
| 10965 | result = RUN_ALL_TESTS(); |
| 10966 | |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 10967 | VkTestFramework::Finish(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 10968 | return result; |
| 10969 | } |