Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015-2016 The Khronos Group Inc. |
| 3 | * Copyright (c) 2015-2016 Valve Corporation |
| 4 | * Copyright (c) 2015-2016 LunarG, Inc. |
Michael Lentine | 0a369f6 | 2016-02-03 16:51:46 -0600 | [diff] [blame] | 5 | * Copyright (c) 2015-2016 Google, Inc. |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6 | * |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 7 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | * you may not use this file except in compliance with the License. |
| 9 | * You may obtain a copy of the License at |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10 | * |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 11 | * http://www.apache.org/licenses/LICENSE-2.0 |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12 | * |
| 13 | * Author: Chia-I Wu <olvaffe@gmail.com> |
| 14 | * Author: Chris Forbes <chrisf@ijw.co.nz> |
| 15 | * Author: Courtney Goeltzenleuchter <courtney@LunarG.com> |
| 16 | * Author: Mark Lobodzinski <mark@lunarg.com> |
| 17 | * Author: Mike Stroyan <mike@LunarG.com> |
| 18 | * Author: Tobin Ehlis <tobine@google.com> |
| 19 | * Author: Tony Barbour <tony@LunarG.com> |
| 20 | */ |
Tony Barbour | 65c48b3 | 2015-11-17 10:02:56 -0700 | [diff] [blame] | 21 | |
Cody Northrop | 8e54a40 | 2016-03-08 22:25:52 -0700 | [diff] [blame] | 22 | #ifdef ANDROID |
| 23 | #include "vulkan_wrapper.h" |
| 24 | #else |
David Pinedo | 9316d3b | 2015-11-06 12:54:48 -0700 | [diff] [blame] | 25 | #include <vulkan/vulkan.h> |
Cody Northrop | 8e54a40 | 2016-03-08 22:25:52 -0700 | [diff] [blame] | 26 | #endif |
Courtney Goeltzenleuchter | 58f3eff | 2015-10-07 13:28:58 -0600 | [diff] [blame] | 27 | #include "test_common.h" |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 28 | #include "vkrenderframework.h" |
Tobin Ehlis | a0cb02e | 2015-07-03 10:15:26 -0600 | [diff] [blame] | 29 | #include "vk_layer_config.h" |
Jon Ashburn | 7fa7e22 | 2016-02-02 12:08:10 -0700 | [diff] [blame] | 30 | #include "icd-spv.h" |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 31 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 32 | #define GLM_FORCE_RADIANS |
| 33 | #include "glm/glm.hpp" |
| 34 | #include <glm/gtc/matrix_transform.hpp> |
| 35 | |
Dustin Graves | ffa90fa | 2016-05-06 11:20:38 -0600 | [diff] [blame] | 36 | #define PARAMETER_VALIDATION_TESTS 1 |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 37 | #define MEM_TRACKER_TESTS 1 |
| 38 | #define OBJ_TRACKER_TESTS 1 |
| 39 | #define DRAW_STATE_TESTS 1 |
| 40 | #define THREADING_TESTS 1 |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 41 | #define SHADER_CHECKER_TESTS 1 |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 42 | #define DEVICE_LIMITS_TESTS 1 |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 43 | #define IMAGE_TESTS 1 |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 44 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 45 | //-------------------------------------------------------------------------------------- |
| 46 | // Mesh and VertexFormat Data |
| 47 | //-------------------------------------------------------------------------------------- |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 48 | struct Vertex { |
| 49 | float posX, posY, posZ, posW; // Position data |
| 50 | float r, g, b, a; // Color |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 51 | }; |
| 52 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 53 | #define XYZ1(_x_, _y_, _z_) (_x_), (_y_), (_z_), 1.f |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 54 | |
| 55 | typedef enum _BsoFailSelect { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 56 | BsoFailNone = 0x00000000, |
| 57 | BsoFailLineWidth = 0x00000001, |
| 58 | BsoFailDepthBias = 0x00000002, |
| 59 | BsoFailViewport = 0x00000004, |
| 60 | BsoFailScissor = 0x00000008, |
| 61 | BsoFailBlend = 0x00000010, |
| 62 | BsoFailDepthBounds = 0x00000020, |
| 63 | BsoFailStencilReadMask = 0x00000040, |
| 64 | BsoFailStencilWriteMask = 0x00000080, |
| 65 | BsoFailStencilReference = 0x00000100, |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 66 | } BsoFailSelect; |
| 67 | |
| 68 | struct vktriangle_vs_uniform { |
| 69 | // Must start with MVP |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 70 | float mvp[4][4]; |
| 71 | float position[3][4]; |
| 72 | float color[3][4]; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 73 | }; |
| 74 | |
Mark Lobodzinski | 75a97e6 | 2015-06-02 09:41:30 -0500 | [diff] [blame] | 75 | static const char bindStateVertShaderText[] = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 76 | "#version 450\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 77 | "vec2 vertices[3];\n" |
| 78 | "out gl_PerVertex {\n" |
| 79 | " vec4 gl_Position;\n" |
| 80 | "};\n" |
| 81 | "void main() {\n" |
| 82 | " vertices[0] = vec2(-1.0, -1.0);\n" |
| 83 | " vertices[1] = vec2( 1.0, -1.0);\n" |
| 84 | " vertices[2] = vec2( 0.0, 1.0);\n" |
| 85 | " gl_Position = vec4(vertices[gl_VertexIndex % 3], 0.0, 1.0);\n" |
| 86 | "}\n"; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 87 | |
Mark Lobodzinski | 75a97e6 | 2015-06-02 09:41:30 -0500 | [diff] [blame] | 88 | static const char bindStateFragShaderText[] = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 89 | "#version 450\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 90 | "\n" |
| 91 | "layout(location = 0) out vec4 uFragColor;\n" |
| 92 | "void main(){\n" |
| 93 | " uFragColor = vec4(0,1,0,1);\n" |
| 94 | "}\n"; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 95 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 96 | static VKAPI_ATTR VkBool32 VKAPI_CALL |
| 97 | myDbgFunc(VkFlags msgFlags, VkDebugReportObjectTypeEXT objType, |
| 98 | uint64_t srcObject, size_t location, int32_t msgCode, |
| 99 | const char *pLayerPrefix, const char *pMsg, void *pUserData); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 100 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 101 | // ******************************************************** |
| 102 | // ErrorMonitor Usage: |
| 103 | // |
| 104 | // Call SetDesiredFailureMsg with a string to be compared against all |
| 105 | // encountered log messages. Passing NULL will match all log messages. |
| 106 | // logMsg will return true for skipCall only if msg is matched or NULL. |
| 107 | // |
| 108 | // Call DesiredMsgFound to determine if the desired failure message |
| 109 | // was encountered. |
| 110 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 111 | class ErrorMonitor { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 112 | public: |
| 113 | ErrorMonitor() { |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 114 | test_platform_thread_create_mutex(&m_mutex); |
| 115 | test_platform_thread_lock_mutex(&m_mutex); |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 116 | m_msgFlags = VK_DEBUG_REPORT_INFORMATION_BIT_EXT; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 117 | m_bailout = NULL; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 118 | test_platform_thread_unlock_mutex(&m_mutex); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 119 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 120 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 121 | ~ErrorMonitor() { test_platform_thread_delete_mutex(&m_mutex); } |
| 122 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 123 | void SetDesiredFailureMsg(VkFlags msgFlags, const char *msgString) { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 124 | // also discard all collected messages to this point |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 125 | test_platform_thread_lock_mutex(&m_mutex); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 126 | m_failureMsg.clear(); |
| 127 | m_otherMsgs.clear(); |
| 128 | m_desiredMsg = msgString; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 129 | m_msgFound = VK_FALSE; |
| 130 | m_msgFlags = msgFlags; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 131 | test_platform_thread_unlock_mutex(&m_mutex); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 132 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 133 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 134 | VkBool32 CheckForDesiredMsg(VkFlags msgFlags, const char *msgString) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 135 | VkBool32 result = VK_FALSE; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 136 | test_platform_thread_lock_mutex(&m_mutex); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 137 | if (m_bailout != NULL) { |
| 138 | *m_bailout = true; |
| 139 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 140 | string errorString(msgString); |
| 141 | if (msgFlags & m_msgFlags) { |
| 142 | if (errorString.find(m_desiredMsg) != string::npos) { |
Chris Forbes | c7b8ad7 | 2016-04-04 18:50:38 +1200 | [diff] [blame] | 143 | if (m_msgFound) { /* if multiple matches, don't lose all but the last! */ |
| 144 | m_otherMsgs.push_back(m_failureMsg); |
| 145 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 146 | m_failureMsg = errorString; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 147 | m_msgFound = VK_TRUE; |
| 148 | result = VK_TRUE; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 149 | } else { |
| 150 | m_otherMsgs.push_back(errorString); |
| 151 | } |
| 152 | } |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 153 | test_platform_thread_unlock_mutex(&m_mutex); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 154 | return result; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 155 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 156 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 157 | vector<string> GetOtherFailureMsgs(void) { return m_otherMsgs; } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 158 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 159 | string GetFailureMsg(void) { return m_failureMsg; } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 160 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 161 | VkBool32 DesiredMsgFound(void) { return m_msgFound; } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 162 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 163 | void SetBailout(bool *bailout) { m_bailout = bailout; } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 164 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 165 | void DumpFailureMsgs(void) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 166 | vector<string> otherMsgs = GetOtherFailureMsgs(); |
| 167 | cout << "Other error messages logged for this test were:" << endl; |
| 168 | for (auto iter = otherMsgs.begin(); iter != otherMsgs.end(); iter++) { |
| 169 | cout << " " << *iter << endl; |
| 170 | } |
| 171 | } |
| 172 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 173 | /* helpers */ |
| 174 | |
| 175 | void ExpectSuccess() { |
| 176 | // match anything |
| 177 | SetDesiredFailureMsg(~0u, ""); |
| 178 | } |
| 179 | |
| 180 | void VerifyFound() { |
| 181 | // Not seeing the desired message is a failure. /Before/ throwing, dump |
| 182 | // any other messages. |
| 183 | if (!DesiredMsgFound()) { |
| 184 | DumpFailureMsgs(); |
| 185 | FAIL() << "Did not receive expected error '" << m_desiredMsg << "'"; |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | void VerifyNotFound() { |
| 190 | // ExpectSuccess() configured us to match anything. Any error is a |
| 191 | // failure. |
| 192 | if (DesiredMsgFound()) { |
| 193 | DumpFailureMsgs(); |
| 194 | FAIL() << "Expected to succeed but got error: " << GetFailureMsg(); |
| 195 | } |
| 196 | } |
| 197 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 198 | private: |
| 199 | VkFlags m_msgFlags; |
| 200 | string m_desiredMsg; |
| 201 | string m_failureMsg; |
| 202 | vector<string> m_otherMsgs; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 203 | test_platform_thread_mutex m_mutex; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 204 | bool *m_bailout; |
| 205 | VkBool32 m_msgFound; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 206 | }; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 207 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 208 | static VKAPI_ATTR VkBool32 VKAPI_CALL |
| 209 | myDbgFunc(VkFlags msgFlags, VkDebugReportObjectTypeEXT objType, |
| 210 | uint64_t srcObject, size_t location, int32_t msgCode, |
| 211 | const char *pLayerPrefix, const char *pMsg, void *pUserData) { |
| 212 | if (msgFlags & |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 213 | (VK_DEBUG_REPORT_WARNING_BIT_EXT | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 214 | VK_DEBUG_REPORT_ERROR_BIT_EXT)) { |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 215 | ErrorMonitor *errMonitor = (ErrorMonitor *)pUserData; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 216 | return errMonitor->CheckForDesiredMsg(msgFlags, pMsg); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 217 | } |
Courtney Goeltzenleuchter | 0664083 | 2015-09-04 13:52:24 -0600 | [diff] [blame] | 218 | return false; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 219 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 220 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 221 | class VkLayerTest : public VkRenderFramework { |
| 222 | public: |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 223 | VkResult BeginCommandBuffer(VkCommandBufferObj &commandBuffer); |
| 224 | VkResult EndCommandBuffer(VkCommandBufferObj &commandBuffer); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 225 | void VKTriangleTest(const char *vertShaderText, const char *fragShaderText, |
| 226 | BsoFailSelect failMask); |
| 227 | void GenericDrawPreparation(VkCommandBufferObj *commandBuffer, |
| 228 | VkPipelineObj &pipelineobj, |
| 229 | VkDescriptorSetObj &descriptorSet, |
| 230 | BsoFailSelect failMask); |
| 231 | void GenericDrawPreparation(VkPipelineObj &pipelineobj, |
| 232 | VkDescriptorSetObj &descriptorSet, |
| 233 | BsoFailSelect failMask) { |
| 234 | GenericDrawPreparation(m_commandBuffer, pipelineobj, descriptorSet, |
| 235 | failMask); |
| 236 | } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 237 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 238 | /* Convenience functions that use built-in command buffer */ |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 239 | VkResult BeginCommandBuffer() { |
| 240 | return BeginCommandBuffer(*m_commandBuffer); |
| 241 | } |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 242 | VkResult EndCommandBuffer() { return EndCommandBuffer(*m_commandBuffer); } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 243 | void Draw(uint32_t vertexCount, uint32_t instanceCount, |
| 244 | uint32_t firstVertex, uint32_t firstInstance) { |
| 245 | m_commandBuffer->Draw(vertexCount, instanceCount, firstVertex, |
| 246 | firstInstance); |
| 247 | } |
| 248 | void DrawIndexed(uint32_t indexCount, uint32_t instanceCount, |
| 249 | uint32_t firstIndex, int32_t vertexOffset, |
| 250 | uint32_t firstInstance) { |
| 251 | m_commandBuffer->DrawIndexed(indexCount, instanceCount, firstIndex, |
| 252 | vertexOffset, firstInstance); |
| 253 | } |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 254 | void QueueCommandBuffer() { m_commandBuffer->QueueCommandBuffer(); } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 255 | void QueueCommandBuffer(const VkFence &fence) { |
| 256 | m_commandBuffer->QueueCommandBuffer(fence); |
| 257 | } |
| 258 | void BindVertexBuffer(VkConstantBufferObj *vertexBuffer, |
| 259 | VkDeviceSize offset, uint32_t binding) { |
| 260 | m_commandBuffer->BindVertexBuffer(vertexBuffer, offset, binding); |
| 261 | } |
| 262 | void BindIndexBuffer(VkIndexBufferObj *indexBuffer, VkDeviceSize offset) { |
| 263 | m_commandBuffer->BindIndexBuffer(indexBuffer, offset); |
| 264 | } |
| 265 | |
| 266 | protected: |
| 267 | ErrorMonitor *m_errorMonitor; |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 268 | bool m_enableWSI; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 269 | |
| 270 | virtual void SetUp() { |
Courtney Goeltzenleuchter | cd69eee | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 271 | std::vector<const char *> instance_layer_names; |
| 272 | std::vector<const char *> device_layer_names; |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 273 | std::vector<const char *> instance_extension_names; |
| 274 | std::vector<const char *> device_extension_names; |
Tony Barbour | 3fdff9e | 2015-04-23 12:55:36 -0600 | [diff] [blame] | 275 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 276 | instance_extension_names.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME); |
Courtney Goeltzenleuchter | c2b06fe | 2015-06-16 15:59:11 -0600 | [diff] [blame] | 277 | /* |
| 278 | * Since CreateDbgMsgCallback is an instance level extension call |
| 279 | * any extension / layer that utilizes that feature also needs |
| 280 | * to be enabled at create instance time. |
| 281 | */ |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 282 | // Use Threading layer first to protect others from |
| 283 | // ThreadCommandBufferCollision test |
Courtney Goeltzenleuchter | 7688532 | 2016-02-06 17:11:22 -0700 | [diff] [blame] | 284 | instance_layer_names.push_back("VK_LAYER_GOOGLE_threading"); |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 285 | instance_layer_names.push_back("VK_LAYER_LUNARG_parameter_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 286 | instance_layer_names.push_back("VK_LAYER_LUNARG_object_tracker"); |
Tobin Ehlis | c96f806 | 2016-03-09 16:12:48 -0700 | [diff] [blame] | 287 | instance_layer_names.push_back("VK_LAYER_LUNARG_core_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 288 | instance_layer_names.push_back("VK_LAYER_LUNARG_device_limits"); |
| 289 | instance_layer_names.push_back("VK_LAYER_LUNARG_image"); |
Ian Elliott | e48a138 | 2016-04-28 14:22:58 -0600 | [diff] [blame] | 290 | instance_layer_names.push_back("VK_LAYER_LUNARG_swapchain"); |
Dustin Graves | eaa78cd | 2016-01-26 16:30:22 -0700 | [diff] [blame] | 291 | instance_layer_names.push_back("VK_LAYER_GOOGLE_unique_objects"); |
Courtney Goeltzenleuchter | d971b61 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 292 | |
Courtney Goeltzenleuchter | 7688532 | 2016-02-06 17:11:22 -0700 | [diff] [blame] | 293 | device_layer_names.push_back("VK_LAYER_GOOGLE_threading"); |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 294 | device_layer_names.push_back("VK_LAYER_LUNARG_parameter_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 295 | device_layer_names.push_back("VK_LAYER_LUNARG_object_tracker"); |
Tobin Ehlis | c96f806 | 2016-03-09 16:12:48 -0700 | [diff] [blame] | 296 | device_layer_names.push_back("VK_LAYER_LUNARG_core_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 297 | device_layer_names.push_back("VK_LAYER_LUNARG_device_limits"); |
| 298 | device_layer_names.push_back("VK_LAYER_LUNARG_image"); |
Ian Elliott | e48a138 | 2016-04-28 14:22:58 -0600 | [diff] [blame] | 299 | device_layer_names.push_back("VK_LAYER_LUNARG_swapchain"); |
Dustin Graves | eaa78cd | 2016-01-26 16:30:22 -0700 | [diff] [blame] | 300 | device_layer_names.push_back("VK_LAYER_GOOGLE_unique_objects"); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 301 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 302 | if (m_enableWSI) { |
| 303 | instance_extension_names.push_back(VK_KHR_SURFACE_EXTENSION_NAME); |
| 304 | device_extension_names.push_back(VK_KHR_SWAPCHAIN_EXTENSION_NAME); |
| 305 | #ifdef NEED_TO_TEST_THIS_ON_PLATFORM |
| 306 | #if defined(VK_USE_PLATFORM_ANDROID_KHR) |
| 307 | instance_extension_names.push_back(VK_KHR_ANDROID_SURFACE_EXTENSION_NAME); |
| 308 | #endif // VK_USE_PLATFORM_ANDROID_KHR |
| 309 | #if defined(VK_USE_PLATFORM_MIR_KHR) |
| 310 | instance_extension_names.push_back(VK_KHR_MIR_SURFACE_EXTENSION_NAME); |
| 311 | #endif // VK_USE_PLATFORM_MIR_KHR |
| 312 | #if defined(VK_USE_PLATFORM_WAYLAND_KHR) |
| 313 | instance_extension_names.push_back(VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME); |
| 314 | #endif // VK_USE_PLATFORM_WAYLAND_KHR |
| 315 | #if defined(VK_USE_PLATFORM_WIN32_KHR) |
| 316 | instance_extension_names.push_back(VK_KHR_WIN32_SURFACE_EXTENSION_NAME); |
| 317 | #endif // VK_USE_PLATFORM_WIN32_KHR |
| 318 | #endif // NEED_TO_TEST_THIS_ON_PLATFORM |
| 319 | #if defined(VK_USE_PLATFORM_XCB_KHR) |
| 320 | instance_extension_names.push_back(VK_KHR_XCB_SURFACE_EXTENSION_NAME); |
| 321 | #elif defined(VK_USE_PLATFORM_XLIB_KHR) |
| 322 | instance_extension_names.push_back(VK_KHR_XLIB_SURFACE_EXTENSION_NAME); |
| 323 | #endif // VK_USE_PLATFORM_XLIB_KHR |
| 324 | } |
| 325 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 326 | this->app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 327 | this->app_info.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 328 | this->app_info.pApplicationName = "layer_tests"; |
| 329 | this->app_info.applicationVersion = 1; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 330 | this->app_info.pEngineName = "unittest"; |
| 331 | this->app_info.engineVersion = 1; |
Jon Ashburn | c5012ff | 2016-03-22 13:57:46 -0600 | [diff] [blame] | 332 | this->app_info.apiVersion = VK_API_VERSION_1_0; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 333 | |
Tony Barbour | 15524c3 | 2015-04-29 17:34:29 -0600 | [diff] [blame] | 334 | m_errorMonitor = new ErrorMonitor; |
Courtney Goeltzenleuchter | cd69eee | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 335 | InitFramework(instance_layer_names, device_layer_names, |
| 336 | instance_extension_names, device_extension_names, |
| 337 | myDbgFunc, m_errorMonitor); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 338 | } |
| 339 | |
| 340 | virtual void TearDown() { |
| 341 | // Clean up resources before we reset |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 342 | ShutdownFramework(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 343 | delete m_errorMonitor; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 344 | } |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 345 | |
| 346 | VkLayerTest() { |
| 347 | m_enableWSI = false; |
| 348 | } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 349 | }; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 350 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 351 | VkResult VkLayerTest::BeginCommandBuffer(VkCommandBufferObj &commandBuffer) { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 352 | VkResult result; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 353 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 354 | result = commandBuffer.BeginCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 355 | |
| 356 | /* |
| 357 | * For render test all drawing happens in a single render pass |
| 358 | * on a single command buffer. |
| 359 | */ |
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 360 | if (VK_SUCCESS == result && renderPass()) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 361 | commandBuffer.BeginRenderPass(renderPassBeginInfo()); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 362 | } |
| 363 | |
| 364 | return result; |
| 365 | } |
| 366 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 367 | VkResult VkLayerTest::EndCommandBuffer(VkCommandBufferObj &commandBuffer) { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 368 | VkResult result; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 369 | |
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 370 | if (renderPass()) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 371 | commandBuffer.EndRenderPass(); |
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 372 | } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 373 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 374 | result = commandBuffer.EndCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 375 | |
| 376 | return result; |
| 377 | } |
| 378 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 379 | void VkLayerTest::VKTriangleTest(const char *vertShaderText, |
| 380 | const char *fragShaderText, |
| 381 | BsoFailSelect failMask) { |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 382 | // Create identity matrix |
| 383 | int i; |
| 384 | struct vktriangle_vs_uniform data; |
| 385 | |
| 386 | glm::mat4 Projection = glm::mat4(1.0f); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 387 | glm::mat4 View = glm::mat4(1.0f); |
| 388 | glm::mat4 Model = glm::mat4(1.0f); |
| 389 | glm::mat4 MVP = Projection * View * Model; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 390 | const int matrixSize = sizeof(MVP); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 391 | const int bufSize = sizeof(vktriangle_vs_uniform) / sizeof(float); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 392 | |
| 393 | memcpy(&data.mvp, &MVP[0][0], matrixSize); |
| 394 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 395 | static const Vertex tri_data[] = { |
| 396 | {XYZ1(-1, -1, 0), XYZ1(1.f, 0.f, 0.f)}, |
| 397 | {XYZ1(1, -1, 0), XYZ1(0.f, 1.f, 0.f)}, |
| 398 | {XYZ1(0, 1, 0), XYZ1(0.f, 0.f, 1.f)}, |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 399 | }; |
| 400 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 401 | for (i = 0; i < 3; i++) { |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 402 | data.position[i][0] = tri_data[i].posX; |
| 403 | data.position[i][1] = tri_data[i].posY; |
| 404 | data.position[i][2] = tri_data[i].posZ; |
| 405 | data.position[i][3] = tri_data[i].posW; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 406 | data.color[i][0] = tri_data[i].r; |
| 407 | data.color[i][1] = tri_data[i].g; |
| 408 | data.color[i][2] = tri_data[i].b; |
| 409 | data.color[i][3] = tri_data[i].a; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 410 | } |
| 411 | |
| 412 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 413 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 414 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 415 | VkConstantBufferObj constantBuffer(m_device, bufSize * 2, sizeof(float), |
| 416 | (const void *)&data); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 417 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 418 | VkShaderObj vs(m_device, vertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 419 | VkShaderObj ps(m_device, fragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, |
| 420 | this); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 421 | |
| 422 | VkPipelineObj pipelineobj(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 423 | pipelineobj.AddColorAttachment(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 424 | pipelineobj.AddShader(&vs); |
| 425 | pipelineobj.AddShader(&ps); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 426 | if (failMask & BsoFailLineWidth) { |
| 427 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_LINE_WIDTH); |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 428 | VkPipelineInputAssemblyStateCreateInfo ia_state = {}; |
| 429 | ia_state.sType = |
| 430 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 431 | ia_state.topology = VK_PRIMITIVE_TOPOLOGY_LINE_LIST; |
| 432 | pipelineobj.SetInputAssembly(&ia_state); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 433 | } |
| 434 | if (failMask & BsoFailDepthBias) { |
| 435 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_DEPTH_BIAS); |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 436 | VkPipelineRasterizationStateCreateInfo rs_state = {}; |
| 437 | rs_state.sType = |
| 438 | VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 439 | rs_state.depthBiasEnable = VK_TRUE; |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 440 | rs_state.lineWidth = 1.0f; |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 441 | pipelineobj.SetRasterization(&rs_state); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 442 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 443 | // Viewport and scissors must stay in synch or other errors will occur than |
| 444 | // the ones we want |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 445 | if (failMask & BsoFailViewport) { |
| 446 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_VIEWPORT); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 447 | m_viewports.clear(); |
| 448 | m_scissors.clear(); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 449 | } |
| 450 | if (failMask & BsoFailScissor) { |
| 451 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_SCISSOR); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 452 | m_scissors.clear(); |
| 453 | m_viewports.clear(); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 454 | } |
| 455 | if (failMask & BsoFailBlend) { |
| 456 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_BLEND_CONSTANTS); |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 457 | VkPipelineColorBlendAttachmentState att_state = {}; |
| 458 | att_state.dstAlphaBlendFactor = VK_BLEND_FACTOR_CONSTANT_COLOR; |
| 459 | att_state.blendEnable = VK_TRUE; |
| 460 | pipelineobj.AddColorAttachment(0, &att_state); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 461 | } |
| 462 | if (failMask & BsoFailDepthBounds) { |
| 463 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_DEPTH_BOUNDS); |
| 464 | } |
| 465 | if (failMask & BsoFailStencilReadMask) { |
| 466 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK); |
| 467 | } |
| 468 | if (failMask & BsoFailStencilWriteMask) { |
| 469 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_WRITE_MASK); |
| 470 | } |
| 471 | if (failMask & BsoFailStencilReference) { |
| 472 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_REFERENCE); |
| 473 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 474 | |
| 475 | VkDescriptorSetObj descriptorSet(m_device); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 476 | descriptorSet.AppendBuffer(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, |
| 477 | constantBuffer); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 478 | |
| 479 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 480 | ASSERT_VK_SUCCESS(BeginCommandBuffer()); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 481 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 482 | GenericDrawPreparation(pipelineobj, descriptorSet, failMask); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 483 | |
| 484 | // render triangle |
Courtney Goeltzenleuchter | 08c2637 | 2015-09-23 12:31:50 -0600 | [diff] [blame] | 485 | Draw(3, 1, 0, 0); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 486 | |
| 487 | // finalize recording of the command buffer |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 488 | EndCommandBuffer(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 489 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 490 | QueueCommandBuffer(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 491 | } |
| 492 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 493 | void VkLayerTest::GenericDrawPreparation(VkCommandBufferObj *commandBuffer, |
| 494 | VkPipelineObj &pipelineobj, |
| 495 | VkDescriptorSetObj &descriptorSet, |
| 496 | BsoFailSelect failMask) { |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 497 | if (m_depthStencil->Initialized()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 498 | commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 499 | m_stencil_clear_color, m_depthStencil); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 500 | } else { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 501 | commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 502 | m_stencil_clear_color, NULL); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 503 | } |
| 504 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 505 | commandBuffer->PrepareAttachments(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 506 | // Make sure depthWriteEnable is set so that Depth fail test will work |
| 507 | // correctly |
| 508 | // Make sure stencilTestEnable is set so that Stencil fail test will work |
| 509 | // correctly |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 510 | VkStencilOpState stencil = {}; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 511 | stencil.failOp = VK_STENCIL_OP_KEEP; |
| 512 | stencil.passOp = VK_STENCIL_OP_KEEP; |
| 513 | stencil.depthFailOp = VK_STENCIL_OP_KEEP; |
| 514 | stencil.compareOp = VK_COMPARE_OP_NEVER; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 515 | |
| 516 | VkPipelineDepthStencilStateCreateInfo ds_ci = {}; |
| 517 | ds_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO; |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 518 | ds_ci.pNext = NULL; |
| 519 | ds_ci.depthTestEnable = VK_FALSE; |
| 520 | ds_ci.depthWriteEnable = VK_TRUE; |
| 521 | ds_ci.depthCompareOp = VK_COMPARE_OP_NEVER; |
| 522 | ds_ci.depthBoundsTestEnable = VK_FALSE; |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 523 | if (failMask & BsoFailDepthBounds) { |
| 524 | ds_ci.depthBoundsTestEnable = VK_TRUE; |
| 525 | } |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 526 | ds_ci.stencilTestEnable = VK_TRUE; |
| 527 | ds_ci.front = stencil; |
| 528 | ds_ci.back = stencil; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 529 | |
Tobin Ehlis | 4bf96d1 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 530 | pipelineobj.SetDepthStencil(&ds_ci); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 531 | pipelineobj.SetViewport(m_viewports); |
| 532 | pipelineobj.SetScissor(m_scissors); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 533 | descriptorSet.CreateVKDescriptorSet(commandBuffer); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 534 | VkResult err = pipelineobj.CreateVKPipeline( |
| 535 | descriptorSet.GetPipelineLayout(), renderPass()); |
Cody Northrop | 29a08f2 | 2015-08-27 10:20:35 -0600 | [diff] [blame] | 536 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 537 | commandBuffer->BindPipeline(pipelineobj); |
| 538 | commandBuffer->BindDescriptorSet(descriptorSet); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 539 | } |
| 540 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 541 | class VkWsiEnabledLayerTest : public VkLayerTest { |
| 542 | public: |
| 543 | protected: |
| 544 | VkWsiEnabledLayerTest() { |
| 545 | m_enableWSI = true; |
| 546 | } |
| 547 | }; |
| 548 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 549 | // ******************************************************************************************************************** |
| 550 | // ******************************************************************************************************************** |
| 551 | // ******************************************************************************************************************** |
| 552 | // ******************************************************************************************************************** |
Dustin Graves | ffa90fa | 2016-05-06 11:20:38 -0600 | [diff] [blame] | 553 | #if PARAMETER_VALIDATION_TESTS |
| 554 | TEST_F(VkLayerTest, RequiredParameter) { |
| 555 | TEST_DESCRIPTION("Specify VK_NULL_HANDLE, NULL, and 0 for required handle, " |
| 556 | "pointer, array, and array count parameters"); |
| 557 | |
| 558 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 559 | |
| 560 | m_errorMonitor->SetDesiredFailureMsg( |
| 561 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 562 | "required parameter pFeatures specified as NULL"); |
| 563 | // Specify NULL for a pointer to a handle |
| 564 | // Expected to trigger an error with |
| 565 | // parameter_validation::validate_required_pointer |
| 566 | vkGetPhysicalDeviceFeatures(gpu(), NULL); |
| 567 | m_errorMonitor->VerifyFound(); |
| 568 | |
| 569 | m_errorMonitor->SetDesiredFailureMsg( |
| 570 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Dustin Graves | a4bb8c1 | 2016-05-16 17:22:51 -0600 | [diff] [blame] | 571 | "required parameter pQueueFamilyPropertyCount specified as NULL"); |
Dustin Graves | ffa90fa | 2016-05-06 11:20:38 -0600 | [diff] [blame] | 572 | // Specify NULL for pointer to array count |
| 573 | // Expected to trigger an error with parameter_validation::validate_array |
Dustin Graves | a4bb8c1 | 2016-05-16 17:22:51 -0600 | [diff] [blame] | 574 | vkGetPhysicalDeviceQueueFamilyProperties(gpu(), NULL, NULL); |
Dustin Graves | ffa90fa | 2016-05-06 11:20:38 -0600 | [diff] [blame] | 575 | m_errorMonitor->VerifyFound(); |
| 576 | |
| 577 | m_errorMonitor->SetDesiredFailureMsg( |
| 578 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 579 | "parameter viewportCount must be greater than 0"); |
| 580 | // Specify 0 for a required array count |
| 581 | // Expected to trigger an error with parameter_validation::validate_array |
| 582 | VkViewport view_port = {}; |
| 583 | m_commandBuffer->SetViewport(0, 0, &view_port); |
| 584 | m_errorMonitor->VerifyFound(); |
| 585 | |
| 586 | m_errorMonitor->SetDesiredFailureMsg( |
| 587 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 588 | "required parameter pViewports specified as NULL"); |
| 589 | // Specify NULL for a required array |
| 590 | // Expected to trigger an error with parameter_validation::validate_array |
| 591 | m_commandBuffer->SetViewport(0, 1, NULL); |
| 592 | m_errorMonitor->VerifyFound(); |
| 593 | |
| 594 | m_errorMonitor->SetDesiredFailureMsg( |
| 595 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 596 | "required parameter memory specified as VK_NULL_HANDLE"); |
| 597 | // Specify VK_NULL_HANDLE for a required handle |
| 598 | // Expected to trigger an error with |
| 599 | // parameter_validation::validate_required_handle |
| 600 | vkUnmapMemory(device(), VK_NULL_HANDLE); |
| 601 | m_errorMonitor->VerifyFound(); |
| 602 | |
| 603 | m_errorMonitor->SetDesiredFailureMsg( |
| 604 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 605 | "required parameter pFences[0] specified as VK_NULL_HANDLE"); |
| 606 | // Specify VK_NULL_HANDLE for a required handle array entry |
| 607 | // Expected to trigger an error with |
| 608 | // parameter_validation::validate_required_handle_array |
| 609 | VkFence fence = VK_NULL_HANDLE; |
| 610 | vkResetFences(device(), 1, &fence); |
| 611 | m_errorMonitor->VerifyFound(); |
| 612 | |
| 613 | m_errorMonitor->SetDesiredFailureMsg( |
| 614 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 615 | "required parameter pAllocateInfo specified as NULL"); |
| 616 | // Specify NULL for a required struct pointer |
| 617 | // Expected to trigger an error with |
| 618 | // parameter_validation::validate_struct_type |
| 619 | VkDeviceMemory memory = VK_NULL_HANDLE; |
| 620 | vkAllocateMemory(device(), NULL, NULL, &memory); |
| 621 | m_errorMonitor->VerifyFound(); |
| 622 | |
| 623 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 624 | "value of faceMask must not be 0"); |
| 625 | // Specify 0 for a required VkFlags parameter |
| 626 | // Expected to trigger an error with parameter_validation::validate_flags |
| 627 | m_commandBuffer->SetStencilReference(0, 0); |
| 628 | m_errorMonitor->VerifyFound(); |
| 629 | |
| 630 | m_errorMonitor->SetDesiredFailureMsg( |
| 631 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 632 | "value of pSubmits[i].pWaitDstStageMask[0] must not be 0"); |
| 633 | // Specify 0 for a required VkFlags array entry |
| 634 | // Expected to trigger an error with |
| 635 | // parameter_validation::validate_flags_array |
| 636 | VkSemaphore semaphore = VK_NULL_HANDLE; |
| 637 | VkPipelineStageFlags stageFlags = 0; |
| 638 | VkSubmitInfo submitInfo = {}; |
| 639 | submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 640 | submitInfo.waitSemaphoreCount = 1; |
| 641 | submitInfo.pWaitSemaphores = &semaphore; |
| 642 | submitInfo.pWaitDstStageMask = &stageFlags; |
| 643 | vkQueueSubmit(m_device->m_queue, 1, &submitInfo, VK_NULL_HANDLE); |
| 644 | m_errorMonitor->VerifyFound(); |
| 645 | } |
Dustin Graves | c99cf5a | 2016-05-09 14:40:29 -0600 | [diff] [blame] | 646 | |
Dustin Graves | fce74c0 | 2016-05-10 11:42:58 -0600 | [diff] [blame] | 647 | TEST_F(VkLayerTest, ReservedParameter) { |
| 648 | TEST_DESCRIPTION("Specify a non-zero value for a reserved parameter"); |
| 649 | |
| 650 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 651 | |
| 652 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 653 | " must be 0"); |
| 654 | // Specify 0 for a reserved VkFlags parameter |
| 655 | // Expected to trigger an error with |
| 656 | // parameter_validation::validate_reserved_flags |
| 657 | VkEvent event_handle = VK_NULL_HANDLE; |
| 658 | VkEventCreateInfo event_info = {}; |
| 659 | event_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 660 | event_info.flags = 1; |
| 661 | vkCreateEvent(device(), &event_info, NULL, &event_handle); |
| 662 | m_errorMonitor->VerifyFound(); |
| 663 | } |
| 664 | |
Dustin Graves | c99cf5a | 2016-05-09 14:40:29 -0600 | [diff] [blame] | 665 | TEST_F(VkLayerTest, InvalidStructSType) { |
| 666 | TEST_DESCRIPTION("Specify an invalid VkStructureType for a Vulkan " |
| 667 | "structure's sType field"); |
| 668 | |
| 669 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 670 | |
| 671 | m_errorMonitor->SetDesiredFailureMsg( |
| 672 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 673 | "parameter pAllocateInfo->sType must be"); |
| 674 | // Zero struct memory, effectively setting sType to |
| 675 | // VK_STRUCTURE_TYPE_APPLICATION_INFO |
| 676 | // Expected to trigger an error with |
| 677 | // parameter_validation::validate_struct_type |
| 678 | VkMemoryAllocateInfo alloc_info = {}; |
| 679 | VkDeviceMemory memory = VK_NULL_HANDLE; |
| 680 | vkAllocateMemory(device(), &alloc_info, NULL, &memory); |
| 681 | m_errorMonitor->VerifyFound(); |
| 682 | |
| 683 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 684 | "parameter pSubmits[0].sType must be"); |
| 685 | // Zero struct memory, effectively setting sType to |
| 686 | // VK_STRUCTURE_TYPE_APPLICATION_INFO |
| 687 | // Expected to trigger an error with |
| 688 | // parameter_validation::validate_struct_type_array |
| 689 | VkSubmitInfo submit_info = {}; |
| 690 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 691 | m_errorMonitor->VerifyFound(); |
| 692 | } |
| 693 | |
| 694 | TEST_F(VkLayerTest, InvalidStructPNext) { |
| 695 | TEST_DESCRIPTION( |
| 696 | "Specify an invalid value for a Vulkan structure's pNext field"); |
| 697 | |
| 698 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 699 | |
| 700 | m_errorMonitor->SetDesiredFailureMsg( |
| 701 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 702 | "value of pAllocateInfo->pNext must be NULL"); |
| 703 | // Set VkMemoryAllocateInfo::pNext to a non-NULL value, when pNext must be |
| 704 | // NULL |
| 705 | // Expected to trigger an error with |
| 706 | // parameter_validation::validate_struct_pnext |
| 707 | VkDeviceMemory memory = VK_NULL_HANDLE; |
| 708 | // Zero-initialization will provide the correct sType |
| 709 | VkApplicationInfo app_info = {}; |
Dustin Graves | 47b6cba | 2016-05-10 17:34:38 -0600 | [diff] [blame] | 710 | VkMemoryAllocateInfo memory_alloc_info = {}; |
| 711 | memory_alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 712 | memory_alloc_info.pNext = &app_info; |
| 713 | vkAllocateMemory(device(), &memory_alloc_info, NULL, &memory); |
Dustin Graves | c99cf5a | 2016-05-09 14:40:29 -0600 | [diff] [blame] | 714 | m_errorMonitor->VerifyFound(); |
| 715 | |
Dustin Graves | 47b6cba | 2016-05-10 17:34:38 -0600 | [diff] [blame] | 716 | m_errorMonitor->SetDesiredFailureMsg( |
| 717 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 718 | " chain includes a structure with unexpected VkStructureType "); |
| 719 | // Set VkGraphicsPipelineCreateInfo::VkPipelineRasterizationStateCreateInfo::pNext to an invalid structure, when pNext is allowed to be a non-NULL value |
| 720 | // Expected to trigger an error with |
| 721 | // parameter_validation::validate_struct_pnext |
| 722 | VkDescriptorPoolSize ds_type_count = {}; |
| 723 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 724 | ds_type_count.descriptorCount = 1; |
| 725 | |
| 726 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 727 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 728 | ds_pool_ci.pNext = NULL; |
| 729 | ds_pool_ci.maxSets = 1; |
| 730 | ds_pool_ci.poolSizeCount = 1; |
| 731 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 732 | |
| 733 | VkDescriptorPool ds_pool; |
| 734 | VkResult err = |
| 735 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 736 | ASSERT_VK_SUCCESS(err); |
| 737 | |
| 738 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 739 | dsl_binding.binding = 0; |
| 740 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 741 | dsl_binding.descriptorCount = 1; |
| 742 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 743 | dsl_binding.pImmutableSamplers = NULL; |
| 744 | |
| 745 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 746 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 747 | ds_layout_ci.pNext = NULL; |
| 748 | ds_layout_ci.bindingCount = 1; |
| 749 | ds_layout_ci.pBindings = &dsl_binding; |
| 750 | |
| 751 | VkDescriptorSetLayout ds_layout; |
| 752 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 753 | &ds_layout); |
| 754 | ASSERT_VK_SUCCESS(err); |
| 755 | |
| 756 | VkDescriptorSet descriptorSet; |
| 757 | VkDescriptorSetAllocateInfo ds_alloc_info = {}; |
| 758 | ds_alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 759 | ds_alloc_info.descriptorSetCount = 1; |
| 760 | ds_alloc_info.descriptorPool = ds_pool; |
| 761 | ds_alloc_info.pSetLayouts = &ds_layout; |
| 762 | err = vkAllocateDescriptorSets(m_device->device(), &ds_alloc_info, |
| 763 | &descriptorSet); |
| 764 | ASSERT_VK_SUCCESS(err); |
| 765 | |
| 766 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 767 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 768 | pipeline_layout_ci.setLayoutCount = 1; |
| 769 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 770 | |
| 771 | VkPipelineLayout pipeline_layout; |
| 772 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 773 | &pipeline_layout); |
| 774 | ASSERT_VK_SUCCESS(err); |
| 775 | |
| 776 | VkViewport vp = {}; // Just need dummy vp to point to |
| 777 | VkRect2D sc = {}; // dummy scissor to point to |
| 778 | |
| 779 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 780 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 781 | vp_state_ci.scissorCount = 1; |
| 782 | vp_state_ci.pScissors = ≻ |
| 783 | vp_state_ci.viewportCount = 1; |
| 784 | vp_state_ci.pViewports = &vp; |
| 785 | |
| 786 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 787 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 788 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 789 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 790 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 791 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 792 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 793 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 794 | |
| 795 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 796 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 797 | gp_ci.pViewportState = &vp_state_ci; |
| 798 | gp_ci.pRasterizationState = &rs_state_ci; |
| 799 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 800 | gp_ci.layout = pipeline_layout; |
| 801 | gp_ci.renderPass = renderPass(); |
| 802 | |
| 803 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 804 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 805 | pc_ci.initialDataSize = 0; |
| 806 | pc_ci.pInitialData = 0; |
| 807 | |
| 808 | VkPipeline pipeline; |
| 809 | VkPipelineCache pipelineCache; |
| 810 | |
| 811 | err = |
| 812 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 813 | ASSERT_VK_SUCCESS(err); |
| 814 | |
| 815 | // Set VkPipelineRasterizationStateCreateInfo::pNext to an invalid value |
| 816 | VkApplicationInfo invalid_pnext_struct = {}; |
| 817 | rs_state_ci.pNext = &invalid_pnext_struct; |
| 818 | |
| 819 | vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 820 | &gp_ci, NULL, &pipeline); |
| 821 | m_errorMonitor->VerifyFound(); |
Dustin Graves | c99cf5a | 2016-05-09 14:40:29 -0600 | [diff] [blame] | 822 | } |
Dustin Graves | 5d33d53 | 2016-05-09 16:21:12 -0600 | [diff] [blame] | 823 | |
| 824 | TEST_F(VkLayerTest, UnrecognizedValue) { |
| 825 | TEST_DESCRIPTION( |
| 826 | "Specify unrecognized Vulkan enumeration, flags, and VkBool32 values"); |
| 827 | |
| 828 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 829 | |
| 830 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 831 | "does not fall within the begin..end " |
| 832 | "range of the core VkFormat " |
| 833 | "enumeration tokens"); |
| 834 | // Specify an invalid VkFormat value |
| 835 | // Expected to trigger an error with |
| 836 | // parameter_validation::validate_ranged_enum |
| 837 | VkFormatProperties format_properties; |
| 838 | vkGetPhysicalDeviceFormatProperties(gpu(), static_cast<VkFormat>(8000), |
| 839 | &format_properties); |
| 840 | m_errorMonitor->VerifyFound(); |
| 841 | |
| 842 | m_errorMonitor->SetDesiredFailureMsg( |
| 843 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 844 | "contains flag bits that are not recognized members of"); |
| 845 | // Specify an invalid VkFlags bitmask value |
| 846 | // Expected to trigger an error with parameter_validation::validate_flags |
| 847 | VkImageFormatProperties image_format_properties; |
| 848 | vkGetPhysicalDeviceImageFormatProperties( |
| 849 | gpu(), VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_TYPE_2D, |
| 850 | VK_IMAGE_TILING_OPTIMAL, static_cast<VkImageUsageFlags>(1 << 25), 0, |
| 851 | &image_format_properties); |
| 852 | m_errorMonitor->VerifyFound(); |
| 853 | |
| 854 | m_errorMonitor->SetDesiredFailureMsg( |
| 855 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 856 | "contains flag bits that are not recognized members of"); |
| 857 | // Specify an invalid VkFlags array entry |
| 858 | // Expected to trigger an error with |
| 859 | // parameter_validation::validate_flags_array |
| 860 | VkSemaphore semaphore = VK_NULL_HANDLE; |
| 861 | VkPipelineStageFlags stage_flags = |
| 862 | static_cast<VkPipelineStageFlags>(1 << 25); |
| 863 | VkSubmitInfo submit_info = {}; |
| 864 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 865 | submit_info.waitSemaphoreCount = 1; |
| 866 | submit_info.pWaitSemaphores = &semaphore; |
| 867 | submit_info.pWaitDstStageMask = &stage_flags; |
| 868 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 869 | m_errorMonitor->VerifyFound(); |
| 870 | |
| 871 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, |
| 872 | "is neither VK_TRUE nor VK_FALSE"); |
| 873 | // Specify an invalid VkBool32 value |
| 874 | // Expected to trigger a warning with |
| 875 | // parameter_validation::validate_bool32 |
| 876 | VkSampler sampler = VK_NULL_HANDLE; |
| 877 | VkSamplerCreateInfo sampler_info = {}; |
| 878 | sampler_info.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 879 | sampler_info.pNext = NULL; |
| 880 | sampler_info.magFilter = VK_FILTER_NEAREST; |
| 881 | sampler_info.minFilter = VK_FILTER_NEAREST; |
| 882 | sampler_info.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 883 | sampler_info.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 884 | sampler_info.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 885 | sampler_info.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 886 | sampler_info.mipLodBias = 1.0; |
| 887 | sampler_info.maxAnisotropy = 1; |
| 888 | sampler_info.compareEnable = VK_FALSE; |
| 889 | sampler_info.compareOp = VK_COMPARE_OP_NEVER; |
| 890 | sampler_info.minLod = 1.0; |
| 891 | sampler_info.maxLod = 1.0; |
| 892 | sampler_info.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 893 | sampler_info.unnormalizedCoordinates = VK_FALSE; |
| 894 | // Not VK_TRUE or VK_FALSE |
| 895 | sampler_info.anisotropyEnable = 3; |
| 896 | vkCreateSampler(m_device->device(), &sampler_info, NULL, &sampler); |
| 897 | m_errorMonitor->VerifyFound(); |
| 898 | } |
Dustin Graves | fce74c0 | 2016-05-10 11:42:58 -0600 | [diff] [blame] | 899 | |
| 900 | TEST_F(VkLayerTest, FailedReturnValue) { |
| 901 | TEST_DESCRIPTION("Check for a message describing a VkResult failure code"); |
| 902 | |
| 903 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 904 | |
Dustin Graves | 13c1e2b | 2016-05-16 15:31:02 -0600 | [diff] [blame] | 905 | // Find an unsupported image format |
| 906 | VkFormat unsupported = VK_FORMAT_UNDEFINED; |
| 907 | for (int f = VK_FORMAT_BEGIN_RANGE; f <= VK_FORMAT_END_RANGE; f++) { |
| 908 | VkFormat format = static_cast<VkFormat>(f); |
| 909 | VkFormatProperties fProps = m_device->format_properties(format); |
| 910 | if (format != VK_FORMAT_UNDEFINED && fProps.linearTilingFeatures == 0 && |
| 911 | fProps.optimalTilingFeatures == 0) { |
| 912 | unsupported = format; |
| 913 | break; |
| 914 | } |
| 915 | } |
| 916 | |
| 917 | if (unsupported != VK_FORMAT_UNDEFINED) { |
| 918 | m_errorMonitor->SetDesiredFailureMsg( |
| 919 | VK_DEBUG_REPORT_WARNING_BIT_EXT, |
| 920 | "the requested format is not supported on this device"); |
| 921 | // Specify an unsupported VkFormat value to generate a |
| 922 | // VK_ERROR_FORMAT_NOT_SUPPORTED return code |
| 923 | // Expected to trigger a warning from |
| 924 | // parameter_validation::validate_result |
| 925 | VkImageFormatProperties image_format_properties; |
| 926 | VkResult err = vkGetPhysicalDeviceImageFormatProperties( |
| 927 | gpu(), unsupported, VK_IMAGE_TYPE_2D, VK_IMAGE_TILING_OPTIMAL, |
| 928 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, 0, &image_format_properties); |
| 929 | ASSERT_TRUE(err == VK_ERROR_FORMAT_NOT_SUPPORTED); |
| 930 | m_errorMonitor->VerifyFound(); |
| 931 | } |
Dustin Graves | fce74c0 | 2016-05-10 11:42:58 -0600 | [diff] [blame] | 932 | } |
Dustin Graves | ffa90fa | 2016-05-06 11:20:38 -0600 | [diff] [blame] | 933 | #endif // PARAMETER_VALIDATION_TESTS |
| 934 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 935 | #if MEM_TRACKER_TESTS |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 936 | #if 0 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 937 | TEST_F(VkLayerTest, CallResetCommandBufferBeforeCompletion) |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 938 | { |
| 939 | vk_testing::Fence testFence; |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 940 | VkFenceCreateInfo fenceInfo = {}; |
| 941 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 942 | fenceInfo.pNext = NULL; |
| 943 | fenceInfo.flags = 0; |
| 944 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 945 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "Resetting CB"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 946 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 947 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tony Barbour | c1eb1a5 | 2015-07-20 13:00:10 -0600 | [diff] [blame] | 948 | |
| 949 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 950 | vk_testing::Buffer buffer; |
| 951 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 952 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 953 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 954 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 4, 0x11111111); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 955 | EndCommandBuffer(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 956 | |
| 957 | testFence.init(*m_device, fenceInfo); |
| 958 | |
| 959 | // Bypass framework since it does the waits automatically |
| 960 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 961 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 962 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 963 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 964 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 965 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 966 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 967 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 968 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 969 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 970 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 971 | |
| 972 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 973 | ASSERT_VK_SUCCESS( err ); |
| 974 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 975 | // Introduce failure by calling begin again before checking fence |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 976 | vkResetCommandBuffer(m_commandBuffer->handle(), 0); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 977 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 978 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 979 | } |
| 980 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 981 | TEST_F(VkLayerTest, CallBeginCommandBufferBeforeCompletion) |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 982 | { |
| 983 | vk_testing::Fence testFence; |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 984 | VkFenceCreateInfo fenceInfo = {}; |
| 985 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 986 | fenceInfo.pNext = NULL; |
| 987 | fenceInfo.flags = 0; |
| 988 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 989 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "Calling vkBeginCommandBuffer() on active CB"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 990 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 991 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 992 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 993 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 994 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 995 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 996 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, m_stencil_clear_color, NULL); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 997 | EndCommandBuffer(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 998 | |
| 999 | testFence.init(*m_device, fenceInfo); |
| 1000 | |
| 1001 | // Bypass framework since it does the waits automatically |
| 1002 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1003 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 1004 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1005 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1006 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1007 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 1008 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1009 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1010 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1011 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1012 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 1013 | |
| 1014 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1015 | ASSERT_VK_SUCCESS( err ); |
| 1016 | |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 1017 | VkCommandBufferInheritanceInfo hinfo = {}; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1018 | VkCommandBufferBeginInfo info = {}; |
| 1019 | info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
| 1020 | info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1021 | info.renderPass = VK_NULL_HANDLE; |
| 1022 | info.subpass = 0; |
| 1023 | info.framebuffer = VK_NULL_HANDLE; |
Chia-I Wu | b8d47ae | 2015-11-11 10:18:12 +0800 | [diff] [blame] | 1024 | info.occlusionQueryEnable = VK_FALSE; |
| 1025 | info.queryFlags = 0; |
| 1026 | info.pipelineStatistics = 0; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1027 | |
| 1028 | // Introduce failure by calling BCB again before checking fence |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1029 | vkBeginCommandBuffer(m_commandBuffer->handle(), &info); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1030 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1031 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1032 | } |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1033 | #endif |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1034 | |
Mark Lobodzinski | 152fe25 | 2016-05-03 16:49:15 -0600 | [diff] [blame] | 1035 | // This is a positive test. No failures are expected. |
| 1036 | TEST_F(VkLayerTest, TestAliasedMemoryTracking) { |
| 1037 | VkResult err; |
| 1038 | bool pass; |
| 1039 | |
| 1040 | TEST_DESCRIPTION("Create a buffer, allocate memory, bind memory, destroy " |
| 1041 | "the buffer, create an image, and bind the same memory to " |
| 1042 | "it"); |
| 1043 | |
| 1044 | m_errorMonitor->ExpectSuccess(); |
| 1045 | |
| 1046 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1047 | |
| 1048 | VkBuffer buffer; |
| 1049 | VkImage image; |
| 1050 | VkDeviceMemory mem; |
| 1051 | VkMemoryRequirements mem_reqs; |
| 1052 | |
| 1053 | VkBufferCreateInfo buf_info = {}; |
| 1054 | buf_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 1055 | buf_info.pNext = NULL; |
| 1056 | buf_info.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 1057 | buf_info.size = 256; |
| 1058 | buf_info.queueFamilyIndexCount = 0; |
| 1059 | buf_info.pQueueFamilyIndices = NULL; |
| 1060 | buf_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 1061 | buf_info.flags = 0; |
| 1062 | err = vkCreateBuffer(m_device->device(), &buf_info, NULL, &buffer); |
| 1063 | ASSERT_VK_SUCCESS(err); |
| 1064 | |
| 1065 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &mem_reqs); |
| 1066 | |
| 1067 | VkMemoryAllocateInfo alloc_info = {}; |
| 1068 | alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1069 | alloc_info.pNext = NULL; |
| 1070 | alloc_info.memoryTypeIndex = 0; |
| 1071 | |
| 1072 | // Ensure memory is big enough for both bindings |
| 1073 | alloc_info.allocationSize = 0x10000; |
| 1074 | |
| 1075 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &alloc_info, |
| 1076 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 1077 | if (!pass) { |
| 1078 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 1079 | return; |
| 1080 | } |
| 1081 | |
| 1082 | err = vkAllocateMemory(m_device->device(), &alloc_info, NULL, &mem); |
| 1083 | ASSERT_VK_SUCCESS(err); |
| 1084 | |
| 1085 | uint8_t *pData; |
| 1086 | err = vkMapMemory(m_device->device(), mem, 0, mem_reqs.size, 0, |
| 1087 | (void **)&pData); |
| 1088 | ASSERT_VK_SUCCESS(err); |
| 1089 | |
Mark Lobodzinski | 2abefa9 | 2016-05-05 11:45:57 -0600 | [diff] [blame] | 1090 | memset(pData, 0xCADECADE, static_cast<size_t>(mem_reqs.size)); |
Mark Lobodzinski | 152fe25 | 2016-05-03 16:49:15 -0600 | [diff] [blame] | 1091 | |
| 1092 | vkUnmapMemory(m_device->device(), mem); |
| 1093 | |
| 1094 | err = vkBindBufferMemory(m_device->device(), buffer, mem, 0); |
| 1095 | ASSERT_VK_SUCCESS(err); |
| 1096 | |
| 1097 | // NOW, destroy the buffer. Obviously, the resource no longer occupies this |
| 1098 | // memory. In fact, it was never used by the GPU. |
| 1099 | // Just be be sure, wait for idle. |
| 1100 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 1101 | vkDeviceWaitIdle(m_device->device()); |
| 1102 | |
| 1103 | VkImageCreateInfo image_create_info = {}; |
| 1104 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1105 | image_create_info.pNext = NULL; |
| 1106 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1107 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 1108 | image_create_info.extent.width = 64; |
| 1109 | image_create_info.extent.height = 64; |
| 1110 | image_create_info.extent.depth = 1; |
| 1111 | image_create_info.mipLevels = 1; |
| 1112 | image_create_info.arrayLayers = 1; |
| 1113 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1114 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1115 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_PREINITIALIZED; |
| 1116 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 1117 | image_create_info.queueFamilyIndexCount = 0; |
| 1118 | image_create_info.pQueueFamilyIndices = NULL; |
| 1119 | image_create_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 1120 | image_create_info.flags = 0; |
| 1121 | |
| 1122 | VkMemoryAllocateInfo mem_alloc = {}; |
| 1123 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1124 | mem_alloc.pNext = NULL; |
| 1125 | mem_alloc.allocationSize = 0; |
| 1126 | mem_alloc.memoryTypeIndex = 0; |
| 1127 | |
| 1128 | /* Create a mappable image. It will be the texture if linear images are ok |
| 1129 | * to be textures or it will be the staging image if they are not. |
| 1130 | */ |
| 1131 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 1132 | ASSERT_VK_SUCCESS(err); |
| 1133 | |
| 1134 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
| 1135 | |
| 1136 | mem_alloc.allocationSize = mem_reqs.size; |
| 1137 | |
| 1138 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, |
| 1139 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 1140 | if (!pass) { |
| 1141 | vkDestroyImage(m_device->device(), image, NULL); |
| 1142 | return; |
| 1143 | } |
| 1144 | |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1145 | // VALIDATION FAILURE: |
Mark Lobodzinski | 152fe25 | 2016-05-03 16:49:15 -0600 | [diff] [blame] | 1146 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 1147 | ASSERT_VK_SUCCESS(err); |
| 1148 | |
| 1149 | m_errorMonitor->VerifyNotFound(); |
| 1150 | |
| 1151 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 1152 | vkDestroyImage(m_device->device(), image, NULL); |
| 1153 | } |
| 1154 | |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1155 | TEST_F(VkLayerTest, InvalidMemoryAliasing) { |
| 1156 | TEST_DESCRIPTION("Create a buffer and image, allocate memory, and bind the " |
| 1157 | "buffer and image to memory such that they will alias."); |
| 1158 | VkResult err; |
| 1159 | bool pass; |
| 1160 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1161 | |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1162 | VkBuffer buffer, buffer2; |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1163 | VkImage image; |
| 1164 | VkDeviceMemory mem; // buffer will be bound first |
| 1165 | VkDeviceMemory mem_img; // image bound first |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1166 | VkMemoryRequirements buff_mem_reqs, img_mem_reqs; |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1167 | |
| 1168 | VkBufferCreateInfo buf_info = {}; |
| 1169 | buf_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 1170 | buf_info.pNext = NULL; |
| 1171 | buf_info.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 1172 | buf_info.size = 256; |
| 1173 | buf_info.queueFamilyIndexCount = 0; |
| 1174 | buf_info.pQueueFamilyIndices = NULL; |
| 1175 | buf_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 1176 | buf_info.flags = 0; |
| 1177 | err = vkCreateBuffer(m_device->device(), &buf_info, NULL, &buffer); |
| 1178 | ASSERT_VK_SUCCESS(err); |
| 1179 | |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1180 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &buff_mem_reqs); |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1181 | |
| 1182 | VkImageCreateInfo image_create_info = {}; |
| 1183 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1184 | image_create_info.pNext = NULL; |
| 1185 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1186 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 1187 | image_create_info.extent.width = 64; |
| 1188 | image_create_info.extent.height = 64; |
| 1189 | image_create_info.extent.depth = 1; |
| 1190 | image_create_info.mipLevels = 1; |
| 1191 | image_create_info.arrayLayers = 1; |
| 1192 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1193 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1194 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_PREINITIALIZED; |
| 1195 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 1196 | image_create_info.queueFamilyIndexCount = 0; |
| 1197 | image_create_info.pQueueFamilyIndices = NULL; |
| 1198 | image_create_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 1199 | image_create_info.flags = 0; |
| 1200 | |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1201 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 1202 | ASSERT_VK_SUCCESS(err); |
| 1203 | |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1204 | vkGetImageMemoryRequirements(m_device->device(), image, &img_mem_reqs); |
| 1205 | |
| 1206 | VkMemoryAllocateInfo alloc_info = {}; |
| 1207 | alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1208 | alloc_info.pNext = NULL; |
| 1209 | alloc_info.memoryTypeIndex = 0; |
| 1210 | // Ensure memory is big enough for both bindings |
| 1211 | alloc_info.allocationSize = buff_mem_reqs.size + img_mem_reqs.size; |
| 1212 | pass = m_device->phy().set_memory_type( |
| 1213 | buff_mem_reqs.memoryTypeBits | img_mem_reqs.memoryTypeBits, &alloc_info, |
| 1214 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1215 | if (!pass) { |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1216 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1217 | vkDestroyImage(m_device->device(), image, NULL); |
| 1218 | return; |
| 1219 | } |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1220 | err = vkAllocateMemory(m_device->device(), &alloc_info, NULL, &mem); |
| 1221 | ASSERT_VK_SUCCESS(err); |
| 1222 | err = vkBindBufferMemory(m_device->device(), buffer, mem, 0); |
| 1223 | ASSERT_VK_SUCCESS(err); |
| 1224 | |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1225 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1226 | " is aliased with buffer 0x"); |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1227 | // VALIDATION FAILURE due to image mapping overlapping buffer mapping |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1228 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 1229 | m_errorMonitor->VerifyFound(); |
| 1230 | |
| 1231 | // Now correctly bind image to second mem allocation before incorrectly |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1232 | // aliasing buffer2 |
| 1233 | err = vkCreateBuffer(m_device->device(), &buf_info, NULL, &buffer2); |
| 1234 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1235 | err = vkAllocateMemory(m_device->device(), &alloc_info, NULL, &mem_img); |
| 1236 | ASSERT_VK_SUCCESS(err); |
| 1237 | err = vkBindImageMemory(m_device->device(), image, mem_img, 0); |
| 1238 | ASSERT_VK_SUCCESS(err); |
| 1239 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1240 | " is aliased with image 0x"); |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1241 | err = vkBindBufferMemory(m_device->device(), buffer2, mem_img, 0); |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1242 | m_errorMonitor->VerifyFound(); |
| 1243 | |
| 1244 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
Tobin Ehlis | 077ded3 | 2016-05-12 17:39:13 -0600 | [diff] [blame] | 1245 | vkDestroyBuffer(m_device->device(), buffer2, NULL); |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1246 | vkDestroyImage(m_device->device(), image, NULL); |
| 1247 | vkFreeMemory(m_device->device(), mem, NULL); |
| 1248 | vkFreeMemory(m_device->device(), mem_img, NULL); |
| 1249 | } |
| 1250 | |
Tobin Ehlis | 3537252 | 2016-05-12 08:32:31 -0600 | [diff] [blame] | 1251 | TEST_F(VkLayerTest, InvalidMemoryMapping) { |
| 1252 | TEST_DESCRIPTION("Attempt to map memory in a number of incorrect ways"); |
| 1253 | VkResult err; |
| 1254 | bool pass; |
| 1255 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1256 | |
| 1257 | VkBuffer buffer; |
| 1258 | VkDeviceMemory mem; |
| 1259 | VkMemoryRequirements mem_reqs; |
| 1260 | |
| 1261 | VkBufferCreateInfo buf_info = {}; |
| 1262 | buf_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 1263 | buf_info.pNext = NULL; |
| 1264 | buf_info.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 1265 | buf_info.size = 256; |
| 1266 | buf_info.queueFamilyIndexCount = 0; |
| 1267 | buf_info.pQueueFamilyIndices = NULL; |
| 1268 | buf_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 1269 | buf_info.flags = 0; |
| 1270 | err = vkCreateBuffer(m_device->device(), &buf_info, NULL, &buffer); |
| 1271 | ASSERT_VK_SUCCESS(err); |
| 1272 | |
| 1273 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &mem_reqs); |
| 1274 | VkMemoryAllocateInfo alloc_info = {}; |
| 1275 | alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1276 | alloc_info.pNext = NULL; |
| 1277 | alloc_info.memoryTypeIndex = 0; |
| 1278 | |
| 1279 | // Ensure memory is big enough for both bindings |
| 1280 | static const VkDeviceSize allocation_size = 0x10000; |
| 1281 | alloc_info.allocationSize = allocation_size; |
| 1282 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &alloc_info, |
| 1283 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 1284 | if (!pass) { |
| 1285 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 1286 | return; |
| 1287 | } |
| 1288 | err = vkAllocateMemory(m_device->device(), &alloc_info, NULL, &mem); |
| 1289 | ASSERT_VK_SUCCESS(err); |
| 1290 | |
| 1291 | uint8_t *pData; |
| 1292 | // Attempt to map memory size 0 is invalid |
| 1293 | m_errorMonitor->SetDesiredFailureMsg( |
| 1294 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1295 | "VkMapMemory: Attempting to map memory range of size zero"); |
| 1296 | err = vkMapMemory(m_device->device(), mem, 0, 0, 0, (void **)&pData); |
| 1297 | m_errorMonitor->VerifyFound(); |
| 1298 | // Map memory twice |
| 1299 | err = vkMapMemory(m_device->device(), mem, 0, mem_reqs.size, 0, |
| 1300 | (void **)&pData); |
| 1301 | ASSERT_VK_SUCCESS(err); |
| 1302 | m_errorMonitor->SetDesiredFailureMsg( |
| 1303 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1304 | "VkMapMemory: Attempting to map memory on an already-mapped object "); |
| 1305 | err = vkMapMemory(m_device->device(), mem, 0, mem_reqs.size, 0, |
| 1306 | (void **)&pData); |
| 1307 | m_errorMonitor->VerifyFound(); |
| 1308 | |
| 1309 | // Unmap the memory to avoid re-map error |
| 1310 | vkUnmapMemory(m_device->device(), mem); |
| 1311 | // overstep allocation with VK_WHOLE_SIZE |
| 1312 | m_errorMonitor->SetDesiredFailureMsg( |
| 1313 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1314 | " with size of VK_WHOLE_SIZE oversteps total array size 0x"); |
| 1315 | err = vkMapMemory(m_device->device(), mem, allocation_size + 1, |
| 1316 | VK_WHOLE_SIZE, 0, (void **)&pData); |
| 1317 | m_errorMonitor->VerifyFound(); |
| 1318 | // overstep allocation w/o VK_WHOLE_SIZE |
| 1319 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1320 | " oversteps total array size 0x"); |
| 1321 | err = vkMapMemory(m_device->device(), mem, 1, allocation_size, 0, |
| 1322 | (void **)&pData); |
| 1323 | m_errorMonitor->VerifyFound(); |
| 1324 | // Now error due to unmapping memory that's not mapped |
| 1325 | m_errorMonitor->SetDesiredFailureMsg( |
| 1326 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1327 | "Unmapping Memory without memory being mapped: "); |
| 1328 | vkUnmapMemory(m_device->device(), mem); |
| 1329 | m_errorMonitor->VerifyFound(); |
| 1330 | // Now map memory and cause errors due to flushing invalid ranges |
| 1331 | err = vkMapMemory(m_device->device(), mem, 16, VK_WHOLE_SIZE, 0, |
| 1332 | (void **)&pData); |
| 1333 | ASSERT_VK_SUCCESS(err); |
| 1334 | VkMappedMemoryRange mmr = {}; |
| 1335 | mmr.memory = mem; |
| 1336 | mmr.offset = 15; // Error b/c offset less than offset of mapped mem |
| 1337 | m_errorMonitor->SetDesiredFailureMsg( |
| 1338 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1339 | ") is less than Memory Object's offset ("); |
| 1340 | vkFlushMappedMemoryRanges(m_device->device(), 1, &mmr); |
| 1341 | m_errorMonitor->VerifyFound(); |
| 1342 | // Now flush range that oversteps mapped range |
| 1343 | vkUnmapMemory(m_device->device(), mem); |
| 1344 | err = vkMapMemory(m_device->device(), mem, 0, 256, 0, (void **)&pData); |
| 1345 | ASSERT_VK_SUCCESS(err); |
| 1346 | mmr.offset = 16; |
| 1347 | mmr.size = 256; // flushing bounds (272) exceed mapped bounds (256) |
| 1348 | m_errorMonitor->SetDesiredFailureMsg( |
| 1349 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1350 | ") exceeds the Memory Object's upper-bound ("); |
| 1351 | vkFlushMappedMemoryRanges(m_device->device(), 1, &mmr); |
| 1352 | m_errorMonitor->VerifyFound(); |
| 1353 | |
| 1354 | pass = |
| 1355 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &alloc_info, |
| 1356 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, |
| 1357 | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT); |
| 1358 | if (!pass) { |
| 1359 | vkFreeMemory(m_device->device(), mem, NULL); |
| 1360 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 1361 | return; |
| 1362 | } |
| 1363 | // TODO : If we can get HOST_VISIBLE w/o HOST_COHERENT we can test cases of |
| 1364 | // MEMTRACK_INVALID_MAP in validateAndCopyNoncoherentMemoryToDriver() |
| 1365 | |
| 1366 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 1367 | vkFreeMemory(m_device->device(), mem, NULL); |
| 1368 | } |
| 1369 | |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1370 | TEST_F(VkLayerTest, EnableWsiBeforeUse) { |
| 1371 | VkResult err; |
| 1372 | bool pass; |
| 1373 | |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1374 | // FIXME: After we turn on this code for non-Linux platforms, uncomment the |
| 1375 | // following declaration (which is temporarily being moved below): |
| 1376 | // VkSurfaceKHR surface = VK_NULL_HANDLE; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1377 | VkSwapchainKHR swapchain = VK_NULL_HANDLE; |
| 1378 | VkSwapchainCreateInfoKHR swapchain_create_info = {}; |
| 1379 | uint32_t swapchain_image_count = 0; |
| 1380 | // VkImage swapchain_images[1] = {VK_NULL_HANDLE}; |
| 1381 | uint32_t image_index = 0; |
| 1382 | // VkPresentInfoKHR present_info = {}; |
| 1383 | |
| 1384 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1385 | |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1386 | #ifdef NEED_TO_TEST_THIS_ON_PLATFORM |
| 1387 | #if defined(VK_USE_PLATFORM_ANDROID_KHR) |
| 1388 | // Use the functions from the VK_KHR_android_surface extension without |
| 1389 | // enabling that extension: |
| 1390 | |
| 1391 | // Create a surface: |
| 1392 | VkAndroidSurfaceCreateInfoKHR android_create_info = {}; |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1393 | m_errorMonitor->SetDesiredFailureMsg( |
| 1394 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1395 | "extension was not enabled for this"); |
| 1396 | err = vkCreateAndroidSurfaceKHR(instance(), &android_create_info, NULL, |
| 1397 | &surface); |
| 1398 | pass = (err != VK_SUCCESS); |
| 1399 | ASSERT_TRUE(pass); |
| 1400 | m_errorMonitor->VerifyFound(); |
| 1401 | #endif // VK_USE_PLATFORM_ANDROID_KHR |
| 1402 | |
| 1403 | |
| 1404 | #if defined(VK_USE_PLATFORM_MIR_KHR) |
| 1405 | // Use the functions from the VK_KHR_mir_surface extension without enabling |
| 1406 | // that extension: |
| 1407 | |
| 1408 | // Create a surface: |
| 1409 | VkMirSurfaceCreateInfoKHR mir_create_info = {}; |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1410 | m_errorMonitor->SetDesiredFailureMsg( |
| 1411 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1412 | "extension was not enabled for this"); |
| 1413 | err = vkCreateMirSurfaceKHR(instance(), &mir_create_info, NULL, &surface); |
| 1414 | pass = (err != VK_SUCCESS); |
| 1415 | ASSERT_TRUE(pass); |
| 1416 | m_errorMonitor->VerifyFound(); |
| 1417 | |
| 1418 | // Tell whether an mir_connection supports presentation: |
| 1419 | MirConnection *mir_connection = NULL; |
| 1420 | m_errorMonitor->SetDesiredFailureMsg( |
| 1421 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1422 | "extension was not enabled for this"); |
| 1423 | vkGetPhysicalDeviceMirPresentationSupportKHR(gpu(), 0, mir_connection, |
| 1424 | visual_id); |
| 1425 | m_errorMonitor->VerifyFound(); |
| 1426 | #endif // VK_USE_PLATFORM_MIR_KHR |
| 1427 | |
| 1428 | |
| 1429 | #if defined(VK_USE_PLATFORM_WAYLAND_KHR) |
| 1430 | // Use the functions from the VK_KHR_wayland_surface extension without |
| 1431 | // enabling that extension: |
| 1432 | |
| 1433 | // Create a surface: |
| 1434 | VkWaylandSurfaceCreateInfoKHR wayland_create_info = {}; |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1435 | m_errorMonitor->SetDesiredFailureMsg( |
| 1436 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1437 | "extension was not enabled for this"); |
| 1438 | err = vkCreateWaylandSurfaceKHR(instance(), &wayland_create_info, NULL, |
| 1439 | &surface); |
| 1440 | pass = (err != VK_SUCCESS); |
| 1441 | ASSERT_TRUE(pass); |
| 1442 | m_errorMonitor->VerifyFound(); |
| 1443 | |
| 1444 | // Tell whether an wayland_display supports presentation: |
| 1445 | struct wl_display wayland_display = {}; |
| 1446 | m_errorMonitor->SetDesiredFailureMsg( |
| 1447 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1448 | "extension was not enabled for this"); |
| 1449 | vkGetPhysicalDeviceWaylandPresentationSupportKHR(gpu(), 0, |
| 1450 | &wayland_display); |
| 1451 | m_errorMonitor->VerifyFound(); |
| 1452 | #endif // VK_USE_PLATFORM_WAYLAND_KHR |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1453 | #endif // NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1454 | |
| 1455 | |
| 1456 | #if defined(VK_USE_PLATFORM_WIN32_KHR) |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1457 | // FIXME: REMOVE THIS HERE, AND UNCOMMENT ABOVE, WHEN THIS TEST HAS BEEN PORTED |
| 1458 | // TO NON-LINUX PLATFORMS: |
| 1459 | VkSurfaceKHR surface = VK_NULL_HANDLE; |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1460 | // Use the functions from the VK_KHR_win32_surface extension without |
| 1461 | // enabling that extension: |
| 1462 | |
| 1463 | // Create a surface: |
| 1464 | VkWin32SurfaceCreateInfoKHR win32_create_info = {}; |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1465 | m_errorMonitor->SetDesiredFailureMsg( |
| 1466 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1467 | "extension was not enabled for this"); |
| 1468 | err = vkCreateWin32SurfaceKHR(instance(), &win32_create_info, NULL, |
| 1469 | &surface); |
| 1470 | pass = (err != VK_SUCCESS); |
| 1471 | ASSERT_TRUE(pass); |
| 1472 | m_errorMonitor->VerifyFound(); |
| 1473 | |
| 1474 | // Tell whether win32 supports presentation: |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1475 | m_errorMonitor->SetDesiredFailureMsg( |
| 1476 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1477 | "extension was not enabled for this"); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1478 | vkGetPhysicalDeviceWin32PresentationSupportKHR(gpu(), 0); |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1479 | m_errorMonitor->VerifyFound(); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1480 | // Set this (for now, until all platforms are supported and tested): |
| 1481 | #define NEED_TO_TEST_THIS_ON_PLATFORM |
| 1482 | #endif // VK_USE_PLATFORM_WIN32_KHR |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1483 | |
| 1484 | |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1485 | #if defined(VK_USE_PLATFORM_XCB_KHR) |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1486 | // FIXME: REMOVE THIS HERE, AND UNCOMMENT ABOVE, WHEN THIS TEST HAS BEEN PORTED |
| 1487 | // TO NON-LINUX PLATFORMS: |
| 1488 | VkSurfaceKHR surface = VK_NULL_HANDLE; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1489 | // Use the functions from the VK_KHR_xcb_surface extension without enabling |
| 1490 | // that extension: |
| 1491 | |
| 1492 | // Create a surface: |
| 1493 | VkXcbSurfaceCreateInfoKHR xcb_create_info = {}; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1494 | m_errorMonitor->SetDesiredFailureMsg( |
| 1495 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1496 | "extension was not enabled for this"); |
| 1497 | err = vkCreateXcbSurfaceKHR(instance(), &xcb_create_info, NULL, &surface); |
| 1498 | pass = (err != VK_SUCCESS); |
| 1499 | ASSERT_TRUE(pass); |
| 1500 | m_errorMonitor->VerifyFound(); |
| 1501 | |
| 1502 | // Tell whether an xcb_visualid_t supports presentation: |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1503 | xcb_connection_t *xcb_connection = NULL; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1504 | xcb_visualid_t visual_id = 0; |
| 1505 | m_errorMonitor->SetDesiredFailureMsg( |
| 1506 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1507 | "extension was not enabled for this"); |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1508 | vkGetPhysicalDeviceXcbPresentationSupportKHR(gpu(), 0, xcb_connection, |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1509 | visual_id); |
| 1510 | m_errorMonitor->VerifyFound(); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1511 | // Set this (for now, until all platforms are supported and tested): |
| 1512 | #define NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1513 | #endif // VK_USE_PLATFORM_XCB_KHR |
| 1514 | |
| 1515 | |
Ian Elliott | 1263081 | 2016-04-29 14:35:43 -0600 | [diff] [blame] | 1516 | #if defined(VK_USE_PLATFORM_XLIB_KHR) |
| 1517 | // Use the functions from the VK_KHR_xlib_surface extension without enabling |
| 1518 | // that extension: |
| 1519 | |
| 1520 | // Create a surface: |
| 1521 | VkXlibSurfaceCreateInfoKHR xlib_create_info = {}; |
Ian Elliott | 1263081 | 2016-04-29 14:35:43 -0600 | [diff] [blame] | 1522 | m_errorMonitor->SetDesiredFailureMsg( |
| 1523 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1524 | "extension was not enabled for this"); |
| 1525 | err = vkCreateXlibSurfaceKHR(instance(), &xlib_create_info, NULL, &surface); |
| 1526 | pass = (err != VK_SUCCESS); |
| 1527 | ASSERT_TRUE(pass); |
| 1528 | m_errorMonitor->VerifyFound(); |
| 1529 | |
| 1530 | // Tell whether an Xlib VisualID supports presentation: |
| 1531 | Display *dpy = NULL; |
| 1532 | VisualID visual = 0; |
| 1533 | m_errorMonitor->SetDesiredFailureMsg( |
| 1534 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1535 | "extension was not enabled for this"); |
| 1536 | vkGetPhysicalDeviceXlibPresentationSupportKHR(gpu(), 0, dpy, visual); |
| 1537 | m_errorMonitor->VerifyFound(); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1538 | // Set this (for now, until all platforms are supported and tested): |
| 1539 | #define NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1263081 | 2016-04-29 14:35:43 -0600 | [diff] [blame] | 1540 | #endif // VK_USE_PLATFORM_XLIB_KHR |
| 1541 | |
| 1542 | |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1543 | // Use the functions from the VK_KHR_surface extension without enabling |
| 1544 | // that extension: |
| 1545 | |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1546 | #ifdef NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1547 | // Destroy a surface: |
| 1548 | m_errorMonitor->SetDesiredFailureMsg( |
| 1549 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1550 | "extension was not enabled for this"); |
| 1551 | vkDestroySurfaceKHR(instance(), surface, NULL); |
| 1552 | m_errorMonitor->VerifyFound(); |
| 1553 | |
| 1554 | // Check if surface supports presentation: |
| 1555 | VkBool32 supported = false; |
| 1556 | m_errorMonitor->SetDesiredFailureMsg( |
| 1557 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1558 | "extension was not enabled for this"); |
| 1559 | err = vkGetPhysicalDeviceSurfaceSupportKHR(gpu(), 0, surface, &supported); |
| 1560 | pass = (err != VK_SUCCESS); |
| 1561 | ASSERT_TRUE(pass); |
| 1562 | m_errorMonitor->VerifyFound(); |
| 1563 | |
| 1564 | // Check surface capabilities: |
| 1565 | VkSurfaceCapabilitiesKHR capabilities = {}; |
| 1566 | m_errorMonitor->SetDesiredFailureMsg( |
| 1567 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1568 | "extension was not enabled for this"); |
| 1569 | err = vkGetPhysicalDeviceSurfaceCapabilitiesKHR(gpu(), surface, |
| 1570 | &capabilities); |
| 1571 | pass = (err != VK_SUCCESS); |
| 1572 | ASSERT_TRUE(pass); |
| 1573 | m_errorMonitor->VerifyFound(); |
| 1574 | |
| 1575 | // Check surface formats: |
| 1576 | uint32_t format_count = 0; |
| 1577 | VkSurfaceFormatKHR *formats = NULL; |
| 1578 | m_errorMonitor->SetDesiredFailureMsg( |
| 1579 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1580 | "extension was not enabled for this"); |
| 1581 | err = vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, |
| 1582 | &format_count, formats); |
| 1583 | pass = (err != VK_SUCCESS); |
| 1584 | ASSERT_TRUE(pass); |
| 1585 | m_errorMonitor->VerifyFound(); |
| 1586 | |
| 1587 | // Check surface present modes: |
| 1588 | uint32_t present_mode_count = 0; |
| 1589 | VkSurfaceFormatKHR *present_modes = NULL; |
| 1590 | m_errorMonitor->SetDesiredFailureMsg( |
| 1591 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1592 | "extension was not enabled for this"); |
| 1593 | err = vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, |
| 1594 | &present_mode_count, present_modes); |
| 1595 | pass = (err != VK_SUCCESS); |
| 1596 | ASSERT_TRUE(pass); |
| 1597 | m_errorMonitor->VerifyFound(); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1598 | #endif // NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1599 | |
| 1600 | |
| 1601 | // Use the functions from the VK_KHR_swapchain extension without enabling |
| 1602 | // that extension: |
| 1603 | |
| 1604 | // Create a swapchain: |
| 1605 | m_errorMonitor->SetDesiredFailureMsg( |
| 1606 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1607 | "extension was not enabled for this"); |
| 1608 | swapchain_create_info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR; |
| 1609 | swapchain_create_info.pNext = NULL; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1610 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, |
| 1611 | NULL, &swapchain); |
| 1612 | pass = (err != VK_SUCCESS); |
| 1613 | ASSERT_TRUE(pass); |
| 1614 | m_errorMonitor->VerifyFound(); |
| 1615 | |
| 1616 | // Get the images from the swapchain: |
| 1617 | m_errorMonitor->SetDesiredFailureMsg( |
| 1618 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1619 | "extension was not enabled for this"); |
| 1620 | err = vkGetSwapchainImagesKHR(m_device->device(), swapchain, |
| 1621 | &swapchain_image_count, NULL); |
| 1622 | pass = (err != VK_SUCCESS); |
| 1623 | ASSERT_TRUE(pass); |
| 1624 | m_errorMonitor->VerifyFound(); |
| 1625 | |
| 1626 | // Try to acquire an image: |
| 1627 | m_errorMonitor->SetDesiredFailureMsg( |
| 1628 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1629 | "extension was not enabled for this"); |
| 1630 | err = vkAcquireNextImageKHR(m_device->device(), swapchain, 0, |
| 1631 | VK_NULL_HANDLE, VK_NULL_HANDLE, &image_index); |
| 1632 | pass = (err != VK_SUCCESS); |
| 1633 | ASSERT_TRUE(pass); |
| 1634 | m_errorMonitor->VerifyFound(); |
| 1635 | |
| 1636 | // Try to present an image: |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1637 | // |
| 1638 | // NOTE: Currently can't test this because a real swapchain is needed (as |
| 1639 | // opposed to the fake one we created) in order for the layer to lookup the |
| 1640 | // VkDevice used to enable the extension: |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1641 | |
| 1642 | // Destroy the swapchain: |
| 1643 | m_errorMonitor->SetDesiredFailureMsg( |
| 1644 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1645 | "extension was not enabled for this"); |
| 1646 | vkDestroySwapchainKHR(m_device->device(), swapchain, NULL); |
| 1647 | m_errorMonitor->VerifyFound(); |
| 1648 | } |
| 1649 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1650 | TEST_F(VkWsiEnabledLayerTest, TestEnabledWsi) { |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1651 | |
Dustin Graves | 6c6d898 | 2016-05-17 10:09:21 -0600 | [diff] [blame] | 1652 | #if defined(VK_USE_PLATFORM_XCB_KHR) |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1653 | VkSurfaceKHR surface = VK_NULL_HANDLE; |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1654 | |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1655 | VkResult err; |
| 1656 | bool pass; |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1657 | VkSwapchainKHR swapchain = VK_NULL_HANDLE; |
| 1658 | VkSwapchainCreateInfoKHR swapchain_create_info = {}; |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1659 | // uint32_t swapchain_image_count = 0; |
| 1660 | // VkImage swapchain_images[1] = {VK_NULL_HANDLE}; |
| 1661 | // uint32_t image_index = 0; |
| 1662 | // VkPresentInfoKHR present_info = {}; |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1663 | |
| 1664 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1665 | |
| 1666 | // Use the create function from one of the VK_KHR_*_surface extension in |
| 1667 | // order to create a surface, testing all known errors in the process, |
| 1668 | // before successfully creating a surface: |
| 1669 | // First, try to create a surface without a VkXcbSurfaceCreateInfoKHR: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1670 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1671 | "called with NULL pointer"); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1672 | err = vkCreateXcbSurfaceKHR(instance(), NULL, NULL, &surface); |
| 1673 | pass = (err != VK_SUCCESS); |
| 1674 | ASSERT_TRUE(pass); |
| 1675 | m_errorMonitor->VerifyFound(); |
| 1676 | |
| 1677 | // Next, try to create a surface with the wrong |
| 1678 | // VkXcbSurfaceCreateInfoKHR::sType: |
| 1679 | VkXcbSurfaceCreateInfoKHR xcb_create_info = {}; |
| 1680 | xcb_create_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1681 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1682 | "called with the wrong value for"); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1683 | err = vkCreateXcbSurfaceKHR(instance(), &xcb_create_info, NULL, &surface); |
| 1684 | pass = (err != VK_SUCCESS); |
| 1685 | ASSERT_TRUE(pass); |
| 1686 | m_errorMonitor->VerifyFound(); |
| 1687 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1688 | // Create a native window, and then correctly create a surface: |
| 1689 | xcb_connection_t *connection; |
| 1690 | xcb_screen_t *screen; |
| 1691 | xcb_window_t xcb_window; |
| 1692 | xcb_intern_atom_reply_t *atom_wm_delete_window; |
| 1693 | |
| 1694 | const xcb_setup_t *setup; |
| 1695 | xcb_screen_iterator_t iter; |
| 1696 | int scr; |
| 1697 | uint32_t value_mask, value_list[32]; |
| 1698 | int width = 1; |
| 1699 | int height = 1; |
| 1700 | |
| 1701 | connection = xcb_connect(NULL, &scr); |
| 1702 | ASSERT_TRUE(connection != NULL); |
| 1703 | setup = xcb_get_setup(connection); |
| 1704 | iter = xcb_setup_roots_iterator(setup); |
| 1705 | while (scr-- > 0) |
| 1706 | xcb_screen_next(&iter); |
| 1707 | screen = iter.data; |
| 1708 | |
| 1709 | xcb_window = xcb_generate_id(connection); |
| 1710 | |
| 1711 | value_mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK; |
| 1712 | value_list[0] = screen->black_pixel; |
| 1713 | value_list[1] = XCB_EVENT_MASK_KEY_RELEASE | XCB_EVENT_MASK_EXPOSURE | |
| 1714 | XCB_EVENT_MASK_STRUCTURE_NOTIFY; |
| 1715 | |
| 1716 | xcb_create_window(connection, XCB_COPY_FROM_PARENT, xcb_window, |
| 1717 | screen->root, 0, 0, width, height, 0, |
| 1718 | XCB_WINDOW_CLASS_INPUT_OUTPUT, screen->root_visual, |
| 1719 | value_mask, value_list); |
| 1720 | |
| 1721 | /* Magic code that will send notification when window is destroyed */ |
| 1722 | xcb_intern_atom_cookie_t cookie = |
| 1723 | xcb_intern_atom(connection, 1, 12, "WM_PROTOCOLS"); |
| 1724 | xcb_intern_atom_reply_t *reply = |
| 1725 | xcb_intern_atom_reply(connection, cookie, 0); |
| 1726 | |
| 1727 | xcb_intern_atom_cookie_t cookie2 = |
| 1728 | xcb_intern_atom(connection, 0, 16, "WM_DELETE_WINDOW"); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1729 | atom_wm_delete_window = xcb_intern_atom_reply(connection, cookie2, 0); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1730 | xcb_change_property(connection, XCB_PROP_MODE_REPLACE, xcb_window, |
| 1731 | (*reply).atom, 4, 32, 1, |
| 1732 | &(*atom_wm_delete_window).atom); |
| 1733 | free(reply); |
| 1734 | |
| 1735 | xcb_map_window(connection, xcb_window); |
| 1736 | |
| 1737 | // Force the x/y coordinates to 100,100 results are identical in consecutive |
| 1738 | // runs |
| 1739 | const uint32_t coords[] = {100, 100}; |
| 1740 | xcb_configure_window(connection, xcb_window, |
| 1741 | XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, coords); |
| 1742 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1743 | // Finally, try to correctly create a surface: |
| 1744 | xcb_create_info.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR; |
| 1745 | xcb_create_info.pNext = NULL; |
| 1746 | xcb_create_info.flags = 0; |
| 1747 | xcb_create_info.connection = connection; |
| 1748 | xcb_create_info.window = xcb_window; |
| 1749 | err = vkCreateXcbSurfaceKHR(instance(), &xcb_create_info, NULL, &surface); |
| 1750 | pass = (err == VK_SUCCESS); |
| 1751 | ASSERT_TRUE(pass); |
| 1752 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1753 | // Check if surface supports presentation: |
| 1754 | |
| 1755 | // 1st, do so without having queried the queue families: |
| 1756 | VkBool32 supported = false; |
| 1757 | // TODO: Get the following error to come out: |
| 1758 | m_errorMonitor->SetDesiredFailureMsg( |
| 1759 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1760 | "called before calling the vkGetPhysicalDeviceQueueFamilyProperties " |
| 1761 | "function"); |
| 1762 | err = vkGetPhysicalDeviceSurfaceSupportKHR(gpu(), 0, surface, &supported); |
| 1763 | pass = (err != VK_SUCCESS); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1764 | // ASSERT_TRUE(pass); |
| 1765 | // m_errorMonitor->VerifyFound(); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1766 | |
| 1767 | // Next, query a queue family index that's too large: |
| 1768 | m_errorMonitor->SetDesiredFailureMsg( |
| 1769 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1770 | "called with a queueFamilyIndex that is too large"); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1771 | err = vkGetPhysicalDeviceSurfaceSupportKHR(gpu(), 100000, surface, |
| 1772 | &supported); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1773 | pass = (err != VK_SUCCESS); |
| 1774 | ASSERT_TRUE(pass); |
| 1775 | m_errorMonitor->VerifyFound(); |
| 1776 | |
| 1777 | // Finally, do so correctly: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1778 | // FIXME: THIS ISN'T CORRECT--MUST QUERY UNTIL WE FIND A QUEUE FAMILY THAT'S |
| 1779 | // SUPPORTED |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1780 | err = vkGetPhysicalDeviceSurfaceSupportKHR(gpu(), 0, surface, &supported); |
| 1781 | pass = (err == VK_SUCCESS); |
| 1782 | ASSERT_TRUE(pass); |
| 1783 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1784 | // Before proceeding, try to create a swapchain without having called |
| 1785 | // vkGetPhysicalDeviceSurfaceCapabilitiesKHR(): |
| 1786 | swapchain_create_info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR; |
| 1787 | swapchain_create_info.pNext = NULL; |
| 1788 | swapchain_create_info.flags = 0; |
| 1789 | m_errorMonitor->SetDesiredFailureMsg( |
| 1790 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1791 | "called before calling vkGetPhysicalDeviceSurfaceCapabilitiesKHR()."); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1792 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, |
| 1793 | &swapchain); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1794 | pass = (err != VK_SUCCESS); |
| 1795 | ASSERT_TRUE(pass); |
| 1796 | m_errorMonitor->VerifyFound(); |
| 1797 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1798 | // Get the surface capabilities: |
| 1799 | VkSurfaceCapabilitiesKHR surface_capabilities; |
| 1800 | |
| 1801 | // Do so correctly (only error logged by this entrypoint is if the |
| 1802 | // extension isn't enabled): |
| 1803 | err = vkGetPhysicalDeviceSurfaceCapabilitiesKHR(gpu(), surface, |
| 1804 | &surface_capabilities); |
| 1805 | pass = (err == VK_SUCCESS); |
| 1806 | ASSERT_TRUE(pass); |
| 1807 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1808 | // Get the surface formats: |
| 1809 | uint32_t surface_format_count; |
| 1810 | |
| 1811 | // First, try without a pointer to surface_format_count: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1812 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1813 | "called with NULL pointer"); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1814 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, NULL, NULL); |
| 1815 | pass = (err == VK_SUCCESS); |
| 1816 | ASSERT_TRUE(pass); |
| 1817 | m_errorMonitor->VerifyFound(); |
| 1818 | |
| 1819 | // Next, call with a non-NULL pSurfaceFormats, even though we haven't |
| 1820 | // correctly done a 1st try (to get the count): |
| 1821 | m_errorMonitor->SetDesiredFailureMsg( |
| 1822 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1823 | "but no prior positive value has been seen for"); |
| 1824 | surface_format_count = 0; |
| 1825 | vkGetPhysicalDeviceSurfaceFormatsKHR( |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1826 | gpu(), surface, &surface_format_count, |
| 1827 | (VkSurfaceFormatKHR *)&surface_format_count); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1828 | pass = (err == VK_SUCCESS); |
| 1829 | ASSERT_TRUE(pass); |
| 1830 | m_errorMonitor->VerifyFound(); |
| 1831 | |
| 1832 | // Next, correctly do a 1st try (with a NULL pointer to surface_formats): |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1833 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, &surface_format_count, |
| 1834 | NULL); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1835 | pass = (err == VK_SUCCESS); |
| 1836 | ASSERT_TRUE(pass); |
| 1837 | |
| 1838 | // Allocate memory for the correct number of VkSurfaceFormatKHR's: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1839 | VkSurfaceFormatKHR *surface_formats = (VkSurfaceFormatKHR *)malloc( |
| 1840 | surface_format_count * sizeof(VkSurfaceFormatKHR)); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1841 | |
| 1842 | // Next, do a 2nd try with surface_format_count being set too high: |
| 1843 | surface_format_count += 5; |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1844 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1845 | "that is greater than the value"); |
| 1846 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, &surface_format_count, |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1847 | surface_formats); |
| 1848 | pass = (err == VK_SUCCESS); |
| 1849 | ASSERT_TRUE(pass); |
| 1850 | m_errorMonitor->VerifyFound(); |
| 1851 | |
| 1852 | // Finally, do a correct 1st and 2nd try: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1853 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, &surface_format_count, |
| 1854 | NULL); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1855 | pass = (err == VK_SUCCESS); |
| 1856 | ASSERT_TRUE(pass); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1857 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, &surface_format_count, |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1858 | surface_formats); |
| 1859 | pass = (err == VK_SUCCESS); |
| 1860 | ASSERT_TRUE(pass); |
| 1861 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1862 | // Get the surface present modes: |
| 1863 | uint32_t surface_present_mode_count; |
| 1864 | |
| 1865 | // First, try without a pointer to surface_format_count: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1866 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1867 | "called with NULL pointer"); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1868 | vkGetPhysicalDeviceSurfacePresentModesKHR(gpu(), surface, NULL, NULL); |
| 1869 | pass = (err == VK_SUCCESS); |
| 1870 | ASSERT_TRUE(pass); |
| 1871 | m_errorMonitor->VerifyFound(); |
| 1872 | |
| 1873 | // Next, call with a non-NULL VkPresentModeKHR, even though we haven't |
| 1874 | // correctly done a 1st try (to get the count): |
| 1875 | m_errorMonitor->SetDesiredFailureMsg( |
| 1876 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1877 | "but no prior positive value has been seen for"); |
| 1878 | surface_present_mode_count = 0; |
| 1879 | vkGetPhysicalDeviceSurfacePresentModesKHR( |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1880 | gpu(), surface, &surface_present_mode_count, |
| 1881 | (VkPresentModeKHR *)&surface_present_mode_count); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1882 | pass = (err == VK_SUCCESS); |
| 1883 | ASSERT_TRUE(pass); |
| 1884 | m_errorMonitor->VerifyFound(); |
| 1885 | |
| 1886 | // Next, correctly do a 1st try (with a NULL pointer to surface_formats): |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1887 | vkGetPhysicalDeviceSurfacePresentModesKHR( |
| 1888 | gpu(), surface, &surface_present_mode_count, NULL); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1889 | pass = (err == VK_SUCCESS); |
| 1890 | ASSERT_TRUE(pass); |
| 1891 | |
| 1892 | // Allocate memory for the correct number of VkSurfaceFormatKHR's: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1893 | VkPresentModeKHR *surface_present_modes = (VkPresentModeKHR *)malloc( |
| 1894 | surface_present_mode_count * sizeof(VkPresentModeKHR)); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1895 | |
| 1896 | // Next, do a 2nd try with surface_format_count being set too high: |
| 1897 | surface_present_mode_count += 5; |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1898 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1899 | "that is greater than the value"); |
| 1900 | vkGetPhysicalDeviceSurfacePresentModesKHR( |
| 1901 | gpu(), surface, &surface_present_mode_count, surface_present_modes); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1902 | pass = (err == VK_SUCCESS); |
| 1903 | ASSERT_TRUE(pass); |
| 1904 | m_errorMonitor->VerifyFound(); |
| 1905 | |
| 1906 | // Finally, do a correct 1st and 2nd try: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1907 | vkGetPhysicalDeviceSurfacePresentModesKHR( |
| 1908 | gpu(), surface, &surface_present_mode_count, NULL); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1909 | pass = (err == VK_SUCCESS); |
| 1910 | ASSERT_TRUE(pass); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1911 | vkGetPhysicalDeviceSurfacePresentModesKHR( |
| 1912 | gpu(), surface, &surface_present_mode_count, surface_present_modes); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1913 | pass = (err == VK_SUCCESS); |
| 1914 | ASSERT_TRUE(pass); |
| 1915 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1916 | // Create a swapchain: |
| 1917 | |
| 1918 | // First, try without a pointer to swapchain_create_info: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1919 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1920 | "called with NULL pointer"); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1921 | err = vkCreateSwapchainKHR(m_device->device(), NULL, NULL, &swapchain); |
| 1922 | pass = (err != VK_SUCCESS); |
| 1923 | ASSERT_TRUE(pass); |
| 1924 | m_errorMonitor->VerifyFound(); |
| 1925 | |
| 1926 | // Next, call with a non-NULL swapchain_create_info, that has the wrong |
| 1927 | // sType: |
| 1928 | swapchain_create_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1929 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1930 | "called with the wrong value for"); |
| 1931 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, |
| 1932 | &swapchain); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1933 | pass = (err != VK_SUCCESS); |
| 1934 | ASSERT_TRUE(pass); |
| 1935 | m_errorMonitor->VerifyFound(); |
| 1936 | |
| 1937 | // Next, call with a NULL swapchain pointer: |
| 1938 | swapchain_create_info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR; |
| 1939 | swapchain_create_info.pNext = NULL; |
| 1940 | swapchain_create_info.flags = 0; |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1941 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1942 | "called with NULL pointer"); |
| 1943 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, |
| 1944 | NULL); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1945 | pass = (err != VK_SUCCESS); |
| 1946 | ASSERT_TRUE(pass); |
| 1947 | m_errorMonitor->VerifyFound(); |
| 1948 | |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1949 | // TODO: Enhance swapchain layer so that |
| 1950 | // swapchain_create_info.queueFamilyIndexCount is checked against something? |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1951 | |
| 1952 | // Next, call with a queue family index that's too large: |
| 1953 | uint32_t queueFamilyIndex[2] = {100000, 0}; |
| 1954 | swapchain_create_info.imageSharingMode = VK_SHARING_MODE_CONCURRENT; |
| 1955 | swapchain_create_info.queueFamilyIndexCount = 2; |
| 1956 | swapchain_create_info.pQueueFamilyIndices = queueFamilyIndex; |
| 1957 | m_errorMonitor->SetDesiredFailureMsg( |
| 1958 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1959 | "called with a queueFamilyIndex that is too large"); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1960 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, |
| 1961 | &swapchain); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1962 | pass = (err != VK_SUCCESS); |
| 1963 | ASSERT_TRUE(pass); |
| 1964 | m_errorMonitor->VerifyFound(); |
| 1965 | |
| 1966 | // Next, call a queueFamilyIndexCount that's too small for CONCURRENT: |
| 1967 | swapchain_create_info.imageSharingMode = VK_SHARING_MODE_CONCURRENT; |
| 1968 | swapchain_create_info.queueFamilyIndexCount = 1; |
| 1969 | m_errorMonitor->SetDesiredFailureMsg( |
| 1970 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1971 | "but with a bad value(s) for pCreateInfo->queueFamilyIndexCount or " |
| 1972 | "pCreateInfo->pQueueFamilyIndices)."); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1973 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, |
| 1974 | &swapchain); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1975 | pass = (err != VK_SUCCESS); |
| 1976 | ASSERT_TRUE(pass); |
| 1977 | m_errorMonitor->VerifyFound(); |
| 1978 | |
| 1979 | // Next, call with an invalid imageSharingMode: |
| 1980 | swapchain_create_info.imageSharingMode = VK_SHARING_MODE_MAX_ENUM; |
| 1981 | swapchain_create_info.queueFamilyIndexCount = 1; |
| 1982 | m_errorMonitor->SetDesiredFailureMsg( |
| 1983 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1984 | "called with a non-supported pCreateInfo->imageSharingMode (i.e."); |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1985 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, NULL, |
| 1986 | &swapchain); |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1987 | pass = (err != VK_SUCCESS); |
| 1988 | ASSERT_TRUE(pass); |
| 1989 | m_errorMonitor->VerifyFound(); |
| 1990 | // Fix for the future: |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1991 | // FIXME: THIS ISN'T CORRECT--MUST QUERY UNTIL WE FIND A QUEUE FAMILY THAT'S |
| 1992 | // SUPPORTED |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1993 | swapchain_create_info.queueFamilyIndexCount = 0; |
| 1994 | queueFamilyIndex[0] = 0; |
| 1995 | swapchain_create_info.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 1996 | |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 1997 | // TODO: CONTINUE TESTING VALIDATION OF vkCreateSwapchainKHR() ... |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1998 | // Get the images from a swapchain: |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1999 | // Acquire an image from a swapchain: |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2000 | // Present an image to a swapchain: |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2001 | // Destroy the swapchain: |
| 2002 | |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2003 | // TODOs: |
| 2004 | // |
| 2005 | // - Try destroying the device without first destroying the swapchain |
| 2006 | // |
| 2007 | // - Try destroying the device without first destroying the surface |
| 2008 | // |
| 2009 | // - Try destroying the surface without first destroying the swapchain |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2010 | |
| 2011 | // Destroy the surface: |
| 2012 | vkDestroySurfaceKHR(instance(), surface, NULL); |
| 2013 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2014 | // Tear down the window: |
| 2015 | xcb_destroy_window(connection, xcb_window); |
| 2016 | xcb_disconnect(connection); |
| 2017 | |
| 2018 | #else // VK_USE_PLATFORM_XCB_KHR |
Mark Lobodzinski | 085d27a | 2016-05-17 09:34:26 -0600 | [diff] [blame] | 2019 | return; |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 2020 | #endif // VK_USE_PLATFORM_XCB_KHR |
| 2021 | } |
| 2022 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2023 | TEST_F(VkLayerTest, MapMemWithoutHostVisibleBit) { |
| 2024 | VkResult err; |
| 2025 | bool pass; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2026 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2027 | m_errorMonitor->SetDesiredFailureMsg( |
| 2028 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2029 | "Mapping Memory without VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT"); |
| 2030 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2031 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2032 | |
| 2033 | // Create an image, allocate memory, free it, and then try to bind it |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2034 | VkImage image; |
| 2035 | VkDeviceMemory mem; |
| 2036 | VkMemoryRequirements mem_reqs; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2037 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2038 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2039 | const int32_t tex_width = 32; |
| 2040 | const int32_t tex_height = 32; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2041 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2042 | VkImageCreateInfo image_create_info = {}; |
| 2043 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2044 | image_create_info.pNext = NULL; |
| 2045 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2046 | image_create_info.format = tex_format; |
| 2047 | image_create_info.extent.width = tex_width; |
| 2048 | image_create_info.extent.height = tex_height; |
| 2049 | image_create_info.extent.depth = 1; |
| 2050 | image_create_info.mipLevels = 1; |
| 2051 | image_create_info.arrayLayers = 1; |
| 2052 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 2053 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 2054 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 2055 | image_create_info.flags = 0; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2056 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2057 | VkMemoryAllocateInfo mem_alloc = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2058 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2059 | mem_alloc.pNext = NULL; |
| 2060 | mem_alloc.allocationSize = 0; |
| 2061 | // Introduce failure, do NOT set memProps to |
| 2062 | // VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
| 2063 | mem_alloc.memoryTypeIndex = 1; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2064 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2065 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2066 | ASSERT_VK_SUCCESS(err); |
| 2067 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2068 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2069 | |
Mark Lobodzinski | 2306535 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 2070 | mem_alloc.allocationSize = mem_reqs.size; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2071 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2072 | pass = |
| 2073 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0, |
| 2074 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 2075 | if (!pass) { // If we can't find any unmappable memory this test doesn't |
| 2076 | // make sense |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2077 | vkDestroyImage(m_device->device(), image, NULL); |
Tony Barbour | 02fdc7d | 2015-08-04 16:13:01 -0600 | [diff] [blame] | 2078 | return; |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2079 | } |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 2080 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2081 | // allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2082 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2083 | ASSERT_VK_SUCCESS(err); |
| 2084 | |
| 2085 | // Try to bind free memory that has been freed |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 2086 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2087 | ASSERT_VK_SUCCESS(err); |
| 2088 | |
| 2089 | // Map memory as if to initialize the image |
| 2090 | void *mappedAddress = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2091 | err = vkMapMemory(m_device->device(), mem, 0, VK_WHOLE_SIZE, 0, |
| 2092 | &mappedAddress); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2093 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2094 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2095 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2096 | vkDestroyImage(m_device->device(), image, NULL); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2097 | } |
| 2098 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2099 | TEST_F(VkLayerTest, RebindMemory) { |
| 2100 | VkResult err; |
| 2101 | bool pass; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2102 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2103 | m_errorMonitor->SetDesiredFailureMsg( |
| 2104 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2105 | "which has already been bound to mem object"); |
| 2106 | |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2107 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2108 | |
| 2109 | // Create an image, allocate memory, free it, and then try to bind it |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2110 | VkImage image; |
| 2111 | VkDeviceMemory mem1; |
| 2112 | VkDeviceMemory mem2; |
| 2113 | VkMemoryRequirements mem_reqs; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2114 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2115 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2116 | const int32_t tex_width = 32; |
| 2117 | const int32_t tex_height = 32; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2118 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2119 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2120 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 2121 | image_create_info.pNext = NULL; |
| 2122 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2123 | image_create_info.format = tex_format; |
| 2124 | image_create_info.extent.width = tex_width; |
| 2125 | image_create_info.extent.height = tex_height; |
| 2126 | image_create_info.extent.depth = 1; |
| 2127 | image_create_info.mipLevels = 1; |
| 2128 | image_create_info.arrayLayers = 1; |
| 2129 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 2130 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 2131 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 2132 | image_create_info.flags = 0; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2133 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2134 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2135 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 2136 | mem_alloc.pNext = NULL; |
| 2137 | mem_alloc.allocationSize = 0; |
| 2138 | mem_alloc.memoryTypeIndex = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2139 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2140 | // Introduce failure, do NOT set memProps to |
| 2141 | // VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2142 | mem_alloc.memoryTypeIndex = 1; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2143 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2144 | ASSERT_VK_SUCCESS(err); |
| 2145 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2146 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2147 | |
| 2148 | mem_alloc.allocationSize = mem_reqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2149 | pass = |
| 2150 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 2151 | ASSERT_TRUE(pass); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2152 | |
| 2153 | // allocate 2 memory objects |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2154 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem1); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2155 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2156 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem2); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2157 | ASSERT_VK_SUCCESS(err); |
| 2158 | |
| 2159 | // Bind first memory object to Image object |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 2160 | err = vkBindImageMemory(m_device->device(), image, mem1, 0); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2161 | ASSERT_VK_SUCCESS(err); |
| 2162 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2163 | // Introduce validation failure, try to bind a different memory object to |
| 2164 | // the same image object |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 2165 | err = vkBindImageMemory(m_device->device(), image, mem2, 0); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2166 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2167 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2168 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2169 | vkDestroyImage(m_device->device(), image, NULL); |
| 2170 | vkFreeMemory(m_device->device(), mem1, NULL); |
| 2171 | vkFreeMemory(m_device->device(), mem2, NULL); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2172 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2173 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2174 | TEST_F(VkLayerTest, SubmitSignaledFence) { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2175 | vk_testing::Fence testFence; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2176 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2177 | m_errorMonitor->SetDesiredFailureMsg( |
| 2178 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "submitted in SIGNALED state. Fences " |
| 2179 | "must be reset before being submitted"); |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2180 | |
| 2181 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2182 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2183 | fenceInfo.pNext = NULL; |
| 2184 | fenceInfo.flags = VK_FENCE_CREATE_SIGNALED_BIT; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2185 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2186 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2187 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 2188 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2189 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 2190 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2191 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 2192 | m_stencil_clear_color, NULL); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 2193 | EndCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2194 | |
| 2195 | testFence.init(*m_device, fenceInfo); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2196 | |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2197 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 2198 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2199 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2200 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2201 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 2202 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2203 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2204 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2205 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2206 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 2207 | |
| 2208 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2209 | vkQueueWaitIdle(m_device->m_queue); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2210 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2211 | m_errorMonitor->VerifyFound(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2212 | } |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 2213 | // This is a positive test. We used to expect error in this case but spec now |
| 2214 | // allows it |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2215 | TEST_F(VkLayerTest, ResetUnsignaledFence) { |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 2216 | m_errorMonitor->ExpectSuccess(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2217 | vk_testing::Fence testFence; |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2218 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2219 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2220 | fenceInfo.pNext = NULL; |
| 2221 | |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2222 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2223 | testFence.init(*m_device, fenceInfo); |
Chia-I Wu | d9e8e82 | 2015-07-03 11:45:55 +0800 | [diff] [blame] | 2224 | VkFence fences[1] = {testFence.handle()}; |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 2225 | VkResult result = vkResetFences(m_device->device(), 1, fences); |
| 2226 | ASSERT_VK_SUCCESS(result); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2227 | |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 2228 | m_errorMonitor->VerifyNotFound(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2229 | } |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2230 | |
| 2231 | TEST_F(VkLayerTest, InvalidUsageBits) |
| 2232 | { |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2233 | TEST_DESCRIPTION( |
Karl Schultz | b5bc11e | 2016-05-04 08:36:08 -0600 | [diff] [blame] | 2234 | "Specify wrong usage for image then create conflicting view of image " |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2235 | "Initialize buffer with wrong usage then perform copy expecting errors " |
| 2236 | "from both the image and the buffer (2 calls)"); |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2237 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2238 | "Invalid usage flag for image "); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2239 | |
| 2240 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2241 | VkImageObj image(m_device); |
| 2242 | // Initialize image with USAGE_INPUT_ATTACHMENT |
Tobin Ehlis | 8b313c0 | 2016-05-25 15:01:52 -0600 | [diff] [blame] | 2243 | image.init(128, 128, VK_FORMAT_D24_UNORM_S8_UINT, |
Karl Schultz | b5bc11e | 2016-05-04 08:36:08 -0600 | [diff] [blame] | 2244 | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
| 2245 | ASSERT_TRUE(image.initialized()); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2246 | |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2247 | VkImageView dsv; |
| 2248 | VkImageViewCreateInfo dsvci = {}; |
| 2249 | dsvci.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 2250 | dsvci.image = image.handle(); |
| 2251 | dsvci.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 2252 | dsvci.format = VK_FORMAT_D32_SFLOAT_S8_UINT; |
| 2253 | dsvci.subresourceRange.layerCount = 1; |
| 2254 | dsvci.subresourceRange.baseMipLevel = 0; |
| 2255 | dsvci.subresourceRange.levelCount = 1; |
| 2256 | dsvci.subresourceRange.aspectMask = |
| 2257 | VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2258 | |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2259 | // Create a view with depth / stencil aspect for image with different usage |
| 2260 | vkCreateImageView(m_device->device(), &dsvci, NULL, &dsv); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2261 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2262 | m_errorMonitor->VerifyFound(); |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2263 | |
| 2264 | // Initialize buffer with TRANSFER_DST usage |
| 2265 | vk_testing::Buffer buffer; |
| 2266 | VkMemoryPropertyFlags reqs = 0; |
| 2267 | buffer.init_as_dst(*m_device, 128 * 128, reqs); |
| 2268 | VkBufferImageCopy region = {}; |
| 2269 | region.bufferRowLength = 128; |
| 2270 | region.bufferImageHeight = 128; |
| 2271 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 2272 | region.imageSubresource.layerCount = 1; |
| 2273 | region.imageExtent.height = 16; |
| 2274 | region.imageExtent.width = 16; |
| 2275 | region.imageExtent.depth = 1; |
| 2276 | |
| 2277 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2278 | "Invalid usage flag for buffer "); |
| 2279 | // Buffer usage not set to TRANSFER_SRC and image usage not set to |
| 2280 | // TRANSFER_DST |
| 2281 | BeginCommandBuffer(); |
| 2282 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 2283 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 2284 | 1, ®ion); |
| 2285 | m_errorMonitor->VerifyFound(); |
| 2286 | |
| 2287 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2288 | "Invalid usage flag for image "); |
| 2289 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 2290 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 2291 | 1, ®ion); |
| 2292 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2293 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 2294 | #endif // MEM_TRACKER_TESTS |
| 2295 | |
Tobin Ehlis | 4bf96d1 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 2296 | #if OBJ_TRACKER_TESTS |
Mark Lobodzinski | fc5cc66 | 2016-05-02 17:17:41 -0600 | [diff] [blame] | 2297 | |
| 2298 | TEST_F(VkLayerTest, LeakAnObject) { |
| 2299 | VkResult err; |
| 2300 | |
| 2301 | TEST_DESCRIPTION( |
| 2302 | "Create a fence and destroy its device without first destroying the fence."); |
| 2303 | |
| 2304 | // Note that we have to create a new device since destroying the |
| 2305 | // framework's device causes Teardown() to fail and just calling Teardown |
| 2306 | // will destroy the errorMonitor. |
| 2307 | |
| 2308 | m_errorMonitor->SetDesiredFailureMsg( |
| 2309 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2310 | "OBJ ERROR : VK_DEBUG_REPORT_OBJECT_TYPE_FENCE_EXT object"); |
| 2311 | |
| 2312 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2313 | |
| 2314 | const std::vector<VkQueueFamilyProperties> queue_props = |
| 2315 | m_device->queue_props; |
| 2316 | std::vector<VkDeviceQueueCreateInfo> queue_info; |
| 2317 | queue_info.reserve(queue_props.size()); |
| 2318 | std::vector<std::vector<float>> queue_priorities; |
| 2319 | for (uint32_t i = 0; i < (uint32_t)queue_props.size(); i++) { |
| 2320 | VkDeviceQueueCreateInfo qi = {}; |
| 2321 | qi.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO; |
| 2322 | qi.pNext = NULL; |
| 2323 | qi.queueFamilyIndex = i; |
| 2324 | qi.queueCount = queue_props[i].queueCount; |
| 2325 | queue_priorities.emplace_back(qi.queueCount, 0.0f); |
| 2326 | qi.pQueuePriorities = queue_priorities[i].data(); |
| 2327 | queue_info.push_back(qi); |
| 2328 | } |
| 2329 | |
| 2330 | std::vector<const char *> device_layer_names; |
| 2331 | std::vector<const char *> device_extension_names; |
| 2332 | device_layer_names.push_back("VK_LAYER_GOOGLE_threading"); |
| 2333 | device_layer_names.push_back("VK_LAYER_LUNARG_parameter_validation"); |
| 2334 | device_layer_names.push_back("VK_LAYER_LUNARG_object_tracker"); |
| 2335 | device_layer_names.push_back("VK_LAYER_LUNARG_core_validation"); |
| 2336 | device_layer_names.push_back("VK_LAYER_LUNARG_device_limits"); |
| 2337 | device_layer_names.push_back("VK_LAYER_LUNARG_image"); |
| 2338 | device_layer_names.push_back("VK_LAYER_GOOGLE_unique_objects"); |
| 2339 | |
| 2340 | // The sacrificial device object |
| 2341 | VkDevice testDevice; |
| 2342 | VkDeviceCreateInfo device_create_info = {}; |
| 2343 | auto features = m_device->phy().features(); |
| 2344 | device_create_info.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO; |
| 2345 | device_create_info.pNext = NULL; |
| 2346 | device_create_info.queueCreateInfoCount = queue_info.size(); |
| 2347 | device_create_info.pQueueCreateInfos = queue_info.data(); |
| 2348 | device_create_info.enabledLayerCount = device_layer_names.size(); |
| 2349 | device_create_info.ppEnabledLayerNames = device_layer_names.data(); |
| 2350 | device_create_info.pEnabledFeatures = &features; |
| 2351 | err = vkCreateDevice(gpu(), &device_create_info, NULL, &testDevice); |
| 2352 | ASSERT_VK_SUCCESS(err); |
| 2353 | |
| 2354 | VkFence fence; |
| 2355 | VkFenceCreateInfo fence_create_info = {}; |
| 2356 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2357 | fence_create_info.pNext = NULL; |
| 2358 | fence_create_info.flags = 0; |
| 2359 | err = vkCreateFence(testDevice, &fence_create_info, NULL, &fence); |
| 2360 | ASSERT_VK_SUCCESS(err); |
| 2361 | |
| 2362 | // Induce failure by not calling vkDestroyFence |
| 2363 | vkDestroyDevice(testDevice, NULL); |
| 2364 | m_errorMonitor->VerifyFound(); |
| 2365 | } |
| 2366 | |
| 2367 | TEST_F(VkLayerTest, InvalidCommandPoolConsistency) { |
| 2368 | |
| 2369 | TEST_DESCRIPTION("Allocate command buffers from one command pool and " |
| 2370 | "attempt to delete them from another."); |
| 2371 | |
| 2372 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2373 | "FreeCommandBuffers is attempting to free Command Buffer"); |
| 2374 | |
| 2375 | VkCommandPool command_pool_one; |
| 2376 | VkCommandPool command_pool_two; |
| 2377 | |
| 2378 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2379 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2380 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2381 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2382 | |
| 2383 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2384 | &command_pool_one); |
| 2385 | |
| 2386 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2387 | &command_pool_two); |
| 2388 | |
| 2389 | VkCommandBuffer command_buffer[9]; |
| 2390 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2391 | command_buffer_allocate_info.sType = |
| 2392 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2393 | command_buffer_allocate_info.commandPool = command_pool_one; |
| 2394 | command_buffer_allocate_info.commandBufferCount = 9; |
| 2395 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2396 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2397 | command_buffer); |
| 2398 | |
| 2399 | vkFreeCommandBuffers(m_device->device(), command_pool_two, 4, |
| 2400 | &command_buffer[3]); |
| 2401 | |
| 2402 | m_errorMonitor->VerifyFound(); |
| 2403 | |
| 2404 | vkDestroyCommandPool(m_device->device(), command_pool_one, NULL); |
| 2405 | vkDestroyCommandPool(m_device->device(), command_pool_two, NULL); |
| 2406 | } |
| 2407 | |
| 2408 | TEST_F(VkLayerTest, InvalidDescriptorPoolConsistency) { |
| 2409 | VkResult err; |
| 2410 | |
| 2411 | TEST_DESCRIPTION("Allocate descriptor sets from one DS pool and " |
| 2412 | "attempt to delete them from another."); |
| 2413 | |
| 2414 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2415 | "FreeDescriptorSets is attempting to free descriptorSet"); |
| 2416 | |
| 2417 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2418 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2419 | |
| 2420 | VkDescriptorPoolSize ds_type_count = {}; |
| 2421 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 2422 | ds_type_count.descriptorCount = 1; |
| 2423 | |
| 2424 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2425 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2426 | ds_pool_ci.pNext = NULL; |
| 2427 | ds_pool_ci.flags = 0; |
| 2428 | ds_pool_ci.maxSets = 1; |
| 2429 | ds_pool_ci.poolSizeCount = 1; |
| 2430 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 2431 | |
| 2432 | VkDescriptorPool ds_pool_one; |
| 2433 | err = |
| 2434 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool_one); |
| 2435 | ASSERT_VK_SUCCESS(err); |
| 2436 | |
| 2437 | // Create a second descriptor pool |
| 2438 | VkDescriptorPool ds_pool_two; |
| 2439 | err = |
| 2440 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool_two); |
| 2441 | ASSERT_VK_SUCCESS(err); |
| 2442 | |
| 2443 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 2444 | dsl_binding.binding = 0; |
| 2445 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 2446 | dsl_binding.descriptorCount = 1; |
| 2447 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2448 | dsl_binding.pImmutableSamplers = NULL; |
| 2449 | |
| 2450 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2451 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2452 | ds_layout_ci.pNext = NULL; |
| 2453 | ds_layout_ci.bindingCount = 1; |
| 2454 | ds_layout_ci.pBindings = &dsl_binding; |
| 2455 | |
| 2456 | VkDescriptorSetLayout ds_layout; |
| 2457 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2458 | &ds_layout); |
| 2459 | ASSERT_VK_SUCCESS(err); |
| 2460 | |
| 2461 | VkDescriptorSet descriptorSet; |
| 2462 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 2463 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 2464 | alloc_info.descriptorSetCount = 1; |
| 2465 | alloc_info.descriptorPool = ds_pool_one; |
| 2466 | alloc_info.pSetLayouts = &ds_layout; |
| 2467 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 2468 | &descriptorSet); |
| 2469 | ASSERT_VK_SUCCESS(err); |
| 2470 | |
| 2471 | err = vkFreeDescriptorSets(m_device->device(), ds_pool_two, 1, &descriptorSet); |
| 2472 | |
| 2473 | m_errorMonitor->VerifyFound(); |
| 2474 | |
| 2475 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2476 | vkDestroyDescriptorPool(m_device->device(), ds_pool_one, NULL); |
| 2477 | vkDestroyDescriptorPool(m_device->device(), ds_pool_two, NULL); |
| 2478 | } |
| 2479 | |
| 2480 | TEST_F(VkLayerTest, CreateUnknownObject) { |
| 2481 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2482 | "Invalid VkImage Object "); |
| 2483 | |
| 2484 | TEST_DESCRIPTION( |
| 2485 | "Pass an invalid image object handle into a Vulkan API call."); |
| 2486 | |
| 2487 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2488 | |
| 2489 | // Pass bogus handle into GetImageMemoryRequirements |
| 2490 | VkMemoryRequirements mem_reqs; |
| 2491 | uint64_t fakeImageHandle = 0xCADECADE; |
| 2492 | VkImage fauxImage = reinterpret_cast<VkImage &>(fakeImageHandle); |
| 2493 | |
| 2494 | vkGetImageMemoryRequirements(m_device->device(), fauxImage, &mem_reqs); |
| 2495 | |
| 2496 | m_errorMonitor->VerifyFound(); |
| 2497 | } |
| 2498 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2499 | TEST_F(VkLayerTest, PipelineNotBound) { |
| 2500 | VkResult err; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2501 | |
Mark Lobodzinski | fc5cc66 | 2016-05-02 17:17:41 -0600 | [diff] [blame] | 2502 | TEST_DESCRIPTION( |
| 2503 | "Pass in an invalid pipeline object handle into a Vulkan API call."); |
| 2504 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2505 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2506 | "Invalid VkPipeline Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2507 | |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2508 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2509 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2510 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2511 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2512 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2513 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2514 | |
| 2515 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2516 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2517 | ds_pool_ci.pNext = NULL; |
| 2518 | ds_pool_ci.maxSets = 1; |
| 2519 | ds_pool_ci.poolSizeCount = 1; |
| 2520 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2521 | |
| 2522 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2523 | err = |
| 2524 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2525 | ASSERT_VK_SUCCESS(err); |
| 2526 | |
| 2527 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2528 | dsl_binding.binding = 0; |
| 2529 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2530 | dsl_binding.descriptorCount = 1; |
| 2531 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2532 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2533 | |
| 2534 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2535 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2536 | ds_layout_ci.pNext = NULL; |
| 2537 | ds_layout_ci.bindingCount = 1; |
| 2538 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2539 | |
| 2540 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2541 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2542 | &ds_layout); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2543 | ASSERT_VK_SUCCESS(err); |
| 2544 | |
| 2545 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2546 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2547 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2548 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2549 | alloc_info.descriptorPool = ds_pool; |
| 2550 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2551 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 2552 | &descriptorSet); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2553 | ASSERT_VK_SUCCESS(err); |
| 2554 | |
| 2555 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2556 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 2557 | pipeline_layout_ci.pNext = NULL; |
| 2558 | pipeline_layout_ci.setLayoutCount = 1; |
| 2559 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2560 | |
| 2561 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2562 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2563 | &pipeline_layout); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2564 | ASSERT_VK_SUCCESS(err); |
| 2565 | |
Mark Young | ad77905 | 2016-01-06 14:26:04 -0700 | [diff] [blame] | 2566 | VkPipeline badPipeline = (VkPipeline)((size_t)0xbaadb1be); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2567 | |
| 2568 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2569 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 2570 | VK_PIPELINE_BIND_POINT_GRAPHICS, badPipeline); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2571 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2572 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2573 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2574 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2575 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2576 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2577 | } |
| 2578 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2579 | TEST_F(VkLayerTest, BindInvalidMemory) { |
| 2580 | VkResult err; |
| 2581 | bool pass; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2582 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2583 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2584 | "Invalid VkDeviceMemory Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2585 | |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2586 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2587 | |
| 2588 | // Create an image, allocate memory, free it, and then try to bind it |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2589 | VkImage image; |
| 2590 | VkDeviceMemory mem; |
| 2591 | VkMemoryRequirements mem_reqs; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2592 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2593 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2594 | const int32_t tex_width = 32; |
| 2595 | const int32_t tex_height = 32; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2596 | |
| 2597 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2598 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 2599 | image_create_info.pNext = NULL; |
| 2600 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2601 | image_create_info.format = tex_format; |
| 2602 | image_create_info.extent.width = tex_width; |
| 2603 | image_create_info.extent.height = tex_height; |
| 2604 | image_create_info.extent.depth = 1; |
| 2605 | image_create_info.mipLevels = 1; |
| 2606 | image_create_info.arrayLayers = 1; |
| 2607 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 2608 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 2609 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 2610 | image_create_info.flags = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2611 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2612 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2613 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 2614 | mem_alloc.pNext = NULL; |
| 2615 | mem_alloc.allocationSize = 0; |
| 2616 | mem_alloc.memoryTypeIndex = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2617 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2618 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2619 | ASSERT_VK_SUCCESS(err); |
| 2620 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2621 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2622 | |
| 2623 | mem_alloc.allocationSize = mem_reqs.size; |
| 2624 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2625 | pass = |
| 2626 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 2627 | ASSERT_TRUE(pass); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2628 | |
| 2629 | // allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2630 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2631 | ASSERT_VK_SUCCESS(err); |
| 2632 | |
| 2633 | // Introduce validation failure, free memory before binding |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2634 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2635 | |
| 2636 | // Try to bind free memory that has been freed |
| 2637 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 2638 | // This may very well return an error. |
| 2639 | (void)err; |
| 2640 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2641 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2642 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2643 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2644 | } |
| 2645 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2646 | TEST_F(VkLayerTest, BindMemoryToDestroyedObject) { |
| 2647 | VkResult err; |
| 2648 | bool pass; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2649 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2650 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2651 | "Invalid VkImage Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2652 | |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2653 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2654 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2655 | // Create an image object, allocate memory, destroy the object and then try |
| 2656 | // to bind it |
| 2657 | VkImage image; |
| 2658 | VkDeviceMemory mem; |
| 2659 | VkMemoryRequirements mem_reqs; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2660 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2661 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2662 | const int32_t tex_width = 32; |
| 2663 | const int32_t tex_height = 32; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2664 | |
| 2665 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2666 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 2667 | image_create_info.pNext = NULL; |
| 2668 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2669 | image_create_info.format = tex_format; |
| 2670 | image_create_info.extent.width = tex_width; |
| 2671 | image_create_info.extent.height = tex_height; |
| 2672 | image_create_info.extent.depth = 1; |
| 2673 | image_create_info.mipLevels = 1; |
| 2674 | image_create_info.arrayLayers = 1; |
| 2675 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 2676 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 2677 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 2678 | image_create_info.flags = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2679 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2680 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2681 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 2682 | mem_alloc.pNext = NULL; |
| 2683 | mem_alloc.allocationSize = 0; |
| 2684 | mem_alloc.memoryTypeIndex = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2685 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2686 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2687 | ASSERT_VK_SUCCESS(err); |
| 2688 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2689 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2690 | |
| 2691 | mem_alloc.allocationSize = mem_reqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2692 | pass = |
| 2693 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 2694 | ASSERT_TRUE(pass); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2695 | |
| 2696 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2697 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2698 | ASSERT_VK_SUCCESS(err); |
| 2699 | |
| 2700 | // Introduce validation failure, destroy Image object before binding |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2701 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2702 | ASSERT_VK_SUCCESS(err); |
| 2703 | |
| 2704 | // Now Try to bind memory to this destroyed object |
| 2705 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 2706 | // This may very well return an error. |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2707 | (void)err; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2708 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2709 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2710 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2711 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2712 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 2713 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 2714 | #endif // OBJ_TRACKER_TESTS |
| 2715 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 2716 | #if DRAW_STATE_TESTS |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 2717 | |
| 2718 | // This is a positive test. No errors should be generated. |
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 2719 | TEST_F(VkLayerTest, WaitEventThenSet) { |
| 2720 | TEST_DESCRIPTION( |
| 2721 | "Wait on a event then set it after the wait has been submitted."); |
| 2722 | |
| 2723 | if ((m_device->queue_props.empty()) || |
| 2724 | (m_device->queue_props[0].queueCount < 2)) |
| 2725 | return; |
| 2726 | |
| 2727 | m_errorMonitor->ExpectSuccess(); |
| 2728 | |
| 2729 | VkEvent event; |
| 2730 | VkEventCreateInfo event_create_info{}; |
| 2731 | event_create_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 2732 | vkCreateEvent(m_device->device(), &event_create_info, nullptr, &event); |
| 2733 | |
| 2734 | VkCommandPool command_pool; |
| 2735 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2736 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2737 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2738 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2739 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2740 | &command_pool); |
| 2741 | |
| 2742 | VkCommandBuffer command_buffer; |
| 2743 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2744 | command_buffer_allocate_info.sType = |
| 2745 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2746 | command_buffer_allocate_info.commandPool = command_pool; |
| 2747 | command_buffer_allocate_info.commandBufferCount = 1; |
| 2748 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2749 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2750 | &command_buffer); |
| 2751 | |
| 2752 | VkQueue queue = VK_NULL_HANDLE; |
| 2753 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 2754 | 1, &queue); |
| 2755 | |
| 2756 | { |
| 2757 | VkCommandBufferBeginInfo begin_info{}; |
| 2758 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2759 | vkBeginCommandBuffer(command_buffer, &begin_info); |
| 2760 | |
| 2761 | vkCmdWaitEvents(command_buffer, 1, &event, VK_PIPELINE_STAGE_HOST_BIT, |
| 2762 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, nullptr, 0, |
| 2763 | nullptr, 0, nullptr); |
| 2764 | vkCmdResetEvent(command_buffer, event, |
| 2765 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); |
| 2766 | vkEndCommandBuffer(command_buffer); |
| 2767 | } |
| 2768 | { |
| 2769 | VkSubmitInfo submit_info{}; |
| 2770 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2771 | submit_info.commandBufferCount = 1; |
| 2772 | submit_info.pCommandBuffers = &command_buffer; |
| 2773 | submit_info.signalSemaphoreCount = 0; |
| 2774 | submit_info.pSignalSemaphores = nullptr; |
| 2775 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2776 | } |
| 2777 | { vkSetEvent(m_device->device(), event); } |
| 2778 | |
| 2779 | vkQueueWaitIdle(queue); |
| 2780 | |
| 2781 | vkDestroyEvent(m_device->device(), event, nullptr); |
| 2782 | vkFreeCommandBuffers(m_device->device(), command_pool, 1, &command_buffer); |
| 2783 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2784 | |
| 2785 | m_errorMonitor->VerifyNotFound(); |
| 2786 | } |
Michael Lentine | 5627e69 | 2016-05-20 17:45:02 -0500 | [diff] [blame] | 2787 | // This is a positive test. No errors should be generated. |
| 2788 | TEST_F(VkLayerTest, QueryAndCopyMultipleCommandBuffers) { |
| 2789 | TEST_DESCRIPTION( |
| 2790 | "Issue a query and copy from it on a second command buffer."); |
| 2791 | |
| 2792 | if ((m_device->queue_props.empty()) || |
| 2793 | (m_device->queue_props[0].queueCount < 2)) |
| 2794 | return; |
| 2795 | |
| 2796 | m_errorMonitor->ExpectSuccess(); |
| 2797 | |
| 2798 | VkQueryPool query_pool; |
| 2799 | VkQueryPoolCreateInfo query_pool_create_info{}; |
| 2800 | query_pool_create_info.sType = VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO; |
| 2801 | query_pool_create_info.queryType = VK_QUERY_TYPE_TIMESTAMP; |
| 2802 | query_pool_create_info.queryCount = 1; |
| 2803 | vkCreateQueryPool(m_device->device(), &query_pool_create_info, nullptr, |
| 2804 | &query_pool); |
| 2805 | |
| 2806 | VkCommandPool command_pool; |
| 2807 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2808 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2809 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2810 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2811 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2812 | &command_pool); |
| 2813 | |
| 2814 | VkCommandBuffer command_buffer[2]; |
| 2815 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2816 | command_buffer_allocate_info.sType = |
| 2817 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2818 | command_buffer_allocate_info.commandPool = command_pool; |
| 2819 | command_buffer_allocate_info.commandBufferCount = 2; |
| 2820 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2821 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2822 | command_buffer); |
| 2823 | |
| 2824 | VkQueue queue = VK_NULL_HANDLE; |
| 2825 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 2826 | 1, &queue); |
| 2827 | |
| 2828 | uint32_t qfi = 0; |
| 2829 | VkBufferCreateInfo buff_create_info = {}; |
| 2830 | buff_create_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 2831 | buff_create_info.size = 1024; |
| 2832 | buff_create_info.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT; |
| 2833 | buff_create_info.queueFamilyIndexCount = 1; |
| 2834 | buff_create_info.pQueueFamilyIndices = &qfi; |
| 2835 | |
| 2836 | VkResult err; |
| 2837 | VkBuffer buffer; |
| 2838 | err = vkCreateBuffer(m_device->device(), &buff_create_info, NULL, &buffer); |
| 2839 | ASSERT_VK_SUCCESS(err); |
| 2840 | VkMemoryAllocateInfo mem_alloc = {}; |
| 2841 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 2842 | mem_alloc.pNext = NULL; |
| 2843 | mem_alloc.allocationSize = 1024; |
| 2844 | mem_alloc.memoryTypeIndex = 0; |
| 2845 | |
| 2846 | VkMemoryRequirements memReqs; |
| 2847 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &memReqs); |
| 2848 | bool pass = |
| 2849 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &mem_alloc, 0); |
| 2850 | if (!pass) { |
| 2851 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 2852 | return; |
| 2853 | } |
| 2854 | |
| 2855 | VkDeviceMemory mem; |
| 2856 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
| 2857 | ASSERT_VK_SUCCESS(err); |
| 2858 | err = vkBindBufferMemory(m_device->device(), buffer, mem, 0); |
| 2859 | ASSERT_VK_SUCCESS(err); |
| 2860 | |
| 2861 | { |
| 2862 | VkCommandBufferBeginInfo begin_info{}; |
| 2863 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2864 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2865 | |
| 2866 | vkCmdResetQueryPool(command_buffer[0], query_pool, 0, 1); |
| 2867 | vkCmdWriteTimestamp(command_buffer[0], |
| 2868 | VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT, query_pool, 0); |
| 2869 | |
| 2870 | vkEndCommandBuffer(command_buffer[0]); |
| 2871 | |
| 2872 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 2873 | |
| 2874 | vkCmdCopyQueryPoolResults(command_buffer[1], query_pool, 0, 1, buffer, |
| 2875 | 0, 0, 0); |
| 2876 | |
| 2877 | vkEndCommandBuffer(command_buffer[1]); |
| 2878 | } |
| 2879 | { |
| 2880 | VkSubmitInfo submit_info{}; |
| 2881 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2882 | submit_info.commandBufferCount = 2; |
| 2883 | submit_info.pCommandBuffers = command_buffer; |
| 2884 | submit_info.signalSemaphoreCount = 0; |
| 2885 | submit_info.pSignalSemaphores = nullptr; |
| 2886 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2887 | } |
| 2888 | |
| 2889 | vkQueueWaitIdle(queue); |
| 2890 | |
| 2891 | vkDestroyQueryPool(m_device->device(), query_pool, nullptr); |
| 2892 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, command_buffer); |
| 2893 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2894 | |
| 2895 | m_errorMonitor->VerifyNotFound(); |
| 2896 | } |
Michael Lentine | 860b0fe | 2016-05-20 10:14:00 -0500 | [diff] [blame] | 2897 | |
| 2898 | TEST_F(VkLayerTest, ResetEventThenSet) { |
| 2899 | TEST_DESCRIPTION( |
| 2900 | "Reset an event then set it after the reset has been submitted."); |
| 2901 | |
| 2902 | if ((m_device->queue_props.empty()) || |
| 2903 | (m_device->queue_props[0].queueCount < 2)) |
| 2904 | return; |
| 2905 | |
| 2906 | m_errorMonitor->ExpectSuccess(); |
| 2907 | |
| 2908 | VkEvent event; |
| 2909 | VkEventCreateInfo event_create_info{}; |
| 2910 | event_create_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 2911 | vkCreateEvent(m_device->device(), &event_create_info, nullptr, &event); |
| 2912 | |
| 2913 | VkCommandPool command_pool; |
| 2914 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2915 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2916 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2917 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2918 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2919 | &command_pool); |
| 2920 | |
| 2921 | VkCommandBuffer command_buffer; |
| 2922 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2923 | command_buffer_allocate_info.sType = |
| 2924 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2925 | command_buffer_allocate_info.commandPool = command_pool; |
| 2926 | command_buffer_allocate_info.commandBufferCount = 1; |
| 2927 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2928 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2929 | &command_buffer); |
| 2930 | |
| 2931 | VkQueue queue = VK_NULL_HANDLE; |
| 2932 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 2933 | 1, &queue); |
| 2934 | |
| 2935 | { |
| 2936 | VkCommandBufferBeginInfo begin_info{}; |
| 2937 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2938 | vkBeginCommandBuffer(command_buffer, &begin_info); |
| 2939 | |
| 2940 | vkCmdResetEvent(command_buffer, event, |
| 2941 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); |
| 2942 | vkCmdWaitEvents(command_buffer, 1, &event, |
| 2943 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2944 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, nullptr, 0, |
| 2945 | nullptr, 0, nullptr); |
| 2946 | vkEndCommandBuffer(command_buffer); |
| 2947 | } |
| 2948 | { |
| 2949 | VkSubmitInfo submit_info{}; |
| 2950 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2951 | submit_info.commandBufferCount = 1; |
| 2952 | submit_info.pCommandBuffers = &command_buffer; |
| 2953 | submit_info.signalSemaphoreCount = 0; |
| 2954 | submit_info.pSignalSemaphores = nullptr; |
| 2955 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2956 | } |
| 2957 | { |
| 2958 | m_errorMonitor->SetDesiredFailureMsg( |
| 2959 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Cannot call vkSetEvent() on event " |
| 2960 | "0x1 that is already in use by a " |
| 2961 | "command buffer."); |
| 2962 | vkSetEvent(m_device->device(), event); |
| 2963 | m_errorMonitor->VerifyFound(); |
| 2964 | } |
| 2965 | |
| 2966 | vkQueueWaitIdle(queue); |
| 2967 | |
| 2968 | vkDestroyEvent(m_device->device(), event, nullptr); |
| 2969 | vkFreeCommandBuffers(m_device->device(), command_pool, 1, &command_buffer); |
| 2970 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2971 | } |
| 2972 | |
| 2973 | // This is a positive test. No errors should be generated. |
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 2974 | TEST_F(VkLayerTest, TwoFencesThreeFrames) { |
| 2975 | TEST_DESCRIPTION("Two command buffers with two separate fences are each " |
| 2976 | "run through a Submit & WaitForFences cycle 3 times. This " |
| 2977 | "previously revealed a bug so running this positive test " |
| 2978 | "to prevent a regression."); |
| 2979 | m_errorMonitor->ExpectSuccess(); |
| 2980 | |
| 2981 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2982 | VkQueue queue = VK_NULL_HANDLE; |
| 2983 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 2984 | 0, &queue); |
| 2985 | |
| 2986 | static const uint32_t NUM_OBJECTS = 2; |
| 2987 | static const uint32_t NUM_FRAMES = 3; |
| 2988 | VkCommandBuffer cmd_buffers[NUM_OBJECTS] = {}; |
| 2989 | VkFence fences[NUM_OBJECTS] = {}; |
| 2990 | |
| 2991 | VkCommandPool cmd_pool; |
| 2992 | VkCommandPoolCreateInfo cmd_pool_ci = {}; |
| 2993 | cmd_pool_ci.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2994 | cmd_pool_ci.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2995 | cmd_pool_ci.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2996 | VkResult err = vkCreateCommandPool(m_device->device(), &cmd_pool_ci, |
| 2997 | nullptr, &cmd_pool); |
| 2998 | ASSERT_VK_SUCCESS(err); |
| 2999 | |
| 3000 | VkCommandBufferAllocateInfo cmd_buf_info = {}; |
| 3001 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3002 | cmd_buf_info.commandPool = cmd_pool; |
| 3003 | cmd_buf_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3004 | cmd_buf_info.commandBufferCount = 1; |
| 3005 | |
| 3006 | VkFenceCreateInfo fence_ci = {}; |
| 3007 | fence_ci.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3008 | fence_ci.pNext = nullptr; |
| 3009 | fence_ci.flags = 0; |
| 3010 | |
| 3011 | for (uint32_t i = 0; i < NUM_OBJECTS; ++i) { |
| 3012 | err = vkAllocateCommandBuffers(m_device->device(), &cmd_buf_info, |
| 3013 | &cmd_buffers[i]); |
| 3014 | ASSERT_VK_SUCCESS(err); |
| 3015 | err = vkCreateFence(m_device->device(), &fence_ci, nullptr, &fences[i]); |
| 3016 | ASSERT_VK_SUCCESS(err); |
| 3017 | } |
| 3018 | |
| 3019 | for (uint32_t frame = 0; frame < NUM_FRAMES; ++frame) { |
Tobin Ehlis | f902516 | 2016-05-26 06:55:21 -0600 | [diff] [blame] | 3020 | for (uint32_t obj = 0; obj < NUM_OBJECTS; ++obj) { |
| 3021 | // Create empty cmd buffer |
| 3022 | VkCommandBufferBeginInfo cmdBufBeginDesc = {}; |
| 3023 | cmdBufBeginDesc.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 3024 | |
Tobin Ehlis | f902516 | 2016-05-26 06:55:21 -0600 | [diff] [blame] | 3025 | err = vkBeginCommandBuffer(cmd_buffers[obj], &cmdBufBeginDesc); |
| 3026 | ASSERT_VK_SUCCESS(err); |
| 3027 | err = vkEndCommandBuffer(cmd_buffers[obj]); |
| 3028 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 3029 | |
Tobin Ehlis | f902516 | 2016-05-26 06:55:21 -0600 | [diff] [blame] | 3030 | VkSubmitInfo submit_info = {}; |
| 3031 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3032 | submit_info.commandBufferCount = 1; |
| 3033 | submit_info.pCommandBuffers = &cmd_buffers[obj]; |
| 3034 | // Submit cmd buffer and wait for fence |
| 3035 | err = vkQueueSubmit(queue, 1, &submit_info, fences[obj]); |
| 3036 | ASSERT_VK_SUCCESS(err); |
| 3037 | err = vkWaitForFences(m_device->device(), 1, &fences[obj], VK_TRUE, |
| 3038 | UINT64_MAX); |
| 3039 | ASSERT_VK_SUCCESS(err); |
| 3040 | err = vkResetFences(m_device->device(), 1, &fences[obj]); |
| 3041 | ASSERT_VK_SUCCESS(err); |
| 3042 | } |
Tobin Ehlis | 0bb263b | 2016-05-10 12:13:02 -0600 | [diff] [blame] | 3043 | } |
| 3044 | m_errorMonitor->VerifyNotFound(); |
| 3045 | } |
| 3046 | // This is a positive test. No errors should be generated. |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3047 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceQWI) { |
| 3048 | |
| 3049 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 3050 | "submitted on separate queues followed by a QueueWaitIdle."); |
| 3051 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 3052 | if ((m_device->queue_props.empty()) || |
| 3053 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 3054 | return; |
| 3055 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3056 | m_errorMonitor->ExpectSuccess(); |
| 3057 | |
| 3058 | VkSemaphore semaphore; |
| 3059 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 3060 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 3061 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 3062 | &semaphore); |
| 3063 | |
| 3064 | VkCommandPool command_pool; |
| 3065 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3066 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3067 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3068 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3069 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3070 | &command_pool); |
| 3071 | |
| 3072 | VkCommandBuffer command_buffer[2]; |
| 3073 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3074 | command_buffer_allocate_info.sType = |
| 3075 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3076 | command_buffer_allocate_info.commandPool = command_pool; |
| 3077 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3078 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3079 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3080 | command_buffer); |
| 3081 | |
| 3082 | VkQueue queue = VK_NULL_HANDLE; |
| 3083 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 3084 | 1, &queue); |
| 3085 | |
| 3086 | { |
| 3087 | VkCommandBufferBeginInfo begin_info{}; |
| 3088 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3089 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3090 | |
| 3091 | vkCmdPipelineBarrier(command_buffer[0], |
| 3092 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3093 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3094 | 0, nullptr, 0, nullptr); |
| 3095 | |
| 3096 | VkViewport viewport{}; |
| 3097 | viewport.maxDepth = 1.0f; |
| 3098 | viewport.minDepth = 0.0f; |
| 3099 | viewport.width = 512; |
| 3100 | viewport.height = 512; |
| 3101 | viewport.x = 0; |
| 3102 | viewport.y = 0; |
| 3103 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3104 | vkEndCommandBuffer(command_buffer[0]); |
| 3105 | } |
| 3106 | { |
| 3107 | VkCommandBufferBeginInfo begin_info{}; |
| 3108 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3109 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3110 | |
| 3111 | VkViewport viewport{}; |
| 3112 | viewport.maxDepth = 1.0f; |
| 3113 | viewport.minDepth = 0.0f; |
| 3114 | viewport.width = 512; |
| 3115 | viewport.height = 512; |
| 3116 | viewport.x = 0; |
| 3117 | viewport.y = 0; |
| 3118 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3119 | vkEndCommandBuffer(command_buffer[1]); |
| 3120 | } |
| 3121 | { |
| 3122 | VkSubmitInfo submit_info{}; |
| 3123 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3124 | submit_info.commandBufferCount = 1; |
| 3125 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3126 | submit_info.signalSemaphoreCount = 1; |
| 3127 | submit_info.pSignalSemaphores = &semaphore; |
| 3128 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3129 | } |
| 3130 | { |
| 3131 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3132 | VkSubmitInfo submit_info{}; |
| 3133 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3134 | submit_info.commandBufferCount = 1; |
| 3135 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3136 | submit_info.waitSemaphoreCount = 1; |
| 3137 | submit_info.pWaitSemaphores = &semaphore; |
| 3138 | submit_info.pWaitDstStageMask = flags; |
| 3139 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3140 | } |
| 3141 | |
| 3142 | vkQueueWaitIdle(m_device->m_queue); |
| 3143 | |
| 3144 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 3145 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3146 | &command_buffer[0]); |
| 3147 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3148 | |
| 3149 | m_errorMonitor->VerifyNotFound(); |
| 3150 | } |
| 3151 | |
| 3152 | // This is a positive test. No errors should be generated. |
| 3153 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceQWIFence) { |
| 3154 | |
| 3155 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 3156 | "submitted on separate queues, the second having a fence" |
| 3157 | "followed by a QueueWaitIdle."); |
| 3158 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 3159 | if ((m_device->queue_props.empty()) || |
| 3160 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 3161 | return; |
| 3162 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3163 | m_errorMonitor->ExpectSuccess(); |
| 3164 | |
| 3165 | VkFence fence; |
| 3166 | VkFenceCreateInfo fence_create_info{}; |
| 3167 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3168 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3169 | |
| 3170 | VkSemaphore semaphore; |
| 3171 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 3172 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 3173 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 3174 | &semaphore); |
| 3175 | |
| 3176 | VkCommandPool command_pool; |
| 3177 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3178 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3179 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3180 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3181 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3182 | &command_pool); |
| 3183 | |
| 3184 | VkCommandBuffer command_buffer[2]; |
| 3185 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3186 | command_buffer_allocate_info.sType = |
| 3187 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3188 | command_buffer_allocate_info.commandPool = command_pool; |
| 3189 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3190 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3191 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3192 | command_buffer); |
| 3193 | |
| 3194 | VkQueue queue = VK_NULL_HANDLE; |
| 3195 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 3196 | 1, &queue); |
| 3197 | |
| 3198 | { |
| 3199 | VkCommandBufferBeginInfo begin_info{}; |
| 3200 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3201 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3202 | |
| 3203 | vkCmdPipelineBarrier(command_buffer[0], |
| 3204 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3205 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3206 | 0, nullptr, 0, nullptr); |
| 3207 | |
| 3208 | VkViewport viewport{}; |
| 3209 | viewport.maxDepth = 1.0f; |
| 3210 | viewport.minDepth = 0.0f; |
| 3211 | viewport.width = 512; |
| 3212 | viewport.height = 512; |
| 3213 | viewport.x = 0; |
| 3214 | viewport.y = 0; |
| 3215 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3216 | vkEndCommandBuffer(command_buffer[0]); |
| 3217 | } |
| 3218 | { |
| 3219 | VkCommandBufferBeginInfo begin_info{}; |
| 3220 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3221 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3222 | |
| 3223 | VkViewport viewport{}; |
| 3224 | viewport.maxDepth = 1.0f; |
| 3225 | viewport.minDepth = 0.0f; |
| 3226 | viewport.width = 512; |
| 3227 | viewport.height = 512; |
| 3228 | viewport.x = 0; |
| 3229 | viewport.y = 0; |
| 3230 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3231 | vkEndCommandBuffer(command_buffer[1]); |
| 3232 | } |
| 3233 | { |
| 3234 | VkSubmitInfo submit_info{}; |
| 3235 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3236 | submit_info.commandBufferCount = 1; |
| 3237 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3238 | submit_info.signalSemaphoreCount = 1; |
| 3239 | submit_info.pSignalSemaphores = &semaphore; |
| 3240 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3241 | } |
| 3242 | { |
| 3243 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3244 | VkSubmitInfo submit_info{}; |
| 3245 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3246 | submit_info.commandBufferCount = 1; |
| 3247 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3248 | submit_info.waitSemaphoreCount = 1; |
| 3249 | submit_info.pWaitSemaphores = &semaphore; |
| 3250 | submit_info.pWaitDstStageMask = flags; |
| 3251 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 3252 | } |
| 3253 | |
| 3254 | vkQueueWaitIdle(m_device->m_queue); |
| 3255 | |
| 3256 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3257 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 3258 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3259 | &command_buffer[0]); |
| 3260 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3261 | |
| 3262 | m_errorMonitor->VerifyNotFound(); |
| 3263 | } |
| 3264 | |
| 3265 | // This is a positive test. No errors should be generated. |
| 3266 | TEST_F(VkLayerTest, |
| 3267 | TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceTwoWFF) { |
| 3268 | |
| 3269 | TEST_DESCRIPTION( |
| 3270 | "Two command buffers, each in a separate QueueSubmit call " |
| 3271 | "submitted on separate queues, the second having a fence" |
| 3272 | "followed by two consecutive WaitForFences calls on the same fence."); |
| 3273 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 3274 | if ((m_device->queue_props.empty()) || |
| 3275 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 3276 | return; |
| 3277 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3278 | m_errorMonitor->ExpectSuccess(); |
| 3279 | |
| 3280 | VkFence fence; |
| 3281 | VkFenceCreateInfo fence_create_info{}; |
| 3282 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3283 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3284 | |
| 3285 | VkSemaphore semaphore; |
| 3286 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 3287 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 3288 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 3289 | &semaphore); |
| 3290 | |
| 3291 | VkCommandPool command_pool; |
| 3292 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3293 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3294 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3295 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3296 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3297 | &command_pool); |
| 3298 | |
| 3299 | VkCommandBuffer command_buffer[2]; |
| 3300 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3301 | command_buffer_allocate_info.sType = |
| 3302 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3303 | command_buffer_allocate_info.commandPool = command_pool; |
| 3304 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3305 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3306 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3307 | command_buffer); |
| 3308 | |
| 3309 | VkQueue queue = VK_NULL_HANDLE; |
| 3310 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 3311 | 1, &queue); |
| 3312 | |
| 3313 | { |
| 3314 | VkCommandBufferBeginInfo begin_info{}; |
| 3315 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3316 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3317 | |
| 3318 | vkCmdPipelineBarrier(command_buffer[0], |
| 3319 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3320 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3321 | 0, nullptr, 0, nullptr); |
| 3322 | |
| 3323 | VkViewport viewport{}; |
| 3324 | viewport.maxDepth = 1.0f; |
| 3325 | viewport.minDepth = 0.0f; |
| 3326 | viewport.width = 512; |
| 3327 | viewport.height = 512; |
| 3328 | viewport.x = 0; |
| 3329 | viewport.y = 0; |
| 3330 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3331 | vkEndCommandBuffer(command_buffer[0]); |
| 3332 | } |
| 3333 | { |
| 3334 | VkCommandBufferBeginInfo begin_info{}; |
| 3335 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3336 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3337 | |
| 3338 | VkViewport viewport{}; |
| 3339 | viewport.maxDepth = 1.0f; |
| 3340 | viewport.minDepth = 0.0f; |
| 3341 | viewport.width = 512; |
| 3342 | viewport.height = 512; |
| 3343 | viewport.x = 0; |
| 3344 | viewport.y = 0; |
| 3345 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3346 | vkEndCommandBuffer(command_buffer[1]); |
| 3347 | } |
| 3348 | { |
| 3349 | VkSubmitInfo submit_info{}; |
| 3350 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3351 | submit_info.commandBufferCount = 1; |
| 3352 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3353 | submit_info.signalSemaphoreCount = 1; |
| 3354 | submit_info.pSignalSemaphores = &semaphore; |
| 3355 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3356 | } |
| 3357 | { |
| 3358 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3359 | VkSubmitInfo submit_info{}; |
| 3360 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3361 | submit_info.commandBufferCount = 1; |
| 3362 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3363 | submit_info.waitSemaphoreCount = 1; |
| 3364 | submit_info.pWaitSemaphores = &semaphore; |
| 3365 | submit_info.pWaitDstStageMask = flags; |
| 3366 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 3367 | } |
| 3368 | |
| 3369 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3370 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3371 | |
| 3372 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3373 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 3374 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3375 | &command_buffer[0]); |
| 3376 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3377 | |
| 3378 | m_errorMonitor->VerifyNotFound(); |
| 3379 | } |
| 3380 | |
| 3381 | // This is a positive test. No errors should be generated. |
| 3382 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFence) { |
| 3383 | |
| 3384 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 3385 | "submitted on separate queues, the second having a fence, " |
| 3386 | "followed by a WaitForFences call."); |
| 3387 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 3388 | if ((m_device->queue_props.empty()) || |
| 3389 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 3390 | return; |
| 3391 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3392 | m_errorMonitor->ExpectSuccess(); |
| 3393 | |
| 3394 | VkFence fence; |
| 3395 | VkFenceCreateInfo fence_create_info{}; |
| 3396 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3397 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3398 | |
| 3399 | VkSemaphore semaphore; |
| 3400 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 3401 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 3402 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 3403 | &semaphore); |
| 3404 | |
| 3405 | VkCommandPool command_pool; |
| 3406 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3407 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3408 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3409 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3410 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3411 | &command_pool); |
| 3412 | |
| 3413 | VkCommandBuffer command_buffer[2]; |
| 3414 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3415 | command_buffer_allocate_info.sType = |
| 3416 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3417 | command_buffer_allocate_info.commandPool = command_pool; |
| 3418 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3419 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3420 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3421 | command_buffer); |
| 3422 | |
| 3423 | VkQueue queue = VK_NULL_HANDLE; |
| 3424 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 3425 | 1, &queue); |
| 3426 | |
| 3427 | |
| 3428 | { |
| 3429 | VkCommandBufferBeginInfo begin_info{}; |
| 3430 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3431 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3432 | |
| 3433 | vkCmdPipelineBarrier(command_buffer[0], |
| 3434 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3435 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3436 | 0, nullptr, 0, nullptr); |
| 3437 | |
| 3438 | VkViewport viewport{}; |
| 3439 | viewport.maxDepth = 1.0f; |
| 3440 | viewport.minDepth = 0.0f; |
| 3441 | viewport.width = 512; |
| 3442 | viewport.height = 512; |
| 3443 | viewport.x = 0; |
| 3444 | viewport.y = 0; |
| 3445 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3446 | vkEndCommandBuffer(command_buffer[0]); |
| 3447 | } |
| 3448 | { |
| 3449 | VkCommandBufferBeginInfo begin_info{}; |
| 3450 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3451 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3452 | |
| 3453 | VkViewport viewport{}; |
| 3454 | viewport.maxDepth = 1.0f; |
| 3455 | viewport.minDepth = 0.0f; |
| 3456 | viewport.width = 512; |
| 3457 | viewport.height = 512; |
| 3458 | viewport.x = 0; |
| 3459 | viewport.y = 0; |
| 3460 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3461 | vkEndCommandBuffer(command_buffer[1]); |
| 3462 | } |
| 3463 | { |
| 3464 | VkSubmitInfo submit_info{}; |
| 3465 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3466 | submit_info.commandBufferCount = 1; |
| 3467 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3468 | submit_info.signalSemaphoreCount = 1; |
| 3469 | submit_info.pSignalSemaphores = &semaphore; |
| 3470 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3471 | } |
| 3472 | { |
| 3473 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3474 | VkSubmitInfo submit_info{}; |
| 3475 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3476 | submit_info.commandBufferCount = 1; |
| 3477 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3478 | submit_info.waitSemaphoreCount = 1; |
| 3479 | submit_info.pWaitSemaphores = &semaphore; |
| 3480 | submit_info.pWaitDstStageMask = flags; |
| 3481 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 3482 | } |
| 3483 | |
| 3484 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3485 | |
| 3486 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3487 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 3488 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3489 | &command_buffer[0]); |
| 3490 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3491 | |
| 3492 | m_errorMonitor->VerifyNotFound(); |
| 3493 | } |
| 3494 | |
| 3495 | // This is a positive test. No errors should be generated. |
| 3496 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueWithSemaphoreAndOneFence) { |
| 3497 | |
| 3498 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 3499 | "on the same queue, sharing a signal/wait semaphore, the " |
| 3500 | "second having a fence, " |
| 3501 | "followed by a WaitForFences call."); |
| 3502 | |
| 3503 | m_errorMonitor->ExpectSuccess(); |
| 3504 | |
| 3505 | VkFence fence; |
| 3506 | VkFenceCreateInfo fence_create_info{}; |
| 3507 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3508 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3509 | |
| 3510 | VkSemaphore semaphore; |
| 3511 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 3512 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 3513 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 3514 | &semaphore); |
| 3515 | |
| 3516 | VkCommandPool command_pool; |
| 3517 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3518 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3519 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3520 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3521 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3522 | &command_pool); |
| 3523 | |
| 3524 | VkCommandBuffer command_buffer[2]; |
| 3525 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3526 | command_buffer_allocate_info.sType = |
| 3527 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3528 | command_buffer_allocate_info.commandPool = command_pool; |
| 3529 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3530 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3531 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3532 | command_buffer); |
| 3533 | |
| 3534 | { |
| 3535 | VkCommandBufferBeginInfo begin_info{}; |
| 3536 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3537 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3538 | |
| 3539 | vkCmdPipelineBarrier(command_buffer[0], |
| 3540 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3541 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3542 | 0, nullptr, 0, nullptr); |
| 3543 | |
| 3544 | VkViewport viewport{}; |
| 3545 | viewport.maxDepth = 1.0f; |
| 3546 | viewport.minDepth = 0.0f; |
| 3547 | viewport.width = 512; |
| 3548 | viewport.height = 512; |
| 3549 | viewport.x = 0; |
| 3550 | viewport.y = 0; |
| 3551 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3552 | vkEndCommandBuffer(command_buffer[0]); |
| 3553 | } |
| 3554 | { |
| 3555 | VkCommandBufferBeginInfo begin_info{}; |
| 3556 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3557 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3558 | |
| 3559 | VkViewport viewport{}; |
| 3560 | viewport.maxDepth = 1.0f; |
| 3561 | viewport.minDepth = 0.0f; |
| 3562 | viewport.width = 512; |
| 3563 | viewport.height = 512; |
| 3564 | viewport.x = 0; |
| 3565 | viewport.y = 0; |
| 3566 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3567 | vkEndCommandBuffer(command_buffer[1]); |
| 3568 | } |
| 3569 | { |
| 3570 | VkSubmitInfo submit_info{}; |
| 3571 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3572 | submit_info.commandBufferCount = 1; |
| 3573 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3574 | submit_info.signalSemaphoreCount = 1; |
| 3575 | submit_info.pSignalSemaphores = &semaphore; |
| 3576 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3577 | } |
| 3578 | { |
| 3579 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3580 | VkSubmitInfo submit_info{}; |
| 3581 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3582 | submit_info.commandBufferCount = 1; |
| 3583 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3584 | submit_info.waitSemaphoreCount = 1; |
| 3585 | submit_info.pWaitSemaphores = &semaphore; |
| 3586 | submit_info.pWaitDstStageMask = flags; |
| 3587 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 3588 | } |
| 3589 | |
| 3590 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3591 | |
| 3592 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3593 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 3594 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3595 | &command_buffer[0]); |
| 3596 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3597 | |
| 3598 | m_errorMonitor->VerifyNotFound(); |
| 3599 | } |
| 3600 | |
| 3601 | // This is a positive test. No errors should be generated. |
| 3602 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueNullQueueSubmitWithFence) { |
| 3603 | |
| 3604 | TEST_DESCRIPTION( |
| 3605 | "Two command buffers, each in a separate QueueSubmit call " |
| 3606 | "on the same queue, no fences, followed by a third QueueSubmit with NO " |
| 3607 | "SubmitInfos but with a fence, followed by a WaitForFences call."); |
| 3608 | |
| 3609 | m_errorMonitor->ExpectSuccess(); |
| 3610 | |
| 3611 | VkFence fence; |
| 3612 | VkFenceCreateInfo fence_create_info{}; |
| 3613 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3614 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3615 | |
| 3616 | VkCommandPool command_pool; |
| 3617 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3618 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3619 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3620 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3621 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3622 | &command_pool); |
| 3623 | |
| 3624 | VkCommandBuffer command_buffer[2]; |
| 3625 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3626 | command_buffer_allocate_info.sType = |
| 3627 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3628 | command_buffer_allocate_info.commandPool = command_pool; |
| 3629 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3630 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3631 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3632 | command_buffer); |
| 3633 | |
| 3634 | { |
| 3635 | VkCommandBufferBeginInfo begin_info{}; |
| 3636 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3637 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3638 | |
| 3639 | vkCmdPipelineBarrier(command_buffer[0], |
| 3640 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3641 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3642 | 0, nullptr, 0, nullptr); |
| 3643 | |
| 3644 | VkViewport viewport{}; |
| 3645 | viewport.maxDepth = 1.0f; |
| 3646 | viewport.minDepth = 0.0f; |
| 3647 | viewport.width = 512; |
| 3648 | viewport.height = 512; |
| 3649 | viewport.x = 0; |
| 3650 | viewport.y = 0; |
| 3651 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3652 | vkEndCommandBuffer(command_buffer[0]); |
| 3653 | } |
| 3654 | { |
| 3655 | VkCommandBufferBeginInfo begin_info{}; |
| 3656 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3657 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3658 | |
| 3659 | VkViewport viewport{}; |
| 3660 | viewport.maxDepth = 1.0f; |
| 3661 | viewport.minDepth = 0.0f; |
| 3662 | viewport.width = 512; |
| 3663 | viewport.height = 512; |
| 3664 | viewport.x = 0; |
| 3665 | viewport.y = 0; |
| 3666 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3667 | vkEndCommandBuffer(command_buffer[1]); |
| 3668 | } |
| 3669 | { |
| 3670 | VkSubmitInfo submit_info{}; |
| 3671 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3672 | submit_info.commandBufferCount = 1; |
| 3673 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3674 | submit_info.signalSemaphoreCount = 0; |
| 3675 | submit_info.pSignalSemaphores = VK_NULL_HANDLE; |
| 3676 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3677 | } |
| 3678 | { |
| 3679 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3680 | VkSubmitInfo submit_info{}; |
| 3681 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3682 | submit_info.commandBufferCount = 1; |
| 3683 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3684 | submit_info.waitSemaphoreCount = 0; |
| 3685 | submit_info.pWaitSemaphores = VK_NULL_HANDLE; |
| 3686 | submit_info.pWaitDstStageMask = flags; |
| 3687 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3688 | } |
| 3689 | |
| 3690 | vkQueueSubmit(m_device->m_queue, 0, NULL, fence); |
| 3691 | |
| 3692 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3693 | |
| 3694 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3695 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3696 | &command_buffer[0]); |
| 3697 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3698 | |
| 3699 | m_errorMonitor->VerifyNotFound(); |
| 3700 | } |
| 3701 | |
| 3702 | // This is a positive test. No errors should be generated. |
| 3703 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueOneFence) { |
| 3704 | |
| 3705 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 3706 | "on the same queue, the second having a fence, followed " |
| 3707 | "by a WaitForFences call."); |
| 3708 | |
| 3709 | m_errorMonitor->ExpectSuccess(); |
| 3710 | |
| 3711 | VkFence fence; |
| 3712 | VkFenceCreateInfo fence_create_info{}; |
| 3713 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3714 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3715 | |
| 3716 | VkCommandPool command_pool; |
| 3717 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3718 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3719 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3720 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3721 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3722 | &command_pool); |
| 3723 | |
| 3724 | VkCommandBuffer command_buffer[2]; |
| 3725 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3726 | command_buffer_allocate_info.sType = |
| 3727 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3728 | command_buffer_allocate_info.commandPool = command_pool; |
| 3729 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3730 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3731 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3732 | command_buffer); |
| 3733 | |
| 3734 | { |
| 3735 | VkCommandBufferBeginInfo begin_info{}; |
| 3736 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3737 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3738 | |
| 3739 | vkCmdPipelineBarrier(command_buffer[0], |
| 3740 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3741 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3742 | 0, nullptr, 0, nullptr); |
| 3743 | |
| 3744 | VkViewport viewport{}; |
| 3745 | viewport.maxDepth = 1.0f; |
| 3746 | viewport.minDepth = 0.0f; |
| 3747 | viewport.width = 512; |
| 3748 | viewport.height = 512; |
| 3749 | viewport.x = 0; |
| 3750 | viewport.y = 0; |
| 3751 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3752 | vkEndCommandBuffer(command_buffer[0]); |
| 3753 | } |
| 3754 | { |
| 3755 | VkCommandBufferBeginInfo begin_info{}; |
| 3756 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3757 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3758 | |
| 3759 | VkViewport viewport{}; |
| 3760 | viewport.maxDepth = 1.0f; |
| 3761 | viewport.minDepth = 0.0f; |
| 3762 | viewport.width = 512; |
| 3763 | viewport.height = 512; |
| 3764 | viewport.x = 0; |
| 3765 | viewport.y = 0; |
| 3766 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3767 | vkEndCommandBuffer(command_buffer[1]); |
| 3768 | } |
| 3769 | { |
| 3770 | VkSubmitInfo submit_info{}; |
| 3771 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3772 | submit_info.commandBufferCount = 1; |
| 3773 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3774 | submit_info.signalSemaphoreCount = 0; |
| 3775 | submit_info.pSignalSemaphores = VK_NULL_HANDLE; |
| 3776 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3777 | } |
| 3778 | { |
| 3779 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3780 | VkSubmitInfo submit_info{}; |
| 3781 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3782 | submit_info.commandBufferCount = 1; |
| 3783 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3784 | submit_info.waitSemaphoreCount = 0; |
| 3785 | submit_info.pWaitSemaphores = VK_NULL_HANDLE; |
| 3786 | submit_info.pWaitDstStageMask = flags; |
| 3787 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 3788 | } |
| 3789 | |
| 3790 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3791 | |
| 3792 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3793 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3794 | &command_buffer[0]); |
| 3795 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3796 | |
| 3797 | m_errorMonitor->VerifyNotFound(); |
| 3798 | } |
| 3799 | |
| 3800 | // This is a positive test. No errors should be generated. |
| 3801 | TEST_F(VkLayerTest, TwoSubmitInfosWithSemaphoreOneQueueSubmitsOneFence) { |
| 3802 | |
| 3803 | TEST_DESCRIPTION( |
| 3804 | "Two command buffers each in a separate SubmitInfo sent in a single " |
| 3805 | "QueueSubmit call followed by a WaitForFences call."); |
| 3806 | |
| 3807 | m_errorMonitor->ExpectSuccess(); |
| 3808 | |
| 3809 | VkFence fence; |
| 3810 | VkFenceCreateInfo fence_create_info{}; |
| 3811 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3812 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3813 | |
| 3814 | VkSemaphore semaphore; |
| 3815 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 3816 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 3817 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 3818 | &semaphore); |
| 3819 | |
| 3820 | VkCommandPool command_pool; |
| 3821 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3822 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3823 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3824 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3825 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3826 | &command_pool); |
| 3827 | |
| 3828 | VkCommandBuffer command_buffer[2]; |
| 3829 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3830 | command_buffer_allocate_info.sType = |
| 3831 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3832 | command_buffer_allocate_info.commandPool = command_pool; |
| 3833 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3834 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3835 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3836 | command_buffer); |
| 3837 | |
| 3838 | { |
| 3839 | VkCommandBufferBeginInfo begin_info{}; |
| 3840 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3841 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3842 | |
| 3843 | vkCmdPipelineBarrier(command_buffer[0], |
| 3844 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3845 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3846 | 0, nullptr, 0, nullptr); |
| 3847 | |
| 3848 | VkViewport viewport{}; |
| 3849 | viewport.maxDepth = 1.0f; |
| 3850 | viewport.minDepth = 0.0f; |
| 3851 | viewport.width = 512; |
| 3852 | viewport.height = 512; |
| 3853 | viewport.x = 0; |
| 3854 | viewport.y = 0; |
| 3855 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3856 | vkEndCommandBuffer(command_buffer[0]); |
| 3857 | } |
| 3858 | { |
| 3859 | VkCommandBufferBeginInfo begin_info{}; |
| 3860 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3861 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3862 | |
| 3863 | VkViewport viewport{}; |
| 3864 | viewport.maxDepth = 1.0f; |
| 3865 | viewport.minDepth = 0.0f; |
| 3866 | viewport.width = 512; |
| 3867 | viewport.height = 512; |
| 3868 | viewport.x = 0; |
| 3869 | viewport.y = 0; |
| 3870 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3871 | vkEndCommandBuffer(command_buffer[1]); |
| 3872 | } |
| 3873 | { |
| 3874 | VkSubmitInfo submit_info[2]; |
| 3875 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3876 | |
| 3877 | submit_info[0].sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3878 | submit_info[0].pNext = NULL; |
| 3879 | submit_info[0].commandBufferCount = 1; |
| 3880 | submit_info[0].pCommandBuffers = &command_buffer[0]; |
| 3881 | submit_info[0].signalSemaphoreCount = 1; |
| 3882 | submit_info[0].pSignalSemaphores = &semaphore; |
| 3883 | submit_info[0].waitSemaphoreCount = 0; |
| 3884 | submit_info[0].pWaitSemaphores = NULL; |
| 3885 | submit_info[0].pWaitDstStageMask = 0; |
| 3886 | |
| 3887 | submit_info[1].sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3888 | submit_info[1].pNext = NULL; |
| 3889 | submit_info[1].commandBufferCount = 1; |
| 3890 | submit_info[1].pCommandBuffers = &command_buffer[1]; |
| 3891 | submit_info[1].waitSemaphoreCount = 1; |
| 3892 | submit_info[1].pWaitSemaphores = &semaphore; |
| 3893 | submit_info[1].pWaitDstStageMask = flags; |
| 3894 | submit_info[1].signalSemaphoreCount = 0; |
| 3895 | submit_info[1].pSignalSemaphores = NULL; |
| 3896 | vkQueueSubmit(m_device->m_queue, 2, &submit_info[0], fence); |
| 3897 | } |
| 3898 | |
| 3899 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3900 | |
| 3901 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3902 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3903 | &command_buffer[0]); |
| 3904 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3905 | |
| 3906 | m_errorMonitor->VerifyNotFound(); |
| 3907 | } |
| 3908 | |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 3909 | TEST_F(VkLayerTest, DynamicDepthBiasNotBound) { |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 3910 | TEST_DESCRIPTION( |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 3911 | "Run a simple draw calls to validate failure when Depth Bias dynamic " |
| 3912 | "state is required but not correctly bound."); |
| 3913 | |
| 3914 | // Dynamic depth bias |
| 3915 | m_errorMonitor->SetDesiredFailureMsg( |
| 3916 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3917 | "Dynamic depth bias state not set for this command buffer"); |
| 3918 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 3919 | BsoFailDepthBias); |
| 3920 | m_errorMonitor->VerifyFound(); |
| 3921 | } |
| 3922 | |
| 3923 | TEST_F(VkLayerTest, DynamicLineWidthNotBound) { |
| 3924 | TEST_DESCRIPTION( |
| 3925 | "Run a simple draw calls to validate failure when Line Width dynamic " |
| 3926 | "state is required but not correctly bound."); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 3927 | |
| 3928 | // Dynamic line width |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3929 | m_errorMonitor->SetDesiredFailureMsg( |
| 3930 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3931 | "Dynamic line width state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3932 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 3933 | BsoFailLineWidth); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3934 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 3935 | } |
| 3936 | |
| 3937 | TEST_F(VkLayerTest, DynamicViewportNotBound) { |
| 3938 | TEST_DESCRIPTION( |
| 3939 | "Run a simple draw calls to validate failure when Viewport dynamic " |
| 3940 | "state is required but not correctly bound."); |
| 3941 | |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 3942 | // Dynamic viewport state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3943 | m_errorMonitor->SetDesiredFailureMsg( |
| 3944 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3945 | "Dynamic viewport state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3946 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 3947 | BsoFailViewport); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3948 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 3949 | } |
| 3950 | |
| 3951 | TEST_F(VkLayerTest, DynamicScissorNotBound) { |
| 3952 | TEST_DESCRIPTION( |
| 3953 | "Run a simple draw calls to validate failure when Scissor dynamic " |
| 3954 | "state is required but not correctly bound."); |
| 3955 | |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 3956 | // Dynamic scissor state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3957 | m_errorMonitor->SetDesiredFailureMsg( |
| 3958 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3959 | "Dynamic scissor state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3960 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 3961 | BsoFailScissor); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3962 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 3963 | } |
| 3964 | |
| 3965 | TEST_F(VkLayerTest, DynamicColorBlendNotBound) { |
| 3966 | TEST_DESCRIPTION( |
| 3967 | "Run a simple draw calls to validate failure when Color Blend dynamic " |
| 3968 | "state is required but not correctly bound."); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 3969 | // Dynamic blend state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3970 | m_errorMonitor->SetDesiredFailureMsg( |
| 3971 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3972 | "Dynamic depth bounds state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3973 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 3974 | BsoFailDepthBounds); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3975 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 3976 | } |
| 3977 | |
| 3978 | TEST_F(VkLayerTest, DynamicStencilReadNotBound) { |
| 3979 | TEST_DESCRIPTION( |
| 3980 | "Run a simple draw calls to validate failure when Stencil Read dynamic " |
| 3981 | "state is required but not correctly bound."); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 3982 | // Dynamic stencil read mask |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3983 | m_errorMonitor->SetDesiredFailureMsg( |
| 3984 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3985 | "Dynamic stencil read mask state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3986 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 3987 | BsoFailStencilReadMask); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3988 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 3989 | } |
| 3990 | |
| 3991 | TEST_F(VkLayerTest, DynamicStencilWriteNotBound) { |
| 3992 | TEST_DESCRIPTION( |
| 3993 | "Run a simple draw calls to validate failure when Stencil Write dynamic" |
| 3994 | " state is required but not correctly bound."); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 3995 | // Dynamic stencil write mask |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3996 | m_errorMonitor->SetDesiredFailureMsg( |
| 3997 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3998 | "Dynamic stencil write mask state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3999 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 4000 | BsoFailStencilWriteMask); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4001 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b1a8799 | 2016-05-25 16:42:47 -0600 | [diff] [blame] | 4002 | } |
| 4003 | |
| 4004 | TEST_F(VkLayerTest, DynamicStencilRefNotBound) { |
| 4005 | TEST_DESCRIPTION( |
| 4006 | "Run a simple draw calls to validate failure when Stencil Ref dynamic " |
| 4007 | "state is required but not correctly bound."); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 4008 | // Dynamic stencil reference |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4009 | m_errorMonitor->SetDesiredFailureMsg( |
| 4010 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4011 | "Dynamic stencil reference state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4012 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 4013 | BsoFailStencilReference); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4014 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 4015 | } |
| 4016 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4017 | TEST_F(VkLayerTest, CommandBufferTwoSubmits) { |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4018 | vk_testing::Fence testFence; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4019 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4020 | m_errorMonitor->SetDesiredFailureMsg( |
| 4021 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4022 | "was begun w/ VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set, but has " |
| 4023 | "been submitted"); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4024 | |
| 4025 | VkFenceCreateInfo fenceInfo = {}; |
| 4026 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 4027 | fenceInfo.pNext = NULL; |
| 4028 | fenceInfo.flags = 0; |
| 4029 | |
| 4030 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4031 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 4032 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4033 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4034 | // We luck out b/c by default the framework creates CB w/ the |
| 4035 | // VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4036 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4037 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 4038 | m_stencil_clear_color, NULL); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4039 | EndCommandBuffer(); |
| 4040 | |
| 4041 | testFence.init(*m_device, fenceInfo); |
| 4042 | |
| 4043 | // Bypass framework since it does the waits automatically |
| 4044 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 4045 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 4046 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 4047 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4048 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 4049 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 4050 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4051 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4052 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4053 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 4054 | submit_info.pSignalSemaphores = NULL; |
| 4055 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4056 | err = vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
| 4057 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4058 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4059 | // Cause validation error by re-submitting cmd buffer that should only be |
| 4060 | // submitted once |
| 4061 | err = vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4062 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4063 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 4064 | } |
| 4065 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4066 | TEST_F(VkLayerTest, AllocDescriptorFromEmptyPool) { |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4067 | // Initiate Draw w/o a PSO bound |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4068 | VkResult err; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4069 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4070 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4071 | "Unable to allocate 1 descriptors of " |
| 4072 | "type " |
| 4073 | "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4074 | |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4075 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4076 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4077 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4078 | // Create Pool w/ 1 Sampler descriptor, but try to alloc Uniform Buffer |
| 4079 | // descriptor from it |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4080 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4081 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 4082 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4083 | |
| 4084 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4085 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4086 | ds_pool_ci.pNext = NULL; |
| 4087 | ds_pool_ci.flags = 0; |
| 4088 | ds_pool_ci.maxSets = 1; |
| 4089 | ds_pool_ci.poolSizeCount = 1; |
| 4090 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4091 | |
| 4092 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4093 | err = |
| 4094 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4095 | ASSERT_VK_SUCCESS(err); |
| 4096 | |
| 4097 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4098 | dsl_binding.binding = 0; |
| 4099 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4100 | dsl_binding.descriptorCount = 1; |
| 4101 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4102 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4103 | |
| 4104 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4105 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4106 | ds_layout_ci.pNext = NULL; |
| 4107 | ds_layout_ci.bindingCount = 1; |
| 4108 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4109 | |
| 4110 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4111 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4112 | &ds_layout); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4113 | ASSERT_VK_SUCCESS(err); |
| 4114 | |
| 4115 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4116 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4117 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4118 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4119 | alloc_info.descriptorPool = ds_pool; |
| 4120 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4121 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4122 | &descriptorSet); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4123 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4124 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4125 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4126 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4127 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 4128 | } |
| 4129 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4130 | TEST_F(VkLayerTest, FreeDescriptorFromOneShotPool) { |
| 4131 | VkResult err; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4132 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4133 | m_errorMonitor->SetDesiredFailureMsg( |
| 4134 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4135 | "It is invalid to call vkFreeDescriptorSets() with a pool created " |
| 4136 | "without setting VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4137 | |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4138 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4139 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4140 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4141 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4142 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4143 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4144 | |
| 4145 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4146 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4147 | ds_pool_ci.pNext = NULL; |
| 4148 | ds_pool_ci.maxSets = 1; |
| 4149 | ds_pool_ci.poolSizeCount = 1; |
| 4150 | ds_pool_ci.flags = 0; |
| 4151 | // Not specifying VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT means |
| 4152 | // app can only call vkResetDescriptorPool on this pool.; |
| 4153 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4154 | |
| 4155 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4156 | err = |
| 4157 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4158 | ASSERT_VK_SUCCESS(err); |
| 4159 | |
| 4160 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4161 | dsl_binding.binding = 0; |
| 4162 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4163 | dsl_binding.descriptorCount = 1; |
| 4164 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4165 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4166 | |
| 4167 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4168 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4169 | ds_layout_ci.pNext = NULL; |
| 4170 | ds_layout_ci.bindingCount = 1; |
| 4171 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4172 | |
| 4173 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4174 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4175 | &ds_layout); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4176 | ASSERT_VK_SUCCESS(err); |
| 4177 | |
| 4178 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4179 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4180 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4181 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4182 | alloc_info.descriptorPool = ds_pool; |
| 4183 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4184 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4185 | &descriptorSet); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4186 | ASSERT_VK_SUCCESS(err); |
| 4187 | |
| 4188 | err = vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptorSet); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4189 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4190 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4191 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4192 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 4193 | } |
| 4194 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4195 | TEST_F(VkLayerTest, InvalidDescriptorPool) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4196 | // Attempt to clear Descriptor Pool with bad object. |
| 4197 | // ObjectTracker should catch this. |
| 4198 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4199 | "Invalid VkDescriptorPool Object 0xbaad6001"); |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 4200 | uint64_t fake_pool_handle = 0xbaad6001; |
| 4201 | VkDescriptorPool bad_pool = reinterpret_cast<VkDescriptorPool &>(fake_pool_handle); |
| 4202 | vkResetDescriptorPool(device(), bad_pool, 0); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4203 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4204 | } |
| 4205 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4206 | TEST_F(VkLayerTest, InvalidDescriptorSet) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4207 | // Attempt to bind an invalid Descriptor Set to a valid Command Buffer |
| 4208 | // ObjectTracker should catch this. |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4209 | // Create a valid cmd buffer |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4210 | // call vkCmdBindDescriptorSets w/ false Descriptor Set |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 4211 | |
| 4212 | uint64_t fake_set_handle = 0xbaad6001; |
| 4213 | VkDescriptorSet bad_set = reinterpret_cast<VkDescriptorSet &>(fake_set_handle); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4214 | VkResult err; |
| 4215 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4216 | "Invalid VkDescriptorSet Object 0xbaad6001"); |
| 4217 | |
| 4218 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4219 | |
| 4220 | VkDescriptorSetLayoutBinding layout_bindings[1] = {}; |
| 4221 | layout_bindings[0].binding = 0; |
| 4222 | layout_bindings[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4223 | layout_bindings[0].descriptorCount = 1; |
| 4224 | layout_bindings[0].stageFlags = VK_SHADER_STAGE_VERTEX_BIT; |
| 4225 | layout_bindings[0].pImmutableSamplers = NULL; |
| 4226 | |
| 4227 | VkDescriptorSetLayout descriptor_set_layout; |
| 4228 | VkDescriptorSetLayoutCreateInfo dslci = {}; |
| 4229 | dslci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4230 | dslci.pNext = NULL; |
| 4231 | dslci.bindingCount = 1; |
| 4232 | dslci.pBindings = layout_bindings; |
| 4233 | err = vkCreateDescriptorSetLayout(device(), &dslci, NULL, &descriptor_set_layout); |
Karl Schultz | 5cb2111 | 2016-04-21 17:17:40 -0600 | [diff] [blame] | 4234 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4235 | |
| 4236 | VkPipelineLayout pipeline_layout; |
| 4237 | VkPipelineLayoutCreateInfo plci = {}; |
| 4238 | plci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4239 | plci.pNext = NULL; |
| 4240 | plci.setLayoutCount = 1; |
| 4241 | plci.pSetLayouts = &descriptor_set_layout; |
| 4242 | err = vkCreatePipelineLayout(device(), &plci, NULL, &pipeline_layout); |
Karl Schultz | 5cb2111 | 2016-04-21 17:17:40 -0600 | [diff] [blame] | 4243 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4244 | |
| 4245 | BeginCommandBuffer(); |
| 4246 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 4247 | pipeline_layout, 0, 1, &bad_set, 0, NULL); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4248 | m_errorMonitor->VerifyFound(); |
| 4249 | EndCommandBuffer(); |
| 4250 | vkDestroyPipelineLayout(device(), pipeline_layout, NULL); |
| 4251 | vkDestroyDescriptorSetLayout(device(), descriptor_set_layout, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4252 | } |
| 4253 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4254 | TEST_F(VkLayerTest, InvalidDescriptorSetLayout) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4255 | // Attempt to create a Pipeline Layout with an invalid Descriptor Set Layout. |
| 4256 | // ObjectTracker should catch this. |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 4257 | uint64_t fake_layout_handle = 0xbaad6001; |
| 4258 | VkDescriptorSetLayout bad_layout = reinterpret_cast<VkDescriptorSetLayout &>(fake_layout_handle); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4259 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4260 | "Invalid VkDescriptorSetLayout Object 0xbaad6001"); |
| 4261 | |
| 4262 | VkPipelineLayout pipeline_layout; |
| 4263 | VkPipelineLayoutCreateInfo plci = {}; |
| 4264 | plci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4265 | plci.pNext = NULL; |
| 4266 | plci.setLayoutCount = 1; |
| 4267 | plci.pSetLayouts = &bad_layout; |
| 4268 | vkCreatePipelineLayout(device(), &plci, NULL, &pipeline_layout); |
| 4269 | |
| 4270 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4271 | } |
| 4272 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4273 | TEST_F(VkLayerTest, InvalidPipeline) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4274 | // Attempt to bind an invalid Pipeline to a valid Command Buffer |
| 4275 | // ObjectTracker should catch this. |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4276 | // Create a valid cmd buffer |
| 4277 | // call vkCmdBindPipeline w/ false Pipeline |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 4278 | uint64_t fake_pipeline_handle = 0xbaad6001; |
| 4279 | VkPipeline bad_pipeline = reinterpret_cast<VkPipeline &>(fake_pipeline_handle); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4280 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4281 | "Invalid VkPipeline Object 0xbaad6001"); |
| 4282 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4283 | BeginCommandBuffer(); |
| 4284 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4285 | VK_PIPELINE_BIND_POINT_GRAPHICS, bad_pipeline); |
| 4286 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b8b6b27 | 2016-05-02 13:26:06 -0600 | [diff] [blame] | 4287 | |
| 4288 | // Now issue a draw call with no pipeline bound |
| 4289 | m_errorMonitor->SetDesiredFailureMsg( |
| 4290 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4291 | "At Draw/Dispatch time no valid VkPipeline is bound!"); |
| 4292 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4293 | BeginCommandBuffer(); |
| 4294 | Draw(1, 0, 0, 0); |
| 4295 | m_errorMonitor->VerifyFound(); |
| 4296 | // Finally same check once more but with Dispatch/Compute |
| 4297 | m_errorMonitor->SetDesiredFailureMsg( |
| 4298 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4299 | "At Draw/Dispatch time no valid VkPipeline is bound!"); |
| 4300 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4301 | BeginCommandBuffer(); |
| 4302 | vkCmdDispatch(m_commandBuffer->GetBufferHandle(), 0, 0, 0); |
| 4303 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4304 | } |
| 4305 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4306 | TEST_F(VkLayerTest, DescriptorSetNotUpdated) { |
| 4307 | // Create and update CommandBuffer then call QueueSubmit w/o calling End on |
| 4308 | // CommandBuffer |
| 4309 | VkResult err; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4310 | |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 4311 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4312 | " bound but it was never updated. "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4313 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4314 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 4315 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 4316 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4317 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4318 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4319 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4320 | |
| 4321 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4322 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4323 | ds_pool_ci.pNext = NULL; |
| 4324 | ds_pool_ci.maxSets = 1; |
| 4325 | ds_pool_ci.poolSizeCount = 1; |
| 4326 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 4327 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4328 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4329 | err = |
| 4330 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4331 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4332 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4333 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4334 | dsl_binding.binding = 0; |
| 4335 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4336 | dsl_binding.descriptorCount = 1; |
| 4337 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4338 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4339 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4340 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4341 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4342 | ds_layout_ci.pNext = NULL; |
| 4343 | ds_layout_ci.bindingCount = 1; |
| 4344 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4345 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4346 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4347 | &ds_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4348 | ASSERT_VK_SUCCESS(err); |
| 4349 | |
| 4350 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4351 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4352 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4353 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4354 | alloc_info.descriptorPool = ds_pool; |
| 4355 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4356 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4357 | &descriptorSet); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4358 | ASSERT_VK_SUCCESS(err); |
| 4359 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4360 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4361 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4362 | pipeline_layout_ci.pNext = NULL; |
| 4363 | pipeline_layout_ci.setLayoutCount = 1; |
| 4364 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4365 | |
| 4366 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4367 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4368 | &pipeline_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4369 | ASSERT_VK_SUCCESS(err); |
| 4370 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4371 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4372 | VK_SHADER_STAGE_VERTEX_BIT, this); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4373 | // 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] | 4374 | // on more devices |
| 4375 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4376 | VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4377 | |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 4378 | VkPipelineObj pipe(m_device); |
| 4379 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 4380 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 4381 | pipe.AddColorAttachment(); |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 4382 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4383 | |
| 4384 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4385 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4386 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 4387 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 4388 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 4389 | 1, &descriptorSet, 0, NULL); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4390 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4391 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 4392 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4393 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4394 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4395 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4396 | } |
| 4397 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4398 | TEST_F(VkLayerTest, InvalidBufferViewObject) { |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4399 | // Create a single TEXEL_BUFFER descriptor and send it an invalid bufferView |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4400 | VkResult err; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4401 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4402 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4403 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Attempted write update to texel buffer " |
| 4404 | "descriptor with invalid buffer view"); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4405 | |
| 4406 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4407 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4408 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 4409 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4410 | |
| 4411 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4412 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4413 | ds_pool_ci.pNext = NULL; |
| 4414 | ds_pool_ci.maxSets = 1; |
| 4415 | ds_pool_ci.poolSizeCount = 1; |
| 4416 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4417 | |
| 4418 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4419 | err = |
| 4420 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4421 | ASSERT_VK_SUCCESS(err); |
| 4422 | |
| 4423 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4424 | dsl_binding.binding = 0; |
| 4425 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 4426 | dsl_binding.descriptorCount = 1; |
| 4427 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4428 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4429 | |
| 4430 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4431 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4432 | ds_layout_ci.pNext = NULL; |
| 4433 | ds_layout_ci.bindingCount = 1; |
| 4434 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4435 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4436 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4437 | &ds_layout); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4438 | ASSERT_VK_SUCCESS(err); |
| 4439 | |
| 4440 | VkDescriptorSet descriptorSet; |
| 4441 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4442 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4443 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4444 | alloc_info.descriptorPool = ds_pool; |
| 4445 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4446 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4447 | &descriptorSet); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4448 | ASSERT_VK_SUCCESS(err); |
| 4449 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4450 | VkBufferView view = |
| 4451 | (VkBufferView)((size_t)0xbaadbeef); // invalid bufferView object |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4452 | VkWriteDescriptorSet descriptor_write; |
| 4453 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 4454 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 4455 | descriptor_write.dstSet = descriptorSet; |
| 4456 | descriptor_write.dstBinding = 0; |
| 4457 | descriptor_write.descriptorCount = 1; |
| 4458 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 4459 | descriptor_write.pTexelBufferView = &view; |
| 4460 | |
| 4461 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 4462 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4463 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4464 | |
| 4465 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4466 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 4467 | } |
| 4468 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4469 | TEST_F(VkLayerTest, InvalidDynamicOffsetCases) { |
| 4470 | // Create a descriptorSet w/ dynamic descriptor and then hit 3 offset error |
| 4471 | // cases: |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4472 | // 1. No dynamicOffset supplied |
| 4473 | // 2. Too many dynamicOffsets supplied |
| 4474 | // 3. Dynamic offset oversteps buffer being updated |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4475 | VkResult err; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4476 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4477 | " requires 1 dynamicOffsets, but only " |
| 4478 | "0 dynamicOffsets are left in " |
| 4479 | "pDynamicOffsets "); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4480 | |
| 4481 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4482 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 4483 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4484 | |
| 4485 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4486 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 4487 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4488 | |
| 4489 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4490 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4491 | ds_pool_ci.pNext = NULL; |
| 4492 | ds_pool_ci.maxSets = 1; |
| 4493 | ds_pool_ci.poolSizeCount = 1; |
| 4494 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4495 | |
| 4496 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4497 | err = |
| 4498 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4499 | ASSERT_VK_SUCCESS(err); |
| 4500 | |
| 4501 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4502 | dsl_binding.binding = 0; |
| 4503 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 4504 | dsl_binding.descriptorCount = 1; |
| 4505 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4506 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4507 | |
| 4508 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4509 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4510 | ds_layout_ci.pNext = NULL; |
| 4511 | ds_layout_ci.bindingCount = 1; |
| 4512 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4513 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4514 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4515 | &ds_layout); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4516 | ASSERT_VK_SUCCESS(err); |
| 4517 | |
| 4518 | VkDescriptorSet descriptorSet; |
| 4519 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4520 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4521 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4522 | alloc_info.descriptorPool = ds_pool; |
| 4523 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4524 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4525 | &descriptorSet); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4526 | ASSERT_VK_SUCCESS(err); |
| 4527 | |
| 4528 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4529 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4530 | pipeline_layout_ci.pNext = NULL; |
| 4531 | pipeline_layout_ci.setLayoutCount = 1; |
| 4532 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4533 | |
| 4534 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4535 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4536 | &pipeline_layout); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4537 | ASSERT_VK_SUCCESS(err); |
| 4538 | |
| 4539 | // Create a buffer to update the descriptor with |
| 4540 | uint32_t qfi = 0; |
| 4541 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4542 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 4543 | buffCI.size = 1024; |
| 4544 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 4545 | buffCI.queueFamilyIndexCount = 1; |
| 4546 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4547 | |
| 4548 | VkBuffer dyub; |
| 4549 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 4550 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4551 | // Allocate memory and bind to buffer so we can make it to the appropriate |
| 4552 | // error |
| 4553 | VkMemoryAllocateInfo mem_alloc = {}; |
| 4554 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 4555 | mem_alloc.pNext = NULL; |
| 4556 | mem_alloc.allocationSize = 1024; |
Chris Forbes | b6116cc | 2016-05-08 11:39:59 +1200 | [diff] [blame] | 4557 | mem_alloc.memoryTypeIndex = 0; |
| 4558 | |
| 4559 | VkMemoryRequirements memReqs; |
| 4560 | vkGetBufferMemoryRequirements(m_device->device(), dyub, &memReqs); |
| 4561 | bool pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &mem_alloc, |
| 4562 | 0); |
| 4563 | if (!pass) { |
| 4564 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
| 4565 | return; |
| 4566 | } |
| 4567 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4568 | VkDeviceMemory mem; |
| 4569 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
| 4570 | ASSERT_VK_SUCCESS(err); |
| 4571 | err = vkBindBufferMemory(m_device->device(), dyub, mem, 0); |
| 4572 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4573 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 4574 | VkDescriptorBufferInfo buffInfo = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4575 | buffInfo.buffer = dyub; |
| 4576 | buffInfo.offset = 0; |
| 4577 | buffInfo.range = 1024; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4578 | |
| 4579 | VkWriteDescriptorSet descriptor_write; |
| 4580 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 4581 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 4582 | descriptor_write.dstSet = descriptorSet; |
| 4583 | descriptor_write.dstBinding = 0; |
| 4584 | descriptor_write.descriptorCount = 1; |
| 4585 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 4586 | descriptor_write.pBufferInfo = &buffInfo; |
| 4587 | |
| 4588 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 4589 | |
| 4590 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4591 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 4592 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 4593 | 1, &descriptorSet, 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4594 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4595 | uint32_t pDynOff[2] = {512, 756}; |
| 4596 | // 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] | 4597 | m_errorMonitor->SetDesiredFailureMsg( |
| 4598 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4599 | "Attempting to bind 1 descriptorSets with 1 dynamic descriptors, but "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4600 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 4601 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 4602 | 1, &descriptorSet, 2, pDynOff); |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 4603 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4604 | // Finally cause error due to dynamicOffset being too big |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4605 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4606 | " dynamic offset 512 combined with " |
| 4607 | "offset 0 and range 1024 that " |
| 4608 | "oversteps the buffer size of 1024"); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4609 | // Create PSO to be used for draw-time errors below |
| 4610 | char const *vsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 4611 | "#version 450\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4612 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 4613 | "out gl_PerVertex { \n" |
| 4614 | " vec4 gl_Position;\n" |
| 4615 | "};\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4616 | "void main(){\n" |
| 4617 | " gl_Position = vec4(1);\n" |
| 4618 | "}\n"; |
| 4619 | char const *fsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 4620 | "#version 450\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4621 | "\n" |
| 4622 | "layout(location=0) out vec4 x;\n" |
| 4623 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 4624 | "void main(){\n" |
| 4625 | " x = vec4(bar.y);\n" |
| 4626 | "}\n"; |
| 4627 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4628 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 4629 | VkPipelineObj pipe(m_device); |
| 4630 | pipe.AddShader(&vs); |
| 4631 | pipe.AddShader(&fs); |
| 4632 | pipe.AddColorAttachment(); |
| 4633 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 4634 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4635 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4636 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 4637 | // This update should succeed, but offset size of 512 will overstep buffer |
| 4638 | // /w range 1024 & size 1024 |
| 4639 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 4640 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 4641 | 1, &descriptorSet, 1, pDynOff); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4642 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4643 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4644 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4645 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
Tobin Ehlis | 512098e | 2016-05-05 09:06:12 -0600 | [diff] [blame] | 4646 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4647 | |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4648 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4649 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 4650 | } |
| 4651 | |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4652 | TEST_F(VkLayerTest, InvalidPushConstants) { |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4653 | VkResult err; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4654 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4655 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 4656 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4657 | |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4658 | VkPipelineLayout pipeline_layout; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4659 | VkPushConstantRange pc_range = {}; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4660 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 4661 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4662 | pipeline_layout_ci.pushConstantRangeCount = 1; |
| 4663 | pipeline_layout_ci.pPushConstantRanges = &pc_range; |
| 4664 | |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4665 | // |
| 4666 | // Check for invalid push constant ranges in pipeline layouts. |
| 4667 | // |
| 4668 | struct PipelineLayoutTestCase { |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4669 | VkPushConstantRange const range; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4670 | char const *msg; |
| 4671 | }; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4672 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4673 | const uint32_t too_big = m_device->props.limits.maxPushConstantsSize + 0x4; |
| 4674 | const std::array<PipelineLayoutTestCase, 10> range_tests = {{ |
| 4675 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 0}, |
| 4676 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 4677 | "size 0."}, |
| 4678 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 1}, |
| 4679 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 4680 | "size 1."}, |
| 4681 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 1}, |
| 4682 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 4683 | "size 1."}, |
| 4684 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 0}, |
| 4685 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 4686 | "size 0."}, |
| 4687 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 4}, |
| 4688 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 4689 | "offset 1. Offset must"}, |
| 4690 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, too_big}, |
| 4691 | "vkCreatePipelineLayout() call has push constants index 0 " |
| 4692 | "with offset "}, |
| 4693 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, too_big}, |
| 4694 | "vkCreatePipelineLayout() call has push constants " |
| 4695 | "index 0 with offset "}, |
| 4696 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, 0}, |
| 4697 | "vkCreatePipelineLayout() call has push constants index 0 " |
| 4698 | "with offset "}, |
| 4699 | {{VK_SHADER_STAGE_VERTEX_BIT, 0xFFFFFFF0, 0x00000020}, |
| 4700 | "vkCreatePipelineLayout() call has push " |
| 4701 | "constants index 0 with offset "}, |
| 4702 | {{VK_SHADER_STAGE_VERTEX_BIT, 0x00000020, 0xFFFFFFF0}, |
| 4703 | "vkCreatePipelineLayout() call has push " |
| 4704 | "constants index 0 with offset "}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4705 | }}; |
| 4706 | |
| 4707 | // Check for invalid offset and size |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4708 | for (const auto &iter : range_tests) { |
| 4709 | pc_range = iter.range; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4710 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4711 | iter.msg); |
| 4712 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, |
| 4713 | NULL, &pipeline_layout); |
| 4714 | m_errorMonitor->VerifyFound(); |
| 4715 | if (VK_SUCCESS == err) { |
| 4716 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4717 | } |
| 4718 | } |
| 4719 | |
| 4720 | // Check for invalid stage flag |
| 4721 | pc_range.offset = 0; |
| 4722 | pc_range.size = 16; |
| 4723 | pc_range.stageFlags = 0; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4724 | m_errorMonitor->SetDesiredFailureMsg( |
| 4725 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4726 | "vkCreatePipelineLayout() call has no stageFlags set."); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4727 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4728 | &pipeline_layout); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4729 | m_errorMonitor->VerifyFound(); |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4730 | if (VK_SUCCESS == err) { |
| 4731 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4732 | } |
| 4733 | |
| 4734 | // Check for overlapping ranges |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4735 | const uint32_t ranges_per_test = 5; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4736 | struct OverlappingRangeTestCase { |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4737 | VkPushConstantRange const ranges[ranges_per_test]; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4738 | char const *msg; |
| 4739 | }; |
| 4740 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4741 | const std::array<OverlappingRangeTestCase, 5> overlapping_range_tests = { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4742 | {{{{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4743 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4744 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4745 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4746 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, |
| 4747 | "vkCreatePipelineLayout() call has push constants with overlapping " |
| 4748 | "ranges: 0:[0, 4), 1:[0, 4)"}, |
| 4749 | { |
| 4750 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4751 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, |
| 4752 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, |
| 4753 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 8}, |
| 4754 | {VK_SHADER_STAGE_VERTEX_BIT, 16, 4}}, |
| 4755 | "vkCreatePipelineLayout() call has push constants with " |
| 4756 | "overlapping " |
| 4757 | "ranges: 3:[12, 20), 4:[16, 20)", |
| 4758 | }, |
| 4759 | { |
| 4760 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, |
| 4761 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 8}, |
| 4762 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, |
| 4763 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, |
| 4764 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, |
| 4765 | "vkCreatePipelineLayout() call has push constants with " |
| 4766 | "overlapping " |
| 4767 | "ranges: 0:[16, 20), 1:[12, 20)", |
| 4768 | }, |
| 4769 | { |
| 4770 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, |
| 4771 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, |
| 4772 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, |
| 4773 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 8}, |
| 4774 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, |
| 4775 | "vkCreatePipelineLayout() call has push constants with " |
| 4776 | "overlapping " |
| 4777 | "ranges: 0:[16, 20), 3:[12, 20)", |
| 4778 | }, |
| 4779 | { |
| 4780 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, |
| 4781 | {VK_SHADER_STAGE_VERTEX_BIT, 32, 4}, |
| 4782 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 96}, |
| 4783 | {VK_SHADER_STAGE_VERTEX_BIT, 40, 8}, |
| 4784 | {VK_SHADER_STAGE_VERTEX_BIT, 52, 4}}, |
| 4785 | "vkCreatePipelineLayout() call has push constants with " |
| 4786 | "overlapping " |
| 4787 | "ranges: 0:[16, 20), 2:[4, 100)", |
| 4788 | }}}; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4789 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4790 | for (const auto &iter : overlapping_range_tests) { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4791 | pipeline_layout_ci.pPushConstantRanges = iter.ranges; |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4792 | pipeline_layout_ci.pushConstantRangeCount = ranges_per_test; |
| 4793 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4794 | iter.msg); |
| 4795 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, |
| 4796 | NULL, &pipeline_layout); |
| 4797 | m_errorMonitor->VerifyFound(); |
| 4798 | if (VK_SUCCESS == err) { |
| 4799 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4800 | } |
| 4801 | } |
| 4802 | |
| 4803 | // 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] | 4804 | const std::array<OverlappingRangeTestCase, 2> overlapping_range_tests_pos = |
| 4805 | {{{{{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4806 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, |
| 4807 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, |
| 4808 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 4}, |
| 4809 | {VK_SHADER_STAGE_VERTEX_BIT, 16, 4}}, |
| 4810 | ""}, |
| 4811 | {{{VK_SHADER_STAGE_VERTEX_BIT, 92, 24}, |
| 4812 | {VK_SHADER_STAGE_VERTEX_BIT, 80, 4}, |
| 4813 | {VK_SHADER_STAGE_VERTEX_BIT, 64, 8}, |
| 4814 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 16}, |
| 4815 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, |
| 4816 | ""}}}; |
| 4817 | for (const auto &iter : overlapping_range_tests_pos) { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4818 | pipeline_layout_ci.pPushConstantRanges = iter.ranges; |
| 4819 | m_errorMonitor->ExpectSuccess(); |
| 4820 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, |
| 4821 | NULL, &pipeline_layout); |
| 4822 | m_errorMonitor->VerifyNotFound(); |
| 4823 | if (VK_SUCCESS == err) { |
| 4824 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4825 | } |
| 4826 | } |
| 4827 | |
| 4828 | // |
| 4829 | // CmdPushConstants tests |
| 4830 | // |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4831 | const uint8_t dummy_values[100] = {}; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4832 | |
| 4833 | // 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] | 4834 | const std::array<PipelineLayoutTestCase, 16> cmd_range_tests = {{ |
| 4835 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 0}, |
| 4836 | "vkCmdPushConstants() call has push constants with size 0. Size " |
| 4837 | "must be greater than zero and a multiple of 4."}, |
| 4838 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 1}, |
| 4839 | "vkCmdPushConstants() call has push constants with size 1. Size " |
| 4840 | "must be greater than zero and a multiple of 4."}, |
| 4841 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 1}, |
| 4842 | "vkCmdPushConstants() call has push constants with size 1. Size " |
| 4843 | "must be greater than zero and a multiple of 4."}, |
| 4844 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 0}, |
| 4845 | "vkCmdPushConstants() call has push constants with offset 1. " |
| 4846 | "Offset must be a multiple of 4."}, |
| 4847 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 4}, |
| 4848 | "vkCmdPushConstants() call has push constants with offset 1. " |
| 4849 | "Offset must be a multiple of 4."}, |
| 4850 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 20}, |
| 4851 | "vkCmdPushConstants() Push constant range [0, 20) with stageFlags = " |
| 4852 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4853 | {{VK_SHADER_STAGE_VERTEX_BIT, 60, 8}, |
| 4854 | "vkCmdPushConstants() Push constant range [60, 68) with stageFlags = " |
| 4855 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4856 | {{VK_SHADER_STAGE_VERTEX_BIT, 76, 8}, |
| 4857 | "vkCmdPushConstants() Push constant range [76, 84) with stageFlags = " |
| 4858 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4859 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 80}, |
| 4860 | "vkCmdPushConstants() Push constant range [0, 80) with stageFlags = " |
| 4861 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4862 | {{VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, 0, 4}, |
| 4863 | "vkCmdPushConstants() stageFlags = 0x2 do not match the stageFlags in " |
| 4864 | "any of the ranges in pipeline layout"}, |
| 4865 | {{VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, |
| 4866 | 0, 16}, |
| 4867 | "vkCmdPushConstants() stageFlags = 0x3 do not match the stageFlags in " |
| 4868 | "any of the ranges in pipeline layout"}, |
| 4869 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, too_big}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4870 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4871 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, too_big}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4872 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4873 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, 0}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4874 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4875 | {{VK_SHADER_STAGE_VERTEX_BIT, 0xFFFFFFF0, 0x00000020}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4876 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4877 | {{VK_SHADER_STAGE_VERTEX_BIT, 0x00000020, 0xFFFFFFF0}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4878 | "vkCmdPushConstants() call has push constants with offset "}, |
| 4879 | }}; |
| 4880 | |
| 4881 | // Two ranges for testing robustness |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4882 | const VkPushConstantRange pc_range2[] = { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4883 | {VK_SHADER_STAGE_VERTEX_BIT, 64, 16}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4884 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4885 | }; |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4886 | pipeline_layout_ci.pushConstantRangeCount = |
| 4887 | sizeof(pc_range2) / sizeof(VkPushConstantRange); |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4888 | pipeline_layout_ci.pPushConstantRanges = pc_range2; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4889 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4890 | &pipeline_layout); |
| 4891 | ASSERT_VK_SUCCESS(err); |
| 4892 | BeginCommandBuffer(); |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4893 | for (const auto &iter : cmd_range_tests) { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4894 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4895 | iter.msg); |
| 4896 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4897 | iter.range.stageFlags, iter.range.offset, |
| 4898 | iter.range.size, dummy_values); |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4899 | m_errorMonitor->VerifyFound(); |
| 4900 | } |
| 4901 | |
| 4902 | // Check for invalid stage flag |
| 4903 | m_errorMonitor->SetDesiredFailureMsg( |
| 4904 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4905 | "vkCmdPushConstants() call has no stageFlags set."); |
| 4906 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, 0, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4907 | 0, 16, dummy_values); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4908 | m_errorMonitor->VerifyFound(); |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4909 | EndCommandBuffer(); |
| 4910 | vkResetCommandBuffer(m_commandBuffer->GetBufferHandle(), 0); |
| 4911 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4912 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4913 | // overlapping range tests with cmd |
| 4914 | const std::array<PipelineLayoutTestCase, 3> cmd_overlap_tests = {{ |
| 4915 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 20}, |
| 4916 | "vkCmdPushConstants() Push constant range [0, 20) with stageFlags = " |
| 4917 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4918 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, |
| 4919 | "vkCmdPushConstants() Push constant range [16, 20) with stageFlags = " |
| 4920 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4921 | {{VK_SHADER_STAGE_VERTEX_BIT, 40, 16}, |
| 4922 | "vkCmdPushConstants() Push constant range [40, 56) with stageFlags = " |
| 4923 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4924 | }}; |
| 4925 | const VkPushConstantRange pc_range3[] = { |
| 4926 | {VK_SHADER_STAGE_VERTEX_BIT, 20, 16}, |
| 4927 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, |
| 4928 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4929 | {VK_SHADER_STAGE_VERTEX_BIT, 44, 8}, |
| 4930 | {VK_SHADER_STAGE_VERTEX_BIT, 80, 12}, |
| 4931 | {VK_SHADER_STAGE_VERTEX_BIT, 36, 8}, |
| 4932 | {VK_SHADER_STAGE_VERTEX_BIT, 56, 28}, |
| 4933 | }; |
| 4934 | pipeline_layout_ci.pushConstantRangeCount = |
| 4935 | sizeof(pc_range3) / sizeof(VkPushConstantRange); |
| 4936 | pipeline_layout_ci.pPushConstantRanges = pc_range3; |
| 4937 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4938 | &pipeline_layout); |
| 4939 | ASSERT_VK_SUCCESS(err); |
| 4940 | BeginCommandBuffer(); |
| 4941 | for (const auto &iter : cmd_overlap_tests) { |
| 4942 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4943 | iter.msg); |
| 4944 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, |
| 4945 | iter.range.stageFlags, iter.range.offset, |
| 4946 | iter.range.size, dummy_values); |
| 4947 | m_errorMonitor->VerifyFound(); |
| 4948 | } |
| 4949 | EndCommandBuffer(); |
| 4950 | vkResetCommandBuffer(m_commandBuffer->GetBufferHandle(), 0); |
| 4951 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4952 | |
| 4953 | // positive overlapping range tests with cmd |
| 4954 | const std::array<PipelineLayoutTestCase, 4> cmd_overlap_tests_pos = {{ |
| 4955 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, ""}, |
| 4956 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, ""}, |
| 4957 | {{VK_SHADER_STAGE_VERTEX_BIT, 20, 12}, ""}, |
| 4958 | {{VK_SHADER_STAGE_VERTEX_BIT, 56, 36}, ""}, |
| 4959 | }}; |
| 4960 | const VkPushConstantRange pc_range4[] = { |
| 4961 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 64}, |
| 4962 | {VK_SHADER_STAGE_VERTEX_BIT, 20, 16}, |
| 4963 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, |
| 4964 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4965 | {VK_SHADER_STAGE_VERTEX_BIT, 44, 8}, |
| 4966 | {VK_SHADER_STAGE_VERTEX_BIT, 80, 12}, |
| 4967 | {VK_SHADER_STAGE_VERTEX_BIT, 36, 8}, |
| 4968 | {VK_SHADER_STAGE_VERTEX_BIT, 56, 28}, |
| 4969 | }; |
| 4970 | pipeline_layout_ci.pushConstantRangeCount = |
| 4971 | sizeof(pc_range4) / sizeof(VkPushConstantRange); |
| 4972 | pipeline_layout_ci.pPushConstantRanges = pc_range4; |
| 4973 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4974 | &pipeline_layout); |
| 4975 | ASSERT_VK_SUCCESS(err); |
| 4976 | BeginCommandBuffer(); |
| 4977 | for (const auto &iter : cmd_overlap_tests_pos) { |
| 4978 | m_errorMonitor->ExpectSuccess(); |
| 4979 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, |
| 4980 | iter.range.stageFlags, iter.range.offset, |
| 4981 | iter.range.size, dummy_values); |
| 4982 | m_errorMonitor->VerifyNotFound(); |
| 4983 | } |
| 4984 | EndCommandBuffer(); |
| 4985 | vkResetCommandBuffer(m_commandBuffer->GetBufferHandle(), 0); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4986 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4987 | } |
| 4988 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4989 | TEST_F(VkLayerTest, DescriptorSetCompatibility) { |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4990 | // Test various desriptorSet errors with bad binding combinations |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4991 | VkResult err; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4992 | |
| 4993 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4994 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 4995 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4996 | |
| 4997 | static const uint32_t NUM_DESCRIPTOR_TYPES = 5; |
| 4998 | VkDescriptorPoolSize ds_type_count[NUM_DESCRIPTOR_TYPES] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4999 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5000 | ds_type_count[0].descriptorCount = 10; |
| 5001 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 5002 | ds_type_count[1].descriptorCount = 2; |
| 5003 | ds_type_count[2].type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 5004 | ds_type_count[2].descriptorCount = 2; |
| 5005 | ds_type_count[3].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 5006 | ds_type_count[3].descriptorCount = 5; |
| 5007 | // TODO : LunarG ILO driver currently asserts in desc.c w/ INPUT_ATTACHMENT |
| 5008 | // type |
| 5009 | // ds_type_count[4].type = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; |
| 5010 | ds_type_count[4].type = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
| 5011 | ds_type_count[4].descriptorCount = 2; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5012 | |
| 5013 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5014 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5015 | ds_pool_ci.pNext = NULL; |
| 5016 | ds_pool_ci.maxSets = 5; |
| 5017 | ds_pool_ci.poolSizeCount = NUM_DESCRIPTOR_TYPES; |
| 5018 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5019 | |
| 5020 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5021 | err = |
| 5022 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5023 | ASSERT_VK_SUCCESS(err); |
| 5024 | |
| 5025 | static const uint32_t MAX_DS_TYPES_IN_LAYOUT = 2; |
| 5026 | VkDescriptorSetLayoutBinding dsl_binding[MAX_DS_TYPES_IN_LAYOUT] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5027 | dsl_binding[0].binding = 0; |
| 5028 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5029 | dsl_binding[0].descriptorCount = 5; |
| 5030 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 5031 | dsl_binding[0].pImmutableSamplers = NULL; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5032 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5033 | // Create layout identical to set0 layout but w/ different stageFlags |
| 5034 | VkDescriptorSetLayoutBinding dsl_fs_stage_only = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5035 | dsl_fs_stage_only.binding = 0; |
| 5036 | dsl_fs_stage_only.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5037 | dsl_fs_stage_only.descriptorCount = 5; |
| 5038 | dsl_fs_stage_only.stageFlags = |
| 5039 | VK_SHADER_STAGE_FRAGMENT_BIT; // Different stageFlags to cause error at |
| 5040 | // bind time |
| 5041 | dsl_fs_stage_only.pImmutableSamplers = NULL; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5042 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5043 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5044 | ds_layout_ci.pNext = NULL; |
| 5045 | ds_layout_ci.bindingCount = 1; |
| 5046 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5047 | static const uint32_t NUM_LAYOUTS = 4; |
| 5048 | VkDescriptorSetLayout ds_layout[NUM_LAYOUTS] = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5049 | VkDescriptorSetLayout ds_layout_fs_only = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5050 | // Create 4 unique layouts for full pipelineLayout, and 1 special fs-only |
| 5051 | // layout for error case |
| 5052 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5053 | &ds_layout[0]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5054 | ASSERT_VK_SUCCESS(err); |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 5055 | ds_layout_ci.pBindings = &dsl_fs_stage_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5056 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5057 | &ds_layout_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5058 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5059 | dsl_binding[0].binding = 0; |
| 5060 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5061 | dsl_binding[0].descriptorCount = 2; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 5062 | dsl_binding[1].binding = 1; |
| 5063 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 5064 | dsl_binding[1].descriptorCount = 2; |
| 5065 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 5066 | dsl_binding[1].pImmutableSamplers = NULL; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 5067 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5068 | ds_layout_ci.bindingCount = 2; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5069 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5070 | &ds_layout[1]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5071 | ASSERT_VK_SUCCESS(err); |
| 5072 | dsl_binding[0].binding = 0; |
| 5073 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5074 | dsl_binding[0].descriptorCount = 5; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5075 | ds_layout_ci.bindingCount = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5076 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5077 | &ds_layout[2]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5078 | ASSERT_VK_SUCCESS(err); |
| 5079 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5080 | dsl_binding[0].descriptorCount = 2; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5081 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5082 | &ds_layout[3]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5083 | ASSERT_VK_SUCCESS(err); |
| 5084 | |
| 5085 | static const uint32_t NUM_SETS = 4; |
| 5086 | VkDescriptorSet descriptorSet[NUM_SETS] = {}; |
| 5087 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5088 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5089 | alloc_info.descriptorSetCount = NUM_LAYOUTS; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5090 | alloc_info.descriptorPool = ds_pool; |
| 5091 | alloc_info.pSetLayouts = ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5092 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5093 | descriptorSet); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5094 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5095 | VkDescriptorSet ds0_fs_only = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5096 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5097 | alloc_info.pSetLayouts = &ds_layout_fs_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5098 | err = |
| 5099 | vkAllocateDescriptorSets(m_device->device(), &alloc_info, &ds0_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5100 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5101 | |
| 5102 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5103 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5104 | pipeline_layout_ci.pNext = NULL; |
| 5105 | pipeline_layout_ci.setLayoutCount = NUM_LAYOUTS; |
| 5106 | pipeline_layout_ci.pSetLayouts = ds_layout; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5107 | |
| 5108 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5109 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5110 | &pipeline_layout); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5111 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5112 | // Create pipelineLayout with only one setLayout |
| 5113 | pipeline_layout_ci.setLayoutCount = 1; |
| 5114 | VkPipelineLayout single_pipe_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5115 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5116 | &single_pipe_layout); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5117 | ASSERT_VK_SUCCESS(err); |
| 5118 | // Create pipelineLayout with 2 descriptor setLayout at index 0 |
| 5119 | pipeline_layout_ci.pSetLayouts = &ds_layout[3]; |
| 5120 | VkPipelineLayout pipe_layout_one_desc; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5121 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5122 | &pipe_layout_one_desc); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5123 | ASSERT_VK_SUCCESS(err); |
| 5124 | // Create pipelineLayout with 5 SAMPLER descriptor setLayout at index 0 |
| 5125 | pipeline_layout_ci.pSetLayouts = &ds_layout[2]; |
| 5126 | VkPipelineLayout pipe_layout_five_samp; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5127 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5128 | &pipe_layout_five_samp); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5129 | ASSERT_VK_SUCCESS(err); |
| 5130 | // Create pipelineLayout with UB type, but stageFlags for FS only |
| 5131 | pipeline_layout_ci.pSetLayouts = &ds_layout_fs_only; |
| 5132 | VkPipelineLayout pipe_layout_fs_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5133 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5134 | &pipe_layout_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5135 | ASSERT_VK_SUCCESS(err); |
| 5136 | // Create pipelineLayout w/ incompatible set0 layout, but set1 is fine |
| 5137 | VkDescriptorSetLayout pl_bad_s0[2] = {}; |
| 5138 | pl_bad_s0[0] = ds_layout_fs_only; |
| 5139 | pl_bad_s0[1] = ds_layout[1]; |
| 5140 | pipeline_layout_ci.setLayoutCount = 2; |
| 5141 | pipeline_layout_ci.pSetLayouts = pl_bad_s0; |
| 5142 | VkPipelineLayout pipe_layout_bad_set0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5143 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5144 | &pipe_layout_bad_set0); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5145 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5146 | |
| 5147 | // Create a buffer to update the descriptor with |
| 5148 | uint32_t qfi = 0; |
| 5149 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5150 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 5151 | buffCI.size = 1024; |
| 5152 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 5153 | buffCI.queueFamilyIndexCount = 1; |
| 5154 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5155 | |
| 5156 | VkBuffer dyub; |
| 5157 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 5158 | ASSERT_VK_SUCCESS(err); |
| 5159 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 5160 | static const uint32_t NUM_BUFFS = 5; |
| 5161 | VkDescriptorBufferInfo buffInfo[NUM_BUFFS] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5162 | for (uint32_t i = 0; i < NUM_BUFFS; ++i) { |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5163 | buffInfo[i].buffer = dyub; |
| 5164 | buffInfo[i].offset = 0; |
| 5165 | buffInfo[i].range = 1024; |
| 5166 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5167 | VkImage image; |
| 5168 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5169 | const int32_t tex_width = 32; |
| 5170 | const int32_t tex_height = 32; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5171 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5172 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5173 | image_create_info.pNext = NULL; |
| 5174 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5175 | image_create_info.format = tex_format; |
| 5176 | image_create_info.extent.width = tex_width; |
| 5177 | image_create_info.extent.height = tex_height; |
| 5178 | image_create_info.extent.depth = 1; |
| 5179 | image_create_info.mipLevels = 1; |
| 5180 | image_create_info.arrayLayers = 1; |
| 5181 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 5182 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 5183 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 5184 | image_create_info.flags = 0; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5185 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 5186 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5187 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5188 | VkMemoryRequirements memReqs; |
| 5189 | VkDeviceMemory imageMem; |
| 5190 | bool pass; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 5191 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5192 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 5193 | memAlloc.pNext = NULL; |
| 5194 | memAlloc.allocationSize = 0; |
| 5195 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 5196 | vkGetImageMemoryRequirements(m_device->device(), image, &memReqs); |
| 5197 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5198 | pass = |
| 5199 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 5200 | ASSERT_TRUE(pass); |
| 5201 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &imageMem); |
| 5202 | ASSERT_VK_SUCCESS(err); |
| 5203 | err = vkBindImageMemory(m_device->device(), image, imageMem, 0); |
| 5204 | ASSERT_VK_SUCCESS(err); |
| 5205 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5206 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5207 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 5208 | image_view_create_info.image = image; |
| 5209 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 5210 | image_view_create_info.format = tex_format; |
| 5211 | image_view_create_info.subresourceRange.layerCount = 1; |
| 5212 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 5213 | image_view_create_info.subresourceRange.levelCount = 1; |
| 5214 | image_view_create_info.subresourceRange.aspectMask = |
| 5215 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5216 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5217 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5218 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 5219 | &view); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5220 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 5221 | VkDescriptorImageInfo imageInfo[4] = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5222 | imageInfo[0].imageView = view; |
| 5223 | imageInfo[0].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 5224 | imageInfo[1].imageView = view; |
| 5225 | imageInfo[1].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 5226 | imageInfo[2].imageView = view; |
| 5227 | imageInfo[2].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 5228 | imageInfo[3].imageView = view; |
| 5229 | imageInfo[3].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5230 | |
| 5231 | static const uint32_t NUM_SET_UPDATES = 3; |
| 5232 | VkWriteDescriptorSet descriptor_write[NUM_SET_UPDATES] = {}; |
| 5233 | descriptor_write[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 5234 | descriptor_write[0].dstSet = descriptorSet[0]; |
| 5235 | descriptor_write[0].dstBinding = 0; |
| 5236 | descriptor_write[0].descriptorCount = 5; |
| 5237 | descriptor_write[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5238 | descriptor_write[0].pBufferInfo = buffInfo; |
| 5239 | descriptor_write[1].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 5240 | descriptor_write[1].dstSet = descriptorSet[1]; |
| 5241 | descriptor_write[1].dstBinding = 0; |
| 5242 | descriptor_write[1].descriptorCount = 2; |
| 5243 | descriptor_write[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 5244 | descriptor_write[1].pImageInfo = imageInfo; |
| 5245 | descriptor_write[2].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 5246 | descriptor_write[2].dstSet = descriptorSet[1]; |
| 5247 | descriptor_write[2].dstBinding = 1; |
| 5248 | descriptor_write[2].descriptorCount = 2; |
| 5249 | descriptor_write[2].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 5250 | descriptor_write[2].pImageInfo = &imageInfo[2]; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5251 | |
| 5252 | vkUpdateDescriptorSets(m_device->device(), 3, descriptor_write, 0, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5253 | |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5254 | // Create PSO to be used for draw-time errors below |
| 5255 | char const *vsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 5256 | "#version 450\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5257 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 5258 | "out gl_PerVertex {\n" |
| 5259 | " vec4 gl_Position;\n" |
| 5260 | "};\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5261 | "void main(){\n" |
| 5262 | " gl_Position = vec4(1);\n" |
| 5263 | "}\n"; |
| 5264 | char const *fsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 5265 | "#version 450\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5266 | "\n" |
| 5267 | "layout(location=0) out vec4 x;\n" |
| 5268 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 5269 | "void main(){\n" |
| 5270 | " x = vec4(bar.y);\n" |
| 5271 | "}\n"; |
| 5272 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5273 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5274 | VkPipelineObj pipe(m_device); |
| 5275 | pipe.AddShader(&vs); |
| 5276 | pipe.AddShader(&fs); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5277 | pipe.AddColorAttachment(); |
| 5278 | pipe.CreateVKPipeline(pipe_layout_fs_only, renderPass()); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5279 | |
| 5280 | BeginCommandBuffer(); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5281 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5282 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 5283 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 5284 | // NOTE : I believe LunarG ilo driver has bug (LX#189) that requires binding |
| 5285 | // of PSO |
| 5286 | // here before binding DSs. Otherwise we assert in cmd_copy_dset_data() of |
| 5287 | // cmd_pipeline.c |
| 5288 | // due to the fact that cmd_alloc_dset_data() has not been called in |
| 5289 | // cmd_bind_graphics_pipeline() |
| 5290 | // TODO : Want to cause various binding incompatibility issues here to test |
| 5291 | // DrawState |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5292 | // First cause various verify_layout_compatibility() fails |
| 5293 | // Second disturb early and late sets and verify INFO msgs |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5294 | // verify_set_layout_compatibility fail cases: |
| 5295 | // 1. invalid VkPipelineLayout (layout) passed into vkCmdBindDescriptorSets |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5296 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5297 | " due to: invalid VkPipelineLayout "); |
| 5298 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5299 | VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5300 | (VkPipelineLayout)((size_t)0xbaadb1be), 0, 1, |
| 5301 | &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5302 | m_errorMonitor->VerifyFound(); |
| 5303 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5304 | // 2. layoutIndex exceeds # of layouts in layout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5305 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5306 | " attempting to bind set to index 1"); |
| 5307 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5308 | VK_PIPELINE_BIND_POINT_GRAPHICS, single_pipe_layout, |
| 5309 | 0, 2, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5310 | m_errorMonitor->VerifyFound(); |
| 5311 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5312 | vkDestroyPipelineLayout(m_device->device(), single_pipe_layout, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5313 | // 3. Pipeline setLayout[0] has 2 descriptors, but set being bound has 5 |
| 5314 | // descriptors |
| 5315 | m_errorMonitor->SetDesiredFailureMsg( |
| 5316 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 5317 | " has 2 descriptors, but DescriptorSetLayout "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5318 | vkCmdBindDescriptorSets( |
| 5319 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5320 | pipe_layout_one_desc, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5321 | m_errorMonitor->VerifyFound(); |
| 5322 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5323 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_one_desc, NULL); |
| 5324 | // 4. same # of descriptors but mismatch in type |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5325 | m_errorMonitor->SetDesiredFailureMsg( |
| 5326 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 5327 | " is type 'VK_DESCRIPTOR_TYPE_SAMPLER' but binding "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5328 | vkCmdBindDescriptorSets( |
| 5329 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5330 | pipe_layout_five_samp, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5331 | m_errorMonitor->VerifyFound(); |
| 5332 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5333 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_five_samp, NULL); |
| 5334 | // 5. same # of descriptors but mismatch in stageFlags |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5335 | m_errorMonitor->SetDesiredFailureMsg( |
| 5336 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 5337 | " has stageFlags 16 but binding 0 for DescriptorSetLayout "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5338 | vkCmdBindDescriptorSets( |
| 5339 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5340 | pipe_layout_fs_only, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5341 | m_errorMonitor->VerifyFound(); |
| 5342 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5343 | // Cause INFO messages due to disturbing previously bound Sets |
| 5344 | // First bind sets 0 & 1 |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5345 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5346 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 5347 | 2, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5348 | // 1. Disturb bound set0 by re-binding set1 w/ updated pipelineLayout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5349 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 5350 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5351 | " previously bound as set #0 was disturbed "); |
| 5352 | vkCmdBindDescriptorSets( |
| 5353 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5354 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5355 | m_errorMonitor->VerifyFound(); |
| 5356 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5357 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5358 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 5359 | 2, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5360 | // 2. Disturb set after last bound set |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 5361 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5362 | " newly bound as set #0 so set #1 and " |
| 5363 | "any subsequent sets were disturbed "); |
| 5364 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5365 | VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5366 | pipe_layout_fs_only, 0, 1, &ds0_fs_only, 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5367 | m_errorMonitor->VerifyFound(); |
| 5368 | |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5369 | // Cause draw-time errors due to PSO incompatibilities |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5370 | // 1. Error due to not binding required set (we actually use same code as |
| 5371 | // above to disturb set0) |
| 5372 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5373 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 5374 | 2, &descriptorSet[0], 0, NULL); |
| 5375 | vkCmdBindDescriptorSets( |
| 5376 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5377 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
| 5378 | m_errorMonitor->SetDesiredFailureMsg( |
| 5379 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5380 | " uses set #0 but that set is not bound."); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5381 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5382 | m_errorMonitor->VerifyFound(); |
| 5383 | |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 5384 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_bad_set0, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5385 | // 2. Error due to bound set not being compatible with PSO's |
| 5386 | // VkPipelineLayout (diff stageFlags in this case) |
| 5387 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5388 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 5389 | 2, &descriptorSet[0], 0, NULL); |
| 5390 | m_errorMonitor->SetDesiredFailureMsg( |
| 5391 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5392 | " bound as set #0 is not compatible with "); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5393 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5394 | m_errorMonitor->VerifyFound(); |
| 5395 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5396 | // Remaining clean-up |
| 5397 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_fs_only, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5398 | for (uint32_t i = 0; i < NUM_LAYOUTS; ++i) { |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5399 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout[i], NULL); |
| 5400 | } |
| 5401 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout_fs_only, NULL); |
Tobin Ehlis | 9bfd449 | 2016-05-05 15:09:11 -0600 | [diff] [blame] | 5402 | vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &ds0_fs_only); |
| 5403 | vkFreeDescriptorSets(m_device->device(), ds_pool, NUM_SETS, descriptorSet); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5404 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5405 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5406 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 5407 | } |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5408 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5409 | TEST_F(VkLayerTest, NoBeginCommandBuffer) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5410 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5411 | m_errorMonitor->SetDesiredFailureMsg( |
| 5412 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5413 | "You must call vkBeginCommandBuffer() before this call to "); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5414 | |
| 5415 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5416 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5417 | // Call EndCommandBuffer() w/o calling BeginCommandBuffer() |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5418 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5419 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5420 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5421 | } |
| 5422 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5423 | TEST_F(VkLayerTest, SecondaryCommandBufferNullRenderpass) { |
| 5424 | VkResult err; |
| 5425 | VkCommandBuffer draw_cmd; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5426 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5427 | m_errorMonitor->SetDesiredFailureMsg( |
| 5428 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 61b36f3 | 2015-12-16 08:19:42 -0700 | [diff] [blame] | 5429 | " must specify a valid renderpass parameter."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5430 | |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 5431 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 5432 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5433 | VkCommandBufferAllocateInfo cmd = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5434 | cmd.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 5435 | cmd.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5436 | cmd.commandPool = m_commandPool; |
| 5437 | cmd.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5438 | cmd.commandBufferCount = 1; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 5439 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5440 | err = vkAllocateCommandBuffers(m_device->device(), &cmd, &draw_cmd); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5441 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 5442 | |
| 5443 | // Force the failure by not setting the Renderpass and Framebuffer fields |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5444 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5445 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5446 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 5447 | cmd_buf_info.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5448 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT | |
| 5449 | VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5450 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 5451 | |
| 5452 | // The error should be caught by validation of the BeginCommandBuffer call |
| 5453 | vkBeginCommandBuffer(draw_cmd, &cmd_buf_info); |
| 5454 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5455 | m_errorMonitor->VerifyFound(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5456 | vkFreeCommandBuffers(m_device->device(), m_commandPool, 1, &draw_cmd); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 5457 | } |
| 5458 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5459 | TEST_F(VkLayerTest, CommandBufferResetErrors) { |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5460 | // Cause error due to Begin while recording CB |
| 5461 | // Then cause 2 errors for attempting to reset CB w/o having |
| 5462 | // VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT set for the pool from |
| 5463 | // which CBs were allocated. Note that this bit is off by default. |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5464 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5465 | "Cannot call Begin on CB"); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5466 | |
| 5467 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5468 | |
| 5469 | // Calls AllocateCommandBuffers |
| 5470 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
| 5471 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5472 | // Force the failure by setting the Renderpass and Framebuffer fields with |
| 5473 | // (fake) data |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5474 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5475 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5476 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 5477 | cmd_buf_info.pNext = NULL; |
| 5478 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5479 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5480 | |
| 5481 | // Begin CB to transition to recording state |
| 5482 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
| 5483 | // Can't re-begin. This should trigger error |
| 5484 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5485 | m_errorMonitor->VerifyFound(); |
| 5486 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5487 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5488 | "Attempt to reset command buffer "); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5489 | VkCommandBufferResetFlags flags = 0; // Don't care about flags for this test |
| 5490 | // Reset attempt will trigger error due to incorrect CommandPool state |
| 5491 | vkResetCommandBuffer(commandBuffer.GetBufferHandle(), flags); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5492 | m_errorMonitor->VerifyFound(); |
| 5493 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5494 | m_errorMonitor->SetDesiredFailureMsg( |
| 5495 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5496 | " attempts to implicitly reset cmdBuffer created from "); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5497 | // Transition CB to RECORDED state |
| 5498 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
| 5499 | // Now attempting to Begin will implicitly reset, which triggers error |
| 5500 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5501 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5502 | } |
| 5503 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5504 | TEST_F(VkLayerTest, InvalidPipelineCreateState) { |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5505 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5506 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5507 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5508 | m_errorMonitor->SetDesiredFailureMsg( |
| 5509 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5510 | "Invalid Pipeline CreateInfo State: Vtx Shader required"); |
| 5511 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5512 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 5513 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 5514 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5515 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5516 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5517 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5518 | |
| 5519 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5520 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5521 | ds_pool_ci.pNext = NULL; |
| 5522 | ds_pool_ci.maxSets = 1; |
| 5523 | ds_pool_ci.poolSizeCount = 1; |
| 5524 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 5525 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5526 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5527 | err = |
| 5528 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5529 | ASSERT_VK_SUCCESS(err); |
| 5530 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5531 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5532 | dsl_binding.binding = 0; |
| 5533 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5534 | dsl_binding.descriptorCount = 1; |
| 5535 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5536 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5537 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5538 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5539 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5540 | ds_layout_ci.pNext = NULL; |
| 5541 | ds_layout_ci.bindingCount = 1; |
| 5542 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5543 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5544 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5545 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5546 | &ds_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5547 | ASSERT_VK_SUCCESS(err); |
| 5548 | |
| 5549 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5550 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5551 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5552 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5553 | alloc_info.descriptorPool = ds_pool; |
| 5554 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5555 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5556 | &descriptorSet); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5557 | ASSERT_VK_SUCCESS(err); |
| 5558 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5559 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5560 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5561 | pipeline_layout_ci.setLayoutCount = 1; |
| 5562 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5563 | |
| 5564 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5565 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5566 | &pipeline_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5567 | ASSERT_VK_SUCCESS(err); |
| 5568 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5569 | VkViewport vp = {}; // Just need dummy vp to point to |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5570 | VkRect2D sc = {}; // dummy scissor to point to |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5571 | |
| 5572 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5573 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 5574 | vp_state_ci.scissorCount = 1; |
| 5575 | vp_state_ci.pScissors = ≻ |
| 5576 | vp_state_ci.viewportCount = 1; |
| 5577 | vp_state_ci.pViewports = &vp; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5578 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 5579 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 5580 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 5581 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 5582 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 5583 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 5584 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 5585 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 5586 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 5587 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5588 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5589 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 5590 | gp_ci.pViewportState = &vp_state_ci; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 5591 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5592 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 5593 | gp_ci.layout = pipeline_layout; |
| 5594 | gp_ci.renderPass = renderPass(); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5595 | |
| 5596 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5597 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 5598 | pc_ci.initialDataSize = 0; |
| 5599 | pc_ci.pInitialData = 0; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5600 | |
| 5601 | VkPipeline pipeline; |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 5602 | VkPipelineCache pipelineCache; |
| 5603 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5604 | err = |
| 5605 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 5606 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5607 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 5608 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 5609 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5610 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5611 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5612 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 5613 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5614 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5615 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5616 | } |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5617 | /*// TODO : This test should be good, but needs Tess support in compiler to run |
| 5618 | TEST_F(VkLayerTest, InvalidPatchControlPoints) |
| 5619 | { |
| 5620 | // Attempt to Create Gfx Pipeline w/o a VS |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5621 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5622 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5623 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5624 | "Invalid Pipeline CreateInfo State: VK_PRIMITIVE_TOPOLOGY_PATCH |
| 5625 | primitive "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5626 | |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5627 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5628 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5629 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5630 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5631 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5632 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5633 | |
| 5634 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 5635 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5636 | ds_pool_ci.pNext = NULL; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5637 | ds_pool_ci.poolSizeCount = 1; |
| 5638 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5639 | |
| 5640 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5641 | err = vkCreateDescriptorPool(m_device->device(), |
| 5642 | 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] | 5643 | ASSERT_VK_SUCCESS(err); |
| 5644 | |
| 5645 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5646 | dsl_binding.binding = 0; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5647 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 5648 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5649 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5650 | dsl_binding.pImmutableSamplers = NULL; |
| 5651 | |
| 5652 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5653 | ds_layout_ci.sType = |
| 5654 | VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5655 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5656 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 5657 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5658 | |
| 5659 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5660 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5661 | &ds_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5662 | ASSERT_VK_SUCCESS(err); |
| 5663 | |
| 5664 | VkDescriptorSet descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5665 | err = vkAllocateDescriptorSets(m_device->device(), ds_pool, |
| 5666 | VK_DESCRIPTOR_SET_USAGE_NON_FREE, 1, &ds_layout, &descriptorSet); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5667 | ASSERT_VK_SUCCESS(err); |
| 5668 | |
| 5669 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5670 | pipeline_layout_ci.sType = |
| 5671 | VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5672 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5673 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5674 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 5675 | |
| 5676 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5677 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5678 | &pipeline_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5679 | ASSERT_VK_SUCCESS(err); |
| 5680 | |
| 5681 | VkPipelineShaderStageCreateInfo shaderStages[3]; |
| 5682 | memset(&shaderStages, 0, 3 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 5683 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5684 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, |
| 5685 | this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5686 | // 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] | 5687 | VkShaderObj |
| 5688 | tc(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, |
| 5689 | this); |
| 5690 | VkShaderObj |
| 5691 | te(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, |
| 5692 | this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5693 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5694 | shaderStages[0].sType = |
| 5695 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5696 | shaderStages[0].stage = VK_SHADER_STAGE_VERTEX_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5697 | shaderStages[0].shader = vs.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5698 | shaderStages[1].sType = |
| 5699 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5700 | shaderStages[1].stage = VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5701 | shaderStages[1].shader = tc.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5702 | shaderStages[2].sType = |
| 5703 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5704 | shaderStages[2].stage = VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5705 | shaderStages[2].shader = te.handle(); |
| 5706 | |
| 5707 | VkPipelineInputAssemblyStateCreateInfo iaCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5708 | iaCI.sType = |
| 5709 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
Chia-I Wu | 515eb8f | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5710 | iaCI.topology = VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5711 | |
| 5712 | VkPipelineTessellationStateCreateInfo tsCI = {}; |
| 5713 | tsCI.sType = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO; |
| 5714 | tsCI.patchControlPoints = 0; // This will cause an error |
| 5715 | |
| 5716 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 5717 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 5718 | gp_ci.pNext = NULL; |
| 5719 | gp_ci.stageCount = 3; |
| 5720 | gp_ci.pStages = shaderStages; |
| 5721 | gp_ci.pVertexInputState = NULL; |
| 5722 | gp_ci.pInputAssemblyState = &iaCI; |
| 5723 | gp_ci.pTessellationState = &tsCI; |
| 5724 | gp_ci.pViewportState = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5725 | gp_ci.pRasterizationState = NULL; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5726 | gp_ci.pMultisampleState = NULL; |
| 5727 | gp_ci.pDepthStencilState = NULL; |
| 5728 | gp_ci.pColorBlendState = NULL; |
| 5729 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 5730 | gp_ci.layout = pipeline_layout; |
| 5731 | gp_ci.renderPass = renderPass(); |
| 5732 | |
| 5733 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 5734 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 5735 | pc_ci.pNext = NULL; |
| 5736 | pc_ci.initialSize = 0; |
| 5737 | pc_ci.initialData = 0; |
| 5738 | pc_ci.maxSize = 0; |
| 5739 | |
| 5740 | VkPipeline pipeline; |
| 5741 | VkPipelineCache pipelineCache; |
| 5742 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5743 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, |
| 5744 | &pipelineCache); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5745 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5746 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 5747 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5748 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5749 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5750 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5751 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 5752 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5753 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5754 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5755 | } |
| 5756 | */ |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5757 | // Set scissor and viewport counts to different numbers |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5758 | TEST_F(VkLayerTest, PSOViewportScissorCountMismatch) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5759 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5760 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5761 | m_errorMonitor->SetDesiredFailureMsg( |
| 5762 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5763 | "Gfx Pipeline viewport count (1) must match scissor count (0)."); |
| 5764 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5765 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5766 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5767 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5768 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5769 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5770 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5771 | |
| 5772 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5773 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5774 | ds_pool_ci.maxSets = 1; |
| 5775 | ds_pool_ci.poolSizeCount = 1; |
| 5776 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5777 | |
| 5778 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5779 | err = |
| 5780 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5781 | ASSERT_VK_SUCCESS(err); |
| 5782 | |
| 5783 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5784 | dsl_binding.binding = 0; |
| 5785 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5786 | dsl_binding.descriptorCount = 1; |
| 5787 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5788 | |
| 5789 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5790 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5791 | ds_layout_ci.bindingCount = 1; |
| 5792 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5793 | |
| 5794 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5795 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5796 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5797 | ASSERT_VK_SUCCESS(err); |
| 5798 | |
| 5799 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5800 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5801 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5802 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5803 | alloc_info.descriptorPool = ds_pool; |
| 5804 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5805 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5806 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5807 | ASSERT_VK_SUCCESS(err); |
| 5808 | |
| 5809 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5810 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5811 | pipeline_layout_ci.setLayoutCount = 1; |
| 5812 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5813 | |
| 5814 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5815 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5816 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5817 | ASSERT_VK_SUCCESS(err); |
| 5818 | |
| 5819 | VkViewport vp = {}; // Just need dummy vp to point to |
| 5820 | |
| 5821 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5822 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 5823 | vp_state_ci.scissorCount = 0; |
| 5824 | vp_state_ci.viewportCount = 1; // Count mismatch should cause error |
| 5825 | vp_state_ci.pViewports = &vp; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5826 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 5827 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 5828 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 5829 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 5830 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 5831 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 5832 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 5833 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 5834 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 5835 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 5836 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5837 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5838 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5839 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 5840 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5841 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 5842 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 5843 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5844 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5845 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 5846 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5847 | |
| 5848 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5849 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 5850 | gp_ci.stageCount = 2; |
| 5851 | gp_ci.pStages = shaderStages; |
| 5852 | gp_ci.pViewportState = &vp_state_ci; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 5853 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5854 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 5855 | gp_ci.layout = pipeline_layout; |
| 5856 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5857 | |
| 5858 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5859 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5860 | |
| 5861 | VkPipeline pipeline; |
| 5862 | VkPipelineCache pipelineCache; |
| 5863 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5864 | err = |
| 5865 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5866 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5867 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 5868 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5869 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5870 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5871 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5872 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 5873 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5874 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5875 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5876 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5877 | // Don't set viewport state in PSO. This is an error b/c we always need this |
| 5878 | // state |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 5879 | // 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] | 5880 | TEST_F(VkLayerTest, PSOViewportStateNotSet) { |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5881 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5882 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5883 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5884 | m_errorMonitor->SetDesiredFailureMsg( |
| 5885 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5886 | "Gfx Pipeline pViewportState is null. Even if "); |
| 5887 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5888 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5889 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5890 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5891 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5892 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5893 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5894 | |
| 5895 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5896 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5897 | ds_pool_ci.maxSets = 1; |
| 5898 | ds_pool_ci.poolSizeCount = 1; |
| 5899 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5900 | |
| 5901 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5902 | err = |
| 5903 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5904 | ASSERT_VK_SUCCESS(err); |
| 5905 | |
| 5906 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5907 | dsl_binding.binding = 0; |
| 5908 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5909 | dsl_binding.descriptorCount = 1; |
| 5910 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5911 | |
| 5912 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5913 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5914 | ds_layout_ci.bindingCount = 1; |
| 5915 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5916 | |
| 5917 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5918 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5919 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5920 | ASSERT_VK_SUCCESS(err); |
| 5921 | |
| 5922 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5923 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5924 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5925 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5926 | alloc_info.descriptorPool = ds_pool; |
| 5927 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5928 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5929 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5930 | ASSERT_VK_SUCCESS(err); |
| 5931 | |
| 5932 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5933 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5934 | pipeline_layout_ci.setLayoutCount = 1; |
| 5935 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5936 | |
| 5937 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5938 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5939 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5940 | ASSERT_VK_SUCCESS(err); |
| 5941 | |
| 5942 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 5943 | // Set scissor as dynamic to avoid second error |
| 5944 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5945 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 5946 | dyn_state_ci.dynamicStateCount = 1; |
| 5947 | dyn_state_ci.pDynamicStates = &sc_state; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5948 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 5949 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5950 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5951 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5952 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 5953 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5954 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 5955 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 5956 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5957 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5958 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 5959 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5960 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 5961 | |
| 5962 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 5963 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 5964 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 5965 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 5966 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 5967 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 5968 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 5969 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 5970 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5971 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5972 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 5973 | gp_ci.stageCount = 2; |
| 5974 | gp_ci.pStages = shaderStages; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 5975 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5976 | gp_ci.pViewportState = NULL; // Not setting VP state w/o dynamic vp state |
| 5977 | // should cause validation error |
| 5978 | gp_ci.pDynamicState = &dyn_state_ci; |
| 5979 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 5980 | gp_ci.layout = pipeline_layout; |
| 5981 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5982 | |
| 5983 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5984 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5985 | |
| 5986 | VkPipeline pipeline; |
| 5987 | VkPipelineCache pipelineCache; |
| 5988 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5989 | err = |
| 5990 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5991 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5992 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 5993 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5994 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5995 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5996 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5997 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 5998 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5999 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6000 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6001 | } |
| 6002 | // Create PSO w/o non-zero viewportCount but no viewport data |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6003 | // Then run second test where dynamic scissor count doesn't match PSO scissor |
| 6004 | // count |
| 6005 | TEST_F(VkLayerTest, PSOViewportCountWithoutDataAndDynScissorMismatch) { |
| 6006 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6007 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6008 | m_errorMonitor->SetDesiredFailureMsg( |
| 6009 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6010 | "Gfx Pipeline viewportCount is 1, but pViewports is NULL. "); |
| 6011 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6012 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6013 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6014 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6015 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6016 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6017 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6018 | |
| 6019 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6020 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6021 | ds_pool_ci.maxSets = 1; |
| 6022 | ds_pool_ci.poolSizeCount = 1; |
| 6023 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6024 | |
| 6025 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6026 | err = |
| 6027 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6028 | ASSERT_VK_SUCCESS(err); |
| 6029 | |
| 6030 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6031 | dsl_binding.binding = 0; |
| 6032 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6033 | dsl_binding.descriptorCount = 1; |
| 6034 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6035 | |
| 6036 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6037 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6038 | ds_layout_ci.bindingCount = 1; |
| 6039 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6040 | |
| 6041 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6042 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6043 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6044 | ASSERT_VK_SUCCESS(err); |
| 6045 | |
| 6046 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6047 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6048 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6049 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 6050 | alloc_info.descriptorPool = ds_pool; |
| 6051 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6052 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6053 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6054 | ASSERT_VK_SUCCESS(err); |
| 6055 | |
| 6056 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6057 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6058 | pipeline_layout_ci.setLayoutCount = 1; |
| 6059 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6060 | |
| 6061 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6062 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6063 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6064 | ASSERT_VK_SUCCESS(err); |
| 6065 | |
| 6066 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6067 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 6068 | vp_state_ci.viewportCount = 1; |
| 6069 | vp_state_ci.pViewports = NULL; // Null vp w/ count of 1 should cause error |
| 6070 | vp_state_ci.scissorCount = 1; |
| 6071 | vp_state_ci.pScissors = |
| 6072 | NULL; // Scissor is dynamic (below) so this won't cause error |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6073 | |
| 6074 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 6075 | // Set scissor as dynamic to avoid that error |
| 6076 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6077 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 6078 | dyn_state_ci.dynamicStateCount = 1; |
| 6079 | dyn_state_ci.pDynamicStates = &sc_state; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6080 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 6081 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6082 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6083 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6084 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6085 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6086 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6087 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6088 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6089 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 6090 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 6091 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6092 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 6093 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 6094 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 6095 | vi_ci.pNext = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6096 | vi_ci.vertexBindingDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 6097 | vi_ci.pVertexBindingDescriptions = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6098 | vi_ci.vertexAttributeDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 6099 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 6100 | |
| 6101 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 6102 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 6103 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 6104 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6105 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6106 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 6107 | rs_ci.pNext = nullptr; |
| 6108 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6109 | VkPipelineColorBlendAttachmentState att = {}; |
| 6110 | att.blendEnable = VK_FALSE; |
| 6111 | att.colorWriteMask = 0xf; |
| 6112 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 6113 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 6114 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 6115 | cb_ci.pNext = nullptr; |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6116 | cb_ci.attachmentCount = 1; |
| 6117 | cb_ci.pAttachments = &att; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 6118 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6119 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6120 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 6121 | gp_ci.stageCount = 2; |
| 6122 | gp_ci.pStages = shaderStages; |
| 6123 | gp_ci.pVertexInputState = &vi_ci; |
| 6124 | gp_ci.pInputAssemblyState = &ia_ci; |
| 6125 | gp_ci.pViewportState = &vp_state_ci; |
| 6126 | gp_ci.pRasterizationState = &rs_ci; |
| 6127 | gp_ci.pColorBlendState = &cb_ci; |
| 6128 | gp_ci.pDynamicState = &dyn_state_ci; |
| 6129 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 6130 | gp_ci.layout = pipeline_layout; |
| 6131 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6132 | |
| 6133 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6134 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6135 | |
| 6136 | VkPipeline pipeline; |
| 6137 | VkPipelineCache pipelineCache; |
| 6138 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6139 | err = |
| 6140 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6141 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6142 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6143 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6144 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6145 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6146 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6147 | // 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] | 6148 | // First need to successfully create the PSO from above by setting |
| 6149 | // pViewports |
| 6150 | m_errorMonitor->SetDesiredFailureMsg( |
| 6151 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6152 | "Dynamic scissorCount from vkCmdSetScissor() is 2, but PSO " |
| 6153 | "scissorCount is 1. These counts must match."); |
| 6154 | |
| 6155 | VkViewport vp = {}; // Just need dummy vp to point to |
| 6156 | vp_state_ci.pViewports = &vp; |
| 6157 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6158 | &gp_ci, NULL, &pipeline); |
| 6159 | ASSERT_VK_SUCCESS(err); |
| 6160 | BeginCommandBuffer(); |
| 6161 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 6162 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
| 6163 | VkRect2D scissors[2] = {}; // don't care about data |
| 6164 | // Count of 2 doesn't match PSO count of 1 |
| 6165 | vkCmdSetScissor(m_commandBuffer->GetBufferHandle(), 0, 2, scissors); |
| 6166 | Draw(1, 0, 0, 0); |
| 6167 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6168 | m_errorMonitor->VerifyFound(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6169 | |
| 6170 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 6171 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6172 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6173 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 6174 | } |
| 6175 | // Create PSO w/o non-zero scissorCount but no scissor data |
| 6176 | // Then run second test where dynamic viewportCount doesn't match PSO |
| 6177 | // viewportCount |
| 6178 | TEST_F(VkLayerTest, PSOScissorCountWithoutDataAndDynViewportMismatch) { |
| 6179 | VkResult err; |
| 6180 | |
| 6181 | m_errorMonitor->SetDesiredFailureMsg( |
| 6182 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6183 | "Gfx Pipeline scissorCount is 1, but pScissors is NULL. "); |
| 6184 | |
| 6185 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6186 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6187 | |
| 6188 | VkDescriptorPoolSize ds_type_count = {}; |
| 6189 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6190 | ds_type_count.descriptorCount = 1; |
| 6191 | |
| 6192 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 6193 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6194 | ds_pool_ci.maxSets = 1; |
| 6195 | ds_pool_ci.poolSizeCount = 1; |
| 6196 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 6197 | |
| 6198 | VkDescriptorPool ds_pool; |
| 6199 | err = |
| 6200 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 6201 | ASSERT_VK_SUCCESS(err); |
| 6202 | |
| 6203 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 6204 | dsl_binding.binding = 0; |
| 6205 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6206 | dsl_binding.descriptorCount = 1; |
| 6207 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6208 | |
| 6209 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 6210 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6211 | ds_layout_ci.bindingCount = 1; |
| 6212 | ds_layout_ci.pBindings = &dsl_binding; |
| 6213 | |
| 6214 | VkDescriptorSetLayout ds_layout; |
| 6215 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6216 | &ds_layout); |
| 6217 | ASSERT_VK_SUCCESS(err); |
| 6218 | |
| 6219 | VkDescriptorSet descriptorSet; |
| 6220 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 6221 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 6222 | alloc_info.descriptorSetCount = 1; |
| 6223 | alloc_info.descriptorPool = ds_pool; |
| 6224 | alloc_info.pSetLayouts = &ds_layout; |
| 6225 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6226 | &descriptorSet); |
| 6227 | ASSERT_VK_SUCCESS(err); |
| 6228 | |
| 6229 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 6230 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6231 | pipeline_layout_ci.setLayoutCount = 1; |
| 6232 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 6233 | |
| 6234 | VkPipelineLayout pipeline_layout; |
| 6235 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6236 | &pipeline_layout); |
| 6237 | ASSERT_VK_SUCCESS(err); |
| 6238 | |
| 6239 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 6240 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 6241 | vp_state_ci.scissorCount = 1; |
| 6242 | vp_state_ci.pScissors = |
| 6243 | NULL; // Null scissor w/ count of 1 should cause error |
| 6244 | vp_state_ci.viewportCount = 1; |
| 6245 | vp_state_ci.pViewports = |
| 6246 | NULL; // vp is dynamic (below) so this won't cause error |
| 6247 | |
| 6248 | VkDynamicState vp_state = VK_DYNAMIC_STATE_VIEWPORT; |
| 6249 | // Set scissor as dynamic to avoid that error |
| 6250 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 6251 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 6252 | dyn_state_ci.dynamicStateCount = 1; |
| 6253 | dyn_state_ci.pDynamicStates = &vp_state; |
| 6254 | |
| 6255 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 6256 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 6257 | |
| 6258 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6259 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6260 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6261 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6262 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6263 | // but add it to be able to run on more devices |
| 6264 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 6265 | shaderStages[1] = fs.GetStageCreateInfo(); |
| 6266 | |
| 6267 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 6268 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 6269 | vi_ci.pNext = nullptr; |
| 6270 | vi_ci.vertexBindingDescriptionCount = 0; |
| 6271 | vi_ci.pVertexBindingDescriptions = nullptr; |
| 6272 | vi_ci.vertexAttributeDescriptionCount = 0; |
| 6273 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 6274 | |
| 6275 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 6276 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 6277 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 6278 | |
| 6279 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
| 6280 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 6281 | rs_ci.pNext = nullptr; |
| 6282 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6283 | VkPipelineColorBlendAttachmentState att = {}; |
| 6284 | att.blendEnable = VK_FALSE; |
| 6285 | att.colorWriteMask = 0xf; |
| 6286 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6287 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 6288 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 6289 | cb_ci.pNext = nullptr; |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6290 | cb_ci.attachmentCount = 1; |
| 6291 | cb_ci.pAttachments = &att; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6292 | |
| 6293 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 6294 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 6295 | gp_ci.stageCount = 2; |
| 6296 | gp_ci.pStages = shaderStages; |
| 6297 | gp_ci.pVertexInputState = &vi_ci; |
| 6298 | gp_ci.pInputAssemblyState = &ia_ci; |
| 6299 | gp_ci.pViewportState = &vp_state_ci; |
| 6300 | gp_ci.pRasterizationState = &rs_ci; |
| 6301 | gp_ci.pColorBlendState = &cb_ci; |
| 6302 | gp_ci.pDynamicState = &dyn_state_ci; |
| 6303 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 6304 | gp_ci.layout = pipeline_layout; |
| 6305 | gp_ci.renderPass = renderPass(); |
| 6306 | |
| 6307 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 6308 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 6309 | |
| 6310 | VkPipeline pipeline; |
| 6311 | VkPipelineCache pipelineCache; |
| 6312 | |
| 6313 | err = |
| 6314 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 6315 | ASSERT_VK_SUCCESS(err); |
| 6316 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6317 | &gp_ci, NULL, &pipeline); |
| 6318 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6319 | m_errorMonitor->VerifyFound(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6320 | |
| 6321 | // Now hit second fail case where we set scissor w/ different count than PSO |
| 6322 | // First need to successfully create the PSO from above by setting |
| 6323 | // pViewports |
| 6324 | m_errorMonitor->SetDesiredFailureMsg( |
| 6325 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6326 | "Dynamic viewportCount from vkCmdSetViewport() is 2, but PSO " |
| 6327 | "viewportCount is 1. These counts must match."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6328 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6329 | VkRect2D sc = {}; // Just need dummy vp to point to |
| 6330 | vp_state_ci.pScissors = ≻ |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6331 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6332 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6333 | ASSERT_VK_SUCCESS(err); |
| 6334 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6335 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 6336 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6337 | VkViewport viewports[2] = {}; // don't care about data |
| 6338 | // Count of 2 doesn't match PSO count of 1 |
Jon Ashburn | 19d3bf1 | 2015-12-30 14:06:55 -0700 | [diff] [blame] | 6339 | vkCmdSetViewport(m_commandBuffer->GetBufferHandle(), 0, 2, viewports); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6340 | Draw(1, 0, 0, 0); |
| 6341 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6342 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6343 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6344 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 6345 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6346 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6347 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6348 | } |
| 6349 | |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6350 | TEST_F(VkLayerTest, PSOLineWidthInvalid) { |
| 6351 | VkResult err; |
| 6352 | |
| 6353 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 6354 | "Attempt to set lineWidth to -1"); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6355 | |
| 6356 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6357 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6358 | |
| 6359 | VkDescriptorPoolSize ds_type_count = {}; |
| 6360 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6361 | ds_type_count.descriptorCount = 1; |
| 6362 | |
| 6363 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 6364 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6365 | ds_pool_ci.maxSets = 1; |
| 6366 | ds_pool_ci.poolSizeCount = 1; |
| 6367 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 6368 | |
| 6369 | VkDescriptorPool ds_pool; |
| 6370 | err = |
| 6371 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 6372 | ASSERT_VK_SUCCESS(err); |
| 6373 | |
| 6374 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 6375 | dsl_binding.binding = 0; |
| 6376 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6377 | dsl_binding.descriptorCount = 1; |
| 6378 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6379 | |
| 6380 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 6381 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6382 | ds_layout_ci.bindingCount = 1; |
| 6383 | ds_layout_ci.pBindings = &dsl_binding; |
| 6384 | |
| 6385 | VkDescriptorSetLayout ds_layout; |
| 6386 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6387 | &ds_layout); |
| 6388 | ASSERT_VK_SUCCESS(err); |
| 6389 | |
| 6390 | VkDescriptorSet descriptorSet; |
| 6391 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 6392 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 6393 | alloc_info.descriptorSetCount = 1; |
| 6394 | alloc_info.descriptorPool = ds_pool; |
| 6395 | alloc_info.pSetLayouts = &ds_layout; |
| 6396 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6397 | &descriptorSet); |
| 6398 | ASSERT_VK_SUCCESS(err); |
| 6399 | |
| 6400 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 6401 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6402 | pipeline_layout_ci.setLayoutCount = 1; |
| 6403 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 6404 | |
| 6405 | VkPipelineLayout pipeline_layout; |
| 6406 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6407 | &pipeline_layout); |
| 6408 | ASSERT_VK_SUCCESS(err); |
| 6409 | |
| 6410 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 6411 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 6412 | vp_state_ci.scissorCount = 1; |
| 6413 | vp_state_ci.pScissors = NULL; |
| 6414 | vp_state_ci.viewportCount = 1; |
| 6415 | vp_state_ci.pViewports = NULL; |
| 6416 | |
| 6417 | VkDynamicState dynamic_states[3] = {VK_DYNAMIC_STATE_VIEWPORT, |
| 6418 | VK_DYNAMIC_STATE_SCISSOR, |
| 6419 | VK_DYNAMIC_STATE_LINE_WIDTH}; |
| 6420 | // Set scissor as dynamic to avoid that error |
| 6421 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 6422 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 6423 | dyn_state_ci.dynamicStateCount = 2; |
| 6424 | dyn_state_ci.pDynamicStates = dynamic_states; |
| 6425 | |
| 6426 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 6427 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 6428 | |
| 6429 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6430 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6431 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6432 | VK_SHADER_STAGE_FRAGMENT_BIT, |
| 6433 | this); // TODO - We shouldn't need a fragment shader |
| 6434 | // but add it to be able to run on more devices |
| 6435 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 6436 | shaderStages[1] = fs.GetStageCreateInfo(); |
| 6437 | |
| 6438 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 6439 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 6440 | vi_ci.pNext = nullptr; |
| 6441 | vi_ci.vertexBindingDescriptionCount = 0; |
| 6442 | vi_ci.pVertexBindingDescriptions = nullptr; |
| 6443 | vi_ci.vertexAttributeDescriptionCount = 0; |
| 6444 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 6445 | |
| 6446 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 6447 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 6448 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 6449 | |
| 6450 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
| 6451 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 6452 | rs_ci.pNext = nullptr; |
| 6453 | |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 6454 | // Check too low (line width of -1.0f). |
| 6455 | rs_ci.lineWidth = -1.0f; |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6456 | |
| 6457 | VkPipelineColorBlendAttachmentState att = {}; |
| 6458 | att.blendEnable = VK_FALSE; |
| 6459 | att.colorWriteMask = 0xf; |
| 6460 | |
| 6461 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 6462 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 6463 | cb_ci.pNext = nullptr; |
| 6464 | cb_ci.attachmentCount = 1; |
| 6465 | cb_ci.pAttachments = &att; |
| 6466 | |
| 6467 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 6468 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 6469 | gp_ci.stageCount = 2; |
| 6470 | gp_ci.pStages = shaderStages; |
| 6471 | gp_ci.pVertexInputState = &vi_ci; |
| 6472 | gp_ci.pInputAssemblyState = &ia_ci; |
| 6473 | gp_ci.pViewportState = &vp_state_ci; |
| 6474 | gp_ci.pRasterizationState = &rs_ci; |
| 6475 | gp_ci.pColorBlendState = &cb_ci; |
| 6476 | gp_ci.pDynamicState = &dyn_state_ci; |
| 6477 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 6478 | gp_ci.layout = pipeline_layout; |
| 6479 | gp_ci.renderPass = renderPass(); |
| 6480 | |
| 6481 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 6482 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 6483 | |
| 6484 | VkPipeline pipeline; |
| 6485 | VkPipelineCache pipelineCache; |
| 6486 | |
| 6487 | err = |
| 6488 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 6489 | ASSERT_VK_SUCCESS(err); |
| 6490 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6491 | &gp_ci, NULL, &pipeline); |
| 6492 | |
| 6493 | m_errorMonitor->VerifyFound(); |
| 6494 | |
| 6495 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6496 | "Attempt to set lineWidth to 65536"); |
| 6497 | |
| 6498 | // Check too high (line width of 65536.0f). |
| 6499 | rs_ci.lineWidth = 65536.0f; |
| 6500 | |
| 6501 | err = |
| 6502 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 6503 | ASSERT_VK_SUCCESS(err); |
| 6504 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6505 | &gp_ci, NULL, &pipeline); |
| 6506 | |
| 6507 | m_errorMonitor->VerifyFound(); |
| 6508 | |
| 6509 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 6510 | "Attempt to set lineWidth to -1"); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6511 | |
| 6512 | dyn_state_ci.dynamicStateCount = 3; |
| 6513 | |
| 6514 | rs_ci.lineWidth = 1.0f; |
| 6515 | |
| 6516 | err = |
| 6517 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 6518 | ASSERT_VK_SUCCESS(err); |
| 6519 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6520 | &gp_ci, NULL, &pipeline); |
| 6521 | BeginCommandBuffer(); |
| 6522 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 6523 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
| 6524 | |
| 6525 | // Check too low with dynamic setting. |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 6526 | vkCmdSetLineWidth(m_commandBuffer->GetBufferHandle(), -1.0f); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6527 | m_errorMonitor->VerifyFound(); |
| 6528 | |
| 6529 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6530 | "Attempt to set lineWidth to 65536"); |
| 6531 | |
| 6532 | // Check too high with dynamic setting. |
| 6533 | vkCmdSetLineWidth(m_commandBuffer->GetBufferHandle(), 65536.0f); |
| 6534 | m_errorMonitor->VerifyFound(); |
| 6535 | EndCommandBuffer(); |
| 6536 | |
| 6537 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 6538 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6539 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6540 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 6541 | } |
| 6542 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6543 | TEST_F(VkLayerTest, NullRenderPass) { |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 6544 | // Bind a NULL RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6545 | m_errorMonitor->SetDesiredFailureMsg( |
| 6546 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6547 | "You cannot use a NULL RenderPass object in vkCmdBeginRenderPass()"); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 6548 | |
| 6549 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6550 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 6551 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 6552 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6553 | // Don't care about RenderPass handle b/c error should be flagged before |
| 6554 | // that |
| 6555 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), NULL, |
| 6556 | VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 6557 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6558 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 6559 | } |
| 6560 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6561 | TEST_F(VkLayerTest, RenderPassWithinRenderPass) { |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6562 | // Bind a BeginRenderPass within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6563 | m_errorMonitor->SetDesiredFailureMsg( |
| 6564 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6565 | "It is invalid to issue this call inside an active render pass"); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6566 | |
| 6567 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6568 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6569 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 6570 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6571 | // Just create a dummy Renderpass that's non-NULL so we can get to the |
| 6572 | // proper error |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6573 | VkRenderPassBeginInfo rp_begin = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6574 | rp_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; |
| 6575 | rp_begin.pNext = NULL; |
| 6576 | rp_begin.renderPass = renderPass(); |
| 6577 | rp_begin.framebuffer = framebuffer(); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6578 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6579 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &rp_begin, |
| 6580 | VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6581 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6582 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 6583 | } |
| 6584 | |
Cody Northrop | 3bb4d96 | 2016-05-09 16:15:57 -0600 | [diff] [blame] | 6585 | TEST_F(VkLayerTest, EndCommandBufferWithinRenderPass) { |
| 6586 | |
| 6587 | TEST_DESCRIPTION("End a command buffer with an active render pass"); |
| 6588 | |
| 6589 | m_errorMonitor->SetDesiredFailureMsg( |
| 6590 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6591 | "It is invalid to issue this call inside an active render pass"); |
| 6592 | |
| 6593 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6594 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6595 | |
| 6596 | // The framework's BeginCommandBuffer calls CreateRenderPass |
| 6597 | BeginCommandBuffer(); |
| 6598 | |
| 6599 | // Call directly into vkEndCommandBuffer instead of the |
| 6600 | // the framework's EndCommandBuffer, which inserts a |
| 6601 | // vkEndRenderPass |
| 6602 | vkEndCommandBuffer(m_commandBuffer->GetBufferHandle()); |
| 6603 | |
| 6604 | m_errorMonitor->VerifyFound(); |
| 6605 | |
| 6606 | // TODO: Add test for VK_COMMAND_BUFFER_LEVEL_SECONDARY |
| 6607 | // TODO: Add test for VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT |
| 6608 | } |
| 6609 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6610 | TEST_F(VkLayerTest, FillBufferWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6611 | // Call CmdFillBuffer within an active renderpass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6612 | m_errorMonitor->SetDesiredFailureMsg( |
| 6613 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6614 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6615 | |
| 6616 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6617 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6618 | |
| 6619 | // Renderpass is started here |
| 6620 | BeginCommandBuffer(); |
| 6621 | |
| 6622 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6623 | vk_testing::Buffer dstBuffer; |
| 6624 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6625 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6626 | m_commandBuffer->FillBuffer(dstBuffer.handle(), 0, 4, 0x11111111); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6627 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6628 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6629 | } |
| 6630 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6631 | TEST_F(VkLayerTest, UpdateBufferWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6632 | // Call CmdUpdateBuffer within an active renderpass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6633 | m_errorMonitor->SetDesiredFailureMsg( |
| 6634 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6635 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6636 | |
| 6637 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6638 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6639 | |
| 6640 | // Renderpass is started here |
| 6641 | BeginCommandBuffer(); |
| 6642 | |
| 6643 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6644 | vk_testing::Buffer dstBuffer; |
| 6645 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6646 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6647 | VkDeviceSize dstOffset = 0; |
| 6648 | VkDeviceSize dataSize = 1024; |
| 6649 | const uint32_t *pData = NULL; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6650 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6651 | vkCmdUpdateBuffer(m_commandBuffer->GetBufferHandle(), dstBuffer.handle(), |
| 6652 | dstOffset, dataSize, pData); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6653 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6654 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6655 | } |
| 6656 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6657 | TEST_F(VkLayerTest, ClearColorImageWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6658 | // Call CmdClearColorImage within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6659 | m_errorMonitor->SetDesiredFailureMsg( |
| 6660 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6661 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6662 | |
| 6663 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6664 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6665 | |
| 6666 | // Renderpass is started here |
| 6667 | BeginCommandBuffer(); |
| 6668 | |
Michael Lentine | 0a369f6 | 2016-02-03 16:51:46 -0600 | [diff] [blame] | 6669 | VkClearColorValue clear_color; |
| 6670 | memset(clear_color.uint32, 0, sizeof(uint32_t) * 4); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6671 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 6672 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6673 | const int32_t tex_width = 32; |
| 6674 | const int32_t tex_height = 32; |
| 6675 | VkImageCreateInfo image_create_info = {}; |
| 6676 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6677 | image_create_info.pNext = NULL; |
| 6678 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6679 | image_create_info.format = tex_format; |
| 6680 | image_create_info.extent.width = tex_width; |
| 6681 | image_create_info.extent.height = tex_height; |
| 6682 | image_create_info.extent.depth = 1; |
| 6683 | image_create_info.mipLevels = 1; |
| 6684 | image_create_info.arrayLayers = 1; |
| 6685 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 6686 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 6687 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6688 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6689 | vk_testing::Image dstImage; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6690 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 6691 | reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6692 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6693 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
| 6694 | image_create_info, VK_IMAGE_ASPECT_COLOR_BIT); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6695 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6696 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), dstImage.handle(), |
| 6697 | VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1, &range); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6698 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6699 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6700 | } |
| 6701 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6702 | TEST_F(VkLayerTest, ClearDepthStencilImageWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6703 | // Call CmdClearDepthStencilImage within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6704 | m_errorMonitor->SetDesiredFailureMsg( |
| 6705 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6706 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6707 | |
| 6708 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6709 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6710 | |
| 6711 | // Renderpass is started here |
| 6712 | BeginCommandBuffer(); |
| 6713 | |
| 6714 | VkClearDepthStencilValue clear_value = {0}; |
Dustin Graves | a2e5c94 | 2016-02-11 18:28:06 -0700 | [diff] [blame] | 6715 | VkMemoryPropertyFlags reqs = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6716 | VkImageCreateInfo image_create_info = vk_testing::Image::create_info(); |
| 6717 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6718 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 6719 | image_create_info.extent.width = 64; |
| 6720 | image_create_info.extent.height = 64; |
| 6721 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 6722 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6723 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6724 | vk_testing::Image dstImage; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6725 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 6726 | reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6727 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6728 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
| 6729 | image_create_info, VK_IMAGE_ASPECT_DEPTH_BIT); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6730 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6731 | vkCmdClearDepthStencilImage( |
| 6732 | m_commandBuffer->GetBufferHandle(), dstImage.handle(), |
| 6733 | VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, &clear_value, 1, |
| 6734 | &range); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6735 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6736 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6737 | } |
| 6738 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6739 | TEST_F(VkLayerTest, ClearColorAttachmentsOutsideRenderPass) { |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 6740 | // Call CmdClearAttachmentss outside of an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6741 | VkResult err; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6742 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6743 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6744 | "vkCmdClearAttachments: This call " |
| 6745 | "must be issued inside an active " |
| 6746 | "render pass"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6747 | |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6748 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6749 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6750 | |
| 6751 | // Start no RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6752 | err = m_commandBuffer->BeginCommandBuffer(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6753 | ASSERT_VK_SUCCESS(err); |
| 6754 | |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 6755 | VkClearAttachment color_attachment; |
| 6756 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 6757 | color_attachment.clearValue.color.float32[0] = 0; |
| 6758 | color_attachment.clearValue.color.float32[1] = 0; |
| 6759 | color_attachment.clearValue.color.float32[2] = 0; |
| 6760 | color_attachment.clearValue.color.float32[3] = 0; |
| 6761 | color_attachment.colorAttachment = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6762 | VkClearRect clear_rect = {{{0, 0}, {32, 32}}}; |
| 6763 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
| 6764 | &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6765 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6766 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6767 | } |
| 6768 | |
Karl Schultz | 9e66a29 | 2016-04-21 15:57:51 -0600 | [diff] [blame] | 6769 | TEST_F(VkLayerTest, BufferMemoryBarrierNoBuffer) { |
| 6770 | // Try to add a buffer memory barrier with no buffer. |
| 6771 | m_errorMonitor->SetDesiredFailureMsg( |
| 6772 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6773 | "required parameter pBufferMemoryBarriers[i].buffer specified as VK_NULL_HANDLE"); |
| 6774 | |
| 6775 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6776 | BeginCommandBuffer(); |
| 6777 | |
| 6778 | VkBufferMemoryBarrier buf_barrier = {}; |
| 6779 | buf_barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; |
| 6780 | buf_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 6781 | buf_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 6782 | buf_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 6783 | buf_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 6784 | buf_barrier.buffer = VK_NULL_HANDLE; |
| 6785 | buf_barrier.offset = 0; |
| 6786 | buf_barrier.size = VK_WHOLE_SIZE; |
| 6787 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6788 | VK_PIPELINE_STAGE_HOST_BIT, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, |
| 6789 | 0, 0, nullptr, 1, &buf_barrier, 0, nullptr); |
| 6790 | |
| 6791 | m_errorMonitor->VerifyFound(); |
| 6792 | } |
| 6793 | |
Tony Barbour | 7fd5c0f | 2016-05-03 16:11:53 -0600 | [diff] [blame] | 6794 | TEST_F(VkLayerTest, InvalidBarriers) { |
| 6795 | TEST_DESCRIPTION("A variety of ways to get VK_INVALID_BARRIER "); |
| 6796 | |
| 6797 | m_errorMonitor->SetDesiredFailureMsg( |
| 6798 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Barriers cannot be set during subpass"); |
| 6799 | |
| 6800 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6801 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6802 | |
| 6803 | VkMemoryBarrier mem_barrier = {}; |
| 6804 | mem_barrier.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER; |
| 6805 | mem_barrier.pNext = NULL; |
| 6806 | mem_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 6807 | mem_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 6808 | BeginCommandBuffer(); |
| 6809 | // BeginCommandBuffer() starts a render pass |
| 6810 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6811 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6812 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 1, |
| 6813 | &mem_barrier, 0, nullptr, 0, nullptr); |
| 6814 | m_errorMonitor->VerifyFound(); |
| 6815 | |
| 6816 | m_errorMonitor->SetDesiredFailureMsg( |
| 6817 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6818 | "Image Layout cannot be transitioned to UNDEFINED"); |
| 6819 | VkImageObj image(m_device); |
| 6820 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 6821 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
| 6822 | ASSERT_TRUE(image.initialized()); |
| 6823 | VkImageMemoryBarrier img_barrier = {}; |
| 6824 | img_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; |
| 6825 | img_barrier.pNext = NULL; |
| 6826 | img_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 6827 | img_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 6828 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 6829 | // New layout can't be UNDEFINED |
| 6830 | img_barrier.newLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 6831 | img_barrier.image = image.handle(); |
| 6832 | img_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 6833 | img_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 6834 | img_barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 6835 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 6836 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 6837 | img_barrier.subresourceRange.layerCount = 1; |
| 6838 | img_barrier.subresourceRange.levelCount = 1; |
| 6839 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6840 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6841 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 6842 | nullptr, 1, &img_barrier); |
| 6843 | m_errorMonitor->VerifyFound(); |
| 6844 | img_barrier.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 6845 | |
| 6846 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6847 | "Subresource must have the sum of the " |
| 6848 | "baseArrayLayer"); |
| 6849 | // baseArrayLayer + layerCount must be <= image's arrayLayers |
| 6850 | img_barrier.subresourceRange.baseArrayLayer = 1; |
| 6851 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6852 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6853 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 6854 | nullptr, 1, &img_barrier); |
| 6855 | m_errorMonitor->VerifyFound(); |
| 6856 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 6857 | |
| 6858 | m_errorMonitor->SetDesiredFailureMsg( |
| 6859 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6860 | "Subresource must have the sum of the baseMipLevel"); |
| 6861 | // baseMipLevel + levelCount must be <= image's mipLevels |
| 6862 | img_barrier.subresourceRange.baseMipLevel = 1; |
| 6863 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6864 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6865 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 6866 | nullptr, 1, &img_barrier); |
| 6867 | m_errorMonitor->VerifyFound(); |
| 6868 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 6869 | |
| 6870 | m_errorMonitor->SetDesiredFailureMsg( |
| 6871 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6872 | "Buffer Barriers cannot be used during a render pass"); |
| 6873 | vk_testing::Buffer buffer; |
| 6874 | buffer.init(*m_device, 256); |
| 6875 | VkBufferMemoryBarrier buf_barrier = {}; |
| 6876 | buf_barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; |
| 6877 | buf_barrier.pNext = NULL; |
| 6878 | buf_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 6879 | buf_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 6880 | buf_barrier.buffer = buffer.handle(); |
| 6881 | buf_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 6882 | buf_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 6883 | buf_barrier.offset = 0; |
| 6884 | buf_barrier.size = VK_WHOLE_SIZE; |
| 6885 | // Can't send buffer barrier during a render pass |
| 6886 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6887 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6888 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 6889 | &buf_barrier, 0, nullptr); |
| 6890 | m_errorMonitor->VerifyFound(); |
| 6891 | vkCmdEndRenderPass(m_commandBuffer->GetBufferHandle()); |
| 6892 | |
| 6893 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6894 | "which is not less than total size"); |
| 6895 | buf_barrier.offset = 257; |
| 6896 | // Offset greater than total size |
| 6897 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6898 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6899 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 6900 | &buf_barrier, 0, nullptr); |
| 6901 | m_errorMonitor->VerifyFound(); |
| 6902 | buf_barrier.offset = 0; |
| 6903 | |
| 6904 | m_errorMonitor->SetDesiredFailureMsg( |
| 6905 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "whose sum is greater than total size"); |
| 6906 | buf_barrier.size = 257; |
| 6907 | // Size greater than total size |
| 6908 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6909 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6910 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 6911 | &buf_barrier, 0, nullptr); |
| 6912 | m_errorMonitor->VerifyFound(); |
| 6913 | buf_barrier.size = VK_WHOLE_SIZE; |
| 6914 | |
| 6915 | m_errorMonitor->SetDesiredFailureMsg( |
| 6916 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6917 | "Image is a depth and stencil format and thus must " |
| 6918 | "have both VK_IMAGE_ASPECT_DEPTH_BIT and " |
| 6919 | "VK_IMAGE_ASPECT_STENCIL_BIT set."); |
| 6920 | VkDepthStencilObj ds_image(m_device); |
| 6921 | ds_image.Init(m_device, 128, 128, VK_FORMAT_D24_UNORM_S8_UINT); |
| 6922 | ASSERT_TRUE(ds_image.initialized()); |
| 6923 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 6924 | img_barrier.newLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; |
| 6925 | img_barrier.image = ds_image.handle(); |
| 6926 | // Leave aspectMask at COLOR on purpose |
| 6927 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6928 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6929 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 6930 | nullptr, 1, &img_barrier); |
| 6931 | m_errorMonitor->VerifyFound(); |
| 6932 | } |
| 6933 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6934 | TEST_F(VkLayerTest, IdxBufferAlignmentError) { |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 6935 | // Bind a BeginRenderPass within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6936 | VkResult err; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 6937 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6938 | m_errorMonitor->SetDesiredFailureMsg( |
| 6939 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6940 | "vkCmdBindIndexBuffer() offset (0x7) does not fall on "); |
| 6941 | |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 6942 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6943 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 6944 | uint32_t qfi = 0; |
| 6945 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6946 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 6947 | buffCI.size = 1024; |
| 6948 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
| 6949 | buffCI.queueFamilyIndexCount = 1; |
| 6950 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 6951 | |
| 6952 | VkBuffer ib; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6953 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 6954 | ASSERT_VK_SUCCESS(err); |
| 6955 | |
| 6956 | BeginCommandBuffer(); |
| 6957 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6958 | // vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 6959 | // VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 6960 | // 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] | 6961 | vkCmdBindIndexBuffer(m_commandBuffer->GetBufferHandle(), ib, 7, |
| 6962 | VK_INDEX_TYPE_UINT16); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 6963 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6964 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 6965 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6966 | vkDestroyBuffer(m_device->device(), ib, NULL); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 6967 | } |
| 6968 | |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 6969 | TEST_F(VkLayerTest, InvalidQueueFamilyIndex) { |
| 6970 | // Create an out-of-range queueFamilyIndex |
| 6971 | m_errorMonitor->SetDesiredFailureMsg( |
| 6972 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Dustin Graves | de62853 | 2016-04-21 16:30:17 -0600 | [diff] [blame] | 6973 | "vkCreateBuffer: pCreateInfo->pQueueFamilyIndices[0] (777) must be one " |
| 6974 | "of the indices specified when the device was created, via the " |
| 6975 | "VkDeviceQueueCreateInfo structure."); |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 6976 | |
| 6977 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6978 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6979 | VkBufferCreateInfo buffCI = {}; |
| 6980 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 6981 | buffCI.size = 1024; |
| 6982 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
| 6983 | buffCI.queueFamilyIndexCount = 1; |
| 6984 | // Introduce failure by specifying invalid queue_family_index |
| 6985 | uint32_t qfi = 777; |
| 6986 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 6987 | buffCI.sharingMode = VK_SHARING_MODE_CONCURRENT; // qfi only matters in CONCURRENT mode |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 6988 | |
| 6989 | VkBuffer ib; |
| 6990 | vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
| 6991 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6992 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 6993 | } |
| 6994 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6995 | TEST_F(VkLayerTest, ExecuteCommandsPrimaryCB) { |
| 6996 | // Attempt vkCmdExecuteCommands w/ a primary cmd buffer (should only be |
| 6997 | // secondary) |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6998 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6999 | m_errorMonitor->SetDesiredFailureMsg( |
| 7000 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7001 | "vkCmdExecuteCommands() called w/ Primary Cmd Buffer "); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 7002 | |
| 7003 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7004 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 7005 | |
| 7006 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7007 | // ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7008 | VkCommandBuffer primCB = m_commandBuffer->GetBufferHandle(); |
| 7009 | vkCmdExecuteCommands(m_commandBuffer->GetBufferHandle(), 1, &primCB); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 7010 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7011 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 7012 | } |
| 7013 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7014 | TEST_F(VkLayerTest, DSTypeMismatch) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 7015 | // 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] | 7016 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7017 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7018 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7019 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7020 | " binding #0 with type VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER but update " |
| 7021 | "type is VK_DESCRIPTOR_TYPE_SAMPLER"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7022 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7023 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7024 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7025 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7026 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7027 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7028 | |
| 7029 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7030 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7031 | ds_pool_ci.pNext = NULL; |
| 7032 | ds_pool_ci.maxSets = 1; |
| 7033 | ds_pool_ci.poolSizeCount = 1; |
| 7034 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7035 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7036 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7037 | err = |
| 7038 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7039 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7040 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7041 | dsl_binding.binding = 0; |
| 7042 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7043 | dsl_binding.descriptorCount = 1; |
| 7044 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7045 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7046 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7047 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7048 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7049 | ds_layout_ci.pNext = NULL; |
| 7050 | ds_layout_ci.bindingCount = 1; |
| 7051 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7052 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7053 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7054 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7055 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7056 | ASSERT_VK_SUCCESS(err); |
| 7057 | |
| 7058 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7059 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7060 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7061 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 7062 | alloc_info.descriptorPool = ds_pool; |
| 7063 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7064 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7065 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7066 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7067 | |
Tobin Ehlis | 30db8f8 | 2016-05-05 08:19:48 -0600 | [diff] [blame] | 7068 | VkSamplerCreateInfo sampler_ci = {}; |
| 7069 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 7070 | sampler_ci.pNext = NULL; |
| 7071 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 7072 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 7073 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 7074 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7075 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7076 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7077 | sampler_ci.mipLodBias = 1.0; |
| 7078 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 7079 | sampler_ci.maxAnisotropy = 1; |
| 7080 | sampler_ci.compareEnable = VK_FALSE; |
| 7081 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 7082 | sampler_ci.minLod = 1.0; |
| 7083 | sampler_ci.maxLod = 1.0; |
| 7084 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 7085 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
| 7086 | VkSampler sampler; |
| 7087 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
| 7088 | ASSERT_VK_SUCCESS(err); |
| 7089 | |
| 7090 | VkDescriptorImageInfo info = {}; |
| 7091 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7092 | |
| 7093 | VkWriteDescriptorSet descriptor_write; |
| 7094 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 7095 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7096 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7097 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7098 | // This is a mismatched type for the layout which expects BUFFER |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7099 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 7100 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7101 | |
| 7102 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 7103 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7104 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7105 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7106 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 7107 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7108 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 7109 | } |
| 7110 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7111 | TEST_F(VkLayerTest, DSUpdateOutOfBounds) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 7112 | // For overlapping Update, have arrayIndex exceed that of layout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7113 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7114 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7115 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7116 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7117 | " binding #0 with 1 total descriptors but update of 1 descriptors " |
| 7118 | "starting at binding offset of 0 combined with update array element " |
| 7119 | "offset of 1 oversteps the size of this descriptor set."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7120 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7121 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7122 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7123 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7124 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7125 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7126 | |
| 7127 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7128 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7129 | ds_pool_ci.pNext = NULL; |
| 7130 | ds_pool_ci.maxSets = 1; |
| 7131 | ds_pool_ci.poolSizeCount = 1; |
| 7132 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7133 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7134 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7135 | err = |
| 7136 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7137 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7138 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7139 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7140 | dsl_binding.binding = 0; |
| 7141 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7142 | dsl_binding.descriptorCount = 1; |
| 7143 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7144 | dsl_binding.pImmutableSamplers = NULL; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7145 | |
| 7146 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7147 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7148 | ds_layout_ci.pNext = NULL; |
| 7149 | ds_layout_ci.bindingCount = 1; |
| 7150 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7151 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7152 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7153 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7154 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7155 | ASSERT_VK_SUCCESS(err); |
| 7156 | |
| 7157 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7158 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7159 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7160 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 7161 | alloc_info.descriptorPool = ds_pool; |
| 7162 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7163 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7164 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7165 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7166 | |
Tobin Ehlis | 30db8f8 | 2016-05-05 08:19:48 -0600 | [diff] [blame] | 7167 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 7168 | VkDescriptorBufferInfo buff_info = {}; |
| 7169 | buff_info.buffer = |
| 7170 | VkBuffer(0); // Don't care about buffer handle for this test |
| 7171 | buff_info.offset = 0; |
| 7172 | buff_info.range = 1024; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7173 | |
| 7174 | VkWriteDescriptorSet descriptor_write; |
| 7175 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 7176 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7177 | descriptor_write.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7178 | descriptor_write.dstArrayElement = |
| 7179 | 1; /* This index out of bounds for the update */ |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7180 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7181 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7182 | descriptor_write.pBufferInfo = &buff_info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7183 | |
| 7184 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 7185 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7186 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7187 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7188 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7189 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 7190 | } |
| 7191 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7192 | TEST_F(VkLayerTest, InvalidDSUpdateIndex) { |
| 7193 | // Create layout w/ count of 1 and attempt update to that layout w/ binding |
| 7194 | // index 2 |
| 7195 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7196 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7197 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7198 | " does not have binding 2."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7199 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7200 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7201 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7202 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7203 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7204 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7205 | |
| 7206 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7207 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7208 | ds_pool_ci.pNext = NULL; |
| 7209 | ds_pool_ci.maxSets = 1; |
| 7210 | ds_pool_ci.poolSizeCount = 1; |
| 7211 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 7212 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7213 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7214 | err = |
| 7215 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7216 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7217 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7218 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7219 | dsl_binding.binding = 0; |
| 7220 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7221 | dsl_binding.descriptorCount = 1; |
| 7222 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7223 | dsl_binding.pImmutableSamplers = NULL; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7224 | |
| 7225 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7226 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7227 | ds_layout_ci.pNext = NULL; |
| 7228 | ds_layout_ci.bindingCount = 1; |
| 7229 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7230 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7231 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7232 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7233 | ASSERT_VK_SUCCESS(err); |
| 7234 | |
| 7235 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7236 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7237 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7238 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 7239 | alloc_info.descriptorPool = ds_pool; |
| 7240 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7241 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7242 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7243 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7244 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7245 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7246 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 7247 | sampler_ci.pNext = NULL; |
| 7248 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 7249 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 7250 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 7251 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7252 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7253 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7254 | sampler_ci.mipLodBias = 1.0; |
| 7255 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 7256 | sampler_ci.maxAnisotropy = 1; |
| 7257 | sampler_ci.compareEnable = VK_FALSE; |
| 7258 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 7259 | sampler_ci.minLod = 1.0; |
| 7260 | sampler_ci.maxLod = 1.0; |
| 7261 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 7262 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7263 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7264 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7265 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7266 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7267 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 7268 | VkDescriptorImageInfo info = {}; |
| 7269 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7270 | |
| 7271 | VkWriteDescriptorSet descriptor_write; |
| 7272 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 7273 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7274 | descriptor_write.dstSet = descriptorSet; |
| 7275 | descriptor_write.dstBinding = 2; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7276 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7277 | // 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] | 7278 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 7279 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7280 | |
| 7281 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 7282 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7283 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7284 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7285 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 7286 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7287 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 7288 | } |
| 7289 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7290 | TEST_F(VkLayerTest, InvalidDSUpdateStruct) { |
| 7291 | // Call UpdateDS w/ struct type other than valid VK_STRUCTUR_TYPE_UPDATE_* |
| 7292 | // types |
| 7293 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7294 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7295 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 660bcdc | 2016-05-17 10:39:46 -0600 | [diff] [blame] | 7296 | ".sType must be VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7297 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7298 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 7299 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7300 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7301 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7302 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7303 | |
| 7304 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7305 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7306 | ds_pool_ci.pNext = NULL; |
| 7307 | ds_pool_ci.maxSets = 1; |
| 7308 | ds_pool_ci.poolSizeCount = 1; |
| 7309 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 7310 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7311 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7312 | err = |
| 7313 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7314 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7315 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7316 | dsl_binding.binding = 0; |
| 7317 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7318 | dsl_binding.descriptorCount = 1; |
| 7319 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7320 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7321 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7322 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7323 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7324 | ds_layout_ci.pNext = NULL; |
| 7325 | ds_layout_ci.bindingCount = 1; |
| 7326 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7327 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7328 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7329 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7330 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7331 | ASSERT_VK_SUCCESS(err); |
| 7332 | |
| 7333 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7334 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7335 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7336 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 7337 | alloc_info.descriptorPool = ds_pool; |
| 7338 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7339 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7340 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7341 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7342 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7343 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7344 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 7345 | sampler_ci.pNext = NULL; |
| 7346 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 7347 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 7348 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 7349 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7350 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7351 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7352 | sampler_ci.mipLodBias = 1.0; |
| 7353 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 7354 | sampler_ci.maxAnisotropy = 1; |
| 7355 | sampler_ci.compareEnable = VK_FALSE; |
| 7356 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 7357 | sampler_ci.minLod = 1.0; |
| 7358 | sampler_ci.maxLod = 1.0; |
| 7359 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 7360 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7361 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7362 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7363 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7364 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 7365 | VkDescriptorImageInfo info = {}; |
| 7366 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7367 | |
| 7368 | VkWriteDescriptorSet descriptor_write; |
| 7369 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7370 | descriptor_write.sType = |
| 7371 | (VkStructureType)0x99999999; /* Intentionally broken struct type */ |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7372 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7373 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7374 | // 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] | 7375 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 7376 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7377 | |
| 7378 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 7379 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7380 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7381 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7382 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 7383 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7384 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 7385 | } |
| 7386 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7387 | TEST_F(VkLayerTest, SampleDescriptorUpdateError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7388 | // Create a single Sampler descriptor and send it an invalid Sampler |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7389 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7390 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7391 | m_errorMonitor->SetDesiredFailureMsg( |
| 7392 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7393 | "Attempted write update to sampler descriptor with invalid sampler"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7394 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7395 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7396 | // TODO : Farm Descriptor setup code to helper function(s) to reduce copied |
| 7397 | // code |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7398 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7399 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 7400 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7401 | |
| 7402 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7403 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7404 | ds_pool_ci.pNext = NULL; |
| 7405 | ds_pool_ci.maxSets = 1; |
| 7406 | ds_pool_ci.poolSizeCount = 1; |
| 7407 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7408 | |
| 7409 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7410 | err = |
| 7411 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7412 | ASSERT_VK_SUCCESS(err); |
| 7413 | |
| 7414 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7415 | dsl_binding.binding = 0; |
| 7416 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 7417 | dsl_binding.descriptorCount = 1; |
| 7418 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7419 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7420 | |
| 7421 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7422 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7423 | ds_layout_ci.pNext = NULL; |
| 7424 | ds_layout_ci.bindingCount = 1; |
| 7425 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7426 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7427 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7428 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7429 | ASSERT_VK_SUCCESS(err); |
| 7430 | |
| 7431 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7432 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7433 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7434 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7435 | alloc_info.descriptorPool = ds_pool; |
| 7436 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7437 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7438 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7439 | ASSERT_VK_SUCCESS(err); |
| 7440 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7441 | VkSampler sampler = |
| 7442 | (VkSampler)((size_t)0xbaadbeef); // Sampler with invalid handle |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7443 | |
| 7444 | VkDescriptorImageInfo descriptor_info; |
| 7445 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 7446 | descriptor_info.sampler = sampler; |
| 7447 | |
| 7448 | VkWriteDescriptorSet descriptor_write; |
| 7449 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 7450 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7451 | descriptor_write.dstSet = descriptorSet; |
| 7452 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7453 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7454 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 7455 | descriptor_write.pImageInfo = &descriptor_info; |
| 7456 | |
| 7457 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 7458 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7459 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7460 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7461 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7462 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7463 | } |
| 7464 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7465 | TEST_F(VkLayerTest, ImageViewDescriptorUpdateError) { |
| 7466 | // Create a single combined Image/Sampler descriptor and send it an invalid |
| 7467 | // imageView |
| 7468 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7469 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7470 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7471 | "Attempted write update to combined " |
| 7472 | "image sampler descriptor failed due " |
Tobin Ehlis | 63c4b8a | 2016-05-09 10:29:34 -0600 | [diff] [blame] | 7473 | "to: Invalid VkImageView:"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7474 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7475 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7476 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7477 | ds_type_count.type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 7478 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7479 | |
| 7480 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7481 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7482 | ds_pool_ci.pNext = NULL; |
| 7483 | ds_pool_ci.maxSets = 1; |
| 7484 | ds_pool_ci.poolSizeCount = 1; |
| 7485 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7486 | |
| 7487 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7488 | err = |
| 7489 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7490 | ASSERT_VK_SUCCESS(err); |
| 7491 | |
| 7492 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7493 | dsl_binding.binding = 0; |
| 7494 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 7495 | dsl_binding.descriptorCount = 1; |
| 7496 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7497 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7498 | |
| 7499 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7500 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7501 | ds_layout_ci.pNext = NULL; |
| 7502 | ds_layout_ci.bindingCount = 1; |
| 7503 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7504 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7505 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7506 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7507 | ASSERT_VK_SUCCESS(err); |
| 7508 | |
| 7509 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7510 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7511 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7512 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7513 | alloc_info.descriptorPool = ds_pool; |
| 7514 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7515 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7516 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7517 | ASSERT_VK_SUCCESS(err); |
| 7518 | |
| 7519 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7520 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 7521 | sampler_ci.pNext = NULL; |
| 7522 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 7523 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 7524 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 7525 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7526 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7527 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7528 | sampler_ci.mipLodBias = 1.0; |
| 7529 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 7530 | sampler_ci.maxAnisotropy = 1; |
| 7531 | sampler_ci.compareEnable = VK_FALSE; |
| 7532 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 7533 | sampler_ci.minLod = 1.0; |
| 7534 | sampler_ci.maxLod = 1.0; |
| 7535 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 7536 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7537 | |
| 7538 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7539 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7540 | ASSERT_VK_SUCCESS(err); |
| 7541 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7542 | VkImageView view = |
| 7543 | (VkImageView)((size_t)0xbaadbeef); // invalid imageView object |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7544 | |
| 7545 | VkDescriptorImageInfo descriptor_info; |
| 7546 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 7547 | descriptor_info.sampler = sampler; |
| 7548 | descriptor_info.imageView = view; |
| 7549 | |
| 7550 | VkWriteDescriptorSet descriptor_write; |
| 7551 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 7552 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7553 | descriptor_write.dstSet = descriptorSet; |
| 7554 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7555 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7556 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 7557 | descriptor_write.pImageInfo = &descriptor_info; |
| 7558 | |
| 7559 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 7560 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7561 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7562 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7563 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 7564 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7565 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7566 | } |
| 7567 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7568 | TEST_F(VkLayerTest, CopyDescriptorUpdateErrors) { |
| 7569 | // Create DS w/ layout of 2 types, write update 1 and attempt to copy-update |
| 7570 | // into the other |
| 7571 | VkResult err; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7572 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7573 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7574 | " binding #1 with type " |
| 7575 | "VK_DESCRIPTOR_TYPE_SAMPLER. Types do " |
| 7576 | "not match."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7577 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7578 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7579 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7580 | VkDescriptorPoolSize ds_type_count[2] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7581 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7582 | ds_type_count[0].descriptorCount = 1; |
| 7583 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 7584 | ds_type_count[1].descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7585 | |
| 7586 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7587 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7588 | ds_pool_ci.pNext = NULL; |
| 7589 | ds_pool_ci.maxSets = 1; |
| 7590 | ds_pool_ci.poolSizeCount = 2; |
| 7591 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7592 | |
| 7593 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7594 | err = |
| 7595 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7596 | ASSERT_VK_SUCCESS(err); |
| 7597 | VkDescriptorSetLayoutBinding dsl_binding[2] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7598 | dsl_binding[0].binding = 0; |
| 7599 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7600 | dsl_binding[0].descriptorCount = 1; |
| 7601 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 7602 | dsl_binding[0].pImmutableSamplers = NULL; |
| 7603 | dsl_binding[1].binding = 1; |
| 7604 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 7605 | dsl_binding[1].descriptorCount = 1; |
| 7606 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 7607 | dsl_binding[1].pImmutableSamplers = NULL; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7608 | |
| 7609 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7610 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7611 | ds_layout_ci.pNext = NULL; |
| 7612 | ds_layout_ci.bindingCount = 2; |
| 7613 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7614 | |
| 7615 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7616 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7617 | &ds_layout); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7618 | ASSERT_VK_SUCCESS(err); |
| 7619 | |
| 7620 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7621 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7622 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7623 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7624 | alloc_info.descriptorPool = ds_pool; |
| 7625 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7626 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7627 | &descriptorSet); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7628 | ASSERT_VK_SUCCESS(err); |
| 7629 | |
| 7630 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7631 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 7632 | sampler_ci.pNext = NULL; |
| 7633 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 7634 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 7635 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 7636 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7637 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7638 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7639 | sampler_ci.mipLodBias = 1.0; |
| 7640 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 7641 | sampler_ci.maxAnisotropy = 1; |
| 7642 | sampler_ci.compareEnable = VK_FALSE; |
| 7643 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 7644 | sampler_ci.minLod = 1.0; |
| 7645 | sampler_ci.maxLod = 1.0; |
| 7646 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 7647 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7648 | |
| 7649 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7650 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7651 | ASSERT_VK_SUCCESS(err); |
| 7652 | |
| 7653 | VkDescriptorImageInfo info = {}; |
| 7654 | info.sampler = sampler; |
| 7655 | |
| 7656 | VkWriteDescriptorSet descriptor_write; |
| 7657 | memset(&descriptor_write, 0, sizeof(VkWriteDescriptorSet)); |
| 7658 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7659 | descriptor_write.dstSet = descriptorSet; |
| 7660 | descriptor_write.dstBinding = 1; // SAMPLER binding from layout above |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7661 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7662 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 7663 | descriptor_write.pImageInfo = &info; |
| 7664 | // This write update should succeed |
| 7665 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 7666 | // Now perform a copy update that fails due to type mismatch |
| 7667 | VkCopyDescriptorSet copy_ds_update; |
| 7668 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 7669 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 7670 | copy_ds_update.srcSet = descriptorSet; |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 7671 | copy_ds_update.srcBinding = 1; // Copy from SAMPLER binding |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7672 | copy_ds_update.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7673 | copy_ds_update.dstBinding = 0; // ERROR : copy to UNIFORM binding |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7674 | copy_ds_update.descriptorCount = 1; // copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7675 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 7676 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7677 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7678 | // 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] | 7679 | m_errorMonitor->SetDesiredFailureMsg( |
| 7680 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7681 | " does not have copy update src binding of 3."); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7682 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 7683 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 7684 | copy_ds_update.srcSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7685 | copy_ds_update.srcBinding = |
| 7686 | 3; // ERROR : Invalid binding for matching layout |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7687 | copy_ds_update.dstSet = descriptorSet; |
| 7688 | copy_ds_update.dstBinding = 0; |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 7689 | copy_ds_update.descriptorCount = 1; // Copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7690 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 7691 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7692 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7693 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7694 | // 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] | 7695 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7696 | VK_DEBUG_REPORT_ERROR_BIT_EXT, " binding#1 with offset index of 1 plus " |
| 7697 | "update array offset of 0 and update of " |
| 7698 | "5 descriptors oversteps total number " |
| 7699 | "of descriptors in set: 2."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7700 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7701 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 7702 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 7703 | copy_ds_update.srcSet = descriptorSet; |
| 7704 | copy_ds_update.srcBinding = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7705 | copy_ds_update.dstSet = descriptorSet; |
| 7706 | copy_ds_update.dstBinding = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7707 | copy_ds_update.descriptorCount = |
| 7708 | 5; // ERROR copy 5 descriptors (out of bounds for layout) |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7709 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 7710 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7711 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7712 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7713 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 7714 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7715 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7716 | } |
| 7717 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7718 | TEST_F(VkLayerTest, NumSamplesMismatch) { |
| 7719 | // Create CommandBuffer where MSAA samples doesn't match RenderPass |
| 7720 | // sampleCount |
| 7721 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7722 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7723 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7724 | "Num samples mismatch! "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7725 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7726 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7727 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7728 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7729 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7730 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7731 | |
| 7732 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7733 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7734 | ds_pool_ci.pNext = NULL; |
| 7735 | ds_pool_ci.maxSets = 1; |
| 7736 | ds_pool_ci.poolSizeCount = 1; |
| 7737 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 7738 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7739 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7740 | err = |
| 7741 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7742 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7743 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7744 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 7745 | dsl_binding.binding = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7746 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 7747 | dsl_binding.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7748 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7749 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7750 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7751 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 7752 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7753 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7754 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 7755 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7756 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7757 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7758 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7759 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7760 | ASSERT_VK_SUCCESS(err); |
| 7761 | |
| 7762 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7763 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7764 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7765 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 7766 | alloc_info.descriptorPool = ds_pool; |
| 7767 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7768 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7769 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7770 | ASSERT_VK_SUCCESS(err); |
| 7771 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7772 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7773 | pipe_ms_state_ci.sType = |
| 7774 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 7775 | pipe_ms_state_ci.pNext = NULL; |
| 7776 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
| 7777 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 7778 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 7779 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7780 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7781 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7782 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 7783 | pipeline_layout_ci.pNext = NULL; |
| 7784 | pipeline_layout_ci.setLayoutCount = 1; |
| 7785 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7786 | |
| 7787 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7788 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 7789 | &pipeline_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7790 | ASSERT_VK_SUCCESS(err); |
| 7791 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7792 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 7793 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7794 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 7795 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 7796 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7797 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 7798 | VkPipelineObj pipe(m_device); |
| 7799 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 7800 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 7801 | pipe.AddColorAttachment(); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 7802 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 7803 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7804 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 7805 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7806 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 7807 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7808 | |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 7809 | // Render triangle (the error should trigger on the attempt to draw). |
| 7810 | Draw(3, 1, 0, 0); |
| 7811 | |
| 7812 | // Finalize recording of the command buffer |
| 7813 | EndCommandBuffer(); |
| 7814 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7815 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7816 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7817 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 7818 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7819 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 7820 | } |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 7821 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 7822 | TEST_F(VkLayerTest, NumBlendAttachMismatch) { |
| 7823 | // Create Pipeline where the number of blend attachments doesn't match the |
| 7824 | // number of color attachments. In this case, we don't add any color |
| 7825 | // blend attachments even though we have a color attachment. |
| 7826 | VkResult err; |
| 7827 | |
| 7828 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 7829 | "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] | 7830 | |
| 7831 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7832 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7833 | VkDescriptorPoolSize ds_type_count = {}; |
| 7834 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7835 | ds_type_count.descriptorCount = 1; |
| 7836 | |
| 7837 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 7838 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7839 | ds_pool_ci.pNext = NULL; |
| 7840 | ds_pool_ci.maxSets = 1; |
| 7841 | ds_pool_ci.poolSizeCount = 1; |
| 7842 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 7843 | |
| 7844 | VkDescriptorPool ds_pool; |
| 7845 | err = |
| 7846 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 7847 | ASSERT_VK_SUCCESS(err); |
| 7848 | |
| 7849 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 7850 | dsl_binding.binding = 0; |
| 7851 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7852 | dsl_binding.descriptorCount = 1; |
| 7853 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7854 | dsl_binding.pImmutableSamplers = NULL; |
| 7855 | |
| 7856 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 7857 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7858 | ds_layout_ci.pNext = NULL; |
| 7859 | ds_layout_ci.bindingCount = 1; |
| 7860 | ds_layout_ci.pBindings = &dsl_binding; |
| 7861 | |
| 7862 | VkDescriptorSetLayout ds_layout; |
| 7863 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7864 | &ds_layout); |
| 7865 | ASSERT_VK_SUCCESS(err); |
| 7866 | |
| 7867 | VkDescriptorSet descriptorSet; |
| 7868 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 7869 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 7870 | alloc_info.descriptorSetCount = 1; |
| 7871 | alloc_info.descriptorPool = ds_pool; |
| 7872 | alloc_info.pSetLayouts = &ds_layout; |
| 7873 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7874 | &descriptorSet); |
| 7875 | ASSERT_VK_SUCCESS(err); |
| 7876 | |
| 7877 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 7878 | pipe_ms_state_ci.sType = |
| 7879 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 7880 | pipe_ms_state_ci.pNext = NULL; |
| 7881 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 7882 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 7883 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 7884 | pipe_ms_state_ci.pSampleMask = NULL; |
| 7885 | |
| 7886 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 7887 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 7888 | pipeline_layout_ci.pNext = NULL; |
| 7889 | pipeline_layout_ci.setLayoutCount = 1; |
| 7890 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 7891 | |
| 7892 | VkPipelineLayout pipeline_layout; |
| 7893 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 7894 | &pipeline_layout); |
| 7895 | ASSERT_VK_SUCCESS(err); |
| 7896 | |
| 7897 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 7898 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7899 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 7900 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 7901 | this); // We shouldn't need a fragment shader |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 7902 | // but add it to be able to run on more devices |
| 7903 | VkPipelineObj pipe(m_device); |
| 7904 | pipe.AddShader(&vs); |
| 7905 | pipe.AddShader(&fs); |
| 7906 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 7907 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 7908 | |
| 7909 | BeginCommandBuffer(); |
| 7910 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 7911 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 7912 | |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 7913 | // Render triangle (the error should trigger on the attempt to draw). |
| 7914 | Draw(3, 1, 0, 0); |
| 7915 | |
| 7916 | // Finalize recording of the command buffer |
| 7917 | EndCommandBuffer(); |
| 7918 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7919 | m_errorMonitor->VerifyFound(); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 7920 | |
| 7921 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 7922 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7923 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 7924 | } |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 7925 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7926 | TEST_F(VkLayerTest, ClearCmdNoDraw) { |
| 7927 | // Create CommandBuffer where we add ClearCmd for FB Color attachment prior |
| 7928 | // to issuing a Draw |
| 7929 | VkResult err; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7930 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7931 | m_errorMonitor->SetDesiredFailureMsg( |
Tony Barbour | 7e56d30 | 2016-03-02 15:12:01 -0700 | [diff] [blame] | 7932 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7933 | "vkCmdClearAttachments() issued on CB object "); |
| 7934 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7935 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7936 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7937 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7938 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7939 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7940 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7941 | |
| 7942 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7943 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7944 | ds_pool_ci.pNext = NULL; |
| 7945 | ds_pool_ci.maxSets = 1; |
| 7946 | ds_pool_ci.poolSizeCount = 1; |
| 7947 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7948 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7949 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7950 | err = |
| 7951 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7952 | ASSERT_VK_SUCCESS(err); |
| 7953 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7954 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7955 | dsl_binding.binding = 0; |
| 7956 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7957 | dsl_binding.descriptorCount = 1; |
| 7958 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7959 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7960 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7961 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7962 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7963 | ds_layout_ci.pNext = NULL; |
| 7964 | ds_layout_ci.bindingCount = 1; |
| 7965 | ds_layout_ci.pBindings = &dsl_binding; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 7966 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7967 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7968 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7969 | &ds_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7970 | ASSERT_VK_SUCCESS(err); |
| 7971 | |
| 7972 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7973 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7974 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7975 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 7976 | alloc_info.descriptorPool = ds_pool; |
| 7977 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7978 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7979 | &descriptorSet); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7980 | ASSERT_VK_SUCCESS(err); |
| 7981 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7982 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7983 | pipe_ms_state_ci.sType = |
| 7984 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 7985 | pipe_ms_state_ci.pNext = NULL; |
| 7986 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
| 7987 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 7988 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 7989 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7990 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7991 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7992 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 7993 | pipeline_layout_ci.pNext = NULL; |
| 7994 | pipeline_layout_ci.setLayoutCount = 1; |
| 7995 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7996 | |
| 7997 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7998 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 7999 | &pipeline_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8000 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 8001 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8002 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 8003 | VK_SHADER_STAGE_VERTEX_BIT, this); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 8004 | // 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] | 8005 | // on more devices |
| 8006 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 8007 | VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8008 | |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 8009 | VkPipelineObj pipe(m_device); |
| 8010 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 8011 | pipe.AddShader(&fs); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 8012 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 8013 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 8014 | |
| 8015 | BeginCommandBuffer(); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8016 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8017 | // Main thing we care about for this test is that the VkImage obj we're |
| 8018 | // clearing matches Color Attachment of FB |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8019 | // Also pass down other dummy params to keep driver and paramchecker happy |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 8020 | VkClearAttachment color_attachment; |
| 8021 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8022 | color_attachment.clearValue.color.float32[0] = 1.0; |
| 8023 | color_attachment.clearValue.color.float32[1] = 1.0; |
| 8024 | color_attachment.clearValue.color.float32[2] = 1.0; |
| 8025 | color_attachment.clearValue.color.float32[3] = 1.0; |
| 8026 | color_attachment.colorAttachment = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8027 | VkClearRect clear_rect = { |
| 8028 | {{0, 0}, {(uint32_t)m_width, (uint32_t)m_height}}}; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8029 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8030 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
| 8031 | &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8032 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8033 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 8034 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8035 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 8036 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 8037 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 8038 | } |
| 8039 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8040 | TEST_F(VkLayerTest, VtxBufferBadIndex) { |
| 8041 | VkResult err; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8042 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8043 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 8044 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | dfcd9b6 | 2015-12-14 15:14:10 -0700 | [diff] [blame] | 8045 | "but no vertex buffers are attached to this Pipeline State Object"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8046 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8047 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 8048 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8049 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8050 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 8051 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8052 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8053 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8054 | |
| 8055 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8056 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 8057 | ds_pool_ci.pNext = NULL; |
| 8058 | ds_pool_ci.maxSets = 1; |
| 8059 | ds_pool_ci.poolSizeCount = 1; |
| 8060 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8061 | |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 8062 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8063 | err = |
| 8064 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8065 | ASSERT_VK_SUCCESS(err); |
| 8066 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8067 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8068 | dsl_binding.binding = 0; |
| 8069 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 8070 | dsl_binding.descriptorCount = 1; |
| 8071 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 8072 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8073 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8074 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8075 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 8076 | ds_layout_ci.pNext = NULL; |
| 8077 | ds_layout_ci.bindingCount = 1; |
| 8078 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8079 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8080 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8081 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 8082 | &ds_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8083 | ASSERT_VK_SUCCESS(err); |
| 8084 | |
| 8085 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8086 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 8087 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 8088 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 8089 | alloc_info.descriptorPool = ds_pool; |
| 8090 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8091 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 8092 | &descriptorSet); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8093 | ASSERT_VK_SUCCESS(err); |
| 8094 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8095 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8096 | pipe_ms_state_ci.sType = |
| 8097 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 8098 | pipe_ms_state_ci.pNext = NULL; |
| 8099 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 8100 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 8101 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 8102 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8103 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 8104 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8105 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 8106 | pipeline_layout_ci.pNext = NULL; |
| 8107 | pipeline_layout_ci.setLayoutCount = 1; |
| 8108 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 8109 | VkPipelineLayout pipeline_layout; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8110 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8111 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 8112 | &pipeline_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8113 | ASSERT_VK_SUCCESS(err); |
| 8114 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8115 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 8116 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8117 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 8118 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 8119 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8120 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 8121 | VkPipelineObj pipe(m_device); |
| 8122 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 8123 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 8124 | pipe.AddColorAttachment(); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 8125 | pipe.SetMSAA(&pipe_ms_state_ci); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 8126 | pipe.SetViewport(m_viewports); |
| 8127 | pipe.SetScissor(m_scissors); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 8128 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 8129 | |
| 8130 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8131 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 8132 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 8133 | // Don't care about actual data, just need to get to draw to flag error |
| 8134 | static const float vbo_data[3] = {1.f, 0.f, 1.f}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8135 | VkConstantBufferObj vbo(m_device, sizeof(vbo_data), sizeof(float), |
| 8136 | (const void *)&vbo_data); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 8137 | 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] | 8138 | Draw(1, 0, 0, 0); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8139 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8140 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 8141 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8142 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 8143 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 8144 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 8145 | } |
Tobin Ehlis | c555a3c | 2016-05-04 14:08:34 -0600 | [diff] [blame] | 8146 | // INVALID_IMAGE_LAYOUT tests (one other case is hit by MapMemWithoutHostVisibleBit and not here) |
| 8147 | TEST_F(VkLayerTest, InvalidImageLayout) { |
| 8148 | TEST_DESCRIPTION("Hit all possible validation checks associated with the " |
| 8149 | "DRAWSTATE_INVALID_IMAGE_LAYOUT enum. Generally these involve having" |
| 8150 | "images in the wrong layout when they're copied or transitioned."); |
| 8151 | // 3 in ValidateCmdBufImageLayouts |
| 8152 | // * -1 Attempt to submit cmd buf w/ deleted image |
| 8153 | // * -2 Cmd buf submit of image w/ layout not matching first use w/ subresource |
| 8154 | // * -3 Cmd buf submit of image w/ layout not matching first use w/o subresource |
| 8155 | m_errorMonitor->SetDesiredFailureMsg( |
| 8156 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 8157 | "Layout for input image should be TRANSFER_SRC_OPTIMAL instead of GENERAL."); |
| 8158 | |
| 8159 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8160 | // Create src & dst images to use for copy operations |
| 8161 | VkImage src_image; |
| 8162 | VkImage dst_image; |
| 8163 | |
| 8164 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8165 | const int32_t tex_width = 32; |
| 8166 | const int32_t tex_height = 32; |
| 8167 | |
| 8168 | VkImageCreateInfo image_create_info = {}; |
| 8169 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8170 | image_create_info.pNext = NULL; |
| 8171 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8172 | image_create_info.format = tex_format; |
| 8173 | image_create_info.extent.width = tex_width; |
| 8174 | image_create_info.extent.height = tex_height; |
| 8175 | image_create_info.extent.depth = 1; |
| 8176 | image_create_info.mipLevels = 1; |
| 8177 | image_create_info.arrayLayers = 4; |
| 8178 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8179 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 8180 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 8181 | image_create_info.flags = 0; |
| 8182 | |
| 8183 | VkResult err = vkCreateImage(m_device->device(), &image_create_info, NULL, &src_image); |
| 8184 | ASSERT_VK_SUCCESS(err); |
| 8185 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dst_image); |
| 8186 | ASSERT_VK_SUCCESS(err); |
| 8187 | |
| 8188 | BeginCommandBuffer(); |
| 8189 | VkImageCopy copyRegion; |
| 8190 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8191 | copyRegion.srcSubresource.mipLevel = 0; |
| 8192 | copyRegion.srcSubresource.baseArrayLayer = 0; |
| 8193 | copyRegion.srcSubresource.layerCount = 1; |
| 8194 | copyRegion.srcOffset.x = 0; |
| 8195 | copyRegion.srcOffset.y = 0; |
| 8196 | copyRegion.srcOffset.z = 0; |
| 8197 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8198 | copyRegion.dstSubresource.mipLevel = 0; |
| 8199 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 8200 | copyRegion.dstSubresource.layerCount = 1; |
| 8201 | copyRegion.dstOffset.x = 0; |
| 8202 | copyRegion.dstOffset.y = 0; |
| 8203 | copyRegion.dstOffset.z = 0; |
| 8204 | copyRegion.extent.width = 1; |
| 8205 | copyRegion.extent.height = 1; |
| 8206 | copyRegion.extent.depth = 1; |
| 8207 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 8208 | m_errorMonitor->VerifyFound(); |
| 8209 | // Now cause error due to src image layout changing |
| 8210 | m_errorMonitor->SetDesiredFailureMsg( |
| 8211 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8212 | "Cannot copy from an image whose source layout is VK_IMAGE_LAYOUT_UNDEFINED and doesn't match the current layout VK_IMAGE_LAYOUT_GENERAL."); |
| 8213 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_UNDEFINED, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 8214 | m_errorMonitor->VerifyFound(); |
| 8215 | // Final src error is due to bad layout type |
| 8216 | m_errorMonitor->SetDesiredFailureMsg( |
| 8217 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8218 | "Layout for input image is VK_IMAGE_LAYOUT_UNDEFINED but can only be TRANSFER_SRC_OPTIMAL or GENERAL."); |
| 8219 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_UNDEFINED, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 8220 | m_errorMonitor->VerifyFound(); |
| 8221 | // Now verify same checks for dst |
| 8222 | m_errorMonitor->SetDesiredFailureMsg( |
| 8223 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 8224 | "Layout for output image should be TRANSFER_DST_OPTIMAL instead of GENERAL."); |
| 8225 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 8226 | m_errorMonitor->VerifyFound(); |
| 8227 | // Now cause error due to src image layout changing |
| 8228 | m_errorMonitor->SetDesiredFailureMsg( |
| 8229 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8230 | "Cannot copy from an image whose dest layout is VK_IMAGE_LAYOUT_UNDEFINED and doesn't match the current layout VK_IMAGE_LAYOUT_GENERAL."); |
| 8231 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_UNDEFINED, 1, ©Region); |
| 8232 | m_errorMonitor->VerifyFound(); |
| 8233 | m_errorMonitor->SetDesiredFailureMsg( |
| 8234 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8235 | "Layout for output image is VK_IMAGE_LAYOUT_UNDEFINED but can only be TRANSFER_DST_OPTIMAL or GENERAL."); |
| 8236 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_UNDEFINED, 1, ©Region); |
| 8237 | m_errorMonitor->VerifyFound(); |
| 8238 | // Now cause error due to bad image layout transition in PipelineBarrier |
| 8239 | VkImageMemoryBarrier image_barrier[1] = {}; |
| 8240 | image_barrier[0].oldLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; |
| 8241 | image_barrier[0].image = src_image; |
| 8242 | image_barrier[0].subresourceRange.layerCount = 2; |
| 8243 | image_barrier[0].subresourceRange.levelCount = 2; |
| 8244 | image_barrier[0].subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8245 | m_errorMonitor->SetDesiredFailureMsg( |
| 8246 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8247 | "You cannot transition the layout from VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL when current layout is VK_IMAGE_LAYOUT_GENERAL."); |
| 8248 | vkCmdPipelineBarrier(m_commandBuffer->handle(), VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, NULL, 0, NULL, 1, image_barrier); |
| 8249 | m_errorMonitor->VerifyFound(); |
| 8250 | |
| 8251 | // Finally some layout errors at RenderPass create time |
| 8252 | // Just hacking in specific state to get to the errors we want so don't copy this unless you know what you're doing. |
| 8253 | VkAttachmentReference attach = {}; |
| 8254 | // perf warning for GENERAL layout w/ non-DS input attachment |
| 8255 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 8256 | VkSubpassDescription subpass = {}; |
| 8257 | subpass.inputAttachmentCount = 1; |
| 8258 | subpass.pInputAttachments = &attach; |
| 8259 | VkRenderPassCreateInfo rpci = {}; |
| 8260 | rpci.subpassCount = 1; |
| 8261 | rpci.pSubpasses = &subpass; |
| 8262 | rpci.attachmentCount = 1; |
| 8263 | VkAttachmentDescription attach_desc = {}; |
| 8264 | attach_desc.format = VK_FORMAT_UNDEFINED; |
| 8265 | rpci.pAttachments = &attach_desc; |
Tobin Ehlis | 1efce02 | 2016-05-11 10:40:34 -0600 | [diff] [blame] | 8266 | rpci.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; |
Tobin Ehlis | c555a3c | 2016-05-04 14:08:34 -0600 | [diff] [blame] | 8267 | VkRenderPass rp; |
| 8268 | m_errorMonitor->SetDesiredFailureMsg( |
| 8269 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 8270 | "Layout for input attachment is GENERAL but should be READ_ONLY_OPTIMAL."); |
| 8271 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 8272 | m_errorMonitor->VerifyFound(); |
| 8273 | // error w/ non-general layout |
| 8274 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; |
| 8275 | |
| 8276 | m_errorMonitor->SetDesiredFailureMsg( |
| 8277 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8278 | "Layout for input attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be READ_ONLY_OPTIMAL or GENERAL."); |
| 8279 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 8280 | m_errorMonitor->VerifyFound(); |
| 8281 | subpass.inputAttachmentCount = 0; |
| 8282 | subpass.colorAttachmentCount = 1; |
| 8283 | subpass.pColorAttachments = &attach; |
| 8284 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 8285 | // perf warning for GENERAL layout on color attachment |
| 8286 | m_errorMonitor->SetDesiredFailureMsg( |
| 8287 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 8288 | "Layout for color attachment is GENERAL but should be COLOR_ATTACHMENT_OPTIMAL."); |
| 8289 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 8290 | m_errorMonitor->VerifyFound(); |
| 8291 | // error w/ non-color opt or GENERAL layout for color attachment |
| 8292 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; |
| 8293 | m_errorMonitor->SetDesiredFailureMsg( |
| 8294 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8295 | "Layout for color attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be COLOR_ATTACHMENT_OPTIMAL or GENERAL."); |
| 8296 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 8297 | m_errorMonitor->VerifyFound(); |
| 8298 | subpass.colorAttachmentCount = 0; |
| 8299 | subpass.pDepthStencilAttachment = &attach; |
| 8300 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 8301 | // perf warning for GENERAL layout on DS attachment |
| 8302 | m_errorMonitor->SetDesiredFailureMsg( |
| 8303 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 8304 | "Layout for depth attachment is GENERAL but should be DEPTH_STENCIL_ATTACHMENT_OPTIMAL."); |
| 8305 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 8306 | m_errorMonitor->VerifyFound(); |
| 8307 | // error w/ non-ds opt or GENERAL layout for color attachment |
| 8308 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; |
| 8309 | m_errorMonitor->SetDesiredFailureMsg( |
| 8310 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8311 | "Layout for depth attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be DEPTH_STENCIL_ATTACHMENT_OPTIMAL or GENERAL."); |
| 8312 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 8313 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 1efce02 | 2016-05-11 10:40:34 -0600 | [diff] [blame] | 8314 | // For this error we need a valid renderpass so create default one |
| 8315 | attach.layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; |
| 8316 | attach.attachment = 0; |
| 8317 | attach_desc.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 8318 | attach_desc.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8319 | attach_desc.storeOp = VK_ATTACHMENT_STORE_OP_STORE; |
| 8320 | attach_desc.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; |
| 8321 | attach_desc.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; |
| 8322 | // Can't do a CLEAR load on READ_ONLY initialLayout |
| 8323 | attach_desc.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; |
| 8324 | attach_desc.initialLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; |
| 8325 | attach_desc.finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 8326 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8327 | " with invalid first layout " |
| 8328 | "VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_" |
| 8329 | "ONLY_OPTIMAL"); |
| 8330 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 8331 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | c555a3c | 2016-05-04 14:08:34 -0600 | [diff] [blame] | 8332 | |
| 8333 | vkDestroyImage(m_device->device(), src_image, NULL); |
| 8334 | vkDestroyImage(m_device->device(), dst_image, NULL); |
| 8335 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 8336 | #endif // DRAW_STATE_TESTS |
| 8337 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 8338 | #if THREADING_TESTS |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8339 | #if GTEST_IS_THREADSAFE |
| 8340 | struct thread_data_struct { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8341 | VkCommandBuffer commandBuffer; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8342 | VkEvent event; |
| 8343 | bool bailout; |
| 8344 | }; |
| 8345 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8346 | extern "C" void *AddToCommandBuffer(void *arg) { |
| 8347 | struct thread_data_struct *data = (struct thread_data_struct *)arg; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8348 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8349 | for (int i = 0; i < 10000; i++) { |
| 8350 | vkCmdSetEvent(data->commandBuffer, data->event, |
| 8351 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8352 | if (data->bailout) { |
| 8353 | break; |
| 8354 | } |
| 8355 | } |
| 8356 | return NULL; |
| 8357 | } |
| 8358 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8359 | TEST_F(VkLayerTest, ThreadCommandBufferCollision) { |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 8360 | test_platform_thread thread; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8361 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8362 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8363 | "THREADING ERROR"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8364 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8365 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8366 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 8367 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8368 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8369 | // Calls AllocateCommandBuffers |
| 8370 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 8371 | |
| 8372 | // Avoid creating RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8373 | commandBuffer.BeginCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8374 | |
| 8375 | VkEventCreateInfo event_info; |
| 8376 | VkEvent event; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8377 | VkResult err; |
| 8378 | |
| 8379 | memset(&event_info, 0, sizeof(event_info)); |
| 8380 | event_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 8381 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8382 | err = vkCreateEvent(device(), &event_info, NULL, &event); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8383 | ASSERT_VK_SUCCESS(err); |
| 8384 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8385 | err = vkResetEvent(device(), event); |
| 8386 | ASSERT_VK_SUCCESS(err); |
| 8387 | |
| 8388 | struct thread_data_struct data; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8389 | data.commandBuffer = commandBuffer.GetBufferHandle(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8390 | data.event = event; |
| 8391 | data.bailout = false; |
| 8392 | m_errorMonitor->SetBailout(&data.bailout); |
| 8393 | // Add many entries to command buffer from another thread. |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 8394 | test_platform_thread_create(&thread, AddToCommandBuffer, (void *)&data); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8395 | // Add many entries to command buffer from this thread at the same time. |
| 8396 | AddToCommandBuffer(&data); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 8397 | |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 8398 | test_platform_thread_join(thread, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8399 | commandBuffer.EndCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8400 | |
Mike Stroyan | 10b8cb7 | 2016-01-22 15:22:03 -0700 | [diff] [blame] | 8401 | m_errorMonitor->SetBailout(NULL); |
| 8402 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8403 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8404 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8405 | vkDestroyEvent(device(), event, NULL); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8406 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 8407 | #endif // GTEST_IS_THREADSAFE |
| 8408 | #endif // THREADING_TESTS |
| 8409 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8410 | #if SHADER_CHECKER_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8411 | TEST_F(VkLayerTest, InvalidSPIRVCodeSize) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8412 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 8413 | "Invalid SPIR-V header"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8414 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8415 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8416 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8417 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8418 | VkShaderModule module; |
| 8419 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 8420 | struct icd_spv_header spv; |
| 8421 | |
| 8422 | spv.magic = ICD_SPV_MAGIC; |
| 8423 | spv.version = ICD_SPV_VERSION; |
| 8424 | spv.gen_magic = 0; |
| 8425 | |
| 8426 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 8427 | moduleCreateInfo.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8428 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8429 | moduleCreateInfo.codeSize = 4; |
| 8430 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8431 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8432 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8433 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8434 | } |
| 8435 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8436 | TEST_F(VkLayerTest, InvalidSPIRVMagic) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8437 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 8438 | "Invalid SPIR-V magic number"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8439 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8440 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8441 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8442 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8443 | VkShaderModule module; |
| 8444 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 8445 | struct icd_spv_header spv; |
| 8446 | |
| 8447 | spv.magic = ~ICD_SPV_MAGIC; |
| 8448 | spv.version = ICD_SPV_VERSION; |
| 8449 | spv.gen_magic = 0; |
| 8450 | |
| 8451 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 8452 | moduleCreateInfo.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8453 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8454 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 8455 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8456 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8457 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8458 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8459 | } |
| 8460 | |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 8461 | #if 0 |
| 8462 | // Not currently covered by SPIRV-Tools validator |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8463 | TEST_F(VkLayerTest, InvalidSPIRVVersion) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8464 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 8465 | "Invalid SPIR-V header"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8466 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8467 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8468 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8469 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8470 | VkShaderModule module; |
| 8471 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 8472 | struct icd_spv_header spv; |
| 8473 | |
| 8474 | spv.magic = ICD_SPV_MAGIC; |
| 8475 | spv.version = ~ICD_SPV_VERSION; |
| 8476 | spv.gen_magic = 0; |
| 8477 | |
| 8478 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 8479 | moduleCreateInfo.pNext = NULL; |
| 8480 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8481 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8482 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 8483 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8484 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8485 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8486 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8487 | } |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 8488 | #endif |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8489 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8490 | TEST_F(VkLayerTest, CreatePipelineVertexOutputNotConsumed) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 8491 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8492 | "not consumed by fragment shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8493 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8494 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 8495 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8496 | |
| 8497 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8498 | "#version 450\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8499 | "\n" |
| 8500 | "layout(location=0) out float x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8501 | "out gl_PerVertex {\n" |
| 8502 | " vec4 gl_Position;\n" |
| 8503 | "};\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8504 | "void main(){\n" |
| 8505 | " gl_Position = vec4(1);\n" |
| 8506 | " x = 0;\n" |
| 8507 | "}\n"; |
| 8508 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8509 | "#version 450\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8510 | "\n" |
| 8511 | "layout(location=0) out vec4 color;\n" |
| 8512 | "void main(){\n" |
| 8513 | " color = vec4(1);\n" |
| 8514 | "}\n"; |
| 8515 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8516 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8517 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8518 | |
| 8519 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 8520 | pipe.AddColorAttachment(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8521 | pipe.AddShader(&vs); |
| 8522 | pipe.AddShader(&fs); |
| 8523 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8524 | VkDescriptorSetObj descriptorSet(m_device); |
| 8525 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8526 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8527 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 8528 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8529 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8530 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8531 | } |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8532 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8533 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvided) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8534 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8535 | "not written by vertex shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8536 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8537 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 8538 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8539 | |
| 8540 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8541 | "#version 450\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8542 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8543 | "out gl_PerVertex {\n" |
| 8544 | " vec4 gl_Position;\n" |
| 8545 | "};\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8546 | "void main(){\n" |
| 8547 | " gl_Position = vec4(1);\n" |
| 8548 | "}\n"; |
| 8549 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8550 | "#version 450\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8551 | "\n" |
| 8552 | "layout(location=0) in float x;\n" |
| 8553 | "layout(location=0) out vec4 color;\n" |
| 8554 | "void main(){\n" |
| 8555 | " color = vec4(x);\n" |
| 8556 | "}\n"; |
| 8557 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8558 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8559 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8560 | |
| 8561 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 8562 | pipe.AddColorAttachment(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8563 | pipe.AddShader(&vs); |
| 8564 | pipe.AddShader(&fs); |
| 8565 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8566 | VkDescriptorSetObj descriptorSet(m_device); |
| 8567 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8568 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8569 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 8570 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8571 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8572 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8573 | } |
| 8574 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8575 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvidedInBlock) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8576 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8577 | "not written by vertex shader"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8578 | |
| 8579 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8580 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8581 | |
| 8582 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8583 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8584 | "\n" |
| 8585 | "out gl_PerVertex {\n" |
| 8586 | " vec4 gl_Position;\n" |
| 8587 | "};\n" |
| 8588 | "void main(){\n" |
| 8589 | " gl_Position = vec4(1);\n" |
| 8590 | "}\n"; |
| 8591 | char const *fsSource = |
| 8592 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8593 | "\n" |
| 8594 | "in block { layout(location=0) float x; } ins;\n" |
| 8595 | "layout(location=0) out vec4 color;\n" |
| 8596 | "void main(){\n" |
| 8597 | " color = vec4(ins.x);\n" |
| 8598 | "}\n"; |
| 8599 | |
| 8600 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8601 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8602 | |
| 8603 | VkPipelineObj pipe(m_device); |
| 8604 | pipe.AddColorAttachment(); |
| 8605 | pipe.AddShader(&vs); |
| 8606 | pipe.AddShader(&fs); |
| 8607 | |
| 8608 | VkDescriptorSetObj descriptorSet(m_device); |
| 8609 | descriptorSet.AppendDummy(); |
| 8610 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8611 | |
| 8612 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8613 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8614 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8615 | } |
| 8616 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8617 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchArraySize) { |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 8618 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 8619 | "Type mismatch on location 0.0: 'ptr to " |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8620 | "output arr[2] of float32' vs 'ptr to " |
| 8621 | "input arr[3] of float32'"); |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 8622 | |
| 8623 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8624 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8625 | |
| 8626 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8627 | "#version 450\n" |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 8628 | "\n" |
| 8629 | "layout(location=0) out float x[2];\n" |
| 8630 | "out gl_PerVertex {\n" |
| 8631 | " vec4 gl_Position;\n" |
| 8632 | "};\n" |
| 8633 | "void main(){\n" |
| 8634 | " x[0] = 0; x[1] = 0;\n" |
| 8635 | " gl_Position = vec4(1);\n" |
| 8636 | "}\n"; |
| 8637 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8638 | "#version 450\n" |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 8639 | "\n" |
| 8640 | "layout(location=0) in float x[3];\n" |
| 8641 | "layout(location=0) out vec4 color;\n" |
| 8642 | "void main(){\n" |
| 8643 | " color = vec4(x[0] + x[1] + x[2]);\n" |
| 8644 | "}\n"; |
| 8645 | |
| 8646 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8647 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8648 | |
| 8649 | VkPipelineObj pipe(m_device); |
| 8650 | pipe.AddColorAttachment(); |
| 8651 | pipe.AddShader(&vs); |
| 8652 | pipe.AddShader(&fs); |
| 8653 | |
| 8654 | VkDescriptorSetObj descriptorSet(m_device); |
| 8655 | descriptorSet.AppendDummy(); |
| 8656 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8657 | |
| 8658 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8659 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8660 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 8661 | } |
| 8662 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8663 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatch) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8664 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8665 | "Type mismatch on location 0"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8666 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8667 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 8668 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8669 | |
| 8670 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8671 | "#version 450\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8672 | "\n" |
| 8673 | "layout(location=0) out int x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8674 | "out gl_PerVertex {\n" |
| 8675 | " vec4 gl_Position;\n" |
| 8676 | "};\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8677 | "void main(){\n" |
| 8678 | " x = 0;\n" |
| 8679 | " gl_Position = vec4(1);\n" |
| 8680 | "}\n"; |
| 8681 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8682 | "#version 450\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8683 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8684 | "layout(location=0) in float x;\n" /* VS writes int */ |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8685 | "layout(location=0) out vec4 color;\n" |
| 8686 | "void main(){\n" |
| 8687 | " color = vec4(x);\n" |
| 8688 | "}\n"; |
| 8689 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8690 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8691 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8692 | |
| 8693 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 8694 | pipe.AddColorAttachment(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8695 | pipe.AddShader(&vs); |
| 8696 | pipe.AddShader(&fs); |
| 8697 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8698 | VkDescriptorSetObj descriptorSet(m_device); |
| 8699 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8700 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8701 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 8702 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8703 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8704 | m_errorMonitor->VerifyFound(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8705 | } |
| 8706 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8707 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchInBlock) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8708 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8709 | "Type mismatch on location 0"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8710 | |
| 8711 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8712 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8713 | |
| 8714 | char const *vsSource = |
| 8715 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8716 | "\n" |
| 8717 | "out block { layout(location=0) int x; } outs;\n" |
| 8718 | "out gl_PerVertex {\n" |
| 8719 | " vec4 gl_Position;\n" |
| 8720 | "};\n" |
| 8721 | "void main(){\n" |
| 8722 | " outs.x = 0;\n" |
| 8723 | " gl_Position = vec4(1);\n" |
| 8724 | "}\n"; |
| 8725 | char const *fsSource = |
| 8726 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8727 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8728 | "in block { layout(location=0) float x; } ins;\n" /* VS writes int */ |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8729 | "layout(location=0) out vec4 color;\n" |
| 8730 | "void main(){\n" |
| 8731 | " color = vec4(ins.x);\n" |
| 8732 | "}\n"; |
| 8733 | |
| 8734 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8735 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8736 | |
| 8737 | VkPipelineObj pipe(m_device); |
| 8738 | pipe.AddColorAttachment(); |
| 8739 | pipe.AddShader(&vs); |
| 8740 | pipe.AddShader(&fs); |
| 8741 | |
| 8742 | VkDescriptorSetObj descriptorSet(m_device); |
| 8743 | descriptorSet.AppendDummy(); |
| 8744 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8745 | |
| 8746 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8747 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8748 | m_errorMonitor->VerifyFound(); |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 8749 | } |
| 8750 | |
| 8751 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByLocation) { |
| 8752 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8753 | "location 0.0 which is not written by vertex shader"); |
| 8754 | |
| 8755 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8756 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8757 | |
| 8758 | char const *vsSource = |
| 8759 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 8760 | "\n" |
| 8761 | "out block { layout(location=1) float x; } outs;\n" |
| 8762 | "out gl_PerVertex {\n" |
| 8763 | " vec4 gl_Position;\n" |
| 8764 | "};\n" |
| 8765 | "void main(){\n" |
| 8766 | " outs.x = 0;\n" |
| 8767 | " gl_Position = vec4(1);\n" |
| 8768 | "}\n"; |
| 8769 | char const *fsSource = |
| 8770 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 8771 | "\n" |
| 8772 | "in block { layout(location=0) float x; } ins;\n" |
| 8773 | "layout(location=0) out vec4 color;\n" |
| 8774 | "void main(){\n" |
| 8775 | " color = vec4(ins.x);\n" |
| 8776 | "}\n"; |
| 8777 | |
| 8778 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8779 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8780 | |
| 8781 | VkPipelineObj pipe(m_device); |
| 8782 | pipe.AddColorAttachment(); |
| 8783 | pipe.AddShader(&vs); |
| 8784 | pipe.AddShader(&fs); |
| 8785 | |
| 8786 | VkDescriptorSetObj descriptorSet(m_device); |
| 8787 | descriptorSet.AppendDummy(); |
| 8788 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8789 | |
| 8790 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8791 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8792 | m_errorMonitor->VerifyFound(); |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 8793 | } |
| 8794 | |
| 8795 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByComponent) { |
| 8796 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8797 | "location 0.1 which is not written by vertex shader"); |
| 8798 | |
| 8799 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8800 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8801 | |
| 8802 | char const *vsSource = |
| 8803 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 8804 | "\n" |
| 8805 | "out block { layout(location=0, component=0) float x; } outs;\n" |
| 8806 | "out gl_PerVertex {\n" |
| 8807 | " vec4 gl_Position;\n" |
| 8808 | "};\n" |
| 8809 | "void main(){\n" |
| 8810 | " outs.x = 0;\n" |
| 8811 | " gl_Position = vec4(1);\n" |
| 8812 | "}\n"; |
| 8813 | char const *fsSource = |
| 8814 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 8815 | "\n" |
| 8816 | "in block { layout(location=0, component=1) float x; } ins;\n" |
| 8817 | "layout(location=0) out vec4 color;\n" |
| 8818 | "void main(){\n" |
| 8819 | " color = vec4(ins.x);\n" |
| 8820 | "}\n"; |
| 8821 | |
| 8822 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8823 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8824 | |
| 8825 | VkPipelineObj pipe(m_device); |
| 8826 | pipe.AddColorAttachment(); |
| 8827 | pipe.AddShader(&vs); |
| 8828 | pipe.AddShader(&fs); |
| 8829 | |
| 8830 | VkDescriptorSetObj descriptorSet(m_device); |
| 8831 | descriptorSet.AppendDummy(); |
| 8832 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8833 | |
| 8834 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8835 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8836 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8837 | } |
| 8838 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8839 | TEST_F(VkLayerTest, CreatePipelineAttribNotConsumed) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 8840 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8841 | "location 0 not consumed by VS"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8842 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8843 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 8844 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8845 | |
| 8846 | VkVertexInputBindingDescription input_binding; |
| 8847 | memset(&input_binding, 0, sizeof(input_binding)); |
| 8848 | |
| 8849 | VkVertexInputAttributeDescription input_attrib; |
| 8850 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 8851 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 8852 | |
| 8853 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8854 | "#version 450\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8855 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8856 | "out gl_PerVertex {\n" |
| 8857 | " vec4 gl_Position;\n" |
| 8858 | "};\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8859 | "void main(){\n" |
| 8860 | " gl_Position = vec4(1);\n" |
| 8861 | "}\n"; |
| 8862 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8863 | "#version 450\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8864 | "\n" |
| 8865 | "layout(location=0) out vec4 color;\n" |
| 8866 | "void main(){\n" |
| 8867 | " color = vec4(1);\n" |
| 8868 | "}\n"; |
| 8869 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8870 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8871 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8872 | |
| 8873 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 8874 | pipe.AddColorAttachment(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8875 | pipe.AddShader(&vs); |
| 8876 | pipe.AddShader(&fs); |
| 8877 | |
| 8878 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 8879 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 8880 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8881 | VkDescriptorSetObj descriptorSet(m_device); |
| 8882 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8883 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8884 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 8885 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8886 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8887 | m_errorMonitor->VerifyFound(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8888 | } |
| 8889 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8890 | TEST_F(VkLayerTest, CreatePipelineAttribLocationMismatch) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 8891 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8892 | "location 0 not consumed by VS"); |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 8893 | |
| 8894 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8895 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8896 | |
| 8897 | VkVertexInputBindingDescription input_binding; |
| 8898 | memset(&input_binding, 0, sizeof(input_binding)); |
| 8899 | |
| 8900 | VkVertexInputAttributeDescription input_attrib; |
| 8901 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 8902 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 8903 | |
| 8904 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8905 | "#version 450\n" |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 8906 | "\n" |
| 8907 | "layout(location=1) in float x;\n" |
| 8908 | "out gl_PerVertex {\n" |
| 8909 | " vec4 gl_Position;\n" |
| 8910 | "};\n" |
| 8911 | "void main(){\n" |
| 8912 | " gl_Position = vec4(x);\n" |
| 8913 | "}\n"; |
| 8914 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8915 | "#version 450\n" |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 8916 | "\n" |
| 8917 | "layout(location=0) out vec4 color;\n" |
| 8918 | "void main(){\n" |
| 8919 | " color = vec4(1);\n" |
| 8920 | "}\n"; |
| 8921 | |
| 8922 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8923 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8924 | |
| 8925 | VkPipelineObj pipe(m_device); |
| 8926 | pipe.AddColorAttachment(); |
| 8927 | pipe.AddShader(&vs); |
| 8928 | pipe.AddShader(&fs); |
| 8929 | |
| 8930 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 8931 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 8932 | |
| 8933 | VkDescriptorSetObj descriptorSet(m_device); |
| 8934 | descriptorSet.AppendDummy(); |
| 8935 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8936 | |
| 8937 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8938 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8939 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 8940 | } |
| 8941 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8942 | TEST_F(VkLayerTest, CreatePipelineAttribNotProvided) { |
| 8943 | m_errorMonitor->SetDesiredFailureMsg( |
| 8944 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8945 | "VS consumes input at location 0 but not provided"); |
| 8946 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8947 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 8948 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8949 | |
| 8950 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8951 | "#version 450\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8952 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8953 | "layout(location=0) in vec4 x;\n" /* not provided */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8954 | "out gl_PerVertex {\n" |
| 8955 | " vec4 gl_Position;\n" |
| 8956 | "};\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8957 | "void main(){\n" |
| 8958 | " gl_Position = x;\n" |
| 8959 | "}\n"; |
| 8960 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8961 | "#version 450\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8962 | "\n" |
| 8963 | "layout(location=0) out vec4 color;\n" |
| 8964 | "void main(){\n" |
| 8965 | " color = vec4(1);\n" |
| 8966 | "}\n"; |
| 8967 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8968 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8969 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8970 | |
| 8971 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 8972 | pipe.AddColorAttachment(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8973 | pipe.AddShader(&vs); |
| 8974 | pipe.AddShader(&fs); |
| 8975 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8976 | VkDescriptorSetObj descriptorSet(m_device); |
| 8977 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8978 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8979 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 8980 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8981 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8982 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8983 | } |
| 8984 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8985 | TEST_F(VkLayerTest, CreatePipelineAttribTypeMismatch) { |
| 8986 | m_errorMonitor->SetDesiredFailureMsg( |
| 8987 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8988 | "location 0 does not match VS input type"); |
| 8989 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 8990 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 8991 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 8992 | |
| 8993 | VkVertexInputBindingDescription input_binding; |
| 8994 | memset(&input_binding, 0, sizeof(input_binding)); |
| 8995 | |
| 8996 | VkVertexInputAttributeDescription input_attrib; |
| 8997 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 8998 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 8999 | |
| 9000 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9001 | "#version 450\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9002 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9003 | "layout(location=0) in int x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9004 | "out gl_PerVertex {\n" |
| 9005 | " vec4 gl_Position;\n" |
| 9006 | "};\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9007 | "void main(){\n" |
| 9008 | " gl_Position = vec4(x);\n" |
| 9009 | "}\n"; |
| 9010 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9011 | "#version 450\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9012 | "\n" |
| 9013 | "layout(location=0) out vec4 color;\n" |
| 9014 | "void main(){\n" |
| 9015 | " color = vec4(1);\n" |
| 9016 | "}\n"; |
| 9017 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9018 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9019 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9020 | |
| 9021 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9022 | pipe.AddColorAttachment(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9023 | pipe.AddShader(&vs); |
| 9024 | pipe.AddShader(&fs); |
| 9025 | |
| 9026 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 9027 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 9028 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9029 | VkDescriptorSetObj descriptorSet(m_device); |
| 9030 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9031 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9032 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9033 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9034 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9035 | m_errorMonitor->VerifyFound(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 9036 | } |
| 9037 | |
Chris Forbes | c68b43c | 2016-04-06 11:18:47 +1200 | [diff] [blame] | 9038 | TEST_F(VkLayerTest, CreatePipelineDuplicateStage) { |
| 9039 | m_errorMonitor->SetDesiredFailureMsg( |
| 9040 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9041 | "Multiple shaders provided for stage VK_SHADER_STAGE_VERTEX_BIT"); |
| 9042 | |
| 9043 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9044 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9045 | |
| 9046 | char const *vsSource = |
| 9047 | "#version 450\n" |
| 9048 | "\n" |
| 9049 | "out gl_PerVertex {\n" |
| 9050 | " vec4 gl_Position;\n" |
| 9051 | "};\n" |
| 9052 | "void main(){\n" |
| 9053 | " gl_Position = vec4(1);\n" |
| 9054 | "}\n"; |
| 9055 | char const *fsSource = |
| 9056 | "#version 450\n" |
| 9057 | "\n" |
| 9058 | "layout(location=0) out vec4 color;\n" |
| 9059 | "void main(){\n" |
| 9060 | " color = vec4(1);\n" |
| 9061 | "}\n"; |
| 9062 | |
| 9063 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9064 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9065 | |
| 9066 | VkPipelineObj pipe(m_device); |
| 9067 | pipe.AddColorAttachment(); |
| 9068 | pipe.AddShader(&vs); |
| 9069 | pipe.AddShader(&vs); |
| 9070 | pipe.AddShader(&fs); |
| 9071 | |
| 9072 | VkDescriptorSetObj descriptorSet(m_device); |
| 9073 | descriptorSet.AppendDummy(); |
| 9074 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9075 | |
| 9076 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9077 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9078 | m_errorMonitor->VerifyFound(); |
Chris Forbes | c68b43c | 2016-04-06 11:18:47 +1200 | [diff] [blame] | 9079 | } |
| 9080 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9081 | TEST_F(VkLayerTest, CreatePipelineAttribMatrixType) { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9082 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9083 | |
| 9084 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9085 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9086 | |
| 9087 | VkVertexInputBindingDescription input_binding; |
| 9088 | memset(&input_binding, 0, sizeof(input_binding)); |
| 9089 | |
| 9090 | VkVertexInputAttributeDescription input_attribs[2]; |
| 9091 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 9092 | |
| 9093 | for (int i = 0; i < 2; i++) { |
| 9094 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 9095 | input_attribs[i].location = i; |
| 9096 | } |
| 9097 | |
| 9098 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9099 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9100 | "\n" |
| 9101 | "layout(location=0) in mat2x4 x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9102 | "out gl_PerVertex {\n" |
| 9103 | " vec4 gl_Position;\n" |
| 9104 | "};\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9105 | "void main(){\n" |
| 9106 | " gl_Position = x[0] + x[1];\n" |
| 9107 | "}\n"; |
| 9108 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9109 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9110 | "\n" |
| 9111 | "layout(location=0) out vec4 color;\n" |
| 9112 | "void main(){\n" |
| 9113 | " color = vec4(1);\n" |
| 9114 | "}\n"; |
| 9115 | |
| 9116 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9117 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9118 | |
| 9119 | VkPipelineObj pipe(m_device); |
| 9120 | pipe.AddColorAttachment(); |
| 9121 | pipe.AddShader(&vs); |
| 9122 | pipe.AddShader(&fs); |
| 9123 | |
| 9124 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 9125 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 9126 | |
| 9127 | VkDescriptorSetObj descriptorSet(m_device); |
| 9128 | descriptorSet.AppendDummy(); |
| 9129 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9130 | |
| 9131 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9132 | |
| 9133 | /* expect success */ |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9134 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9135 | } |
| 9136 | |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9137 | TEST_F(VkLayerTest, CreatePipelineAttribArrayType) |
| 9138 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9139 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9140 | |
| 9141 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9142 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9143 | |
| 9144 | VkVertexInputBindingDescription input_binding; |
| 9145 | memset(&input_binding, 0, sizeof(input_binding)); |
| 9146 | |
| 9147 | VkVertexInputAttributeDescription input_attribs[2]; |
| 9148 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 9149 | |
| 9150 | for (int i = 0; i < 2; i++) { |
| 9151 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 9152 | input_attribs[i].location = i; |
| 9153 | } |
| 9154 | |
| 9155 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9156 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9157 | "\n" |
| 9158 | "layout(location=0) in vec4 x[2];\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9159 | "out gl_PerVertex {\n" |
| 9160 | " vec4 gl_Position;\n" |
| 9161 | "};\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9162 | "void main(){\n" |
| 9163 | " gl_Position = x[0] + x[1];\n" |
| 9164 | "}\n"; |
| 9165 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9166 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9167 | "\n" |
| 9168 | "layout(location=0) out vec4 color;\n" |
| 9169 | "void main(){\n" |
| 9170 | " color = vec4(1);\n" |
| 9171 | "}\n"; |
| 9172 | |
| 9173 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9174 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9175 | |
| 9176 | VkPipelineObj pipe(m_device); |
| 9177 | pipe.AddColorAttachment(); |
| 9178 | pipe.AddShader(&vs); |
| 9179 | pipe.AddShader(&fs); |
| 9180 | |
| 9181 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 9182 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 9183 | |
| 9184 | VkDescriptorSetObj descriptorSet(m_device); |
| 9185 | descriptorSet.AppendDummy(); |
| 9186 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9187 | |
| 9188 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9189 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9190 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9191 | } |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 9192 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9193 | TEST_F(VkLayerTest, CreatePipelineSimplePositive) |
| 9194 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9195 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9196 | |
| 9197 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9198 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9199 | |
| 9200 | char const *vsSource = |
| 9201 | "#version 450\n" |
| 9202 | "out gl_PerVertex {\n" |
| 9203 | " vec4 gl_Position;\n" |
| 9204 | "};\n" |
| 9205 | "void main(){\n" |
| 9206 | " gl_Position = vec4(0);\n" |
| 9207 | "}\n"; |
| 9208 | char const *fsSource = |
| 9209 | "#version 450\n" |
| 9210 | "\n" |
| 9211 | "layout(location=0) out vec4 color;\n" |
| 9212 | "void main(){\n" |
| 9213 | " color = vec4(1);\n" |
| 9214 | "}\n"; |
| 9215 | |
| 9216 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9217 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9218 | |
| 9219 | VkPipelineObj pipe(m_device); |
| 9220 | pipe.AddColorAttachment(); |
| 9221 | pipe.AddShader(&vs); |
| 9222 | pipe.AddShader(&fs); |
| 9223 | |
| 9224 | VkDescriptorSetObj descriptorSet(m_device); |
| 9225 | descriptorSet.AppendDummy(); |
| 9226 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9227 | |
| 9228 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9229 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9230 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9231 | } |
| 9232 | |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 9233 | TEST_F(VkLayerTest, CreatePipelineRelaxedTypeMatch) |
| 9234 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9235 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 9236 | |
| 9237 | // VK 1.0.8 Specification, 14.1.3 "Additionally,..." block |
| 9238 | |
| 9239 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9240 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9241 | |
| 9242 | char const *vsSource = |
| 9243 | "#version 450\n" |
| 9244 | "out gl_PerVertex {\n" |
| 9245 | " vec4 gl_Position;\n" |
| 9246 | "};\n" |
| 9247 | "layout(location=0) out vec3 x;\n" |
| 9248 | "layout(location=1) out ivec3 y;\n" |
| 9249 | "layout(location=2) out vec3 z;\n" |
| 9250 | "void main(){\n" |
| 9251 | " gl_Position = vec4(0);\n" |
| 9252 | " x = vec3(0); y = ivec3(0); z = vec3(0);\n" |
| 9253 | "}\n"; |
| 9254 | char const *fsSource = |
| 9255 | "#version 450\n" |
| 9256 | "\n" |
| 9257 | "layout(location=0) out vec4 color;\n" |
| 9258 | "layout(location=0) in float x;\n" |
| 9259 | "layout(location=1) flat in int y;\n" |
| 9260 | "layout(location=2) in vec2 z;\n" |
| 9261 | "void main(){\n" |
| 9262 | " color = vec4(1 + x + y + z.x);\n" |
| 9263 | "}\n"; |
| 9264 | |
| 9265 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9266 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9267 | |
| 9268 | VkPipelineObj pipe(m_device); |
| 9269 | pipe.AddColorAttachment(); |
| 9270 | pipe.AddShader(&vs); |
| 9271 | pipe.AddShader(&fs); |
| 9272 | |
| 9273 | VkDescriptorSetObj descriptorSet(m_device); |
| 9274 | descriptorSet.AppendDummy(); |
| 9275 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9276 | |
| 9277 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9278 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9279 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 9280 | } |
| 9281 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9282 | TEST_F(VkLayerTest, CreatePipelineTessPerVertex) |
| 9283 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9284 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9285 | |
| 9286 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9287 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9288 | |
Chris Forbes | c1e852d | 2016-04-04 19:26:42 +1200 | [diff] [blame] | 9289 | if (!m_device->phy().features().tessellationShader) { |
| 9290 | printf("Device does not support tessellation shaders; skipped.\n"); |
| 9291 | return; |
| 9292 | } |
| 9293 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9294 | char const *vsSource = |
| 9295 | "#version 450\n" |
| 9296 | "void main(){}\n"; |
| 9297 | char const *tcsSource = |
| 9298 | "#version 450\n" |
| 9299 | "layout(location=0) out int x[];\n" |
| 9300 | "layout(vertices=3) out;\n" |
| 9301 | "void main(){\n" |
| 9302 | " gl_TessLevelOuter[0] = gl_TessLevelOuter[1] = gl_TessLevelOuter[2] = 1;\n" |
| 9303 | " gl_TessLevelInner[0] = 1;\n" |
| 9304 | " x[gl_InvocationID] = gl_InvocationID;\n" |
| 9305 | "}\n"; |
| 9306 | char const *tesSource = |
| 9307 | "#version 450\n" |
| 9308 | "layout(triangles, equal_spacing, cw) in;\n" |
| 9309 | "layout(location=0) in int x[];\n" |
| 9310 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 9311 | "void main(){\n" |
| 9312 | " gl_Position.xyz = gl_TessCoord;\n" |
| 9313 | " gl_Position.w = x[0] + x[1] + x[2];\n" |
| 9314 | "}\n"; |
| 9315 | char const *fsSource = |
| 9316 | "#version 450\n" |
| 9317 | "layout(location=0) out vec4 color;\n" |
| 9318 | "void main(){\n" |
| 9319 | " color = vec4(1);\n" |
| 9320 | "}\n"; |
| 9321 | |
| 9322 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9323 | VkShaderObj tcs(m_device, tcsSource, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 9324 | VkShaderObj tes(m_device, tesSource, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
| 9325 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9326 | |
| 9327 | VkPipelineInputAssemblyStateCreateInfo iasci{ |
| 9328 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, |
| 9329 | nullptr, |
| 9330 | 0, |
| 9331 | VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, |
| 9332 | VK_FALSE}; |
| 9333 | |
Chris Forbes | b4cacb6 | 2016-04-04 19:15:00 +1200 | [diff] [blame] | 9334 | VkPipelineTessellationStateCreateInfo tsci{ |
| 9335 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, |
| 9336 | nullptr, |
| 9337 | 0, |
| 9338 | 3}; |
| 9339 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9340 | VkPipelineObj pipe(m_device); |
| 9341 | pipe.SetInputAssembly(&iasci); |
Chris Forbes | b4cacb6 | 2016-04-04 19:15:00 +1200 | [diff] [blame] | 9342 | pipe.SetTessellation(&tsci); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9343 | pipe.AddColorAttachment(); |
| 9344 | pipe.AddShader(&vs); |
| 9345 | pipe.AddShader(&tcs); |
| 9346 | pipe.AddShader(&tes); |
| 9347 | pipe.AddShader(&fs); |
| 9348 | |
| 9349 | VkDescriptorSetObj descriptorSet(m_device); |
| 9350 | descriptorSet.AppendDummy(); |
| 9351 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9352 | |
| 9353 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9354 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9355 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9356 | } |
| 9357 | |
Chris Forbes | a0ab815 | 2016-04-20 13:34:27 +1200 | [diff] [blame] | 9358 | TEST_F(VkLayerTest, CreatePipelineGeometryInputBlockPositive) |
| 9359 | { |
| 9360 | m_errorMonitor->ExpectSuccess(); |
| 9361 | |
| 9362 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9363 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9364 | |
| 9365 | if (!m_device->phy().features().geometryShader) { |
| 9366 | printf("Device does not support geometry shaders; skipped.\n"); |
| 9367 | return; |
| 9368 | } |
| 9369 | |
| 9370 | char const *vsSource = |
| 9371 | "#version 450\n" |
| 9372 | "layout(location=0) out VertexData { vec4 x; } vs_out;\n" |
| 9373 | "void main(){\n" |
| 9374 | " vs_out.x = vec4(1);\n" |
| 9375 | "}\n"; |
| 9376 | char const *gsSource = |
| 9377 | "#version 450\n" |
| 9378 | "layout(triangles) in;\n" |
| 9379 | "layout(triangle_strip, max_vertices=3) out;\n" |
| 9380 | "layout(location=0) in VertexData { vec4 x; } gs_in[];\n" |
| 9381 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 9382 | "void main() {\n" |
| 9383 | " gl_Position = gs_in[0].x;\n" |
| 9384 | " EmitVertex();\n" |
| 9385 | "}\n"; |
| 9386 | char const *fsSource = |
| 9387 | "#version 450\n" |
| 9388 | "layout(location=0) out vec4 color;\n" |
| 9389 | "void main(){\n" |
| 9390 | " color = vec4(1);\n" |
| 9391 | "}\n"; |
| 9392 | |
| 9393 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9394 | VkShaderObj gs(m_device, gsSource, VK_SHADER_STAGE_GEOMETRY_BIT, this); |
| 9395 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9396 | |
| 9397 | VkPipelineObj pipe(m_device); |
| 9398 | pipe.AddColorAttachment(); |
| 9399 | pipe.AddShader(&vs); |
| 9400 | pipe.AddShader(&gs); |
| 9401 | pipe.AddShader(&fs); |
| 9402 | |
| 9403 | VkDescriptorSetObj descriptorSet(m_device); |
| 9404 | descriptorSet.AppendDummy(); |
| 9405 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9406 | |
| 9407 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9408 | |
| 9409 | m_errorMonitor->VerifyNotFound(); |
| 9410 | } |
| 9411 | |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 9412 | TEST_F(VkLayerTest, CreatePipelineTessPatchDecorationMismatch) |
| 9413 | { |
| 9414 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9415 | "is per-vertex in tessellation control shader stage " |
| 9416 | "but per-patch in tessellation evaluation shader stage"); |
| 9417 | |
| 9418 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9419 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9420 | |
Chris Forbes | c1e852d | 2016-04-04 19:26:42 +1200 | [diff] [blame] | 9421 | if (!m_device->phy().features().tessellationShader) { |
| 9422 | printf("Device does not support tessellation shaders; skipped.\n"); |
| 9423 | return; |
| 9424 | } |
| 9425 | |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 9426 | char const *vsSource = |
| 9427 | "#version 450\n" |
| 9428 | "void main(){}\n"; |
| 9429 | char const *tcsSource = |
| 9430 | "#version 450\n" |
| 9431 | "layout(location=0) out int x[];\n" |
| 9432 | "layout(vertices=3) out;\n" |
| 9433 | "void main(){\n" |
| 9434 | " gl_TessLevelOuter[0] = gl_TessLevelOuter[1] = gl_TessLevelOuter[2] = 1;\n" |
| 9435 | " gl_TessLevelInner[0] = 1;\n" |
| 9436 | " x[gl_InvocationID] = gl_InvocationID;\n" |
| 9437 | "}\n"; |
| 9438 | char const *tesSource = |
| 9439 | "#version 450\n" |
| 9440 | "layout(triangles, equal_spacing, cw) in;\n" |
| 9441 | "layout(location=0) patch in int x;\n" |
| 9442 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 9443 | "void main(){\n" |
| 9444 | " gl_Position.xyz = gl_TessCoord;\n" |
| 9445 | " gl_Position.w = x;\n" |
| 9446 | "}\n"; |
| 9447 | char const *fsSource = |
| 9448 | "#version 450\n" |
| 9449 | "layout(location=0) out vec4 color;\n" |
| 9450 | "void main(){\n" |
| 9451 | " color = vec4(1);\n" |
| 9452 | "}\n"; |
| 9453 | |
| 9454 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9455 | VkShaderObj tcs(m_device, tcsSource, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 9456 | VkShaderObj tes(m_device, tesSource, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
| 9457 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9458 | |
| 9459 | VkPipelineInputAssemblyStateCreateInfo iasci{ |
| 9460 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, |
| 9461 | nullptr, |
| 9462 | 0, |
| 9463 | VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, |
| 9464 | VK_FALSE}; |
| 9465 | |
| 9466 | VkPipelineTessellationStateCreateInfo tsci{ |
| 9467 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, |
| 9468 | nullptr, |
| 9469 | 0, |
| 9470 | 3}; |
| 9471 | |
| 9472 | VkPipelineObj pipe(m_device); |
| 9473 | pipe.SetInputAssembly(&iasci); |
| 9474 | pipe.SetTessellation(&tsci); |
| 9475 | pipe.AddColorAttachment(); |
| 9476 | pipe.AddShader(&vs); |
| 9477 | pipe.AddShader(&tcs); |
| 9478 | pipe.AddShader(&tes); |
| 9479 | pipe.AddShader(&fs); |
| 9480 | |
| 9481 | VkDescriptorSetObj descriptorSet(m_device); |
| 9482 | descriptorSet.AppendDummy(); |
| 9483 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9484 | |
| 9485 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9486 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9487 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 9488 | } |
| 9489 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9490 | TEST_F(VkLayerTest, CreatePipelineAttribBindingConflict) { |
| 9491 | m_errorMonitor->SetDesiredFailureMsg( |
| 9492 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9493 | "Duplicate vertex input binding descriptions for binding 0"); |
| 9494 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9495 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 9496 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9497 | |
| 9498 | /* Two binding descriptions for binding 0 */ |
| 9499 | VkVertexInputBindingDescription input_bindings[2]; |
| 9500 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 9501 | |
| 9502 | VkVertexInputAttributeDescription input_attrib; |
| 9503 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 9504 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 9505 | |
| 9506 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9507 | "#version 450\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9508 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9509 | "layout(location=0) in float x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9510 | "out gl_PerVertex {\n" |
| 9511 | " vec4 gl_Position;\n" |
| 9512 | "};\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9513 | "void main(){\n" |
| 9514 | " gl_Position = vec4(x);\n" |
| 9515 | "}\n"; |
| 9516 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9517 | "#version 450\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9518 | "\n" |
| 9519 | "layout(location=0) out vec4 color;\n" |
| 9520 | "void main(){\n" |
| 9521 | " color = vec4(1);\n" |
| 9522 | "}\n"; |
| 9523 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9524 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9525 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9526 | |
| 9527 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9528 | pipe.AddColorAttachment(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9529 | pipe.AddShader(&vs); |
| 9530 | pipe.AddShader(&fs); |
| 9531 | |
| 9532 | pipe.AddVertexInputBindings(input_bindings, 2); |
| 9533 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 9534 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9535 | VkDescriptorSetObj descriptorSet(m_device); |
| 9536 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9537 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9538 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9539 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9540 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9541 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9542 | } |
Chris Forbes | 8f68b56 | 2015-05-25 11:13:32 +1200 | [diff] [blame] | 9543 | |
Chris Forbes | 35efec7 | 2016-04-21 14:32:08 +1200 | [diff] [blame] | 9544 | TEST_F(VkLayerTest, CreatePipeline64BitAttributesPositive) { |
| 9545 | m_errorMonitor->ExpectSuccess(); |
| 9546 | |
| 9547 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9548 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9549 | |
| 9550 | if (!m_device->phy().features().tessellationShader) { |
| 9551 | printf("Device does not support 64bit vertex attributes; skipped.\n"); |
| 9552 | return; |
| 9553 | } |
| 9554 | |
| 9555 | VkVertexInputBindingDescription input_bindings[1]; |
| 9556 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 9557 | |
| 9558 | VkVertexInputAttributeDescription input_attribs[4]; |
| 9559 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 9560 | input_attribs[0].location = 0; |
| 9561 | input_attribs[0].offset = 0; |
| 9562 | input_attribs[0].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 9563 | input_attribs[1].location = 2; |
| 9564 | input_attribs[1].offset = 32; |
| 9565 | input_attribs[1].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 9566 | input_attribs[2].location = 4; |
| 9567 | input_attribs[2].offset = 64; |
| 9568 | input_attribs[2].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 9569 | input_attribs[3].location = 6; |
| 9570 | input_attribs[3].offset = 96; |
| 9571 | input_attribs[3].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 9572 | |
| 9573 | char const *vsSource = |
| 9574 | "#version 450\n" |
| 9575 | "\n" |
| 9576 | "layout(location=0) in dmat4 x;\n" |
| 9577 | "out gl_PerVertex {\n" |
| 9578 | " vec4 gl_Position;\n" |
| 9579 | "};\n" |
| 9580 | "void main(){\n" |
| 9581 | " gl_Position = vec4(x[0][0]);\n" |
| 9582 | "}\n"; |
| 9583 | char const *fsSource = |
| 9584 | "#version 450\n" |
| 9585 | "\n" |
| 9586 | "layout(location=0) out vec4 color;\n" |
| 9587 | "void main(){\n" |
| 9588 | " color = vec4(1);\n" |
| 9589 | "}\n"; |
| 9590 | |
| 9591 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9592 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9593 | |
| 9594 | VkPipelineObj pipe(m_device); |
| 9595 | pipe.AddColorAttachment(); |
| 9596 | pipe.AddShader(&vs); |
| 9597 | pipe.AddShader(&fs); |
| 9598 | |
| 9599 | pipe.AddVertexInputBindings(input_bindings, 1); |
| 9600 | pipe.AddVertexInputAttribs(input_attribs, 4); |
| 9601 | |
| 9602 | VkDescriptorSetObj descriptorSet(m_device); |
| 9603 | descriptorSet.AppendDummy(); |
| 9604 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9605 | |
| 9606 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9607 | |
| 9608 | m_errorMonitor->VerifyNotFound(); |
| 9609 | } |
| 9610 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9611 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotWritten) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9612 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9613 | "Attachment 0 not written by FS"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9614 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9615 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9616 | |
| 9617 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9618 | "#version 450\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9619 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9620 | "out gl_PerVertex {\n" |
| 9621 | " vec4 gl_Position;\n" |
| 9622 | "};\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9623 | "void main(){\n" |
| 9624 | " gl_Position = vec4(1);\n" |
| 9625 | "}\n"; |
| 9626 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9627 | "#version 450\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9628 | "\n" |
| 9629 | "void main(){\n" |
| 9630 | "}\n"; |
| 9631 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9632 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9633 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9634 | |
| 9635 | VkPipelineObj pipe(m_device); |
| 9636 | pipe.AddShader(&vs); |
| 9637 | pipe.AddShader(&fs); |
| 9638 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9639 | /* set up CB 0, not written */ |
| 9640 | pipe.AddColorAttachment(); |
| 9641 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9642 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9643 | VkDescriptorSetObj descriptorSet(m_device); |
| 9644 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9645 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9646 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9647 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9648 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9649 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9650 | } |
| 9651 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9652 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotConsumed) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9653 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 9654 | VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9655 | "FS writes to output location 1 with no matching attachment"); |
| 9656 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9657 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9658 | |
| 9659 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9660 | "#version 450\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9661 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9662 | "out gl_PerVertex {\n" |
| 9663 | " vec4 gl_Position;\n" |
| 9664 | "};\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9665 | "void main(){\n" |
| 9666 | " gl_Position = vec4(1);\n" |
| 9667 | "}\n"; |
| 9668 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9669 | "#version 450\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9670 | "\n" |
| 9671 | "layout(location=0) out vec4 x;\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9672 | "layout(location=1) out vec4 y;\n" /* no matching attachment for this */ |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9673 | "void main(){\n" |
| 9674 | " x = vec4(1);\n" |
| 9675 | " y = vec4(1);\n" |
| 9676 | "}\n"; |
| 9677 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9678 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9679 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9680 | |
| 9681 | VkPipelineObj pipe(m_device); |
| 9682 | pipe.AddShader(&vs); |
| 9683 | pipe.AddShader(&fs); |
| 9684 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9685 | /* set up CB 0, not written */ |
| 9686 | pipe.AddColorAttachment(); |
| 9687 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9688 | /* FS writes CB 1, but we don't configure it */ |
| 9689 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9690 | VkDescriptorSetObj descriptorSet(m_device); |
| 9691 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9692 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9693 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9694 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9695 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9696 | m_errorMonitor->VerifyFound(); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9697 | } |
| 9698 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9699 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputTypeMismatch) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9700 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9701 | "does not match FS output type"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9702 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9703 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9704 | |
| 9705 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9706 | "#version 450\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9707 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9708 | "out gl_PerVertex {\n" |
| 9709 | " vec4 gl_Position;\n" |
| 9710 | "};\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9711 | "void main(){\n" |
| 9712 | " gl_Position = vec4(1);\n" |
| 9713 | "}\n"; |
| 9714 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9715 | "#version 450\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9716 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9717 | "layout(location=0) out ivec4 x;\n" /* not UNORM */ |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9718 | "void main(){\n" |
| 9719 | " x = ivec4(1);\n" |
| 9720 | "}\n"; |
| 9721 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9722 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9723 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9724 | |
| 9725 | VkPipelineObj pipe(m_device); |
| 9726 | pipe.AddShader(&vs); |
| 9727 | pipe.AddShader(&fs); |
| 9728 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9729 | /* set up CB 0; type is UNORM by default */ |
| 9730 | pipe.AddColorAttachment(); |
| 9731 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9732 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9733 | VkDescriptorSetObj descriptorSet(m_device); |
| 9734 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9735 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9736 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9737 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9738 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9739 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9740 | } |
Chris Forbes | 7b1b893 | 2015-06-05 14:43:36 +1200 | [diff] [blame] | 9741 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9742 | TEST_F(VkLayerTest, CreatePipelineUniformBlockNotProvided) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9743 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9744 | "not declared in pipeline layout"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9745 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 9746 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 9747 | |
| 9748 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9749 | "#version 450\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 9750 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9751 | "out gl_PerVertex {\n" |
| 9752 | " vec4 gl_Position;\n" |
| 9753 | "};\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 9754 | "void main(){\n" |
| 9755 | " gl_Position = vec4(1);\n" |
| 9756 | "}\n"; |
| 9757 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9758 | "#version 450\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 9759 | "\n" |
| 9760 | "layout(location=0) out vec4 x;\n" |
| 9761 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 9762 | "void main(){\n" |
| 9763 | " x = vec4(bar.y);\n" |
| 9764 | "}\n"; |
| 9765 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9766 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9767 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 9768 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 9769 | VkPipelineObj pipe(m_device); |
| 9770 | pipe.AddShader(&vs); |
| 9771 | pipe.AddShader(&fs); |
| 9772 | |
| 9773 | /* set up CB 0; type is UNORM by default */ |
| 9774 | pipe.AddColorAttachment(); |
| 9775 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9776 | |
| 9777 | VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9778 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 9779 | |
| 9780 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9781 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9782 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 9783 | } |
| 9784 | |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 9785 | TEST_F(VkLayerTest, CreatePipelinePushConstantsNotInLayout) { |
| 9786 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9787 | "not declared in layout"); |
| 9788 | |
| 9789 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9790 | |
| 9791 | char const *vsSource = |
| 9792 | "#version 450\n" |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 9793 | "\n" |
| 9794 | "layout(push_constant, std430) uniform foo { float x; } consts;\n" |
| 9795 | "out gl_PerVertex {\n" |
| 9796 | " vec4 gl_Position;\n" |
| 9797 | "};\n" |
| 9798 | "void main(){\n" |
| 9799 | " gl_Position = vec4(consts.x);\n" |
| 9800 | "}\n"; |
| 9801 | char const *fsSource = |
| 9802 | "#version 450\n" |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 9803 | "\n" |
| 9804 | "layout(location=0) out vec4 x;\n" |
| 9805 | "void main(){\n" |
| 9806 | " x = vec4(1);\n" |
| 9807 | "}\n"; |
| 9808 | |
| 9809 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9810 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9811 | |
| 9812 | VkPipelineObj pipe(m_device); |
| 9813 | pipe.AddShader(&vs); |
| 9814 | pipe.AddShader(&fs); |
| 9815 | |
| 9816 | /* set up CB 0; type is UNORM by default */ |
| 9817 | pipe.AddColorAttachment(); |
| 9818 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9819 | |
| 9820 | VkDescriptorSetObj descriptorSet(m_device); |
| 9821 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9822 | |
| 9823 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9824 | |
| 9825 | /* should have generated an error -- no push constant ranges provided! */ |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9826 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 9827 | } |
| 9828 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 9829 | #endif // SHADER_CHECKER_TESTS |
| 9830 | |
| 9831 | #if DEVICE_LIMITS_TESTS |
Mark Young | c48c4c1 | 2016-04-11 14:26:49 -0600 | [diff] [blame] | 9832 | TEST_F(VkLayerTest, CreateImageLimitsViolationMaxWidth) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9833 | m_errorMonitor->SetDesiredFailureMsg( |
| 9834 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9835 | "CreateImage extents exceed allowable limits for format"); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 9836 | |
| 9837 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 9838 | |
| 9839 | // Create an image |
| 9840 | VkImage image; |
| 9841 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9842 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 9843 | const int32_t tex_width = 32; |
| 9844 | const int32_t tex_height = 32; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 9845 | |
| 9846 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9847 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9848 | image_create_info.pNext = NULL; |
| 9849 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 9850 | image_create_info.format = tex_format; |
| 9851 | image_create_info.extent.width = tex_width; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 9852 | image_create_info.extent.height = tex_height; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9853 | image_create_info.extent.depth = 1; |
| 9854 | image_create_info.mipLevels = 1; |
| 9855 | image_create_info.arrayLayers = 1; |
| 9856 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 9857 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 9858 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 9859 | image_create_info.flags = 0; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 9860 | |
| 9861 | // Introduce error by sending down a bogus width extent |
| 9862 | image_create_info.extent.width = 65536; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9863 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 9864 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9865 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 9866 | } |
| 9867 | |
Mark Young | c48c4c1 | 2016-04-11 14:26:49 -0600 | [diff] [blame] | 9868 | TEST_F(VkLayerTest, CreateImageLimitsViolationMinWidth) { |
| 9869 | m_errorMonitor->SetDesiredFailureMsg( |
| 9870 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9871 | "CreateImage extents is 0 for at least one required dimension"); |
| 9872 | |
| 9873 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9874 | |
| 9875 | // Create an image |
| 9876 | VkImage image; |
| 9877 | |
| 9878 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 9879 | const int32_t tex_width = 32; |
| 9880 | const int32_t tex_height = 32; |
| 9881 | |
| 9882 | VkImageCreateInfo image_create_info = {}; |
| 9883 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9884 | image_create_info.pNext = NULL; |
| 9885 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 9886 | image_create_info.format = tex_format; |
| 9887 | image_create_info.extent.width = tex_width; |
| 9888 | image_create_info.extent.height = tex_height; |
| 9889 | image_create_info.extent.depth = 1; |
| 9890 | image_create_info.mipLevels = 1; |
| 9891 | image_create_info.arrayLayers = 1; |
| 9892 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 9893 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 9894 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 9895 | image_create_info.flags = 0; |
| 9896 | |
| 9897 | // Introduce error by sending down a bogus width extent |
| 9898 | image_create_info.extent.width = 0; |
| 9899 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 9900 | |
| 9901 | m_errorMonitor->VerifyFound(); |
| 9902 | } |
| 9903 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9904 | TEST_F(VkLayerTest, UpdateBufferAlignment) { |
| 9905 | uint32_t updateData[] = {1, 2, 3, 4, 5, 6, 7, 8}; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9906 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9907 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9908 | "dstOffset, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9909 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9910 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9911 | |
| 9912 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 9913 | vk_testing::Buffer buffer; |
| 9914 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 9915 | |
| 9916 | BeginCommandBuffer(); |
| 9917 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9918 | m_commandBuffer->UpdateBuffer(buffer.handle(), 1, 4, updateData); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9919 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9920 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9921 | // Introduce failure by using size that is not multiple of 4 |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9922 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9923 | "dataSize, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9924 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9925 | m_commandBuffer->UpdateBuffer(buffer.handle(), 0, 6, updateData); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9926 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9927 | EndCommandBuffer(); |
| 9928 | } |
| 9929 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9930 | TEST_F(VkLayerTest, FillBufferAlignment) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9931 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9932 | "dstOffset, is not a multiple of 4"); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9933 | |
| 9934 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9935 | |
| 9936 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 9937 | vk_testing::Buffer buffer; |
| 9938 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 9939 | |
| 9940 | BeginCommandBuffer(); |
| 9941 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9942 | m_commandBuffer->FillBuffer(buffer.handle(), 1, 4, 0x11111111); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9943 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9944 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9945 | // Introduce failure by using size that is not multiple of 4 |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9946 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9947 | "size, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9948 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9949 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 6, 0x11111111); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9950 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9951 | m_errorMonitor->VerifyFound(); |
| 9952 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9953 | EndCommandBuffer(); |
| 9954 | } |
| 9955 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 9956 | #endif // DEVICE_LIMITS_TESTS |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9957 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 9958 | #if IMAGE_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9959 | TEST_F(VkLayerTest, InvalidImageView) { |
| 9960 | VkResult err; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 9961 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9962 | m_errorMonitor->SetDesiredFailureMsg( |
| 9963 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9964 | "vkCreateImageView called with baseMipLevel 10 "); |
| 9965 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 9966 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 9967 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9968 | // Create an image and try to create a view with bad baseMipLevel |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9969 | VkImage image; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 9970 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9971 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 9972 | const int32_t tex_width = 32; |
| 9973 | const int32_t tex_height = 32; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 9974 | |
| 9975 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9976 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9977 | image_create_info.pNext = NULL; |
| 9978 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 9979 | image_create_info.format = tex_format; |
| 9980 | image_create_info.extent.width = tex_width; |
| 9981 | image_create_info.extent.height = tex_height; |
| 9982 | image_create_info.extent.depth = 1; |
| 9983 | image_create_info.mipLevels = 1; |
| 9984 | image_create_info.arrayLayers = 1; |
| 9985 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 9986 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 9987 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 9988 | image_create_info.flags = 0; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 9989 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9990 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 9991 | ASSERT_VK_SUCCESS(err); |
| 9992 | |
| 9993 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9994 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9995 | image_view_create_info.image = image; |
| 9996 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 9997 | image_view_create_info.format = tex_format; |
| 9998 | image_view_create_info.subresourceRange.layerCount = 1; |
| 9999 | image_view_create_info.subresourceRange.baseMipLevel = 10; // cause an error |
| 10000 | image_view_create_info.subresourceRange.levelCount = 1; |
| 10001 | image_view_create_info.subresourceRange.aspectMask = |
| 10002 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10003 | |
| 10004 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10005 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 10006 | &view); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10007 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10008 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10009 | } |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10010 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10011 | TEST_F(VkLayerTest, InvalidImageViewAspect) { |
Tobin Ehlis | 1f567a2 | 2016-05-25 16:15:18 -0600 | [diff] [blame] | 10012 | TEST_DESCRIPTION( |
| 10013 | "Create an image and try to create a view with an invalid aspectMask"); |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 10014 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10015 | "vkCreateImageView: Color image " |
| 10016 | "formats must have ONLY the " |
| 10017 | "VK_IMAGE_ASPECT_COLOR_BIT set"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10018 | |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 10019 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 10020 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10021 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
Tobin Ehlis | 1f567a2 | 2016-05-25 16:15:18 -0600 | [diff] [blame] | 10022 | VkImageObj image(m_device); |
| 10023 | image.init(32, 32, tex_format, VK_IMAGE_USAGE_SAMPLED_BIT, |
| 10024 | VK_IMAGE_TILING_LINEAR, 0); |
| 10025 | ASSERT_TRUE(image.initialized()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 10026 | |
| 10027 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10028 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
Tobin Ehlis | 1f567a2 | 2016-05-25 16:15:18 -0600 | [diff] [blame] | 10029 | image_view_create_info.image = image.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10030 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 10031 | image_view_create_info.format = tex_format; |
| 10032 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 10033 | image_view_create_info.subresourceRange.levelCount = 1; |
| 10034 | // Cause an error by setting an invalid image aspect |
| 10035 | image_view_create_info.subresourceRange.aspectMask = |
| 10036 | VK_IMAGE_ASPECT_METADATA_BIT; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 10037 | |
| 10038 | VkImageView view; |
Tobin Ehlis | 1f567a2 | 2016-05-25 16:15:18 -0600 | [diff] [blame] | 10039 | vkCreateImageView(m_device->device(), &image_view_create_info, NULL, &view); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 10040 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10041 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 10042 | } |
| 10043 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10044 | TEST_F(VkLayerTest, CopyImageLayerCountMismatch) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10045 | VkResult err; |
| 10046 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10047 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10048 | m_errorMonitor->SetDesiredFailureMsg( |
| 10049 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10050 | "vkCmdCopyImage: number of layers in source and destination subresources for pRegions"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10051 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10052 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10053 | |
| 10054 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10055 | VkImage srcImage; |
| 10056 | VkImage dstImage; |
| 10057 | VkDeviceMemory srcMem; |
| 10058 | VkDeviceMemory destMem; |
| 10059 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10060 | |
| 10061 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10062 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10063 | image_create_info.pNext = NULL; |
| 10064 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10065 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10066 | image_create_info.extent.width = 32; |
| 10067 | image_create_info.extent.height = 32; |
| 10068 | image_create_info.extent.depth = 1; |
| 10069 | image_create_info.mipLevels = 1; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10070 | image_create_info.arrayLayers = 4; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10071 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10072 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 10073 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 10074 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10075 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10076 | err = |
| 10077 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10078 | ASSERT_VK_SUCCESS(err); |
| 10079 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10080 | err = |
| 10081 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10082 | ASSERT_VK_SUCCESS(err); |
| 10083 | |
| 10084 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10085 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10086 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 10087 | memAlloc.pNext = NULL; |
| 10088 | memAlloc.allocationSize = 0; |
| 10089 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10090 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 10091 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10092 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10093 | pass = |
| 10094 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10095 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10096 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10097 | ASSERT_VK_SUCCESS(err); |
| 10098 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10099 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10100 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10101 | pass = |
| 10102 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10103 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10104 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10105 | ASSERT_VK_SUCCESS(err); |
| 10106 | |
| 10107 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 10108 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10109 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10110 | ASSERT_VK_SUCCESS(err); |
| 10111 | |
| 10112 | BeginCommandBuffer(); |
| 10113 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10114 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10115 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 10116 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10117 | copyRegion.srcSubresource.layerCount = 1; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10118 | copyRegion.srcOffset.x = 0; |
| 10119 | copyRegion.srcOffset.y = 0; |
| 10120 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10121 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10122 | copyRegion.dstSubresource.mipLevel = 0; |
| 10123 | copyRegion.dstSubresource.baseArrayLayer = 0; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10124 | // Introduce failure by forcing the dst layerCount to differ from src |
| 10125 | copyRegion.dstSubresource.layerCount = 3; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10126 | copyRegion.dstOffset.x = 0; |
| 10127 | copyRegion.dstOffset.y = 0; |
| 10128 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10129 | copyRegion.extent.width = 1; |
| 10130 | copyRegion.extent.height = 1; |
| 10131 | copyRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10132 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 10133 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10134 | EndCommandBuffer(); |
| 10135 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10136 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10137 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10138 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10139 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10140 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 10141 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10142 | } |
| 10143 | |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10144 | TEST_F(VkLayerTest, ImageLayerUnsupportedFormat) { |
| 10145 | |
| 10146 | TEST_DESCRIPTION("Creating images with unsuported formats "); |
| 10147 | |
| 10148 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10149 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 10150 | VkImageObj image(m_device); |
| 10151 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 10152 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 10153 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 10154 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 10155 | ASSERT_TRUE(image.initialized()); |
| 10156 | |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 10157 | // Create image with unsupported format - Expect FORMAT_UNSUPPORTED |
| 10158 | VkImageCreateInfo image_create_info; |
| 10159 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10160 | image_create_info.pNext = NULL; |
| 10161 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10162 | image_create_info.format = VK_FORMAT_UNDEFINED; |
| 10163 | image_create_info.extent.width = 32; |
| 10164 | image_create_info.extent.height = 32; |
| 10165 | image_create_info.extent.depth = 1; |
| 10166 | image_create_info.mipLevels = 1; |
| 10167 | image_create_info.arrayLayers = 1; |
| 10168 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10169 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 10170 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 10171 | image_create_info.flags = 0; |
| 10172 | |
| 10173 | m_errorMonitor->SetDesiredFailureMsg( |
| 10174 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10175 | "vkCreateImage: VkFormat for image must not be VK_FORMAT_UNDEFINED"); |
| 10176 | |
| 10177 | VkImage localImage; |
| 10178 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &localImage); |
| 10179 | m_errorMonitor->VerifyFound(); |
| 10180 | |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10181 | VkFormat unsupported = VK_FORMAT_UNDEFINED; |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 10182 | // Look for a format that is COMPLETELY unsupported with this hardware |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10183 | for (int f = VK_FORMAT_BEGIN_RANGE; f <= VK_FORMAT_END_RANGE; f++) { |
| 10184 | VkFormat format = static_cast<VkFormat>(f); |
| 10185 | VkFormatProperties fProps = m_device->format_properties(format); |
| 10186 | if (format != VK_FORMAT_UNDEFINED && fProps.linearTilingFeatures == 0 && |
| 10187 | fProps.optimalTilingFeatures == 0) { |
| 10188 | unsupported = format; |
| 10189 | break; |
| 10190 | } |
| 10191 | } |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 10192 | |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10193 | if (unsupported != VK_FORMAT_UNDEFINED) { |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10194 | image_create_info.format = unsupported; |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10195 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 10196 | "is an unsupported format"); |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10197 | |
Mark Lobodzinski | ba5c686 | 2016-05-17 08:14:00 -0600 | [diff] [blame] | 10198 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &localImage); |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 10199 | m_errorMonitor->VerifyFound(); |
| 10200 | } |
| 10201 | } |
| 10202 | |
| 10203 | TEST_F(VkLayerTest, ImageLayerViewTests) { |
| 10204 | VkResult ret; |
| 10205 | TEST_DESCRIPTION("Passing bad parameters to CreateImageView"); |
| 10206 | |
| 10207 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10208 | |
| 10209 | VkImageObj image(m_device); |
| 10210 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 10211 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 10212 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 10213 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 10214 | ASSERT_TRUE(image.initialized()); |
| 10215 | |
| 10216 | VkImageView imgView; |
| 10217 | VkImageViewCreateInfo imgViewInfo = {}; |
| 10218 | imgViewInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 10219 | imgViewInfo.image = image.handle(); |
| 10220 | imgViewInfo.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 10221 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10222 | imgViewInfo.subresourceRange.layerCount = 1; |
| 10223 | imgViewInfo.subresourceRange.baseMipLevel = 0; |
| 10224 | imgViewInfo.subresourceRange.levelCount = 1; |
| 10225 | imgViewInfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10226 | |
| 10227 | m_errorMonitor->SetDesiredFailureMsg( |
| 10228 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10229 | "vkCreateImageView called with baseMipLevel"); |
| 10230 | // View can't have baseMipLevel >= image's mipLevels - Expect |
| 10231 | // VIEW_CREATE_ERROR |
| 10232 | imgViewInfo.subresourceRange.baseMipLevel = 1; |
| 10233 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 10234 | m_errorMonitor->VerifyFound(); |
| 10235 | imgViewInfo.subresourceRange.baseMipLevel = 0; |
| 10236 | |
| 10237 | m_errorMonitor->SetDesiredFailureMsg( |
| 10238 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10239 | "vkCreateImageView called with baseArrayLayer"); |
| 10240 | // View can't have baseArrayLayer >= image's arraySize - Expect |
| 10241 | // VIEW_CREATE_ERROR |
| 10242 | imgViewInfo.subresourceRange.baseArrayLayer = 1; |
| 10243 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 10244 | m_errorMonitor->VerifyFound(); |
| 10245 | imgViewInfo.subresourceRange.baseArrayLayer = 0; |
| 10246 | |
| 10247 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10248 | "vkCreateImageView called with 0 in " |
| 10249 | "pCreateInfo->subresourceRange." |
| 10250 | "levelCount"); |
| 10251 | // View's levelCount can't be 0 - Expect VIEW_CREATE_ERROR |
| 10252 | imgViewInfo.subresourceRange.levelCount = 0; |
| 10253 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 10254 | m_errorMonitor->VerifyFound(); |
| 10255 | imgViewInfo.subresourceRange.levelCount = 1; |
| 10256 | |
| 10257 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10258 | "vkCreateImageView called with 0 in " |
| 10259 | "pCreateInfo->subresourceRange." |
| 10260 | "layerCount"); |
| 10261 | // View's layerCount can't be 0 - Expect VIEW_CREATE_ERROR |
| 10262 | imgViewInfo.subresourceRange.layerCount = 0; |
| 10263 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 10264 | m_errorMonitor->VerifyFound(); |
| 10265 | imgViewInfo.subresourceRange.layerCount = 1; |
| 10266 | |
| 10267 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10268 | "but both must be color formats"); |
| 10269 | // Can't use depth format for view into color image - Expect INVALID_FORMAT |
| 10270 | imgViewInfo.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 10271 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 10272 | m_errorMonitor->VerifyFound(); |
| 10273 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10274 | |
| 10275 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10276 | "Formats MUST be IDENTICAL unless " |
| 10277 | "VK_IMAGE_CREATE_MUTABLE_FORMAT BIT " |
| 10278 | "was set on image creation."); |
| 10279 | // Same compatibility class but no MUTABLE_FORMAT bit - Expect |
| 10280 | // VIEW_CREATE_ERROR |
| 10281 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UINT; |
| 10282 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 10283 | m_errorMonitor->VerifyFound(); |
| 10284 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10285 | |
| 10286 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10287 | "can support ImageViews with " |
| 10288 | "differing formats but they must be " |
| 10289 | "in the same compatibility class."); |
| 10290 | // Have MUTABLE_FORMAT bit but not in same compatibility class - Expect |
| 10291 | // VIEW_CREATE_ERROR |
| 10292 | VkImageCreateInfo mutImgInfo = image.create_info(); |
| 10293 | VkImage mutImage; |
| 10294 | mutImgInfo.format = VK_FORMAT_R8_UINT; |
| 10295 | assert( |
| 10296 | m_device->format_properties(VK_FORMAT_R8_UINT).optimalTilingFeatures & |
| 10297 | VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT); |
| 10298 | mutImgInfo.flags = VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT; |
| 10299 | mutImgInfo.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 10300 | ret = vkCreateImage(m_device->handle(), &mutImgInfo, NULL, &mutImage); |
| 10301 | ASSERT_VK_SUCCESS(ret); |
| 10302 | imgViewInfo.image = mutImage; |
| 10303 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 10304 | m_errorMonitor->VerifyFound(); |
| 10305 | imgViewInfo.image = image.handle(); |
| 10306 | vkDestroyImage(m_device->handle(), mutImage, NULL); |
| 10307 | } |
| 10308 | |
| 10309 | TEST_F(VkLayerTest, MiscImageLayerTests) { |
| 10310 | |
| 10311 | TEST_DESCRIPTION("Image layer tests that don't belong elsewhare"); |
| 10312 | |
| 10313 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10314 | |
| 10315 | VkImageObj image(m_device); |
| 10316 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 10317 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 10318 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 10319 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 10320 | ASSERT_TRUE(image.initialized()); |
| 10321 | |
| 10322 | m_errorMonitor->SetDesiredFailureMsg( |
| 10323 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10324 | "number of layers in image subresource is zero"); |
| 10325 | vk_testing::Buffer buffer; |
| 10326 | VkMemoryPropertyFlags reqs = 0; |
| 10327 | buffer.init_as_src(*m_device, 128 * 128 * 4, reqs); |
| 10328 | VkBufferImageCopy region = {}; |
| 10329 | region.bufferRowLength = 128; |
| 10330 | region.bufferImageHeight = 128; |
| 10331 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10332 | // layerCount can't be 0 - Expect MISMATCHED_IMAGE_ASPECT |
| 10333 | region.imageSubresource.layerCount = 0; |
| 10334 | region.imageExtent.height = 4; |
| 10335 | region.imageExtent.width = 4; |
| 10336 | region.imageExtent.depth = 1; |
| 10337 | m_commandBuffer->BeginCommandBuffer(); |
| 10338 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 10339 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 10340 | 1, ®ion); |
| 10341 | m_errorMonitor->VerifyFound(); |
| 10342 | region.imageSubresource.layerCount = 1; |
| 10343 | |
| 10344 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10345 | "aspectMasks for each region must " |
| 10346 | "specify only COLOR or DEPTH or " |
| 10347 | "STENCIL"); |
| 10348 | // Expect MISMATCHED_IMAGE_ASPECT |
| 10349 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_METADATA_BIT; |
| 10350 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 10351 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 10352 | 1, ®ion); |
| 10353 | m_errorMonitor->VerifyFound(); |
| 10354 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10355 | |
| 10356 | m_errorMonitor->SetDesiredFailureMsg( |
| 10357 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10358 | "If the format of srcImage is a depth, stencil, depth stencil or " |
| 10359 | "integer-based format then filter must be VK_FILTER_NEAREST"); |
| 10360 | // Expect INVALID_FILTER |
| 10361 | VkImageObj intImage1(m_device); |
| 10362 | intImage1.init(128, 128, VK_FORMAT_R8_UINT, |
| 10363 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, |
| 10364 | 0); |
| 10365 | VkImageObj intImage2(m_device); |
| 10366 | intImage2.init(128, 128, VK_FORMAT_R8_UINT, |
| 10367 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, |
| 10368 | 0); |
| 10369 | VkImageBlit blitRegion = {}; |
| 10370 | blitRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10371 | blitRegion.srcSubresource.baseArrayLayer = 0; |
| 10372 | blitRegion.srcSubresource.layerCount = 1; |
| 10373 | blitRegion.srcSubresource.mipLevel = 0; |
| 10374 | blitRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10375 | blitRegion.dstSubresource.baseArrayLayer = 0; |
| 10376 | blitRegion.dstSubresource.layerCount = 1; |
| 10377 | blitRegion.dstSubresource.mipLevel = 0; |
| 10378 | |
| 10379 | vkCmdBlitImage(m_commandBuffer->GetBufferHandle(), intImage1.handle(), |
| 10380 | intImage1.layout(), intImage2.handle(), intImage2.layout(), |
| 10381 | 16, &blitRegion, VK_FILTER_LINEAR); |
| 10382 | m_errorMonitor->VerifyFound(); |
| 10383 | |
| 10384 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10385 | "called with 0 in ppMemoryBarriers"); |
| 10386 | VkImageMemoryBarrier img_barrier; |
| 10387 | img_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; |
| 10388 | img_barrier.pNext = NULL; |
| 10389 | img_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 10390 | img_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 10391 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 10392 | img_barrier.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 10393 | img_barrier.image = image.handle(); |
| 10394 | img_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 10395 | img_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 10396 | img_barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10397 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 10398 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 10399 | // layerCount should not be 0 - Expect INVALID_IMAGE_RESOURCE |
| 10400 | img_barrier.subresourceRange.layerCount = 0; |
| 10401 | img_barrier.subresourceRange.levelCount = 1; |
| 10402 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 10403 | VK_PIPELINE_STAGE_HOST_BIT, |
| 10404 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 10405 | nullptr, 1, &img_barrier); |
| 10406 | m_errorMonitor->VerifyFound(); |
| 10407 | img_barrier.subresourceRange.layerCount = 1; |
| 10408 | } |
| 10409 | |
| 10410 | TEST_F(VkLayerTest, ImageFormatLimits) { |
| 10411 | |
| 10412 | TEST_DESCRIPTION("Exceed the limits of image format "); |
| 10413 | |
| 10414 | m_errorMonitor->SetDesiredFailureMsg( |
| 10415 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10416 | "CreateImage extents exceed allowable limits for format"); |
| 10417 | VkImageCreateInfo image_create_info = {}; |
| 10418 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10419 | image_create_info.pNext = NULL; |
| 10420 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10421 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10422 | image_create_info.extent.width = 32; |
| 10423 | image_create_info.extent.height = 32; |
| 10424 | image_create_info.extent.depth = 1; |
| 10425 | image_create_info.mipLevels = 1; |
| 10426 | image_create_info.arrayLayers = 1; |
| 10427 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10428 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 10429 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 10430 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 10431 | image_create_info.flags = 0; |
| 10432 | |
| 10433 | VkImage nullImg; |
| 10434 | VkImageFormatProperties imgFmtProps; |
| 10435 | vkGetPhysicalDeviceImageFormatProperties( |
| 10436 | gpu(), image_create_info.format, image_create_info.imageType, |
| 10437 | image_create_info.tiling, image_create_info.usage, |
| 10438 | image_create_info.flags, &imgFmtProps); |
| 10439 | image_create_info.extent.depth = imgFmtProps.maxExtent.depth + 1; |
| 10440 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 10441 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 10442 | m_errorMonitor->VerifyFound(); |
| 10443 | image_create_info.extent.depth = 1; |
| 10444 | |
| 10445 | m_errorMonitor->SetDesiredFailureMsg( |
| 10446 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10447 | "exceeds allowable maximum supported by format of"); |
| 10448 | image_create_info.mipLevels = imgFmtProps.maxMipLevels + 1; |
| 10449 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 10450 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 10451 | m_errorMonitor->VerifyFound(); |
| 10452 | image_create_info.mipLevels = 1; |
| 10453 | |
| 10454 | m_errorMonitor->SetDesiredFailureMsg( |
| 10455 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10456 | "exceeds allowable maximum supported by format of"); |
| 10457 | image_create_info.arrayLayers = imgFmtProps.maxArrayLayers + 1; |
| 10458 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 10459 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 10460 | m_errorMonitor->VerifyFound(); |
| 10461 | image_create_info.arrayLayers = 1; |
| 10462 | |
| 10463 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10464 | "is not supported by format"); |
| 10465 | int samples = imgFmtProps.sampleCounts >> 1; |
| 10466 | image_create_info.samples = (VkSampleCountFlagBits)samples; |
| 10467 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 10468 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 10469 | m_errorMonitor->VerifyFound(); |
| 10470 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10471 | |
| 10472 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10473 | "pCreateInfo->initialLayout, must be " |
| 10474 | "VK_IMAGE_LAYOUT_UNDEFINED or " |
| 10475 | "VK_IMAGE_LAYOUT_PREINITIALIZED"); |
| 10476 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 10477 | // Expect INVALID_LAYOUT |
| 10478 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 10479 | m_errorMonitor->VerifyFound(); |
| 10480 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 10481 | } |
| 10482 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10483 | TEST_F(VkLayerTest, CopyImageFormatSizeMismatch) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 10484 | VkResult err; |
| 10485 | bool pass; |
| 10486 | |
| 10487 | // Create color images with different format sizes and try to copy between them |
| 10488 | m_errorMonitor->SetDesiredFailureMsg( |
| 10489 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10490 | "vkCmdCopyImage called with unmatched source and dest image format sizes"); |
| 10491 | |
| 10492 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10493 | |
| 10494 | // Create two images of different types and try to copy between them |
| 10495 | VkImage srcImage; |
| 10496 | VkImage dstImage; |
| 10497 | VkDeviceMemory srcMem; |
| 10498 | VkDeviceMemory destMem; |
| 10499 | VkMemoryRequirements memReqs; |
| 10500 | |
| 10501 | VkImageCreateInfo image_create_info = {}; |
| 10502 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10503 | image_create_info.pNext = NULL; |
| 10504 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10505 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10506 | image_create_info.extent.width = 32; |
| 10507 | image_create_info.extent.height = 32; |
| 10508 | image_create_info.extent.depth = 1; |
| 10509 | image_create_info.mipLevels = 1; |
| 10510 | image_create_info.arrayLayers = 1; |
| 10511 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10512 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 10513 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 10514 | image_create_info.flags = 0; |
| 10515 | |
| 10516 | err = |
| 10517 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
| 10518 | ASSERT_VK_SUCCESS(err); |
| 10519 | |
| 10520 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 10521 | // Introduce failure by creating second image with a different-sized format. |
| 10522 | image_create_info.format = VK_FORMAT_R5G5B5A1_UNORM_PACK16; |
| 10523 | |
| 10524 | err = |
| 10525 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
| 10526 | ASSERT_VK_SUCCESS(err); |
| 10527 | |
| 10528 | // Allocate memory |
| 10529 | VkMemoryAllocateInfo memAlloc = {}; |
| 10530 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 10531 | memAlloc.pNext = NULL; |
| 10532 | memAlloc.allocationSize = 0; |
| 10533 | memAlloc.memoryTypeIndex = 0; |
| 10534 | |
| 10535 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
| 10536 | memAlloc.allocationSize = memReqs.size; |
| 10537 | pass = |
| 10538 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 10539 | ASSERT_TRUE(pass); |
| 10540 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
| 10541 | ASSERT_VK_SUCCESS(err); |
| 10542 | |
| 10543 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
| 10544 | memAlloc.allocationSize = memReqs.size; |
| 10545 | pass = |
| 10546 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 10547 | ASSERT_TRUE(pass); |
| 10548 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
| 10549 | ASSERT_VK_SUCCESS(err); |
| 10550 | |
| 10551 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 10552 | ASSERT_VK_SUCCESS(err); |
| 10553 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
| 10554 | ASSERT_VK_SUCCESS(err); |
| 10555 | |
| 10556 | BeginCommandBuffer(); |
| 10557 | VkImageCopy copyRegion; |
| 10558 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10559 | copyRegion.srcSubresource.mipLevel = 0; |
| 10560 | copyRegion.srcSubresource.baseArrayLayer = 0; |
| 10561 | copyRegion.srcSubresource.layerCount = 0; |
| 10562 | copyRegion.srcOffset.x = 0; |
| 10563 | copyRegion.srcOffset.y = 0; |
| 10564 | copyRegion.srcOffset.z = 0; |
| 10565 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10566 | copyRegion.dstSubresource.mipLevel = 0; |
| 10567 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 10568 | copyRegion.dstSubresource.layerCount = 0; |
| 10569 | copyRegion.dstOffset.x = 0; |
| 10570 | copyRegion.dstOffset.y = 0; |
| 10571 | copyRegion.dstOffset.z = 0; |
| 10572 | copyRegion.extent.width = 1; |
| 10573 | copyRegion.extent.height = 1; |
| 10574 | copyRegion.extent.depth = 1; |
| 10575 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 10576 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 10577 | EndCommandBuffer(); |
| 10578 | |
| 10579 | m_errorMonitor->VerifyFound(); |
| 10580 | |
| 10581 | vkDestroyImage(m_device->device(), srcImage, NULL); |
| 10582 | vkDestroyImage(m_device->device(), dstImage, NULL); |
| 10583 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 10584 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10585 | } |
| 10586 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10587 | TEST_F(VkLayerTest, CopyImageDepthStencilFormatMismatch) { |
| 10588 | VkResult err; |
| 10589 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10590 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10591 | // 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] | 10592 | m_errorMonitor->SetDesiredFailureMsg( |
| 10593 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10594 | "vkCmdCopyImage called with unmatched source and dest image depth"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10595 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10596 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10597 | |
| 10598 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10599 | VkImage srcImage; |
| 10600 | VkImage dstImage; |
| 10601 | VkDeviceMemory srcMem; |
| 10602 | VkDeviceMemory destMem; |
| 10603 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10604 | |
| 10605 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10606 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10607 | image_create_info.pNext = NULL; |
| 10608 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10609 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10610 | image_create_info.extent.width = 32; |
| 10611 | image_create_info.extent.height = 32; |
| 10612 | image_create_info.extent.depth = 1; |
| 10613 | image_create_info.mipLevels = 1; |
| 10614 | image_create_info.arrayLayers = 1; |
| 10615 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10616 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 10617 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 10618 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10619 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10620 | err = |
| 10621 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10622 | ASSERT_VK_SUCCESS(err); |
| 10623 | |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 10624 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 10625 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10626 | // Introduce failure by creating second image with a depth/stencil format |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10627 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10628 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 10629 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10630 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10631 | err = |
| 10632 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10633 | ASSERT_VK_SUCCESS(err); |
| 10634 | |
| 10635 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10636 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10637 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 10638 | memAlloc.pNext = NULL; |
| 10639 | memAlloc.allocationSize = 0; |
| 10640 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10641 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 10642 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10643 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10644 | pass = |
| 10645 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10646 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10647 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10648 | ASSERT_VK_SUCCESS(err); |
| 10649 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10650 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10651 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10652 | pass = |
| 10653 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10654 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10655 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10656 | ASSERT_VK_SUCCESS(err); |
| 10657 | |
| 10658 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 10659 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10660 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10661 | ASSERT_VK_SUCCESS(err); |
| 10662 | |
| 10663 | BeginCommandBuffer(); |
| 10664 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10665 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10666 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 10667 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10668 | copyRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10669 | copyRegion.srcOffset.x = 0; |
| 10670 | copyRegion.srcOffset.y = 0; |
| 10671 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10672 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10673 | copyRegion.dstSubresource.mipLevel = 0; |
| 10674 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 10675 | copyRegion.dstSubresource.layerCount = 0; |
| 10676 | copyRegion.dstOffset.x = 0; |
| 10677 | copyRegion.dstOffset.y = 0; |
| 10678 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10679 | copyRegion.extent.width = 1; |
| 10680 | copyRegion.extent.height = 1; |
| 10681 | copyRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10682 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 10683 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10684 | EndCommandBuffer(); |
| 10685 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10686 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10687 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10688 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10689 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10690 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 10691 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10692 | } |
| 10693 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10694 | TEST_F(VkLayerTest, ResolveImageLowSampleCount) { |
| 10695 | VkResult err; |
| 10696 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10697 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10698 | m_errorMonitor->SetDesiredFailureMsg( |
| 10699 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10700 | "vkCmdResolveImage called with source sample count less than 2."); |
| 10701 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10702 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10703 | |
| 10704 | // 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] | 10705 | VkImage srcImage; |
| 10706 | VkImage dstImage; |
| 10707 | VkDeviceMemory srcMem; |
| 10708 | VkDeviceMemory destMem; |
| 10709 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10710 | |
| 10711 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10712 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10713 | image_create_info.pNext = NULL; |
| 10714 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10715 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10716 | image_create_info.extent.width = 32; |
| 10717 | image_create_info.extent.height = 1; |
| 10718 | image_create_info.extent.depth = 1; |
| 10719 | image_create_info.mipLevels = 1; |
| 10720 | image_create_info.arrayLayers = 1; |
| 10721 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10722 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 10723 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 10724 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10725 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10726 | err = |
| 10727 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10728 | ASSERT_VK_SUCCESS(err); |
| 10729 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10730 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10731 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10732 | err = |
| 10733 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10734 | ASSERT_VK_SUCCESS(err); |
| 10735 | |
| 10736 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10737 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10738 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 10739 | memAlloc.pNext = NULL; |
| 10740 | memAlloc.allocationSize = 0; |
| 10741 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10742 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 10743 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10744 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10745 | pass = |
| 10746 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10747 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10748 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10749 | ASSERT_VK_SUCCESS(err); |
| 10750 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10751 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10752 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10753 | pass = |
| 10754 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10755 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10756 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10757 | ASSERT_VK_SUCCESS(err); |
| 10758 | |
| 10759 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 10760 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10761 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10762 | ASSERT_VK_SUCCESS(err); |
| 10763 | |
| 10764 | BeginCommandBuffer(); |
| 10765 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10766 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 10767 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10768 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10769 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10770 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 10771 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10772 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10773 | resolveRegion.srcOffset.x = 0; |
| 10774 | resolveRegion.srcOffset.y = 0; |
| 10775 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10776 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10777 | resolveRegion.dstSubresource.mipLevel = 0; |
| 10778 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 10779 | resolveRegion.dstSubresource.layerCount = 0; |
| 10780 | resolveRegion.dstOffset.x = 0; |
| 10781 | resolveRegion.dstOffset.y = 0; |
| 10782 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10783 | resolveRegion.extent.width = 1; |
| 10784 | resolveRegion.extent.height = 1; |
| 10785 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10786 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 10787 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10788 | EndCommandBuffer(); |
| 10789 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10790 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10791 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10792 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10793 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10794 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 10795 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10796 | } |
| 10797 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10798 | TEST_F(VkLayerTest, ResolveImageHighSampleCount) { |
| 10799 | VkResult err; |
| 10800 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10801 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10802 | m_errorMonitor->SetDesiredFailureMsg( |
| 10803 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10804 | "vkCmdResolveImage called with dest sample count greater than 1."); |
| 10805 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10806 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10807 | |
Chris Forbes | a753069 | 2016-05-08 12:35:39 +1200 | [diff] [blame] | 10808 | // 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] | 10809 | VkImage srcImage; |
| 10810 | VkImage dstImage; |
| 10811 | VkDeviceMemory srcMem; |
| 10812 | VkDeviceMemory destMem; |
| 10813 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10814 | |
| 10815 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10816 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10817 | image_create_info.pNext = NULL; |
| 10818 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10819 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10820 | image_create_info.extent.width = 32; |
| 10821 | image_create_info.extent.height = 1; |
| 10822 | image_create_info.extent.depth = 1; |
| 10823 | image_create_info.mipLevels = 1; |
| 10824 | image_create_info.arrayLayers = 1; |
Chris Forbes | a753069 | 2016-05-08 12:35:39 +1200 | [diff] [blame] | 10825 | image_create_info.samples = VK_SAMPLE_COUNT_4_BIT; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10826 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 10827 | // Note: Some implementations expect color attachment usage for any |
| 10828 | // multisample surface |
| 10829 | image_create_info.usage = |
| 10830 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 10831 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10832 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10833 | err = |
| 10834 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10835 | ASSERT_VK_SUCCESS(err); |
| 10836 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10837 | // Note: Some implementations expect color attachment usage for any |
| 10838 | // multisample surface |
| 10839 | image_create_info.usage = |
| 10840 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10841 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10842 | err = |
| 10843 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10844 | ASSERT_VK_SUCCESS(err); |
| 10845 | |
| 10846 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10847 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10848 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 10849 | memAlloc.pNext = NULL; |
| 10850 | memAlloc.allocationSize = 0; |
| 10851 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10852 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 10853 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10854 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10855 | pass = |
| 10856 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10857 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10858 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10859 | ASSERT_VK_SUCCESS(err); |
| 10860 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10861 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10862 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10863 | pass = |
| 10864 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10865 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10866 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10867 | ASSERT_VK_SUCCESS(err); |
| 10868 | |
| 10869 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 10870 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10871 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10872 | ASSERT_VK_SUCCESS(err); |
| 10873 | |
| 10874 | BeginCommandBuffer(); |
| 10875 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10876 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 10877 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10878 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10879 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10880 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 10881 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10882 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10883 | resolveRegion.srcOffset.x = 0; |
| 10884 | resolveRegion.srcOffset.y = 0; |
| 10885 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10886 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10887 | resolveRegion.dstSubresource.mipLevel = 0; |
| 10888 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 10889 | resolveRegion.dstSubresource.layerCount = 0; |
| 10890 | resolveRegion.dstOffset.x = 0; |
| 10891 | resolveRegion.dstOffset.y = 0; |
| 10892 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10893 | resolveRegion.extent.width = 1; |
| 10894 | resolveRegion.extent.height = 1; |
| 10895 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10896 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 10897 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10898 | EndCommandBuffer(); |
| 10899 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10900 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10901 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10902 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10903 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10904 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 10905 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10906 | } |
| 10907 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10908 | TEST_F(VkLayerTest, ResolveImageFormatMismatch) { |
| 10909 | VkResult err; |
| 10910 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10911 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10912 | m_errorMonitor->SetDesiredFailureMsg( |
| 10913 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10914 | "vkCmdResolveImage called with unmatched source and dest formats."); |
| 10915 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10916 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10917 | |
| 10918 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10919 | VkImage srcImage; |
| 10920 | VkImage dstImage; |
| 10921 | VkDeviceMemory srcMem; |
| 10922 | VkDeviceMemory destMem; |
| 10923 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10924 | |
| 10925 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10926 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10927 | image_create_info.pNext = NULL; |
| 10928 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10929 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10930 | image_create_info.extent.width = 32; |
| 10931 | image_create_info.extent.height = 1; |
| 10932 | image_create_info.extent.depth = 1; |
| 10933 | image_create_info.mipLevels = 1; |
| 10934 | image_create_info.arrayLayers = 1; |
| 10935 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 10936 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 10937 | // Note: Some implementations expect color attachment usage for any |
| 10938 | // multisample surface |
| 10939 | image_create_info.usage = |
| 10940 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 10941 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10942 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10943 | err = |
| 10944 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10945 | ASSERT_VK_SUCCESS(err); |
| 10946 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10947 | // Set format to something other than source image |
| 10948 | image_create_info.format = VK_FORMAT_R32_SFLOAT; |
| 10949 | // Note: Some implementations expect color attachment usage for any |
| 10950 | // multisample surface |
| 10951 | image_create_info.usage = |
| 10952 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 10953 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10954 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10955 | err = |
| 10956 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10957 | ASSERT_VK_SUCCESS(err); |
| 10958 | |
| 10959 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10960 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10961 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 10962 | memAlloc.pNext = NULL; |
| 10963 | memAlloc.allocationSize = 0; |
| 10964 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10965 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 10966 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10967 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10968 | pass = |
| 10969 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10970 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10971 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10972 | ASSERT_VK_SUCCESS(err); |
| 10973 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10974 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10975 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10976 | pass = |
| 10977 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10978 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10979 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10980 | ASSERT_VK_SUCCESS(err); |
| 10981 | |
| 10982 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 10983 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10984 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10985 | ASSERT_VK_SUCCESS(err); |
| 10986 | |
| 10987 | BeginCommandBuffer(); |
| 10988 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10989 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 10990 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10991 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10992 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10993 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 10994 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10995 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10996 | resolveRegion.srcOffset.x = 0; |
| 10997 | resolveRegion.srcOffset.y = 0; |
| 10998 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10999 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11000 | resolveRegion.dstSubresource.mipLevel = 0; |
| 11001 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 11002 | resolveRegion.dstSubresource.layerCount = 0; |
| 11003 | resolveRegion.dstOffset.x = 0; |
| 11004 | resolveRegion.dstOffset.y = 0; |
| 11005 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11006 | resolveRegion.extent.width = 1; |
| 11007 | resolveRegion.extent.height = 1; |
| 11008 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11009 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 11010 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11011 | EndCommandBuffer(); |
| 11012 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11013 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11014 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11015 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11016 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11017 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 11018 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11019 | } |
| 11020 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11021 | TEST_F(VkLayerTest, ResolveImageTypeMismatch) { |
| 11022 | VkResult err; |
| 11023 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11024 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11025 | m_errorMonitor->SetDesiredFailureMsg( |
| 11026 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11027 | "vkCmdResolveImage called with unmatched source and dest image types."); |
| 11028 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11029 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11030 | |
| 11031 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11032 | VkImage srcImage; |
| 11033 | VkImage dstImage; |
| 11034 | VkDeviceMemory srcMem; |
| 11035 | VkDeviceMemory destMem; |
| 11036 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11037 | |
| 11038 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11039 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11040 | image_create_info.pNext = NULL; |
| 11041 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11042 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 11043 | image_create_info.extent.width = 32; |
| 11044 | image_create_info.extent.height = 1; |
| 11045 | image_create_info.extent.depth = 1; |
| 11046 | image_create_info.mipLevels = 1; |
| 11047 | image_create_info.arrayLayers = 1; |
| 11048 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 11049 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 11050 | // Note: Some implementations expect color attachment usage for any |
| 11051 | // multisample surface |
| 11052 | image_create_info.usage = |
| 11053 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 11054 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11055 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11056 | err = |
| 11057 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11058 | ASSERT_VK_SUCCESS(err); |
| 11059 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11060 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 11061 | // Note: Some implementations expect color attachment usage for any |
| 11062 | // multisample surface |
| 11063 | image_create_info.usage = |
| 11064 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 11065 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11066 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11067 | err = |
| 11068 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11069 | ASSERT_VK_SUCCESS(err); |
| 11070 | |
| 11071 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11072 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11073 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 11074 | memAlloc.pNext = NULL; |
| 11075 | memAlloc.allocationSize = 0; |
| 11076 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11077 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 11078 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11079 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11080 | pass = |
| 11081 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11082 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11083 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11084 | ASSERT_VK_SUCCESS(err); |
| 11085 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11086 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11087 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11088 | pass = |
| 11089 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 11090 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11091 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11092 | ASSERT_VK_SUCCESS(err); |
| 11093 | |
| 11094 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 11095 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11096 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11097 | ASSERT_VK_SUCCESS(err); |
| 11098 | |
| 11099 | BeginCommandBuffer(); |
| 11100 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11101 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 11102 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11103 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11104 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11105 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 11106 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11107 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11108 | resolveRegion.srcOffset.x = 0; |
| 11109 | resolveRegion.srcOffset.y = 0; |
| 11110 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 11111 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11112 | resolveRegion.dstSubresource.mipLevel = 0; |
| 11113 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 11114 | resolveRegion.dstSubresource.layerCount = 0; |
| 11115 | resolveRegion.dstOffset.x = 0; |
| 11116 | resolveRegion.dstOffset.y = 0; |
| 11117 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11118 | resolveRegion.extent.width = 1; |
| 11119 | resolveRegion.extent.height = 1; |
| 11120 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11121 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 11122 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11123 | EndCommandBuffer(); |
| 11124 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11125 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11126 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11127 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11128 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11129 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 11130 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 11131 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11132 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11133 | TEST_F(VkLayerTest, DepthStencilImageViewWithColorAspectBitError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11134 | // 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] | 11135 | // to using a DS format, then cause it to hit error due to COLOR_BIT not |
| 11136 | // set in aspect |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11137 | // The image format check comes 2nd in validation so we trigger it first, |
| 11138 | // 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] | 11139 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11140 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11141 | m_errorMonitor->SetDesiredFailureMsg( |
| 11142 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11143 | "Combination depth/stencil image formats can have only the "); |
| 11144 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11145 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11146 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 11147 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11148 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 11149 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11150 | |
| 11151 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11152 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 11153 | ds_pool_ci.pNext = NULL; |
| 11154 | ds_pool_ci.maxSets = 1; |
| 11155 | ds_pool_ci.poolSizeCount = 1; |
| 11156 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11157 | |
| 11158 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11159 | err = |
| 11160 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11161 | ASSERT_VK_SUCCESS(err); |
| 11162 | |
| 11163 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11164 | dsl_binding.binding = 0; |
| 11165 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 11166 | dsl_binding.descriptorCount = 1; |
| 11167 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 11168 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11169 | |
| 11170 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11171 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 11172 | ds_layout_ci.pNext = NULL; |
| 11173 | ds_layout_ci.bindingCount = 1; |
| 11174 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11175 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11176 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 11177 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11178 | ASSERT_VK_SUCCESS(err); |
| 11179 | |
| 11180 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 11181 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 11182 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 11183 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11184 | alloc_info.descriptorPool = ds_pool; |
| 11185 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11186 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 11187 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11188 | ASSERT_VK_SUCCESS(err); |
| 11189 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11190 | VkImage image_bad; |
| 11191 | VkImage image_good; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11192 | // One bad format and one good format for Color attachment |
Tobin Ehlis | 269f032 | 2016-05-25 16:24:21 -0600 | [diff] [blame] | 11193 | const VkFormat tex_format_bad = VK_FORMAT_D24_UNORM_S8_UINT; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11194 | const VkFormat tex_format_good = VK_FORMAT_B8G8R8A8_UNORM; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11195 | const int32_t tex_width = 32; |
| 11196 | const int32_t tex_height = 32; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11197 | |
| 11198 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11199 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11200 | image_create_info.pNext = NULL; |
| 11201 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11202 | image_create_info.format = tex_format_bad; |
| 11203 | image_create_info.extent.width = tex_width; |
| 11204 | image_create_info.extent.height = tex_height; |
| 11205 | image_create_info.extent.depth = 1; |
| 11206 | image_create_info.mipLevels = 1; |
| 11207 | image_create_info.arrayLayers = 1; |
| 11208 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 11209 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 11210 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT | |
| 11211 | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 11212 | image_create_info.flags = 0; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11213 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11214 | err = |
| 11215 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image_bad); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11216 | ASSERT_VK_SUCCESS(err); |
| 11217 | image_create_info.format = tex_format_good; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11218 | image_create_info.usage = |
| 11219 | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 11220 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, |
| 11221 | &image_good); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11222 | ASSERT_VK_SUCCESS(err); |
| 11223 | |
| 11224 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11225 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11226 | image_view_create_info.image = image_bad; |
| 11227 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 11228 | image_view_create_info.format = tex_format_bad; |
| 11229 | image_view_create_info.subresourceRange.baseArrayLayer = 0; |
| 11230 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 11231 | image_view_create_info.subresourceRange.layerCount = 1; |
| 11232 | image_view_create_info.subresourceRange.levelCount = 1; |
| 11233 | image_view_create_info.subresourceRange.aspectMask = |
| 11234 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11235 | |
| 11236 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 11237 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 11238 | &view); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 11239 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 11240 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11241 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11242 | vkDestroyImage(m_device->device(), image_bad, NULL); |
| 11243 | vkDestroyImage(m_device->device(), image_good, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 11244 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 11245 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 11246 | } |
Tobin Ehlis | 6e23d77 | 2016-05-19 11:08:34 -0600 | [diff] [blame] | 11247 | |
| 11248 | TEST_F(VkLayerTest, ClearImageErrors) { |
| 11249 | TEST_DESCRIPTION("Call ClearColorImage w/ a depth|stencil image and " |
| 11250 | "ClearDepthStencilImage with a color image."); |
| 11251 | |
| 11252 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 11253 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 11254 | |
| 11255 | // Renderpass is started here so end it as Clear cmds can't be in renderpass |
| 11256 | BeginCommandBuffer(); |
| 11257 | m_commandBuffer->EndRenderPass(); |
| 11258 | |
| 11259 | // Color image |
| 11260 | VkClearColorValue clear_color; |
| 11261 | memset(clear_color.uint32, 0, sizeof(uint32_t) * 4); |
| 11262 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 11263 | const VkFormat color_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 11264 | const int32_t img_width = 32; |
| 11265 | const int32_t img_height = 32; |
| 11266 | VkImageCreateInfo image_create_info = {}; |
| 11267 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 11268 | image_create_info.pNext = NULL; |
| 11269 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11270 | image_create_info.format = color_format; |
| 11271 | image_create_info.extent.width = img_width; |
| 11272 | image_create_info.extent.height = img_height; |
| 11273 | image_create_info.extent.depth = 1; |
| 11274 | image_create_info.mipLevels = 1; |
| 11275 | image_create_info.arrayLayers = 1; |
| 11276 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 11277 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 11278 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 11279 | |
| 11280 | vk_testing::Image color_image; |
| 11281 | color_image.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 11282 | reqs); |
| 11283 | |
| 11284 | const VkImageSubresourceRange color_range = |
| 11285 | vk_testing::Image::subresource_range(image_create_info, |
| 11286 | VK_IMAGE_ASPECT_COLOR_BIT); |
| 11287 | |
| 11288 | // Depth/Stencil image |
| 11289 | VkClearDepthStencilValue clear_value = {0}; |
| 11290 | reqs = 0; // don't need HOST_VISIBLE DS image |
| 11291 | VkImageCreateInfo ds_image_create_info = vk_testing::Image::create_info(); |
| 11292 | ds_image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 11293 | ds_image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 11294 | ds_image_create_info.extent.width = 64; |
| 11295 | ds_image_create_info.extent.height = 64; |
| 11296 | ds_image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 11297 | ds_image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 11298 | |
| 11299 | vk_testing::Image ds_image; |
| 11300 | ds_image.init(*m_device, (const VkImageCreateInfo &)ds_image_create_info, |
| 11301 | reqs); |
| 11302 | |
| 11303 | const VkImageSubresourceRange ds_range = |
| 11304 | vk_testing::Image::subresource_range(ds_image_create_info, |
| 11305 | VK_IMAGE_ASPECT_DEPTH_BIT); |
| 11306 | |
| 11307 | m_errorMonitor->SetDesiredFailureMsg( |
| 11308 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11309 | "vkCmdClearColorImage called with depth/stencil image."); |
| 11310 | |
| 11311 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), ds_image.handle(), |
| 11312 | VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1, |
| 11313 | &color_range); |
| 11314 | |
| 11315 | m_errorMonitor->VerifyFound(); |
| 11316 | |
| 11317 | // Call CmdClearDepthStencilImage with color image |
| 11318 | m_errorMonitor->SetDesiredFailureMsg( |
| 11319 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 11320 | "vkCmdClearDepthStencilImage called without a depth/stencil image."); |
| 11321 | |
| 11322 | vkCmdClearDepthStencilImage( |
| 11323 | m_commandBuffer->GetBufferHandle(), color_image.handle(), |
| 11324 | VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, &clear_value, 1, |
| 11325 | &ds_range); |
| 11326 | |
| 11327 | m_errorMonitor->VerifyFound(); |
| 11328 | } |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 11329 | #endif // IMAGE_TESTS |
| 11330 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 11331 | int main(int argc, char **argv) { |
| 11332 | int result; |
| 11333 | |
Cody Northrop | 8e54a40 | 2016-03-08 22:25:52 -0700 | [diff] [blame] | 11334 | #ifdef ANDROID |
| 11335 | int vulkanSupport = InitVulkan(); |
| 11336 | if (vulkanSupport == 0) |
| 11337 | return 1; |
| 11338 | #endif |
| 11339 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 11340 | ::testing::InitGoogleTest(&argc, argv); |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 11341 | VkTestFramework::InitArgs(&argc, argv); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 11342 | |
| 11343 | ::testing::AddGlobalTestEnvironment(new TestEnvironment); |
| 11344 | |
| 11345 | result = RUN_ALL_TESTS(); |
| 11346 | |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 11347 | VkTestFramework::Finish(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 11348 | return result; |
| 11349 | } |