Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015-2016 The Khronos Group Inc. |
| 3 | * Copyright (c) 2015-2016 Valve Corporation |
| 4 | * Copyright (c) 2015-2016 LunarG, Inc. |
Michael Lentine | 0a369f6 | 2016-02-03 16:51:46 -0600 | [diff] [blame] | 5 | * Copyright (c) 2015-2016 Google, Inc. |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6 | * |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 7 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | * you may not use this file except in compliance with the License. |
| 9 | * You may obtain a copy of the License at |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10 | * |
Jon Ashburn | 3ebf125 | 2016-04-19 11:30:31 -0600 | [diff] [blame] | 11 | * http://www.apache.org/licenses/LICENSE-2.0 |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 12 | * |
| 13 | * Author: Chia-I Wu <olvaffe@gmail.com> |
| 14 | * Author: Chris Forbes <chrisf@ijw.co.nz> |
| 15 | * Author: Courtney Goeltzenleuchter <courtney@LunarG.com> |
| 16 | * Author: Mark Lobodzinski <mark@lunarg.com> |
| 17 | * Author: Mike Stroyan <mike@LunarG.com> |
| 18 | * Author: Tobin Ehlis <tobine@google.com> |
| 19 | * Author: Tony Barbour <tony@LunarG.com> |
| 20 | */ |
Tony Barbour | 65c48b3 | 2015-11-17 10:02:56 -0700 | [diff] [blame] | 21 | |
Cody Northrop | 8e54a40 | 2016-03-08 22:25:52 -0700 | [diff] [blame] | 22 | #ifdef ANDROID |
| 23 | #include "vulkan_wrapper.h" |
| 24 | #else |
David Pinedo | 9316d3b | 2015-11-06 12:54:48 -0700 | [diff] [blame] | 25 | #include <vulkan/vulkan.h> |
Cody Northrop | 8e54a40 | 2016-03-08 22:25:52 -0700 | [diff] [blame] | 26 | #endif |
Courtney Goeltzenleuchter | 58f3eff | 2015-10-07 13:28:58 -0600 | [diff] [blame] | 27 | #include "test_common.h" |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 28 | #include "vkrenderframework.h" |
Tobin Ehlis | a0cb02e | 2015-07-03 10:15:26 -0600 | [diff] [blame] | 29 | #include "vk_layer_config.h" |
Jon Ashburn | 7fa7e22 | 2016-02-02 12:08:10 -0700 | [diff] [blame] | 30 | #include "icd-spv.h" |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 31 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 32 | #define GLM_FORCE_RADIANS |
| 33 | #include "glm/glm.hpp" |
| 34 | #include <glm/gtc/matrix_transform.hpp> |
| 35 | |
Dustin Graves | ffa90fa | 2016-05-06 11:20:38 -0600 | [diff] [blame] | 36 | #define PARAMETER_VALIDATION_TESTS 1 |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 37 | #define MEM_TRACKER_TESTS 1 |
| 38 | #define OBJ_TRACKER_TESTS 1 |
| 39 | #define DRAW_STATE_TESTS 1 |
| 40 | #define THREADING_TESTS 1 |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 41 | #define SHADER_CHECKER_TESTS 1 |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 42 | #define DEVICE_LIMITS_TESTS 1 |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 43 | #define IMAGE_TESTS 1 |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 44 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 45 | //-------------------------------------------------------------------------------------- |
| 46 | // Mesh and VertexFormat Data |
| 47 | //-------------------------------------------------------------------------------------- |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 48 | struct Vertex { |
| 49 | float posX, posY, posZ, posW; // Position data |
| 50 | float r, g, b, a; // Color |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 51 | }; |
| 52 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 53 | #define XYZ1(_x_, _y_, _z_) (_x_), (_y_), (_z_), 1.f |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 54 | |
| 55 | typedef enum _BsoFailSelect { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 56 | BsoFailNone = 0x00000000, |
| 57 | BsoFailLineWidth = 0x00000001, |
| 58 | BsoFailDepthBias = 0x00000002, |
| 59 | BsoFailViewport = 0x00000004, |
| 60 | BsoFailScissor = 0x00000008, |
| 61 | BsoFailBlend = 0x00000010, |
| 62 | BsoFailDepthBounds = 0x00000020, |
| 63 | BsoFailStencilReadMask = 0x00000040, |
| 64 | BsoFailStencilWriteMask = 0x00000080, |
| 65 | BsoFailStencilReference = 0x00000100, |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 66 | } BsoFailSelect; |
| 67 | |
| 68 | struct vktriangle_vs_uniform { |
| 69 | // Must start with MVP |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 70 | float mvp[4][4]; |
| 71 | float position[3][4]; |
| 72 | float color[3][4]; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 73 | }; |
| 74 | |
Mark Lobodzinski | 75a97e6 | 2015-06-02 09:41:30 -0500 | [diff] [blame] | 75 | static const char bindStateVertShaderText[] = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 76 | "#version 450\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 77 | "vec2 vertices[3];\n" |
| 78 | "out gl_PerVertex {\n" |
| 79 | " vec4 gl_Position;\n" |
| 80 | "};\n" |
| 81 | "void main() {\n" |
| 82 | " vertices[0] = vec2(-1.0, -1.0);\n" |
| 83 | " vertices[1] = vec2( 1.0, -1.0);\n" |
| 84 | " vertices[2] = vec2( 0.0, 1.0);\n" |
| 85 | " gl_Position = vec4(vertices[gl_VertexIndex % 3], 0.0, 1.0);\n" |
| 86 | "}\n"; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 87 | |
Mark Lobodzinski | 75a97e6 | 2015-06-02 09:41:30 -0500 | [diff] [blame] | 88 | static const char bindStateFragShaderText[] = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 89 | "#version 450\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 90 | "\n" |
| 91 | "layout(location = 0) out vec4 uFragColor;\n" |
| 92 | "void main(){\n" |
| 93 | " uFragColor = vec4(0,1,0,1);\n" |
| 94 | "}\n"; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 95 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 96 | static VKAPI_ATTR VkBool32 VKAPI_CALL |
| 97 | myDbgFunc(VkFlags msgFlags, VkDebugReportObjectTypeEXT objType, |
| 98 | uint64_t srcObject, size_t location, int32_t msgCode, |
| 99 | const char *pLayerPrefix, const char *pMsg, void *pUserData); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 100 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 101 | // ******************************************************** |
| 102 | // ErrorMonitor Usage: |
| 103 | // |
| 104 | // Call SetDesiredFailureMsg with a string to be compared against all |
| 105 | // encountered log messages. Passing NULL will match all log messages. |
| 106 | // logMsg will return true for skipCall only if msg is matched or NULL. |
| 107 | // |
| 108 | // Call DesiredMsgFound to determine if the desired failure message |
| 109 | // was encountered. |
| 110 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 111 | class ErrorMonitor { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 112 | public: |
| 113 | ErrorMonitor() { |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 114 | test_platform_thread_create_mutex(&m_mutex); |
| 115 | test_platform_thread_lock_mutex(&m_mutex); |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 116 | m_msgFlags = VK_DEBUG_REPORT_INFORMATION_BIT_EXT; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 117 | m_bailout = NULL; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 118 | test_platform_thread_unlock_mutex(&m_mutex); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 119 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 120 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 121 | ~ErrorMonitor() { test_platform_thread_delete_mutex(&m_mutex); } |
| 122 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 123 | void SetDesiredFailureMsg(VkFlags msgFlags, const char *msgString) { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 124 | // also discard all collected messages to this point |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 125 | test_platform_thread_lock_mutex(&m_mutex); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 126 | m_failureMsg.clear(); |
| 127 | m_otherMsgs.clear(); |
| 128 | m_desiredMsg = msgString; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 129 | m_msgFound = VK_FALSE; |
| 130 | m_msgFlags = msgFlags; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 131 | test_platform_thread_unlock_mutex(&m_mutex); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 132 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 133 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 134 | VkBool32 CheckForDesiredMsg(VkFlags msgFlags, const char *msgString) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 135 | VkBool32 result = VK_FALSE; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 136 | test_platform_thread_lock_mutex(&m_mutex); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 137 | if (m_bailout != NULL) { |
| 138 | *m_bailout = true; |
| 139 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 140 | string errorString(msgString); |
| 141 | if (msgFlags & m_msgFlags) { |
| 142 | if (errorString.find(m_desiredMsg) != string::npos) { |
Chris Forbes | c7b8ad7 | 2016-04-04 18:50:38 +1200 | [diff] [blame] | 143 | if (m_msgFound) { /* if multiple matches, don't lose all but the last! */ |
| 144 | m_otherMsgs.push_back(m_failureMsg); |
| 145 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 146 | m_failureMsg = errorString; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 147 | m_msgFound = VK_TRUE; |
| 148 | result = VK_TRUE; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 149 | } else { |
| 150 | m_otherMsgs.push_back(errorString); |
| 151 | } |
| 152 | } |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 153 | test_platform_thread_unlock_mutex(&m_mutex); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 154 | return result; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 155 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 156 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 157 | vector<string> GetOtherFailureMsgs(void) { return m_otherMsgs; } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 158 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 159 | string GetFailureMsg(void) { return m_failureMsg; } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 160 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 161 | VkBool32 DesiredMsgFound(void) { return m_msgFound; } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 162 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 163 | void SetBailout(bool *bailout) { m_bailout = bailout; } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 164 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 165 | void DumpFailureMsgs(void) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 166 | vector<string> otherMsgs = GetOtherFailureMsgs(); |
| 167 | cout << "Other error messages logged for this test were:" << endl; |
| 168 | for (auto iter = otherMsgs.begin(); iter != otherMsgs.end(); iter++) { |
| 169 | cout << " " << *iter << endl; |
| 170 | } |
| 171 | } |
| 172 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 173 | /* helpers */ |
| 174 | |
| 175 | void ExpectSuccess() { |
| 176 | // match anything |
| 177 | SetDesiredFailureMsg(~0u, ""); |
| 178 | } |
| 179 | |
| 180 | void VerifyFound() { |
| 181 | // Not seeing the desired message is a failure. /Before/ throwing, dump |
| 182 | // any other messages. |
| 183 | if (!DesiredMsgFound()) { |
| 184 | DumpFailureMsgs(); |
| 185 | FAIL() << "Did not receive expected error '" << m_desiredMsg << "'"; |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | void VerifyNotFound() { |
| 190 | // ExpectSuccess() configured us to match anything. Any error is a |
| 191 | // failure. |
| 192 | if (DesiredMsgFound()) { |
| 193 | DumpFailureMsgs(); |
| 194 | FAIL() << "Expected to succeed but got error: " << GetFailureMsg(); |
| 195 | } |
| 196 | } |
| 197 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 198 | private: |
| 199 | VkFlags m_msgFlags; |
| 200 | string m_desiredMsg; |
| 201 | string m_failureMsg; |
| 202 | vector<string> m_otherMsgs; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 203 | test_platform_thread_mutex m_mutex; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 204 | bool *m_bailout; |
| 205 | VkBool32 m_msgFound; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 206 | }; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 207 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 208 | static VKAPI_ATTR VkBool32 VKAPI_CALL |
| 209 | myDbgFunc(VkFlags msgFlags, VkDebugReportObjectTypeEXT objType, |
| 210 | uint64_t srcObject, size_t location, int32_t msgCode, |
| 211 | const char *pLayerPrefix, const char *pMsg, void *pUserData) { |
| 212 | if (msgFlags & |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 213 | (VK_DEBUG_REPORT_WARNING_BIT_EXT | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 214 | VK_DEBUG_REPORT_ERROR_BIT_EXT)) { |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 215 | ErrorMonitor *errMonitor = (ErrorMonitor *)pUserData; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 216 | return errMonitor->CheckForDesiredMsg(msgFlags, pMsg); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 217 | } |
Courtney Goeltzenleuchter | 0664083 | 2015-09-04 13:52:24 -0600 | [diff] [blame] | 218 | return false; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 219 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 220 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 221 | class VkLayerTest : public VkRenderFramework { |
| 222 | public: |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 223 | VkResult BeginCommandBuffer(VkCommandBufferObj &commandBuffer); |
| 224 | VkResult EndCommandBuffer(VkCommandBufferObj &commandBuffer); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 225 | void VKTriangleTest(const char *vertShaderText, const char *fragShaderText, |
| 226 | BsoFailSelect failMask); |
| 227 | void GenericDrawPreparation(VkCommandBufferObj *commandBuffer, |
| 228 | VkPipelineObj &pipelineobj, |
| 229 | VkDescriptorSetObj &descriptorSet, |
| 230 | BsoFailSelect failMask); |
| 231 | void GenericDrawPreparation(VkPipelineObj &pipelineobj, |
| 232 | VkDescriptorSetObj &descriptorSet, |
| 233 | BsoFailSelect failMask) { |
| 234 | GenericDrawPreparation(m_commandBuffer, pipelineobj, descriptorSet, |
| 235 | failMask); |
| 236 | } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 237 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 238 | /* Convenience functions that use built-in command buffer */ |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 239 | VkResult BeginCommandBuffer() { |
| 240 | return BeginCommandBuffer(*m_commandBuffer); |
| 241 | } |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 242 | VkResult EndCommandBuffer() { return EndCommandBuffer(*m_commandBuffer); } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 243 | void Draw(uint32_t vertexCount, uint32_t instanceCount, |
| 244 | uint32_t firstVertex, uint32_t firstInstance) { |
| 245 | m_commandBuffer->Draw(vertexCount, instanceCount, firstVertex, |
| 246 | firstInstance); |
| 247 | } |
| 248 | void DrawIndexed(uint32_t indexCount, uint32_t instanceCount, |
| 249 | uint32_t firstIndex, int32_t vertexOffset, |
| 250 | uint32_t firstInstance) { |
| 251 | m_commandBuffer->DrawIndexed(indexCount, instanceCount, firstIndex, |
| 252 | vertexOffset, firstInstance); |
| 253 | } |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 254 | void QueueCommandBuffer() { m_commandBuffer->QueueCommandBuffer(); } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 255 | void QueueCommandBuffer(const VkFence &fence) { |
| 256 | m_commandBuffer->QueueCommandBuffer(fence); |
| 257 | } |
| 258 | void BindVertexBuffer(VkConstantBufferObj *vertexBuffer, |
| 259 | VkDeviceSize offset, uint32_t binding) { |
| 260 | m_commandBuffer->BindVertexBuffer(vertexBuffer, offset, binding); |
| 261 | } |
| 262 | void BindIndexBuffer(VkIndexBufferObj *indexBuffer, VkDeviceSize offset) { |
| 263 | m_commandBuffer->BindIndexBuffer(indexBuffer, offset); |
| 264 | } |
| 265 | |
| 266 | protected: |
| 267 | ErrorMonitor *m_errorMonitor; |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 268 | bool m_enableWSI; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 269 | |
| 270 | virtual void SetUp() { |
Courtney Goeltzenleuchter | cd69eee | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 271 | std::vector<const char *> instance_layer_names; |
| 272 | std::vector<const char *> device_layer_names; |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 273 | std::vector<const char *> instance_extension_names; |
| 274 | std::vector<const char *> device_extension_names; |
Tony Barbour | 3fdff9e | 2015-04-23 12:55:36 -0600 | [diff] [blame] | 275 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 276 | instance_extension_names.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME); |
Courtney Goeltzenleuchter | c2b06fe | 2015-06-16 15:59:11 -0600 | [diff] [blame] | 277 | /* |
| 278 | * Since CreateDbgMsgCallback is an instance level extension call |
| 279 | * any extension / layer that utilizes that feature also needs |
| 280 | * to be enabled at create instance time. |
| 281 | */ |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 282 | // Use Threading layer first to protect others from |
| 283 | // ThreadCommandBufferCollision test |
Courtney Goeltzenleuchter | 7688532 | 2016-02-06 17:11:22 -0700 | [diff] [blame] | 284 | instance_layer_names.push_back("VK_LAYER_GOOGLE_threading"); |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 285 | instance_layer_names.push_back("VK_LAYER_LUNARG_parameter_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 286 | instance_layer_names.push_back("VK_LAYER_LUNARG_object_tracker"); |
Tobin Ehlis | c96f806 | 2016-03-09 16:12:48 -0700 | [diff] [blame] | 287 | instance_layer_names.push_back("VK_LAYER_LUNARG_core_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 288 | instance_layer_names.push_back("VK_LAYER_LUNARG_device_limits"); |
| 289 | instance_layer_names.push_back("VK_LAYER_LUNARG_image"); |
Ian Elliott | e48a138 | 2016-04-28 14:22:58 -0600 | [diff] [blame] | 290 | instance_layer_names.push_back("VK_LAYER_LUNARG_swapchain"); |
Dustin Graves | eaa78cd | 2016-01-26 16:30:22 -0700 | [diff] [blame] | 291 | instance_layer_names.push_back("VK_LAYER_GOOGLE_unique_objects"); |
Courtney Goeltzenleuchter | d971b61 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 292 | |
Courtney Goeltzenleuchter | 7688532 | 2016-02-06 17:11:22 -0700 | [diff] [blame] | 293 | device_layer_names.push_back("VK_LAYER_GOOGLE_threading"); |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 294 | device_layer_names.push_back("VK_LAYER_LUNARG_parameter_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 295 | device_layer_names.push_back("VK_LAYER_LUNARG_object_tracker"); |
Tobin Ehlis | c96f806 | 2016-03-09 16:12:48 -0700 | [diff] [blame] | 296 | device_layer_names.push_back("VK_LAYER_LUNARG_core_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 297 | device_layer_names.push_back("VK_LAYER_LUNARG_device_limits"); |
| 298 | device_layer_names.push_back("VK_LAYER_LUNARG_image"); |
Ian Elliott | e48a138 | 2016-04-28 14:22:58 -0600 | [diff] [blame] | 299 | device_layer_names.push_back("VK_LAYER_LUNARG_swapchain"); |
Dustin Graves | eaa78cd | 2016-01-26 16:30:22 -0700 | [diff] [blame] | 300 | device_layer_names.push_back("VK_LAYER_GOOGLE_unique_objects"); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 301 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 302 | if (m_enableWSI) { |
| 303 | instance_extension_names.push_back(VK_KHR_SURFACE_EXTENSION_NAME); |
| 304 | device_extension_names.push_back(VK_KHR_SWAPCHAIN_EXTENSION_NAME); |
| 305 | #ifdef NEED_TO_TEST_THIS_ON_PLATFORM |
| 306 | #if defined(VK_USE_PLATFORM_ANDROID_KHR) |
| 307 | instance_extension_names.push_back(VK_KHR_ANDROID_SURFACE_EXTENSION_NAME); |
| 308 | #endif // VK_USE_PLATFORM_ANDROID_KHR |
| 309 | #if defined(VK_USE_PLATFORM_MIR_KHR) |
| 310 | instance_extension_names.push_back(VK_KHR_MIR_SURFACE_EXTENSION_NAME); |
| 311 | #endif // VK_USE_PLATFORM_MIR_KHR |
| 312 | #if defined(VK_USE_PLATFORM_WAYLAND_KHR) |
| 313 | instance_extension_names.push_back(VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME); |
| 314 | #endif // VK_USE_PLATFORM_WAYLAND_KHR |
| 315 | #if defined(VK_USE_PLATFORM_WIN32_KHR) |
| 316 | instance_extension_names.push_back(VK_KHR_WIN32_SURFACE_EXTENSION_NAME); |
| 317 | #endif // VK_USE_PLATFORM_WIN32_KHR |
| 318 | #endif // NEED_TO_TEST_THIS_ON_PLATFORM |
| 319 | #if defined(VK_USE_PLATFORM_XCB_KHR) |
| 320 | instance_extension_names.push_back(VK_KHR_XCB_SURFACE_EXTENSION_NAME); |
| 321 | #elif defined(VK_USE_PLATFORM_XLIB_KHR) |
| 322 | instance_extension_names.push_back(VK_KHR_XLIB_SURFACE_EXTENSION_NAME); |
| 323 | #endif // VK_USE_PLATFORM_XLIB_KHR |
| 324 | } |
| 325 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 326 | this->app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 327 | this->app_info.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 328 | this->app_info.pApplicationName = "layer_tests"; |
| 329 | this->app_info.applicationVersion = 1; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 330 | this->app_info.pEngineName = "unittest"; |
| 331 | this->app_info.engineVersion = 1; |
Jon Ashburn | c5012ff | 2016-03-22 13:57:46 -0600 | [diff] [blame] | 332 | this->app_info.apiVersion = VK_API_VERSION_1_0; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 333 | |
Tony Barbour | 15524c3 | 2015-04-29 17:34:29 -0600 | [diff] [blame] | 334 | m_errorMonitor = new ErrorMonitor; |
Courtney Goeltzenleuchter | cd69eee | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 335 | InitFramework(instance_layer_names, device_layer_names, |
| 336 | instance_extension_names, device_extension_names, |
| 337 | myDbgFunc, m_errorMonitor); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 338 | } |
| 339 | |
| 340 | virtual void TearDown() { |
| 341 | // Clean up resources before we reset |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 342 | ShutdownFramework(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 343 | delete m_errorMonitor; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 344 | } |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 345 | |
| 346 | VkLayerTest() { |
| 347 | m_enableWSI = false; |
| 348 | } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 349 | }; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 350 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 351 | VkResult VkLayerTest::BeginCommandBuffer(VkCommandBufferObj &commandBuffer) { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 352 | VkResult result; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 353 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 354 | result = commandBuffer.BeginCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 355 | |
| 356 | /* |
| 357 | * For render test all drawing happens in a single render pass |
| 358 | * on a single command buffer. |
| 359 | */ |
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 360 | if (VK_SUCCESS == result && renderPass()) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 361 | commandBuffer.BeginRenderPass(renderPassBeginInfo()); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 362 | } |
| 363 | |
| 364 | return result; |
| 365 | } |
| 366 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 367 | VkResult VkLayerTest::EndCommandBuffer(VkCommandBufferObj &commandBuffer) { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 368 | VkResult result; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 369 | |
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 370 | if (renderPass()) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 371 | commandBuffer.EndRenderPass(); |
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 372 | } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 373 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 374 | result = commandBuffer.EndCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 375 | |
| 376 | return result; |
| 377 | } |
| 378 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 379 | void VkLayerTest::VKTriangleTest(const char *vertShaderText, |
| 380 | const char *fragShaderText, |
| 381 | BsoFailSelect failMask) { |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 382 | // Create identity matrix |
| 383 | int i; |
| 384 | struct vktriangle_vs_uniform data; |
| 385 | |
| 386 | glm::mat4 Projection = glm::mat4(1.0f); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 387 | glm::mat4 View = glm::mat4(1.0f); |
| 388 | glm::mat4 Model = glm::mat4(1.0f); |
| 389 | glm::mat4 MVP = Projection * View * Model; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 390 | const int matrixSize = sizeof(MVP); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 391 | const int bufSize = sizeof(vktriangle_vs_uniform) / sizeof(float); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 392 | |
| 393 | memcpy(&data.mvp, &MVP[0][0], matrixSize); |
| 394 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 395 | static const Vertex tri_data[] = { |
| 396 | {XYZ1(-1, -1, 0), XYZ1(1.f, 0.f, 0.f)}, |
| 397 | {XYZ1(1, -1, 0), XYZ1(0.f, 1.f, 0.f)}, |
| 398 | {XYZ1(0, 1, 0), XYZ1(0.f, 0.f, 1.f)}, |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 399 | }; |
| 400 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 401 | for (i = 0; i < 3; i++) { |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 402 | data.position[i][0] = tri_data[i].posX; |
| 403 | data.position[i][1] = tri_data[i].posY; |
| 404 | data.position[i][2] = tri_data[i].posZ; |
| 405 | data.position[i][3] = tri_data[i].posW; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 406 | data.color[i][0] = tri_data[i].r; |
| 407 | data.color[i][1] = tri_data[i].g; |
| 408 | data.color[i][2] = tri_data[i].b; |
| 409 | data.color[i][3] = tri_data[i].a; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 410 | } |
| 411 | |
| 412 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 413 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 414 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 415 | VkConstantBufferObj constantBuffer(m_device, bufSize * 2, sizeof(float), |
| 416 | (const void *)&data); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 417 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 418 | VkShaderObj vs(m_device, vertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 419 | VkShaderObj ps(m_device, fragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, |
| 420 | this); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 421 | |
| 422 | VkPipelineObj pipelineobj(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 423 | pipelineobj.AddColorAttachment(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 424 | pipelineobj.AddShader(&vs); |
| 425 | pipelineobj.AddShader(&ps); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 426 | if (failMask & BsoFailLineWidth) { |
| 427 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_LINE_WIDTH); |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 428 | VkPipelineInputAssemblyStateCreateInfo ia_state = {}; |
| 429 | ia_state.sType = |
| 430 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 431 | ia_state.topology = VK_PRIMITIVE_TOPOLOGY_LINE_LIST; |
| 432 | pipelineobj.SetInputAssembly(&ia_state); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 433 | } |
| 434 | if (failMask & BsoFailDepthBias) { |
| 435 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_DEPTH_BIAS); |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 436 | VkPipelineRasterizationStateCreateInfo rs_state = {}; |
| 437 | rs_state.sType = |
| 438 | VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 439 | rs_state.depthBiasEnable = VK_TRUE; |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 440 | rs_state.lineWidth = 1.0f; |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 441 | pipelineobj.SetRasterization(&rs_state); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 442 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 443 | // Viewport and scissors must stay in synch or other errors will occur than |
| 444 | // the ones we want |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 445 | if (failMask & BsoFailViewport) { |
| 446 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_VIEWPORT); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 447 | m_viewports.clear(); |
| 448 | m_scissors.clear(); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 449 | } |
| 450 | if (failMask & BsoFailScissor) { |
| 451 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_SCISSOR); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 452 | m_scissors.clear(); |
| 453 | m_viewports.clear(); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 454 | } |
| 455 | if (failMask & BsoFailBlend) { |
| 456 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_BLEND_CONSTANTS); |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 457 | VkPipelineColorBlendAttachmentState att_state = {}; |
| 458 | att_state.dstAlphaBlendFactor = VK_BLEND_FACTOR_CONSTANT_COLOR; |
| 459 | att_state.blendEnable = VK_TRUE; |
| 460 | pipelineobj.AddColorAttachment(0, &att_state); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 461 | } |
| 462 | if (failMask & BsoFailDepthBounds) { |
| 463 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_DEPTH_BOUNDS); |
| 464 | } |
| 465 | if (failMask & BsoFailStencilReadMask) { |
| 466 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK); |
| 467 | } |
| 468 | if (failMask & BsoFailStencilWriteMask) { |
| 469 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_WRITE_MASK); |
| 470 | } |
| 471 | if (failMask & BsoFailStencilReference) { |
| 472 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_REFERENCE); |
| 473 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 474 | |
| 475 | VkDescriptorSetObj descriptorSet(m_device); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 476 | descriptorSet.AppendBuffer(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, |
| 477 | constantBuffer); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 478 | |
| 479 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 480 | ASSERT_VK_SUCCESS(BeginCommandBuffer()); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 481 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 482 | GenericDrawPreparation(pipelineobj, descriptorSet, failMask); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 483 | |
| 484 | // render triangle |
Courtney Goeltzenleuchter | 08c2637 | 2015-09-23 12:31:50 -0600 | [diff] [blame] | 485 | Draw(3, 1, 0, 0); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 486 | |
| 487 | // finalize recording of the command buffer |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 488 | EndCommandBuffer(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 489 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 490 | QueueCommandBuffer(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 491 | } |
| 492 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 493 | void VkLayerTest::GenericDrawPreparation(VkCommandBufferObj *commandBuffer, |
| 494 | VkPipelineObj &pipelineobj, |
| 495 | VkDescriptorSetObj &descriptorSet, |
| 496 | BsoFailSelect failMask) { |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 497 | if (m_depthStencil->Initialized()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 498 | commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 499 | m_stencil_clear_color, m_depthStencil); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 500 | } else { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 501 | commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 502 | m_stencil_clear_color, NULL); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 503 | } |
| 504 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 505 | commandBuffer->PrepareAttachments(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 506 | // Make sure depthWriteEnable is set so that Depth fail test will work |
| 507 | // correctly |
| 508 | // Make sure stencilTestEnable is set so that Stencil fail test will work |
| 509 | // correctly |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 510 | VkStencilOpState stencil = {}; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 511 | stencil.failOp = VK_STENCIL_OP_KEEP; |
| 512 | stencil.passOp = VK_STENCIL_OP_KEEP; |
| 513 | stencil.depthFailOp = VK_STENCIL_OP_KEEP; |
| 514 | stencil.compareOp = VK_COMPARE_OP_NEVER; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 515 | |
| 516 | VkPipelineDepthStencilStateCreateInfo ds_ci = {}; |
| 517 | ds_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO; |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 518 | ds_ci.pNext = NULL; |
| 519 | ds_ci.depthTestEnable = VK_FALSE; |
| 520 | ds_ci.depthWriteEnable = VK_TRUE; |
| 521 | ds_ci.depthCompareOp = VK_COMPARE_OP_NEVER; |
| 522 | ds_ci.depthBoundsTestEnable = VK_FALSE; |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 523 | if (failMask & BsoFailDepthBounds) { |
| 524 | ds_ci.depthBoundsTestEnable = VK_TRUE; |
| 525 | } |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 526 | ds_ci.stencilTestEnable = VK_TRUE; |
| 527 | ds_ci.front = stencil; |
| 528 | ds_ci.back = stencil; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 529 | |
Tobin Ehlis | 4bf96d1 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 530 | pipelineobj.SetDepthStencil(&ds_ci); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 531 | pipelineobj.SetViewport(m_viewports); |
| 532 | pipelineobj.SetScissor(m_scissors); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 533 | descriptorSet.CreateVKDescriptorSet(commandBuffer); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 534 | VkResult err = pipelineobj.CreateVKPipeline( |
| 535 | descriptorSet.GetPipelineLayout(), renderPass()); |
Cody Northrop | 29a08f2 | 2015-08-27 10:20:35 -0600 | [diff] [blame] | 536 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 537 | commandBuffer->BindPipeline(pipelineobj); |
| 538 | commandBuffer->BindDescriptorSet(descriptorSet); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 539 | } |
| 540 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 541 | class VkWsiEnabledLayerTest : public VkLayerTest { |
| 542 | public: |
| 543 | protected: |
| 544 | VkWsiEnabledLayerTest() { |
| 545 | m_enableWSI = true; |
| 546 | } |
| 547 | }; |
| 548 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 549 | // ******************************************************************************************************************** |
| 550 | // ******************************************************************************************************************** |
| 551 | // ******************************************************************************************************************** |
| 552 | // ******************************************************************************************************************** |
Dustin Graves | ffa90fa | 2016-05-06 11:20:38 -0600 | [diff] [blame] | 553 | #if PARAMETER_VALIDATION_TESTS |
| 554 | TEST_F(VkLayerTest, RequiredParameter) { |
| 555 | TEST_DESCRIPTION("Specify VK_NULL_HANDLE, NULL, and 0 for required handle, " |
| 556 | "pointer, array, and array count parameters"); |
| 557 | |
| 558 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 559 | |
| 560 | m_errorMonitor->SetDesiredFailureMsg( |
| 561 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 562 | "required parameter pFeatures specified as NULL"); |
| 563 | // Specify NULL for a pointer to a handle |
| 564 | // Expected to trigger an error with |
| 565 | // parameter_validation::validate_required_pointer |
| 566 | vkGetPhysicalDeviceFeatures(gpu(), NULL); |
| 567 | m_errorMonitor->VerifyFound(); |
| 568 | |
| 569 | m_errorMonitor->SetDesiredFailureMsg( |
| 570 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 571 | "required parameter pPhysicalDeviceCount specified as NULL"); |
| 572 | // Specify NULL for pointer to array count |
| 573 | // Expected to trigger an error with parameter_validation::validate_array |
| 574 | vkEnumeratePhysicalDevices(instance(), NULL, NULL); |
| 575 | m_errorMonitor->VerifyFound(); |
| 576 | |
| 577 | m_errorMonitor->SetDesiredFailureMsg( |
| 578 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 579 | "parameter viewportCount must be greater than 0"); |
| 580 | // Specify 0 for a required array count |
| 581 | // Expected to trigger an error with parameter_validation::validate_array |
| 582 | VkViewport view_port = {}; |
| 583 | m_commandBuffer->SetViewport(0, 0, &view_port); |
| 584 | m_errorMonitor->VerifyFound(); |
| 585 | |
| 586 | m_errorMonitor->SetDesiredFailureMsg( |
| 587 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 588 | "required parameter pViewports specified as NULL"); |
| 589 | // Specify NULL for a required array |
| 590 | // Expected to trigger an error with parameter_validation::validate_array |
| 591 | m_commandBuffer->SetViewport(0, 1, NULL); |
| 592 | m_errorMonitor->VerifyFound(); |
| 593 | |
| 594 | m_errorMonitor->SetDesiredFailureMsg( |
| 595 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 596 | "required parameter memory specified as VK_NULL_HANDLE"); |
| 597 | // Specify VK_NULL_HANDLE for a required handle |
| 598 | // Expected to trigger an error with |
| 599 | // parameter_validation::validate_required_handle |
| 600 | vkUnmapMemory(device(), VK_NULL_HANDLE); |
| 601 | m_errorMonitor->VerifyFound(); |
| 602 | |
| 603 | m_errorMonitor->SetDesiredFailureMsg( |
| 604 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 605 | "required parameter pFences[0] specified as VK_NULL_HANDLE"); |
| 606 | // Specify VK_NULL_HANDLE for a required handle array entry |
| 607 | // Expected to trigger an error with |
| 608 | // parameter_validation::validate_required_handle_array |
| 609 | VkFence fence = VK_NULL_HANDLE; |
| 610 | vkResetFences(device(), 1, &fence); |
| 611 | m_errorMonitor->VerifyFound(); |
| 612 | |
| 613 | m_errorMonitor->SetDesiredFailureMsg( |
| 614 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 615 | "required parameter pAllocateInfo specified as NULL"); |
| 616 | // Specify NULL for a required struct pointer |
| 617 | // Expected to trigger an error with |
| 618 | // parameter_validation::validate_struct_type |
| 619 | VkDeviceMemory memory = VK_NULL_HANDLE; |
| 620 | vkAllocateMemory(device(), NULL, NULL, &memory); |
| 621 | m_errorMonitor->VerifyFound(); |
| 622 | |
| 623 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 624 | "value of faceMask must not be 0"); |
| 625 | // Specify 0 for a required VkFlags parameter |
| 626 | // Expected to trigger an error with parameter_validation::validate_flags |
| 627 | m_commandBuffer->SetStencilReference(0, 0); |
| 628 | m_errorMonitor->VerifyFound(); |
| 629 | |
| 630 | m_errorMonitor->SetDesiredFailureMsg( |
| 631 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 632 | "value of pSubmits[i].pWaitDstStageMask[0] must not be 0"); |
| 633 | // Specify 0 for a required VkFlags array entry |
| 634 | // Expected to trigger an error with |
| 635 | // parameter_validation::validate_flags_array |
| 636 | VkSemaphore semaphore = VK_NULL_HANDLE; |
| 637 | VkPipelineStageFlags stageFlags = 0; |
| 638 | VkSubmitInfo submitInfo = {}; |
| 639 | submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 640 | submitInfo.waitSemaphoreCount = 1; |
| 641 | submitInfo.pWaitSemaphores = &semaphore; |
| 642 | submitInfo.pWaitDstStageMask = &stageFlags; |
| 643 | vkQueueSubmit(m_device->m_queue, 1, &submitInfo, VK_NULL_HANDLE); |
| 644 | m_errorMonitor->VerifyFound(); |
| 645 | } |
Dustin Graves | c99cf5a | 2016-05-09 14:40:29 -0600 | [diff] [blame] | 646 | |
Dustin Graves | fce74c0 | 2016-05-10 11:42:58 -0600 | [diff] [blame] | 647 | TEST_F(VkLayerTest, ReservedParameter) { |
| 648 | TEST_DESCRIPTION("Specify a non-zero value for a reserved parameter"); |
| 649 | |
| 650 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 651 | |
| 652 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 653 | " must be 0"); |
| 654 | // Specify 0 for a reserved VkFlags parameter |
| 655 | // Expected to trigger an error with |
| 656 | // parameter_validation::validate_reserved_flags |
| 657 | VkEvent event_handle = VK_NULL_HANDLE; |
| 658 | VkEventCreateInfo event_info = {}; |
| 659 | event_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 660 | event_info.flags = 1; |
| 661 | vkCreateEvent(device(), &event_info, NULL, &event_handle); |
| 662 | m_errorMonitor->VerifyFound(); |
| 663 | } |
| 664 | |
Dustin Graves | c99cf5a | 2016-05-09 14:40:29 -0600 | [diff] [blame] | 665 | TEST_F(VkLayerTest, InvalidStructSType) { |
| 666 | TEST_DESCRIPTION("Specify an invalid VkStructureType for a Vulkan " |
| 667 | "structure's sType field"); |
| 668 | |
| 669 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 670 | |
| 671 | m_errorMonitor->SetDesiredFailureMsg( |
| 672 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 673 | "parameter pAllocateInfo->sType must be"); |
| 674 | // Zero struct memory, effectively setting sType to |
| 675 | // VK_STRUCTURE_TYPE_APPLICATION_INFO |
| 676 | // Expected to trigger an error with |
| 677 | // parameter_validation::validate_struct_type |
| 678 | VkMemoryAllocateInfo alloc_info = {}; |
| 679 | VkDeviceMemory memory = VK_NULL_HANDLE; |
| 680 | vkAllocateMemory(device(), &alloc_info, NULL, &memory); |
| 681 | m_errorMonitor->VerifyFound(); |
| 682 | |
| 683 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 684 | "parameter pSubmits[0].sType must be"); |
| 685 | // Zero struct memory, effectively setting sType to |
| 686 | // VK_STRUCTURE_TYPE_APPLICATION_INFO |
| 687 | // Expected to trigger an error with |
| 688 | // parameter_validation::validate_struct_type_array |
| 689 | VkSubmitInfo submit_info = {}; |
| 690 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 691 | m_errorMonitor->VerifyFound(); |
| 692 | } |
| 693 | |
| 694 | TEST_F(VkLayerTest, InvalidStructPNext) { |
| 695 | TEST_DESCRIPTION( |
| 696 | "Specify an invalid value for a Vulkan structure's pNext field"); |
| 697 | |
| 698 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 699 | |
| 700 | m_errorMonitor->SetDesiredFailureMsg( |
| 701 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 702 | "value of pAllocateInfo->pNext must be NULL"); |
| 703 | // Set VkMemoryAllocateInfo::pNext to a non-NULL value, when pNext must be |
| 704 | // NULL |
| 705 | // Expected to trigger an error with |
| 706 | // parameter_validation::validate_struct_pnext |
| 707 | VkDeviceMemory memory = VK_NULL_HANDLE; |
| 708 | // Zero-initialization will provide the correct sType |
| 709 | VkApplicationInfo app_info = {}; |
Dustin Graves | 47b6cba | 2016-05-10 17:34:38 -0600 | [diff] [blame] | 710 | VkMemoryAllocateInfo memory_alloc_info = {}; |
| 711 | memory_alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 712 | memory_alloc_info.pNext = &app_info; |
| 713 | vkAllocateMemory(device(), &memory_alloc_info, NULL, &memory); |
Dustin Graves | c99cf5a | 2016-05-09 14:40:29 -0600 | [diff] [blame] | 714 | m_errorMonitor->VerifyFound(); |
| 715 | |
Dustin Graves | 47b6cba | 2016-05-10 17:34:38 -0600 | [diff] [blame] | 716 | m_errorMonitor->SetDesiredFailureMsg( |
| 717 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 718 | " chain includes a structure with unexpected VkStructureType "); |
| 719 | // Set VkGraphicsPipelineCreateInfo::VkPipelineRasterizationStateCreateInfo::pNext to an invalid structure, when pNext is allowed to be a non-NULL value |
| 720 | // Expected to trigger an error with |
| 721 | // parameter_validation::validate_struct_pnext |
| 722 | VkDescriptorPoolSize ds_type_count = {}; |
| 723 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 724 | ds_type_count.descriptorCount = 1; |
| 725 | |
| 726 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 727 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 728 | ds_pool_ci.pNext = NULL; |
| 729 | ds_pool_ci.maxSets = 1; |
| 730 | ds_pool_ci.poolSizeCount = 1; |
| 731 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 732 | |
| 733 | VkDescriptorPool ds_pool; |
| 734 | VkResult err = |
| 735 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 736 | ASSERT_VK_SUCCESS(err); |
| 737 | |
| 738 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 739 | dsl_binding.binding = 0; |
| 740 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 741 | dsl_binding.descriptorCount = 1; |
| 742 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 743 | dsl_binding.pImmutableSamplers = NULL; |
| 744 | |
| 745 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 746 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 747 | ds_layout_ci.pNext = NULL; |
| 748 | ds_layout_ci.bindingCount = 1; |
| 749 | ds_layout_ci.pBindings = &dsl_binding; |
| 750 | |
| 751 | VkDescriptorSetLayout ds_layout; |
| 752 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 753 | &ds_layout); |
| 754 | ASSERT_VK_SUCCESS(err); |
| 755 | |
| 756 | VkDescriptorSet descriptorSet; |
| 757 | VkDescriptorSetAllocateInfo ds_alloc_info = {}; |
| 758 | ds_alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 759 | ds_alloc_info.descriptorSetCount = 1; |
| 760 | ds_alloc_info.descriptorPool = ds_pool; |
| 761 | ds_alloc_info.pSetLayouts = &ds_layout; |
| 762 | err = vkAllocateDescriptorSets(m_device->device(), &ds_alloc_info, |
| 763 | &descriptorSet); |
| 764 | ASSERT_VK_SUCCESS(err); |
| 765 | |
| 766 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 767 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 768 | pipeline_layout_ci.setLayoutCount = 1; |
| 769 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 770 | |
| 771 | VkPipelineLayout pipeline_layout; |
| 772 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 773 | &pipeline_layout); |
| 774 | ASSERT_VK_SUCCESS(err); |
| 775 | |
| 776 | VkViewport vp = {}; // Just need dummy vp to point to |
| 777 | VkRect2D sc = {}; // dummy scissor to point to |
| 778 | |
| 779 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 780 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 781 | vp_state_ci.scissorCount = 1; |
| 782 | vp_state_ci.pScissors = ≻ |
| 783 | vp_state_ci.viewportCount = 1; |
| 784 | vp_state_ci.pViewports = &vp; |
| 785 | |
| 786 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 787 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 788 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 789 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 790 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 791 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 792 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 793 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 794 | |
| 795 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 796 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 797 | gp_ci.pViewportState = &vp_state_ci; |
| 798 | gp_ci.pRasterizationState = &rs_state_ci; |
| 799 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 800 | gp_ci.layout = pipeline_layout; |
| 801 | gp_ci.renderPass = renderPass(); |
| 802 | |
| 803 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 804 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 805 | pc_ci.initialDataSize = 0; |
| 806 | pc_ci.pInitialData = 0; |
| 807 | |
| 808 | VkPipeline pipeline; |
| 809 | VkPipelineCache pipelineCache; |
| 810 | |
| 811 | err = |
| 812 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 813 | ASSERT_VK_SUCCESS(err); |
| 814 | |
| 815 | // Set VkPipelineRasterizationStateCreateInfo::pNext to an invalid value |
| 816 | VkApplicationInfo invalid_pnext_struct = {}; |
| 817 | rs_state_ci.pNext = &invalid_pnext_struct; |
| 818 | |
| 819 | vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 820 | &gp_ci, NULL, &pipeline); |
| 821 | m_errorMonitor->VerifyFound(); |
Dustin Graves | c99cf5a | 2016-05-09 14:40:29 -0600 | [diff] [blame] | 822 | } |
Dustin Graves | 5d33d53 | 2016-05-09 16:21:12 -0600 | [diff] [blame] | 823 | |
| 824 | TEST_F(VkLayerTest, UnrecognizedValue) { |
| 825 | TEST_DESCRIPTION( |
| 826 | "Specify unrecognized Vulkan enumeration, flags, and VkBool32 values"); |
| 827 | |
| 828 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 829 | |
| 830 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 831 | "does not fall within the begin..end " |
| 832 | "range of the core VkFormat " |
| 833 | "enumeration tokens"); |
| 834 | // Specify an invalid VkFormat value |
| 835 | // Expected to trigger an error with |
| 836 | // parameter_validation::validate_ranged_enum |
| 837 | VkFormatProperties format_properties; |
| 838 | vkGetPhysicalDeviceFormatProperties(gpu(), static_cast<VkFormat>(8000), |
| 839 | &format_properties); |
| 840 | m_errorMonitor->VerifyFound(); |
| 841 | |
| 842 | m_errorMonitor->SetDesiredFailureMsg( |
| 843 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 844 | "contains flag bits that are not recognized members of"); |
| 845 | // Specify an invalid VkFlags bitmask value |
| 846 | // Expected to trigger an error with parameter_validation::validate_flags |
| 847 | VkImageFormatProperties image_format_properties; |
| 848 | vkGetPhysicalDeviceImageFormatProperties( |
| 849 | gpu(), VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_TYPE_2D, |
| 850 | VK_IMAGE_TILING_OPTIMAL, static_cast<VkImageUsageFlags>(1 << 25), 0, |
| 851 | &image_format_properties); |
| 852 | m_errorMonitor->VerifyFound(); |
| 853 | |
| 854 | m_errorMonitor->SetDesiredFailureMsg( |
| 855 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 856 | "contains flag bits that are not recognized members of"); |
| 857 | // Specify an invalid VkFlags array entry |
| 858 | // Expected to trigger an error with |
| 859 | // parameter_validation::validate_flags_array |
| 860 | VkSemaphore semaphore = VK_NULL_HANDLE; |
| 861 | VkPipelineStageFlags stage_flags = |
| 862 | static_cast<VkPipelineStageFlags>(1 << 25); |
| 863 | VkSubmitInfo submit_info = {}; |
| 864 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 865 | submit_info.waitSemaphoreCount = 1; |
| 866 | submit_info.pWaitSemaphores = &semaphore; |
| 867 | submit_info.pWaitDstStageMask = &stage_flags; |
| 868 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 869 | m_errorMonitor->VerifyFound(); |
| 870 | |
| 871 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, |
| 872 | "is neither VK_TRUE nor VK_FALSE"); |
| 873 | // Specify an invalid VkBool32 value |
| 874 | // Expected to trigger a warning with |
| 875 | // parameter_validation::validate_bool32 |
| 876 | VkSampler sampler = VK_NULL_HANDLE; |
| 877 | VkSamplerCreateInfo sampler_info = {}; |
| 878 | sampler_info.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 879 | sampler_info.pNext = NULL; |
| 880 | sampler_info.magFilter = VK_FILTER_NEAREST; |
| 881 | sampler_info.minFilter = VK_FILTER_NEAREST; |
| 882 | sampler_info.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 883 | sampler_info.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 884 | sampler_info.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 885 | sampler_info.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 886 | sampler_info.mipLodBias = 1.0; |
| 887 | sampler_info.maxAnisotropy = 1; |
| 888 | sampler_info.compareEnable = VK_FALSE; |
| 889 | sampler_info.compareOp = VK_COMPARE_OP_NEVER; |
| 890 | sampler_info.minLod = 1.0; |
| 891 | sampler_info.maxLod = 1.0; |
| 892 | sampler_info.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 893 | sampler_info.unnormalizedCoordinates = VK_FALSE; |
| 894 | // Not VK_TRUE or VK_FALSE |
| 895 | sampler_info.anisotropyEnable = 3; |
| 896 | vkCreateSampler(m_device->device(), &sampler_info, NULL, &sampler); |
| 897 | m_errorMonitor->VerifyFound(); |
| 898 | } |
Dustin Graves | fce74c0 | 2016-05-10 11:42:58 -0600 | [diff] [blame] | 899 | |
| 900 | TEST_F(VkLayerTest, FailedReturnValue) { |
| 901 | TEST_DESCRIPTION("Check for a message describing a VkResult failure code"); |
| 902 | |
| 903 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 904 | |
| 905 | m_errorMonitor->SetDesiredFailureMsg( |
| 906 | VK_DEBUG_REPORT_WARNING_BIT_EXT, |
| 907 | "the requested format is not supported on this device"); |
| 908 | // Specify invalid VkFormat value to generate a |
| 909 | // VK_ERROR_FORMAT_NOT_SUPPORTED return code |
| 910 | // Expected to trigger a warning from parameter_validation::validate_result |
| 911 | VkImageFormatProperties image_format_properties; |
| 912 | VkResult err = vkGetPhysicalDeviceImageFormatProperties( |
| 913 | gpu(), static_cast<VkFormat>(0x8000), VK_IMAGE_TYPE_2D, |
| 914 | VK_IMAGE_TILING_OPTIMAL, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, 0, |
| 915 | &image_format_properties); |
| 916 | ASSERT_TRUE(err == VK_ERROR_FORMAT_NOT_SUPPORTED); |
| 917 | m_errorMonitor->VerifyFound(); |
| 918 | } |
Dustin Graves | ffa90fa | 2016-05-06 11:20:38 -0600 | [diff] [blame] | 919 | #endif // PARAMETER_VALIDATION_TESTS |
| 920 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 921 | #if MEM_TRACKER_TESTS |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 922 | #if 0 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 923 | TEST_F(VkLayerTest, CallResetCommandBufferBeforeCompletion) |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 924 | { |
| 925 | vk_testing::Fence testFence; |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 926 | VkFenceCreateInfo fenceInfo = {}; |
| 927 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 928 | fenceInfo.pNext = NULL; |
| 929 | fenceInfo.flags = 0; |
| 930 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 931 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "Resetting CB"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 932 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 933 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tony Barbour | c1eb1a5 | 2015-07-20 13:00:10 -0600 | [diff] [blame] | 934 | |
| 935 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 936 | vk_testing::Buffer buffer; |
| 937 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 938 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 939 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 940 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 4, 0x11111111); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 941 | EndCommandBuffer(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 942 | |
| 943 | testFence.init(*m_device, fenceInfo); |
| 944 | |
| 945 | // Bypass framework since it does the waits automatically |
| 946 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 947 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 948 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 949 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 950 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 951 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 952 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 953 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 954 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 955 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 956 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 957 | |
| 958 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 959 | ASSERT_VK_SUCCESS( err ); |
| 960 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 961 | // Introduce failure by calling begin again before checking fence |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 962 | vkResetCommandBuffer(m_commandBuffer->handle(), 0); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 963 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 964 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 965 | } |
| 966 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 967 | TEST_F(VkLayerTest, CallBeginCommandBufferBeforeCompletion) |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 968 | { |
| 969 | vk_testing::Fence testFence; |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 970 | VkFenceCreateInfo fenceInfo = {}; |
| 971 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 972 | fenceInfo.pNext = NULL; |
| 973 | fenceInfo.flags = 0; |
| 974 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 975 | 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] | 976 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 977 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 978 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 979 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 980 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 981 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 982 | 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] | 983 | EndCommandBuffer(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 984 | |
| 985 | testFence.init(*m_device, fenceInfo); |
| 986 | |
| 987 | // Bypass framework since it does the waits automatically |
| 988 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 989 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 990 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 991 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 992 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 993 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 994 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 995 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 996 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 997 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 998 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 999 | |
| 1000 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1001 | ASSERT_VK_SUCCESS( err ); |
| 1002 | |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 1003 | VkCommandBufferInheritanceInfo hinfo = {}; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1004 | VkCommandBufferBeginInfo info = {}; |
| 1005 | info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
| 1006 | info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1007 | info.renderPass = VK_NULL_HANDLE; |
| 1008 | info.subpass = 0; |
| 1009 | info.framebuffer = VK_NULL_HANDLE; |
Chia-I Wu | b8d47ae | 2015-11-11 10:18:12 +0800 | [diff] [blame] | 1010 | info.occlusionQueryEnable = VK_FALSE; |
| 1011 | info.queryFlags = 0; |
| 1012 | info.pipelineStatistics = 0; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1013 | |
| 1014 | // Introduce failure by calling BCB again before checking fence |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1015 | vkBeginCommandBuffer(m_commandBuffer->handle(), &info); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1016 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1017 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 1018 | } |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1019 | #endif |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1020 | |
Mark Lobodzinski | 152fe25 | 2016-05-03 16:49:15 -0600 | [diff] [blame] | 1021 | // This is a positive test. No failures are expected. |
| 1022 | TEST_F(VkLayerTest, TestAliasedMemoryTracking) { |
| 1023 | VkResult err; |
| 1024 | bool pass; |
| 1025 | |
| 1026 | TEST_DESCRIPTION("Create a buffer, allocate memory, bind memory, destroy " |
| 1027 | "the buffer, create an image, and bind the same memory to " |
| 1028 | "it"); |
| 1029 | |
| 1030 | m_errorMonitor->ExpectSuccess(); |
| 1031 | |
| 1032 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1033 | |
| 1034 | VkBuffer buffer; |
| 1035 | VkImage image; |
| 1036 | VkDeviceMemory mem; |
| 1037 | VkMemoryRequirements mem_reqs; |
| 1038 | |
| 1039 | VkBufferCreateInfo buf_info = {}; |
| 1040 | buf_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 1041 | buf_info.pNext = NULL; |
| 1042 | buf_info.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 1043 | buf_info.size = 256; |
| 1044 | buf_info.queueFamilyIndexCount = 0; |
| 1045 | buf_info.pQueueFamilyIndices = NULL; |
| 1046 | buf_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 1047 | buf_info.flags = 0; |
| 1048 | err = vkCreateBuffer(m_device->device(), &buf_info, NULL, &buffer); |
| 1049 | ASSERT_VK_SUCCESS(err); |
| 1050 | |
| 1051 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &mem_reqs); |
| 1052 | |
| 1053 | VkMemoryAllocateInfo alloc_info = {}; |
| 1054 | alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1055 | alloc_info.pNext = NULL; |
| 1056 | alloc_info.memoryTypeIndex = 0; |
| 1057 | |
| 1058 | // Ensure memory is big enough for both bindings |
| 1059 | alloc_info.allocationSize = 0x10000; |
| 1060 | |
| 1061 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &alloc_info, |
| 1062 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 1063 | if (!pass) { |
| 1064 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 1065 | return; |
| 1066 | } |
| 1067 | |
| 1068 | err = vkAllocateMemory(m_device->device(), &alloc_info, NULL, &mem); |
| 1069 | ASSERT_VK_SUCCESS(err); |
| 1070 | |
| 1071 | uint8_t *pData; |
| 1072 | err = vkMapMemory(m_device->device(), mem, 0, mem_reqs.size, 0, |
| 1073 | (void **)&pData); |
| 1074 | ASSERT_VK_SUCCESS(err); |
| 1075 | |
Mark Lobodzinski | 2abefa9 | 2016-05-05 11:45:57 -0600 | [diff] [blame] | 1076 | memset(pData, 0xCADECADE, static_cast<size_t>(mem_reqs.size)); |
Mark Lobodzinski | 152fe25 | 2016-05-03 16:49:15 -0600 | [diff] [blame] | 1077 | |
| 1078 | vkUnmapMemory(m_device->device(), mem); |
| 1079 | |
| 1080 | err = vkBindBufferMemory(m_device->device(), buffer, mem, 0); |
| 1081 | ASSERT_VK_SUCCESS(err); |
| 1082 | |
| 1083 | // NOW, destroy the buffer. Obviously, the resource no longer occupies this |
| 1084 | // memory. In fact, it was never used by the GPU. |
| 1085 | // Just be be sure, wait for idle. |
| 1086 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 1087 | vkDeviceWaitIdle(m_device->device()); |
| 1088 | |
| 1089 | VkImageCreateInfo image_create_info = {}; |
| 1090 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1091 | image_create_info.pNext = NULL; |
| 1092 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1093 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 1094 | image_create_info.extent.width = 64; |
| 1095 | image_create_info.extent.height = 64; |
| 1096 | image_create_info.extent.depth = 1; |
| 1097 | image_create_info.mipLevels = 1; |
| 1098 | image_create_info.arrayLayers = 1; |
| 1099 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1100 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1101 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_PREINITIALIZED; |
| 1102 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 1103 | image_create_info.queueFamilyIndexCount = 0; |
| 1104 | image_create_info.pQueueFamilyIndices = NULL; |
| 1105 | image_create_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 1106 | image_create_info.flags = 0; |
| 1107 | |
| 1108 | VkMemoryAllocateInfo mem_alloc = {}; |
| 1109 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1110 | mem_alloc.pNext = NULL; |
| 1111 | mem_alloc.allocationSize = 0; |
| 1112 | mem_alloc.memoryTypeIndex = 0; |
| 1113 | |
| 1114 | /* Create a mappable image. It will be the texture if linear images are ok |
| 1115 | * to be textures or it will be the staging image if they are not. |
| 1116 | */ |
| 1117 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 1118 | ASSERT_VK_SUCCESS(err); |
| 1119 | |
| 1120 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
| 1121 | |
| 1122 | mem_alloc.allocationSize = mem_reqs.size; |
| 1123 | |
| 1124 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, |
| 1125 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 1126 | if (!pass) { |
| 1127 | vkDestroyImage(m_device->device(), image, NULL); |
| 1128 | return; |
| 1129 | } |
| 1130 | |
| 1131 | // VALDIATION FAILURE: |
| 1132 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 1133 | ASSERT_VK_SUCCESS(err); |
| 1134 | |
| 1135 | m_errorMonitor->VerifyNotFound(); |
| 1136 | |
| 1137 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 1138 | vkDestroyImage(m_device->device(), image, NULL); |
| 1139 | } |
| 1140 | |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1141 | TEST_F(VkLayerTest, EnableWsiBeforeUse) { |
| 1142 | VkResult err; |
| 1143 | bool pass; |
| 1144 | |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1145 | // FIXME: After we turn on this code for non-Linux platforms, uncomment the |
| 1146 | // following declaration (which is temporarily being moved below): |
| 1147 | // VkSurfaceKHR surface = VK_NULL_HANDLE; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1148 | VkSwapchainKHR swapchain = VK_NULL_HANDLE; |
| 1149 | VkSwapchainCreateInfoKHR swapchain_create_info = {}; |
| 1150 | uint32_t swapchain_image_count = 0; |
| 1151 | // VkImage swapchain_images[1] = {VK_NULL_HANDLE}; |
| 1152 | uint32_t image_index = 0; |
| 1153 | // VkPresentInfoKHR present_info = {}; |
| 1154 | |
| 1155 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1156 | |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1157 | #ifdef NEED_TO_TEST_THIS_ON_PLATFORM |
| 1158 | #if defined(VK_USE_PLATFORM_ANDROID_KHR) |
| 1159 | // Use the functions from the VK_KHR_android_surface extension without |
| 1160 | // enabling that extension: |
| 1161 | |
| 1162 | // Create a surface: |
| 1163 | VkAndroidSurfaceCreateInfoKHR android_create_info = {}; |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1164 | m_errorMonitor->SetDesiredFailureMsg( |
| 1165 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1166 | "extension was not enabled for this"); |
| 1167 | err = vkCreateAndroidSurfaceKHR(instance(), &android_create_info, NULL, |
| 1168 | &surface); |
| 1169 | pass = (err != VK_SUCCESS); |
| 1170 | ASSERT_TRUE(pass); |
| 1171 | m_errorMonitor->VerifyFound(); |
| 1172 | #endif // VK_USE_PLATFORM_ANDROID_KHR |
| 1173 | |
| 1174 | |
| 1175 | #if defined(VK_USE_PLATFORM_MIR_KHR) |
| 1176 | // Use the functions from the VK_KHR_mir_surface extension without enabling |
| 1177 | // that extension: |
| 1178 | |
| 1179 | // Create a surface: |
| 1180 | VkMirSurfaceCreateInfoKHR mir_create_info = {}; |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1181 | m_errorMonitor->SetDesiredFailureMsg( |
| 1182 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1183 | "extension was not enabled for this"); |
| 1184 | err = vkCreateMirSurfaceKHR(instance(), &mir_create_info, NULL, &surface); |
| 1185 | pass = (err != VK_SUCCESS); |
| 1186 | ASSERT_TRUE(pass); |
| 1187 | m_errorMonitor->VerifyFound(); |
| 1188 | |
| 1189 | // Tell whether an mir_connection supports presentation: |
| 1190 | MirConnection *mir_connection = NULL; |
| 1191 | m_errorMonitor->SetDesiredFailureMsg( |
| 1192 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1193 | "extension was not enabled for this"); |
| 1194 | vkGetPhysicalDeviceMirPresentationSupportKHR(gpu(), 0, mir_connection, |
| 1195 | visual_id); |
| 1196 | m_errorMonitor->VerifyFound(); |
| 1197 | #endif // VK_USE_PLATFORM_MIR_KHR |
| 1198 | |
| 1199 | |
| 1200 | #if defined(VK_USE_PLATFORM_WAYLAND_KHR) |
| 1201 | // Use the functions from the VK_KHR_wayland_surface extension without |
| 1202 | // enabling that extension: |
| 1203 | |
| 1204 | // Create a surface: |
| 1205 | VkWaylandSurfaceCreateInfoKHR wayland_create_info = {}; |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1206 | m_errorMonitor->SetDesiredFailureMsg( |
| 1207 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1208 | "extension was not enabled for this"); |
| 1209 | err = vkCreateWaylandSurfaceKHR(instance(), &wayland_create_info, NULL, |
| 1210 | &surface); |
| 1211 | pass = (err != VK_SUCCESS); |
| 1212 | ASSERT_TRUE(pass); |
| 1213 | m_errorMonitor->VerifyFound(); |
| 1214 | |
| 1215 | // Tell whether an wayland_display supports presentation: |
| 1216 | struct wl_display wayland_display = {}; |
| 1217 | m_errorMonitor->SetDesiredFailureMsg( |
| 1218 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1219 | "extension was not enabled for this"); |
| 1220 | vkGetPhysicalDeviceWaylandPresentationSupportKHR(gpu(), 0, |
| 1221 | &wayland_display); |
| 1222 | m_errorMonitor->VerifyFound(); |
| 1223 | #endif // VK_USE_PLATFORM_WAYLAND_KHR |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1224 | #endif // NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1225 | |
| 1226 | |
| 1227 | #if defined(VK_USE_PLATFORM_WIN32_KHR) |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1228 | // FIXME: REMOVE THIS HERE, AND UNCOMMENT ABOVE, WHEN THIS TEST HAS BEEN PORTED |
| 1229 | // TO NON-LINUX PLATFORMS: |
| 1230 | VkSurfaceKHR surface = VK_NULL_HANDLE; |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1231 | // Use the functions from the VK_KHR_win32_surface extension without |
| 1232 | // enabling that extension: |
| 1233 | |
| 1234 | // Create a surface: |
| 1235 | VkWin32SurfaceCreateInfoKHR win32_create_info = {}; |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1236 | m_errorMonitor->SetDesiredFailureMsg( |
| 1237 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1238 | "extension was not enabled for this"); |
| 1239 | err = vkCreateWin32SurfaceKHR(instance(), &win32_create_info, NULL, |
| 1240 | &surface); |
| 1241 | pass = (err != VK_SUCCESS); |
| 1242 | ASSERT_TRUE(pass); |
| 1243 | m_errorMonitor->VerifyFound(); |
| 1244 | |
| 1245 | // Tell whether win32 supports presentation: |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1246 | m_errorMonitor->SetDesiredFailureMsg( |
| 1247 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1248 | "extension was not enabled for this"); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1249 | vkGetPhysicalDeviceWin32PresentationSupportKHR(gpu(), 0); |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1250 | m_errorMonitor->VerifyFound(); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1251 | // Set this (for now, until all platforms are supported and tested): |
| 1252 | #define NEED_TO_TEST_THIS_ON_PLATFORM |
| 1253 | #endif // VK_USE_PLATFORM_WIN32_KHR |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1254 | |
| 1255 | |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1256 | #if defined(VK_USE_PLATFORM_XCB_KHR) |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1257 | // FIXME: REMOVE THIS HERE, AND UNCOMMENT ABOVE, WHEN THIS TEST HAS BEEN PORTED |
| 1258 | // TO NON-LINUX PLATFORMS: |
| 1259 | VkSurfaceKHR surface = VK_NULL_HANDLE; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1260 | // Use the functions from the VK_KHR_xcb_surface extension without enabling |
| 1261 | // that extension: |
| 1262 | |
| 1263 | // Create a surface: |
| 1264 | VkXcbSurfaceCreateInfoKHR xcb_create_info = {}; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1265 | m_errorMonitor->SetDesiredFailureMsg( |
| 1266 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1267 | "extension was not enabled for this"); |
| 1268 | err = vkCreateXcbSurfaceKHR(instance(), &xcb_create_info, NULL, &surface); |
| 1269 | pass = (err != VK_SUCCESS); |
| 1270 | ASSERT_TRUE(pass); |
| 1271 | m_errorMonitor->VerifyFound(); |
| 1272 | |
| 1273 | // Tell whether an xcb_visualid_t supports presentation: |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1274 | xcb_connection_t *xcb_connection = NULL; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1275 | xcb_visualid_t visual_id = 0; |
| 1276 | m_errorMonitor->SetDesiredFailureMsg( |
| 1277 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1278 | "extension was not enabled for this"); |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1279 | vkGetPhysicalDeviceXcbPresentationSupportKHR(gpu(), 0, xcb_connection, |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1280 | visual_id); |
| 1281 | m_errorMonitor->VerifyFound(); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1282 | // Set this (for now, until all platforms are supported and tested): |
| 1283 | #define NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1284 | #endif // VK_USE_PLATFORM_XCB_KHR |
| 1285 | |
| 1286 | |
Ian Elliott | 1263081 | 2016-04-29 14:35:43 -0600 | [diff] [blame] | 1287 | #if defined(VK_USE_PLATFORM_XLIB_KHR) |
| 1288 | // Use the functions from the VK_KHR_xlib_surface extension without enabling |
| 1289 | // that extension: |
| 1290 | |
| 1291 | // Create a surface: |
| 1292 | VkXlibSurfaceCreateInfoKHR xlib_create_info = {}; |
Ian Elliott | 1263081 | 2016-04-29 14:35:43 -0600 | [diff] [blame] | 1293 | m_errorMonitor->SetDesiredFailureMsg( |
| 1294 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1295 | "extension was not enabled for this"); |
| 1296 | err = vkCreateXlibSurfaceKHR(instance(), &xlib_create_info, NULL, &surface); |
| 1297 | pass = (err != VK_SUCCESS); |
| 1298 | ASSERT_TRUE(pass); |
| 1299 | m_errorMonitor->VerifyFound(); |
| 1300 | |
| 1301 | // Tell whether an Xlib VisualID supports presentation: |
| 1302 | Display *dpy = NULL; |
| 1303 | VisualID visual = 0; |
| 1304 | m_errorMonitor->SetDesiredFailureMsg( |
| 1305 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1306 | "extension was not enabled for this"); |
| 1307 | vkGetPhysicalDeviceXlibPresentationSupportKHR(gpu(), 0, dpy, visual); |
| 1308 | m_errorMonitor->VerifyFound(); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1309 | // Set this (for now, until all platforms are supported and tested): |
| 1310 | #define NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1263081 | 2016-04-29 14:35:43 -0600 | [diff] [blame] | 1311 | #endif // VK_USE_PLATFORM_XLIB_KHR |
| 1312 | |
| 1313 | |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1314 | // Use the functions from the VK_KHR_surface extension without enabling |
| 1315 | // that extension: |
| 1316 | |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1317 | #ifdef NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1318 | // Destroy a surface: |
| 1319 | m_errorMonitor->SetDesiredFailureMsg( |
| 1320 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1321 | "extension was not enabled for this"); |
| 1322 | vkDestroySurfaceKHR(instance(), surface, NULL); |
| 1323 | m_errorMonitor->VerifyFound(); |
| 1324 | |
| 1325 | // Check if surface supports presentation: |
| 1326 | VkBool32 supported = false; |
| 1327 | m_errorMonitor->SetDesiredFailureMsg( |
| 1328 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1329 | "extension was not enabled for this"); |
| 1330 | err = vkGetPhysicalDeviceSurfaceSupportKHR(gpu(), 0, surface, &supported); |
| 1331 | pass = (err != VK_SUCCESS); |
| 1332 | ASSERT_TRUE(pass); |
| 1333 | m_errorMonitor->VerifyFound(); |
| 1334 | |
| 1335 | // Check surface capabilities: |
| 1336 | VkSurfaceCapabilitiesKHR capabilities = {}; |
| 1337 | m_errorMonitor->SetDesiredFailureMsg( |
| 1338 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1339 | "extension was not enabled for this"); |
| 1340 | err = vkGetPhysicalDeviceSurfaceCapabilitiesKHR(gpu(), surface, |
| 1341 | &capabilities); |
| 1342 | pass = (err != VK_SUCCESS); |
| 1343 | ASSERT_TRUE(pass); |
| 1344 | m_errorMonitor->VerifyFound(); |
| 1345 | |
| 1346 | // Check surface formats: |
| 1347 | uint32_t format_count = 0; |
| 1348 | VkSurfaceFormatKHR *formats = NULL; |
| 1349 | m_errorMonitor->SetDesiredFailureMsg( |
| 1350 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1351 | "extension was not enabled for this"); |
| 1352 | err = vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, |
| 1353 | &format_count, formats); |
| 1354 | pass = (err != VK_SUCCESS); |
| 1355 | ASSERT_TRUE(pass); |
| 1356 | m_errorMonitor->VerifyFound(); |
| 1357 | |
| 1358 | // Check surface present modes: |
| 1359 | uint32_t present_mode_count = 0; |
| 1360 | VkSurfaceFormatKHR *present_modes = NULL; |
| 1361 | m_errorMonitor->SetDesiredFailureMsg( |
| 1362 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1363 | "extension was not enabled for this"); |
| 1364 | err = vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, |
| 1365 | &present_mode_count, present_modes); |
| 1366 | pass = (err != VK_SUCCESS); |
| 1367 | ASSERT_TRUE(pass); |
| 1368 | m_errorMonitor->VerifyFound(); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1369 | #endif // NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1370 | |
| 1371 | |
| 1372 | // Use the functions from the VK_KHR_swapchain extension without enabling |
| 1373 | // that extension: |
| 1374 | |
| 1375 | // Create a swapchain: |
| 1376 | m_errorMonitor->SetDesiredFailureMsg( |
| 1377 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1378 | "extension was not enabled for this"); |
| 1379 | swapchain_create_info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR; |
| 1380 | swapchain_create_info.pNext = NULL; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1381 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, |
| 1382 | NULL, &swapchain); |
| 1383 | pass = (err != VK_SUCCESS); |
| 1384 | ASSERT_TRUE(pass); |
| 1385 | m_errorMonitor->VerifyFound(); |
| 1386 | |
| 1387 | // Get the images from the swapchain: |
| 1388 | m_errorMonitor->SetDesiredFailureMsg( |
| 1389 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1390 | "extension was not enabled for this"); |
| 1391 | err = vkGetSwapchainImagesKHR(m_device->device(), swapchain, |
| 1392 | &swapchain_image_count, NULL); |
| 1393 | pass = (err != VK_SUCCESS); |
| 1394 | ASSERT_TRUE(pass); |
| 1395 | m_errorMonitor->VerifyFound(); |
| 1396 | |
| 1397 | // Try to acquire an image: |
| 1398 | m_errorMonitor->SetDesiredFailureMsg( |
| 1399 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1400 | "extension was not enabled for this"); |
| 1401 | err = vkAcquireNextImageKHR(m_device->device(), swapchain, 0, |
| 1402 | VK_NULL_HANDLE, VK_NULL_HANDLE, &image_index); |
| 1403 | pass = (err != VK_SUCCESS); |
| 1404 | ASSERT_TRUE(pass); |
| 1405 | m_errorMonitor->VerifyFound(); |
| 1406 | |
| 1407 | // Try to present an image: |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1408 | // |
| 1409 | // NOTE: Currently can't test this because a real swapchain is needed (as |
| 1410 | // opposed to the fake one we created) in order for the layer to lookup the |
| 1411 | // VkDevice used to enable the extension: |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1412 | |
| 1413 | // Destroy the swapchain: |
| 1414 | m_errorMonitor->SetDesiredFailureMsg( |
| 1415 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1416 | "extension was not enabled for this"); |
| 1417 | vkDestroySwapchainKHR(m_device->device(), swapchain, NULL); |
| 1418 | m_errorMonitor->VerifyFound(); |
| 1419 | } |
| 1420 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1421 | TEST_F(VkWsiEnabledLayerTest, TestEnabledWsi) { |
| 1422 | VkResult err; |
| 1423 | bool pass; |
| 1424 | |
| 1425 | VkSurfaceKHR surface = VK_NULL_HANDLE; |
| 1426 | #if defined(VK_USE_PLATFORM_XCB_KHR) |
| 1427 | VkSwapchainKHR swapchain = VK_NULL_HANDLE; |
| 1428 | VkSwapchainCreateInfoKHR swapchain_create_info = {}; |
| 1429 | // uint32_t swapchain_image_count = 0; |
| 1430 | // VkImage swapchain_images[1] = {VK_NULL_HANDLE}; |
| 1431 | // uint32_t image_index = 0; |
| 1432 | // VkPresentInfoKHR present_info = {}; |
| 1433 | |
| 1434 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1435 | |
| 1436 | // Use the create function from one of the VK_KHR_*_surface extension in |
| 1437 | // order to create a surface, testing all known errors in the process, |
| 1438 | // before successfully creating a surface: |
| 1439 | // First, try to create a surface without a VkXcbSurfaceCreateInfoKHR: |
| 1440 | m_errorMonitor->SetDesiredFailureMsg( |
| 1441 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1442 | "called with NULL pointer"); |
| 1443 | err = vkCreateXcbSurfaceKHR(instance(), NULL, NULL, &surface); |
| 1444 | pass = (err != VK_SUCCESS); |
| 1445 | ASSERT_TRUE(pass); |
| 1446 | m_errorMonitor->VerifyFound(); |
| 1447 | |
| 1448 | // Next, try to create a surface with the wrong |
| 1449 | // VkXcbSurfaceCreateInfoKHR::sType: |
| 1450 | VkXcbSurfaceCreateInfoKHR xcb_create_info = {}; |
| 1451 | xcb_create_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; |
| 1452 | m_errorMonitor->SetDesiredFailureMsg( |
| 1453 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1454 | "called with the wrong value for"); |
| 1455 | err = vkCreateXcbSurfaceKHR(instance(), &xcb_create_info, NULL, &surface); |
| 1456 | pass = (err != VK_SUCCESS); |
| 1457 | ASSERT_TRUE(pass); |
| 1458 | m_errorMonitor->VerifyFound(); |
| 1459 | |
| 1460 | |
| 1461 | // Create a native window, and then correctly create a surface: |
| 1462 | xcb_connection_t *connection; |
| 1463 | xcb_screen_t *screen; |
| 1464 | xcb_window_t xcb_window; |
| 1465 | xcb_intern_atom_reply_t *atom_wm_delete_window; |
| 1466 | |
| 1467 | const xcb_setup_t *setup; |
| 1468 | xcb_screen_iterator_t iter; |
| 1469 | int scr; |
| 1470 | uint32_t value_mask, value_list[32]; |
| 1471 | int width = 1; |
| 1472 | int height = 1; |
| 1473 | |
| 1474 | connection = xcb_connect(NULL, &scr); |
| 1475 | ASSERT_TRUE(connection != NULL); |
| 1476 | setup = xcb_get_setup(connection); |
| 1477 | iter = xcb_setup_roots_iterator(setup); |
| 1478 | while (scr-- > 0) |
| 1479 | xcb_screen_next(&iter); |
| 1480 | screen = iter.data; |
| 1481 | |
| 1482 | xcb_window = xcb_generate_id(connection); |
| 1483 | |
| 1484 | value_mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK; |
| 1485 | value_list[0] = screen->black_pixel; |
| 1486 | value_list[1] = XCB_EVENT_MASK_KEY_RELEASE | XCB_EVENT_MASK_EXPOSURE | |
| 1487 | XCB_EVENT_MASK_STRUCTURE_NOTIFY; |
| 1488 | |
| 1489 | xcb_create_window(connection, XCB_COPY_FROM_PARENT, xcb_window, |
| 1490 | screen->root, 0, 0, width, height, 0, |
| 1491 | XCB_WINDOW_CLASS_INPUT_OUTPUT, screen->root_visual, |
| 1492 | value_mask, value_list); |
| 1493 | |
| 1494 | /* Magic code that will send notification when window is destroyed */ |
| 1495 | xcb_intern_atom_cookie_t cookie = |
| 1496 | xcb_intern_atom(connection, 1, 12, "WM_PROTOCOLS"); |
| 1497 | xcb_intern_atom_reply_t *reply = |
| 1498 | xcb_intern_atom_reply(connection, cookie, 0); |
| 1499 | |
| 1500 | xcb_intern_atom_cookie_t cookie2 = |
| 1501 | xcb_intern_atom(connection, 0, 16, "WM_DELETE_WINDOW"); |
| 1502 | atom_wm_delete_window = |
| 1503 | xcb_intern_atom_reply(connection, cookie2, 0); |
| 1504 | xcb_change_property(connection, XCB_PROP_MODE_REPLACE, xcb_window, |
| 1505 | (*reply).atom, 4, 32, 1, |
| 1506 | &(*atom_wm_delete_window).atom); |
| 1507 | free(reply); |
| 1508 | |
| 1509 | xcb_map_window(connection, xcb_window); |
| 1510 | |
| 1511 | // Force the x/y coordinates to 100,100 results are identical in consecutive |
| 1512 | // runs |
| 1513 | const uint32_t coords[] = {100, 100}; |
| 1514 | xcb_configure_window(connection, xcb_window, |
| 1515 | XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, coords); |
| 1516 | |
| 1517 | |
| 1518 | |
| 1519 | // Finally, try to correctly create a surface: |
| 1520 | xcb_create_info.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR; |
| 1521 | xcb_create_info.pNext = NULL; |
| 1522 | xcb_create_info.flags = 0; |
| 1523 | xcb_create_info.connection = connection; |
| 1524 | xcb_create_info.window = xcb_window; |
| 1525 | err = vkCreateXcbSurfaceKHR(instance(), &xcb_create_info, NULL, &surface); |
| 1526 | pass = (err == VK_SUCCESS); |
| 1527 | ASSERT_TRUE(pass); |
| 1528 | |
| 1529 | |
| 1530 | |
| 1531 | // Check if surface supports presentation: |
| 1532 | |
| 1533 | // 1st, do so without having queried the queue families: |
| 1534 | VkBool32 supported = false; |
| 1535 | // TODO: Get the following error to come out: |
| 1536 | m_errorMonitor->SetDesiredFailureMsg( |
| 1537 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1538 | "called before calling the vkGetPhysicalDeviceQueueFamilyProperties " |
| 1539 | "function"); |
| 1540 | err = vkGetPhysicalDeviceSurfaceSupportKHR(gpu(), 0, surface, &supported); |
| 1541 | pass = (err != VK_SUCCESS); |
| 1542 | // ASSERT_TRUE(pass); |
| 1543 | // m_errorMonitor->VerifyFound(); |
| 1544 | |
| 1545 | // Next, query a queue family index that's too large: |
| 1546 | m_errorMonitor->SetDesiredFailureMsg( |
| 1547 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1548 | "called with a queueFamilyIndex that is too large"); |
| 1549 | err = vkGetPhysicalDeviceSurfaceSupportKHR(gpu(), 100000, surface, &supported); |
| 1550 | pass = (err != VK_SUCCESS); |
| 1551 | ASSERT_TRUE(pass); |
| 1552 | m_errorMonitor->VerifyFound(); |
| 1553 | |
| 1554 | // Finally, do so correctly: |
| 1555 | // FIXME: THIS ISN'T CORRECT--MUST QUERY UNTIL WE FIND A QUEUE FAMILY THAT'S SUPPORTED |
| 1556 | err = vkGetPhysicalDeviceSurfaceSupportKHR(gpu(), 0, surface, &supported); |
| 1557 | pass = (err == VK_SUCCESS); |
| 1558 | ASSERT_TRUE(pass); |
| 1559 | |
| 1560 | |
| 1561 | |
| 1562 | // Before proceeding, try to create a swapchain without having called |
| 1563 | // vkGetPhysicalDeviceSurfaceCapabilitiesKHR(): |
| 1564 | swapchain_create_info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR; |
| 1565 | swapchain_create_info.pNext = NULL; |
| 1566 | swapchain_create_info.flags = 0; |
| 1567 | m_errorMonitor->SetDesiredFailureMsg( |
| 1568 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1569 | "called before calling vkGetPhysicalDeviceSurfaceCapabilitiesKHR()."); |
| 1570 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, |
| 1571 | NULL, &swapchain); |
| 1572 | pass = (err != VK_SUCCESS); |
| 1573 | ASSERT_TRUE(pass); |
| 1574 | m_errorMonitor->VerifyFound(); |
| 1575 | |
| 1576 | |
| 1577 | |
| 1578 | // Get the surface capabilities: |
| 1579 | VkSurfaceCapabilitiesKHR surface_capabilities; |
| 1580 | |
| 1581 | // Do so correctly (only error logged by this entrypoint is if the |
| 1582 | // extension isn't enabled): |
| 1583 | err = vkGetPhysicalDeviceSurfaceCapabilitiesKHR(gpu(), surface, |
| 1584 | &surface_capabilities); |
| 1585 | pass = (err == VK_SUCCESS); |
| 1586 | ASSERT_TRUE(pass); |
| 1587 | |
| 1588 | |
| 1589 | |
| 1590 | // Get the surface formats: |
| 1591 | uint32_t surface_format_count; |
| 1592 | |
| 1593 | // First, try without a pointer to surface_format_count: |
| 1594 | m_errorMonitor->SetDesiredFailureMsg( |
| 1595 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1596 | "called with NULL pointer"); |
| 1597 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, NULL, NULL); |
| 1598 | pass = (err == VK_SUCCESS); |
| 1599 | ASSERT_TRUE(pass); |
| 1600 | m_errorMonitor->VerifyFound(); |
| 1601 | |
| 1602 | // Next, call with a non-NULL pSurfaceFormats, even though we haven't |
| 1603 | // correctly done a 1st try (to get the count): |
| 1604 | m_errorMonitor->SetDesiredFailureMsg( |
| 1605 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1606 | "but no prior positive value has been seen for"); |
| 1607 | surface_format_count = 0; |
| 1608 | vkGetPhysicalDeviceSurfaceFormatsKHR( |
| 1609 | gpu(), |
| 1610 | surface, |
| 1611 | &surface_format_count, |
| 1612 | (VkSurfaceFormatKHR *) &surface_format_count); |
| 1613 | pass = (err == VK_SUCCESS); |
| 1614 | ASSERT_TRUE(pass); |
| 1615 | m_errorMonitor->VerifyFound(); |
| 1616 | |
| 1617 | // Next, correctly do a 1st try (with a NULL pointer to surface_formats): |
| 1618 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, |
| 1619 | &surface_format_count, NULL); |
| 1620 | pass = (err == VK_SUCCESS); |
| 1621 | ASSERT_TRUE(pass); |
| 1622 | |
| 1623 | // Allocate memory for the correct number of VkSurfaceFormatKHR's: |
| 1624 | VkSurfaceFormatKHR *surface_formats = |
| 1625 | (VkSurfaceFormatKHR *)malloc(surface_format_count * |
| 1626 | sizeof(VkSurfaceFormatKHR)); |
| 1627 | |
| 1628 | // Next, do a 2nd try with surface_format_count being set too high: |
| 1629 | surface_format_count += 5; |
| 1630 | m_errorMonitor->SetDesiredFailureMsg( |
| 1631 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1632 | "that is greater than the value"); |
| 1633 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, |
| 1634 | &surface_format_count, |
| 1635 | surface_formats); |
| 1636 | pass = (err == VK_SUCCESS); |
| 1637 | ASSERT_TRUE(pass); |
| 1638 | m_errorMonitor->VerifyFound(); |
| 1639 | |
| 1640 | // Finally, do a correct 1st and 2nd try: |
| 1641 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, |
| 1642 | &surface_format_count, NULL); |
| 1643 | pass = (err == VK_SUCCESS); |
| 1644 | ASSERT_TRUE(pass); |
| 1645 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, |
| 1646 | &surface_format_count, |
| 1647 | surface_formats); |
| 1648 | pass = (err == VK_SUCCESS); |
| 1649 | ASSERT_TRUE(pass); |
| 1650 | |
| 1651 | |
| 1652 | |
| 1653 | // Get the surface present modes: |
| 1654 | uint32_t surface_present_mode_count; |
| 1655 | |
| 1656 | // First, try without a pointer to surface_format_count: |
| 1657 | m_errorMonitor->SetDesiredFailureMsg( |
| 1658 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1659 | "called with NULL pointer"); |
| 1660 | vkGetPhysicalDeviceSurfacePresentModesKHR(gpu(), surface, NULL, NULL); |
| 1661 | pass = (err == VK_SUCCESS); |
| 1662 | ASSERT_TRUE(pass); |
| 1663 | m_errorMonitor->VerifyFound(); |
| 1664 | |
| 1665 | // Next, call with a non-NULL VkPresentModeKHR, even though we haven't |
| 1666 | // correctly done a 1st try (to get the count): |
| 1667 | m_errorMonitor->SetDesiredFailureMsg( |
| 1668 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1669 | "but no prior positive value has been seen for"); |
| 1670 | surface_present_mode_count = 0; |
| 1671 | vkGetPhysicalDeviceSurfacePresentModesKHR( |
| 1672 | gpu(), |
| 1673 | surface, |
| 1674 | &surface_present_mode_count, |
| 1675 | (VkPresentModeKHR *) &surface_present_mode_count); |
| 1676 | pass = (err == VK_SUCCESS); |
| 1677 | ASSERT_TRUE(pass); |
| 1678 | m_errorMonitor->VerifyFound(); |
| 1679 | |
| 1680 | // Next, correctly do a 1st try (with a NULL pointer to surface_formats): |
| 1681 | vkGetPhysicalDeviceSurfacePresentModesKHR(gpu(), surface, |
| 1682 | &surface_present_mode_count, |
| 1683 | NULL); |
| 1684 | pass = (err == VK_SUCCESS); |
| 1685 | ASSERT_TRUE(pass); |
| 1686 | |
| 1687 | // Allocate memory for the correct number of VkSurfaceFormatKHR's: |
| 1688 | VkPresentModeKHR *surface_present_modes = |
| 1689 | (VkPresentModeKHR *)malloc(surface_present_mode_count * |
| 1690 | sizeof(VkPresentModeKHR)); |
| 1691 | |
| 1692 | // Next, do a 2nd try with surface_format_count being set too high: |
| 1693 | surface_present_mode_count += 5; |
| 1694 | m_errorMonitor->SetDesiredFailureMsg( |
| 1695 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1696 | "that is greater than the value"); |
| 1697 | vkGetPhysicalDeviceSurfacePresentModesKHR(gpu(), surface, |
| 1698 | &surface_present_mode_count, |
| 1699 | surface_present_modes); |
| 1700 | pass = (err == VK_SUCCESS); |
| 1701 | ASSERT_TRUE(pass); |
| 1702 | m_errorMonitor->VerifyFound(); |
| 1703 | |
| 1704 | // Finally, do a correct 1st and 2nd try: |
| 1705 | vkGetPhysicalDeviceSurfacePresentModesKHR(gpu(), surface, |
| 1706 | &surface_present_mode_count, |
| 1707 | NULL); |
| 1708 | pass = (err == VK_SUCCESS); |
| 1709 | ASSERT_TRUE(pass); |
| 1710 | vkGetPhysicalDeviceSurfacePresentModesKHR(gpu(), surface, |
| 1711 | &surface_present_mode_count, |
| 1712 | surface_present_modes); |
| 1713 | pass = (err == VK_SUCCESS); |
| 1714 | ASSERT_TRUE(pass); |
| 1715 | |
| 1716 | |
| 1717 | |
| 1718 | // Create a swapchain: |
| 1719 | |
| 1720 | // First, try without a pointer to swapchain_create_info: |
| 1721 | m_errorMonitor->SetDesiredFailureMsg( |
| 1722 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1723 | "called with NULL pointer"); |
| 1724 | err = vkCreateSwapchainKHR(m_device->device(), NULL, NULL, &swapchain); |
| 1725 | pass = (err != VK_SUCCESS); |
| 1726 | ASSERT_TRUE(pass); |
| 1727 | m_errorMonitor->VerifyFound(); |
| 1728 | |
| 1729 | // Next, call with a non-NULL swapchain_create_info, that has the wrong |
| 1730 | // sType: |
| 1731 | swapchain_create_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; |
| 1732 | m_errorMonitor->SetDesiredFailureMsg( |
| 1733 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1734 | "called with the wrong value for"); |
| 1735 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, |
| 1736 | NULL, &swapchain); |
| 1737 | pass = (err != VK_SUCCESS); |
| 1738 | ASSERT_TRUE(pass); |
| 1739 | m_errorMonitor->VerifyFound(); |
| 1740 | |
| 1741 | // Next, call with a NULL swapchain pointer: |
| 1742 | swapchain_create_info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR; |
| 1743 | swapchain_create_info.pNext = NULL; |
| 1744 | swapchain_create_info.flags = 0; |
| 1745 | m_errorMonitor->SetDesiredFailureMsg( |
| 1746 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1747 | "called with NULL pointer"); |
| 1748 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, |
| 1749 | NULL, NULL); |
| 1750 | pass = (err != VK_SUCCESS); |
| 1751 | ASSERT_TRUE(pass); |
| 1752 | m_errorMonitor->VerifyFound(); |
| 1753 | |
| 1754 | // TODO: Enhance swapchain layer so that |
| 1755 | // swapchain_create_info.queueFamilyIndexCount is checked against something? |
| 1756 | |
| 1757 | // Next, call with a queue family index that's too large: |
| 1758 | uint32_t queueFamilyIndex[2] = {100000, 0}; |
| 1759 | swapchain_create_info.imageSharingMode = VK_SHARING_MODE_CONCURRENT; |
| 1760 | swapchain_create_info.queueFamilyIndexCount = 2; |
| 1761 | swapchain_create_info.pQueueFamilyIndices = queueFamilyIndex; |
| 1762 | m_errorMonitor->SetDesiredFailureMsg( |
| 1763 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1764 | "called with a queueFamilyIndex that is too large"); |
| 1765 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, |
| 1766 | NULL, &swapchain); |
| 1767 | pass = (err != VK_SUCCESS); |
| 1768 | ASSERT_TRUE(pass); |
| 1769 | m_errorMonitor->VerifyFound(); |
| 1770 | |
| 1771 | // Next, call a queueFamilyIndexCount that's too small for CONCURRENT: |
| 1772 | swapchain_create_info.imageSharingMode = VK_SHARING_MODE_CONCURRENT; |
| 1773 | swapchain_create_info.queueFamilyIndexCount = 1; |
| 1774 | m_errorMonitor->SetDesiredFailureMsg( |
| 1775 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1776 | "but with a bad value(s) for pCreateInfo->queueFamilyIndexCount or " |
| 1777 | "pCreateInfo->pQueueFamilyIndices)."); |
| 1778 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, |
| 1779 | NULL, &swapchain); |
| 1780 | pass = (err != VK_SUCCESS); |
| 1781 | ASSERT_TRUE(pass); |
| 1782 | m_errorMonitor->VerifyFound(); |
| 1783 | |
| 1784 | // Next, call with an invalid imageSharingMode: |
| 1785 | swapchain_create_info.imageSharingMode = VK_SHARING_MODE_MAX_ENUM; |
| 1786 | swapchain_create_info.queueFamilyIndexCount = 1; |
| 1787 | m_errorMonitor->SetDesiredFailureMsg( |
| 1788 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1789 | "called with a non-supported pCreateInfo->imageSharingMode (i.e."); |
| 1790 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, |
| 1791 | NULL, &swapchain); |
| 1792 | pass = (err != VK_SUCCESS); |
| 1793 | ASSERT_TRUE(pass); |
| 1794 | m_errorMonitor->VerifyFound(); |
| 1795 | // Fix for the future: |
| 1796 | // FIXME: THIS ISN'T CORRECT--MUST QUERY UNTIL WE FIND A QUEUE FAMILY THAT'S SUPPORTED |
| 1797 | swapchain_create_info.queueFamilyIndexCount = 0; |
| 1798 | queueFamilyIndex[0] = 0; |
| 1799 | swapchain_create_info.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 1800 | |
| 1801 | // TODO: CONTINUE TESTING VALIDATION OF vkCreateSwapchainKHR() ... |
| 1802 | |
| 1803 | |
| 1804 | |
| 1805 | // Get the images from a swapchain: |
| 1806 | |
| 1807 | |
| 1808 | |
| 1809 | // Acquire an image from a swapchain: |
| 1810 | |
| 1811 | |
| 1812 | |
| 1813 | // Present an image to a swapchain: |
| 1814 | |
| 1815 | |
| 1816 | |
| 1817 | // Destroy the swapchain: |
| 1818 | |
| 1819 | |
| 1820 | |
| 1821 | // TODOs: |
| 1822 | // |
| 1823 | // - Try destroying the device without first destroying the swapchain |
| 1824 | // |
| 1825 | // - Try destroying the device without first destroying the surface |
| 1826 | // |
| 1827 | // - Try destroying the surface without first destroying the swapchain |
| 1828 | |
| 1829 | |
| 1830 | // Destroy the surface: |
| 1831 | vkDestroySurfaceKHR(instance(), surface, NULL); |
| 1832 | |
| 1833 | |
| 1834 | // Tear down the window: |
| 1835 | xcb_destroy_window(connection, xcb_window); |
| 1836 | xcb_disconnect(connection); |
| 1837 | |
| 1838 | #else // VK_USE_PLATFORM_XCB_KHR |
| 1839 | err = (surface == VK_NULL_HANDLE) ? VK_SUCCESS : VK_SUCCESS; |
| 1840 | pass = (err != VK_SUCCESS); |
| 1841 | ASSERT_TRUE(pass); |
| 1842 | #endif // VK_USE_PLATFORM_XCB_KHR |
| 1843 | } |
| 1844 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1845 | TEST_F(VkLayerTest, MapMemWithoutHostVisibleBit) { |
| 1846 | VkResult err; |
| 1847 | bool pass; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1848 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1849 | m_errorMonitor->SetDesiredFailureMsg( |
| 1850 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1851 | "Mapping Memory without VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT"); |
| 1852 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1853 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1854 | |
| 1855 | // 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] | 1856 | VkImage image; |
| 1857 | VkDeviceMemory mem; |
| 1858 | VkMemoryRequirements mem_reqs; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1859 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1860 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 1861 | const int32_t tex_width = 32; |
| 1862 | const int32_t tex_height = 32; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1863 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1864 | VkImageCreateInfo image_create_info = {}; |
| 1865 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1866 | image_create_info.pNext = NULL; |
| 1867 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1868 | image_create_info.format = tex_format; |
| 1869 | image_create_info.extent.width = tex_width; |
| 1870 | image_create_info.extent.height = tex_height; |
| 1871 | image_create_info.extent.depth = 1; |
| 1872 | image_create_info.mipLevels = 1; |
| 1873 | image_create_info.arrayLayers = 1; |
| 1874 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1875 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1876 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 1877 | image_create_info.flags = 0; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1878 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1879 | VkMemoryAllocateInfo mem_alloc = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1880 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1881 | mem_alloc.pNext = NULL; |
| 1882 | mem_alloc.allocationSize = 0; |
| 1883 | // Introduce failure, do NOT set memProps to |
| 1884 | // VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
| 1885 | mem_alloc.memoryTypeIndex = 1; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1886 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1887 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1888 | ASSERT_VK_SUCCESS(err); |
| 1889 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1890 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1891 | |
Mark Lobodzinski | 2306535 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 1892 | mem_alloc.allocationSize = mem_reqs.size; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1893 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1894 | pass = |
| 1895 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0, |
| 1896 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 1897 | if (!pass) { // If we can't find any unmappable memory this test doesn't |
| 1898 | // make sense |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1899 | vkDestroyImage(m_device->device(), image, NULL); |
Tony Barbour | 02fdc7d | 2015-08-04 16:13:01 -0600 | [diff] [blame] | 1900 | return; |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1901 | } |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 1902 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1903 | // allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1904 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1905 | ASSERT_VK_SUCCESS(err); |
| 1906 | |
| 1907 | // Try to bind free memory that has been freed |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 1908 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1909 | ASSERT_VK_SUCCESS(err); |
| 1910 | |
| 1911 | // Map memory as if to initialize the image |
| 1912 | void *mappedAddress = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1913 | err = vkMapMemory(m_device->device(), mem, 0, VK_WHOLE_SIZE, 0, |
| 1914 | &mappedAddress); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1915 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1916 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1917 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1918 | vkDestroyImage(m_device->device(), image, NULL); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1919 | } |
| 1920 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1921 | TEST_F(VkLayerTest, RebindMemory) { |
| 1922 | VkResult err; |
| 1923 | bool pass; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1924 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1925 | m_errorMonitor->SetDesiredFailureMsg( |
| 1926 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1927 | "which has already been bound to mem object"); |
| 1928 | |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1929 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1930 | |
| 1931 | // 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] | 1932 | VkImage image; |
| 1933 | VkDeviceMemory mem1; |
| 1934 | VkDeviceMemory mem2; |
| 1935 | VkMemoryRequirements mem_reqs; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1936 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1937 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 1938 | const int32_t tex_width = 32; |
| 1939 | const int32_t tex_height = 32; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1940 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1941 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1942 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1943 | image_create_info.pNext = NULL; |
| 1944 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1945 | image_create_info.format = tex_format; |
| 1946 | image_create_info.extent.width = tex_width; |
| 1947 | image_create_info.extent.height = tex_height; |
| 1948 | image_create_info.extent.depth = 1; |
| 1949 | image_create_info.mipLevels = 1; |
| 1950 | image_create_info.arrayLayers = 1; |
| 1951 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1952 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1953 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 1954 | image_create_info.flags = 0; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1955 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1956 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1957 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1958 | mem_alloc.pNext = NULL; |
| 1959 | mem_alloc.allocationSize = 0; |
| 1960 | mem_alloc.memoryTypeIndex = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1961 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1962 | // Introduce failure, do NOT set memProps to |
| 1963 | // VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1964 | mem_alloc.memoryTypeIndex = 1; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1965 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1966 | ASSERT_VK_SUCCESS(err); |
| 1967 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1968 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1969 | |
| 1970 | mem_alloc.allocationSize = mem_reqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1971 | pass = |
| 1972 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 1973 | ASSERT_TRUE(pass); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1974 | |
| 1975 | // allocate 2 memory objects |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1976 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem1); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1977 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1978 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem2); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1979 | ASSERT_VK_SUCCESS(err); |
| 1980 | |
| 1981 | // Bind first memory object to Image object |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 1982 | err = vkBindImageMemory(m_device->device(), image, mem1, 0); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1983 | ASSERT_VK_SUCCESS(err); |
| 1984 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1985 | // Introduce validation failure, try to bind a different memory object to |
| 1986 | // the same image object |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 1987 | err = vkBindImageMemory(m_device->device(), image, mem2, 0); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1988 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1989 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1990 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1991 | vkDestroyImage(m_device->device(), image, NULL); |
| 1992 | vkFreeMemory(m_device->device(), mem1, NULL); |
| 1993 | vkFreeMemory(m_device->device(), mem2, NULL); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1994 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1995 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1996 | TEST_F(VkLayerTest, SubmitSignaledFence) { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1997 | vk_testing::Fence testFence; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1998 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1999 | m_errorMonitor->SetDesiredFailureMsg( |
| 2000 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "submitted in SIGNALED state. Fences " |
| 2001 | "must be reset before being submitted"); |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2002 | |
| 2003 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2004 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2005 | fenceInfo.pNext = NULL; |
| 2006 | fenceInfo.flags = VK_FENCE_CREATE_SIGNALED_BIT; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2007 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2008 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2009 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 2010 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2011 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 2012 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2013 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 2014 | m_stencil_clear_color, NULL); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 2015 | EndCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2016 | |
| 2017 | testFence.init(*m_device, fenceInfo); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2018 | |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2019 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 2020 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2021 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2022 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2023 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 2024 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2025 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2026 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2027 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2028 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 2029 | |
| 2030 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2031 | vkQueueWaitIdle(m_device->m_queue); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2032 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2033 | m_errorMonitor->VerifyFound(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2034 | } |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 2035 | // This is a positive test. We used to expect error in this case but spec now |
| 2036 | // allows it |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2037 | TEST_F(VkLayerTest, ResetUnsignaledFence) { |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 2038 | m_errorMonitor->ExpectSuccess(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2039 | vk_testing::Fence testFence; |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2040 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2041 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2042 | fenceInfo.pNext = NULL; |
| 2043 | |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2044 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2045 | testFence.init(*m_device, fenceInfo); |
Chia-I Wu | d9e8e82 | 2015-07-03 11:45:55 +0800 | [diff] [blame] | 2046 | VkFence fences[1] = {testFence.handle()}; |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 2047 | VkResult result = vkResetFences(m_device->device(), 1, fences); |
| 2048 | ASSERT_VK_SUCCESS(result); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2049 | |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 2050 | m_errorMonitor->VerifyNotFound(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2051 | } |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2052 | |
| 2053 | TEST_F(VkLayerTest, InvalidUsageBits) |
| 2054 | { |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2055 | TEST_DESCRIPTION( |
Karl Schultz | b5bc11e | 2016-05-04 08:36:08 -0600 | [diff] [blame] | 2056 | "Specify wrong usage for image then create conflicting view of image " |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2057 | "Initialize buffer with wrong usage then perform copy expecting errors " |
| 2058 | "from both the image and the buffer (2 calls)"); |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2059 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2060 | "Invalid usage flag for image "); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2061 | |
| 2062 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2063 | VkImageObj image(m_device); |
| 2064 | // Initialize image with USAGE_INPUT_ATTACHMENT |
| 2065 | image.init(128, 128, VK_FORMAT_D32_SFLOAT_S8_UINT, |
Karl Schultz | b5bc11e | 2016-05-04 08:36:08 -0600 | [diff] [blame] | 2066 | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
| 2067 | ASSERT_TRUE(image.initialized()); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2068 | |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2069 | VkImageView dsv; |
| 2070 | VkImageViewCreateInfo dsvci = {}; |
| 2071 | dsvci.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 2072 | dsvci.image = image.handle(); |
| 2073 | dsvci.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 2074 | dsvci.format = VK_FORMAT_D32_SFLOAT_S8_UINT; |
| 2075 | dsvci.subresourceRange.layerCount = 1; |
| 2076 | dsvci.subresourceRange.baseMipLevel = 0; |
| 2077 | dsvci.subresourceRange.levelCount = 1; |
| 2078 | dsvci.subresourceRange.aspectMask = |
| 2079 | VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2080 | |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2081 | // Create a view with depth / stencil aspect for image with different usage |
| 2082 | vkCreateImageView(m_device->device(), &dsvci, NULL, &dsv); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2083 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2084 | m_errorMonitor->VerifyFound(); |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2085 | |
| 2086 | // Initialize buffer with TRANSFER_DST usage |
| 2087 | vk_testing::Buffer buffer; |
| 2088 | VkMemoryPropertyFlags reqs = 0; |
| 2089 | buffer.init_as_dst(*m_device, 128 * 128, reqs); |
| 2090 | VkBufferImageCopy region = {}; |
| 2091 | region.bufferRowLength = 128; |
| 2092 | region.bufferImageHeight = 128; |
| 2093 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 2094 | region.imageSubresource.layerCount = 1; |
| 2095 | region.imageExtent.height = 16; |
| 2096 | region.imageExtent.width = 16; |
| 2097 | region.imageExtent.depth = 1; |
| 2098 | |
| 2099 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2100 | "Invalid usage flag for buffer "); |
| 2101 | // Buffer usage not set to TRANSFER_SRC and image usage not set to |
| 2102 | // TRANSFER_DST |
| 2103 | BeginCommandBuffer(); |
| 2104 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 2105 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 2106 | 1, ®ion); |
| 2107 | m_errorMonitor->VerifyFound(); |
| 2108 | |
| 2109 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2110 | "Invalid usage flag for image "); |
| 2111 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 2112 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 2113 | 1, ®ion); |
| 2114 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2115 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 2116 | #endif // MEM_TRACKER_TESTS |
| 2117 | |
Tobin Ehlis | 4bf96d1 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 2118 | #if OBJ_TRACKER_TESTS |
Mark Lobodzinski | fc5cc66 | 2016-05-02 17:17:41 -0600 | [diff] [blame] | 2119 | |
| 2120 | TEST_F(VkLayerTest, LeakAnObject) { |
| 2121 | VkResult err; |
| 2122 | |
| 2123 | TEST_DESCRIPTION( |
| 2124 | "Create a fence and destroy its device without first destroying the fence."); |
| 2125 | |
| 2126 | // Note that we have to create a new device since destroying the |
| 2127 | // framework's device causes Teardown() to fail and just calling Teardown |
| 2128 | // will destroy the errorMonitor. |
| 2129 | |
| 2130 | m_errorMonitor->SetDesiredFailureMsg( |
| 2131 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2132 | "OBJ ERROR : VK_DEBUG_REPORT_OBJECT_TYPE_FENCE_EXT object"); |
| 2133 | |
| 2134 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2135 | |
| 2136 | const std::vector<VkQueueFamilyProperties> queue_props = |
| 2137 | m_device->queue_props; |
| 2138 | std::vector<VkDeviceQueueCreateInfo> queue_info; |
| 2139 | queue_info.reserve(queue_props.size()); |
| 2140 | std::vector<std::vector<float>> queue_priorities; |
| 2141 | for (uint32_t i = 0; i < (uint32_t)queue_props.size(); i++) { |
| 2142 | VkDeviceQueueCreateInfo qi = {}; |
| 2143 | qi.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO; |
| 2144 | qi.pNext = NULL; |
| 2145 | qi.queueFamilyIndex = i; |
| 2146 | qi.queueCount = queue_props[i].queueCount; |
| 2147 | queue_priorities.emplace_back(qi.queueCount, 0.0f); |
| 2148 | qi.pQueuePriorities = queue_priorities[i].data(); |
| 2149 | queue_info.push_back(qi); |
| 2150 | } |
| 2151 | |
| 2152 | std::vector<const char *> device_layer_names; |
| 2153 | std::vector<const char *> device_extension_names; |
| 2154 | device_layer_names.push_back("VK_LAYER_GOOGLE_threading"); |
| 2155 | device_layer_names.push_back("VK_LAYER_LUNARG_parameter_validation"); |
| 2156 | device_layer_names.push_back("VK_LAYER_LUNARG_object_tracker"); |
| 2157 | device_layer_names.push_back("VK_LAYER_LUNARG_core_validation"); |
| 2158 | device_layer_names.push_back("VK_LAYER_LUNARG_device_limits"); |
| 2159 | device_layer_names.push_back("VK_LAYER_LUNARG_image"); |
| 2160 | device_layer_names.push_back("VK_LAYER_GOOGLE_unique_objects"); |
| 2161 | |
| 2162 | // The sacrificial device object |
| 2163 | VkDevice testDevice; |
| 2164 | VkDeviceCreateInfo device_create_info = {}; |
| 2165 | auto features = m_device->phy().features(); |
| 2166 | device_create_info.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO; |
| 2167 | device_create_info.pNext = NULL; |
| 2168 | device_create_info.queueCreateInfoCount = queue_info.size(); |
| 2169 | device_create_info.pQueueCreateInfos = queue_info.data(); |
| 2170 | device_create_info.enabledLayerCount = device_layer_names.size(); |
| 2171 | device_create_info.ppEnabledLayerNames = device_layer_names.data(); |
| 2172 | device_create_info.pEnabledFeatures = &features; |
| 2173 | err = vkCreateDevice(gpu(), &device_create_info, NULL, &testDevice); |
| 2174 | ASSERT_VK_SUCCESS(err); |
| 2175 | |
| 2176 | VkFence fence; |
| 2177 | VkFenceCreateInfo fence_create_info = {}; |
| 2178 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2179 | fence_create_info.pNext = NULL; |
| 2180 | fence_create_info.flags = 0; |
| 2181 | err = vkCreateFence(testDevice, &fence_create_info, NULL, &fence); |
| 2182 | ASSERT_VK_SUCCESS(err); |
| 2183 | |
| 2184 | // Induce failure by not calling vkDestroyFence |
| 2185 | vkDestroyDevice(testDevice, NULL); |
| 2186 | m_errorMonitor->VerifyFound(); |
| 2187 | } |
| 2188 | |
| 2189 | TEST_F(VkLayerTest, InvalidCommandPoolConsistency) { |
| 2190 | |
| 2191 | TEST_DESCRIPTION("Allocate command buffers from one command pool and " |
| 2192 | "attempt to delete them from another."); |
| 2193 | |
| 2194 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2195 | "FreeCommandBuffers is attempting to free Command Buffer"); |
| 2196 | |
| 2197 | VkCommandPool command_pool_one; |
| 2198 | VkCommandPool command_pool_two; |
| 2199 | |
| 2200 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2201 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2202 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2203 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2204 | |
| 2205 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2206 | &command_pool_one); |
| 2207 | |
| 2208 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2209 | &command_pool_two); |
| 2210 | |
| 2211 | VkCommandBuffer command_buffer[9]; |
| 2212 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2213 | command_buffer_allocate_info.sType = |
| 2214 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2215 | command_buffer_allocate_info.commandPool = command_pool_one; |
| 2216 | command_buffer_allocate_info.commandBufferCount = 9; |
| 2217 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2218 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2219 | command_buffer); |
| 2220 | |
| 2221 | vkFreeCommandBuffers(m_device->device(), command_pool_two, 4, |
| 2222 | &command_buffer[3]); |
| 2223 | |
| 2224 | m_errorMonitor->VerifyFound(); |
| 2225 | |
| 2226 | vkDestroyCommandPool(m_device->device(), command_pool_one, NULL); |
| 2227 | vkDestroyCommandPool(m_device->device(), command_pool_two, NULL); |
| 2228 | } |
| 2229 | |
| 2230 | TEST_F(VkLayerTest, InvalidDescriptorPoolConsistency) { |
| 2231 | VkResult err; |
| 2232 | |
| 2233 | TEST_DESCRIPTION("Allocate descriptor sets from one DS pool and " |
| 2234 | "attempt to delete them from another."); |
| 2235 | |
| 2236 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2237 | "FreeDescriptorSets is attempting to free descriptorSet"); |
| 2238 | |
| 2239 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2240 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2241 | |
| 2242 | VkDescriptorPoolSize ds_type_count = {}; |
| 2243 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 2244 | ds_type_count.descriptorCount = 1; |
| 2245 | |
| 2246 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2247 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2248 | ds_pool_ci.pNext = NULL; |
| 2249 | ds_pool_ci.flags = 0; |
| 2250 | ds_pool_ci.maxSets = 1; |
| 2251 | ds_pool_ci.poolSizeCount = 1; |
| 2252 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 2253 | |
| 2254 | VkDescriptorPool ds_pool_one; |
| 2255 | err = |
| 2256 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool_one); |
| 2257 | ASSERT_VK_SUCCESS(err); |
| 2258 | |
| 2259 | // Create a second descriptor pool |
| 2260 | VkDescriptorPool ds_pool_two; |
| 2261 | err = |
| 2262 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool_two); |
| 2263 | ASSERT_VK_SUCCESS(err); |
| 2264 | |
| 2265 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 2266 | dsl_binding.binding = 0; |
| 2267 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 2268 | dsl_binding.descriptorCount = 1; |
| 2269 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2270 | dsl_binding.pImmutableSamplers = NULL; |
| 2271 | |
| 2272 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2273 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2274 | ds_layout_ci.pNext = NULL; |
| 2275 | ds_layout_ci.bindingCount = 1; |
| 2276 | ds_layout_ci.pBindings = &dsl_binding; |
| 2277 | |
| 2278 | VkDescriptorSetLayout ds_layout; |
| 2279 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2280 | &ds_layout); |
| 2281 | ASSERT_VK_SUCCESS(err); |
| 2282 | |
| 2283 | VkDescriptorSet descriptorSet; |
| 2284 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 2285 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 2286 | alloc_info.descriptorSetCount = 1; |
| 2287 | alloc_info.descriptorPool = ds_pool_one; |
| 2288 | alloc_info.pSetLayouts = &ds_layout; |
| 2289 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 2290 | &descriptorSet); |
| 2291 | ASSERT_VK_SUCCESS(err); |
| 2292 | |
| 2293 | err = vkFreeDescriptorSets(m_device->device(), ds_pool_two, 1, &descriptorSet); |
| 2294 | |
| 2295 | m_errorMonitor->VerifyFound(); |
| 2296 | |
| 2297 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2298 | vkDestroyDescriptorPool(m_device->device(), ds_pool_one, NULL); |
| 2299 | vkDestroyDescriptorPool(m_device->device(), ds_pool_two, NULL); |
| 2300 | } |
| 2301 | |
| 2302 | TEST_F(VkLayerTest, CreateUnknownObject) { |
| 2303 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2304 | "Invalid VkImage Object "); |
| 2305 | |
| 2306 | TEST_DESCRIPTION( |
| 2307 | "Pass an invalid image object handle into a Vulkan API call."); |
| 2308 | |
| 2309 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2310 | |
| 2311 | // Pass bogus handle into GetImageMemoryRequirements |
| 2312 | VkMemoryRequirements mem_reqs; |
| 2313 | uint64_t fakeImageHandle = 0xCADECADE; |
| 2314 | VkImage fauxImage = reinterpret_cast<VkImage &>(fakeImageHandle); |
| 2315 | |
| 2316 | vkGetImageMemoryRequirements(m_device->device(), fauxImage, &mem_reqs); |
| 2317 | |
| 2318 | m_errorMonitor->VerifyFound(); |
| 2319 | } |
| 2320 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2321 | TEST_F(VkLayerTest, PipelineNotBound) { |
| 2322 | VkResult err; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2323 | |
Mark Lobodzinski | fc5cc66 | 2016-05-02 17:17:41 -0600 | [diff] [blame] | 2324 | TEST_DESCRIPTION( |
| 2325 | "Pass in an invalid pipeline object handle into a Vulkan API call."); |
| 2326 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2327 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2328 | "Invalid VkPipeline Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2329 | |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2330 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2331 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2332 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2333 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2334 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2335 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2336 | |
| 2337 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2338 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2339 | ds_pool_ci.pNext = NULL; |
| 2340 | ds_pool_ci.maxSets = 1; |
| 2341 | ds_pool_ci.poolSizeCount = 1; |
| 2342 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2343 | |
| 2344 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2345 | err = |
| 2346 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2347 | ASSERT_VK_SUCCESS(err); |
| 2348 | |
| 2349 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2350 | dsl_binding.binding = 0; |
| 2351 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2352 | dsl_binding.descriptorCount = 1; |
| 2353 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2354 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2355 | |
| 2356 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2357 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2358 | ds_layout_ci.pNext = NULL; |
| 2359 | ds_layout_ci.bindingCount = 1; |
| 2360 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2361 | |
| 2362 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2363 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2364 | &ds_layout); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2365 | ASSERT_VK_SUCCESS(err); |
| 2366 | |
| 2367 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2368 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2369 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2370 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2371 | alloc_info.descriptorPool = ds_pool; |
| 2372 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2373 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 2374 | &descriptorSet); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2375 | ASSERT_VK_SUCCESS(err); |
| 2376 | |
| 2377 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2378 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 2379 | pipeline_layout_ci.pNext = NULL; |
| 2380 | pipeline_layout_ci.setLayoutCount = 1; |
| 2381 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2382 | |
| 2383 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2384 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2385 | &pipeline_layout); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2386 | ASSERT_VK_SUCCESS(err); |
| 2387 | |
Mark Young | ad77905 | 2016-01-06 14:26:04 -0700 | [diff] [blame] | 2388 | VkPipeline badPipeline = (VkPipeline)((size_t)0xbaadb1be); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2389 | |
| 2390 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2391 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 2392 | VK_PIPELINE_BIND_POINT_GRAPHICS, badPipeline); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2393 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2394 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2395 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2396 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2397 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2398 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2399 | } |
| 2400 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2401 | TEST_F(VkLayerTest, BindInvalidMemory) { |
| 2402 | VkResult err; |
| 2403 | bool pass; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2404 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2405 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2406 | "Invalid VkDeviceMemory Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2407 | |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2408 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2409 | |
| 2410 | // 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] | 2411 | VkImage image; |
| 2412 | VkDeviceMemory mem; |
| 2413 | VkMemoryRequirements mem_reqs; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2414 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2415 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2416 | const int32_t tex_width = 32; |
| 2417 | const int32_t tex_height = 32; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2418 | |
| 2419 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2420 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 2421 | image_create_info.pNext = NULL; |
| 2422 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2423 | image_create_info.format = tex_format; |
| 2424 | image_create_info.extent.width = tex_width; |
| 2425 | image_create_info.extent.height = tex_height; |
| 2426 | image_create_info.extent.depth = 1; |
| 2427 | image_create_info.mipLevels = 1; |
| 2428 | image_create_info.arrayLayers = 1; |
| 2429 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 2430 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 2431 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 2432 | image_create_info.flags = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2433 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2434 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2435 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 2436 | mem_alloc.pNext = NULL; |
| 2437 | mem_alloc.allocationSize = 0; |
| 2438 | mem_alloc.memoryTypeIndex = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2439 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2440 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2441 | ASSERT_VK_SUCCESS(err); |
| 2442 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2443 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2444 | |
| 2445 | mem_alloc.allocationSize = mem_reqs.size; |
| 2446 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2447 | pass = |
| 2448 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 2449 | ASSERT_TRUE(pass); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2450 | |
| 2451 | // allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2452 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2453 | ASSERT_VK_SUCCESS(err); |
| 2454 | |
| 2455 | // Introduce validation failure, free memory before binding |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2456 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2457 | |
| 2458 | // Try to bind free memory that has been freed |
| 2459 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 2460 | // This may very well return an error. |
| 2461 | (void)err; |
| 2462 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2463 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2464 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2465 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2466 | } |
| 2467 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2468 | TEST_F(VkLayerTest, BindMemoryToDestroyedObject) { |
| 2469 | VkResult err; |
| 2470 | bool pass; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2471 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2472 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2473 | "Invalid VkImage Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2474 | |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2475 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2476 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2477 | // Create an image object, allocate memory, destroy the object and then try |
| 2478 | // to bind it |
| 2479 | VkImage image; |
| 2480 | VkDeviceMemory mem; |
| 2481 | VkMemoryRequirements mem_reqs; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2482 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2483 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2484 | const int32_t tex_width = 32; |
| 2485 | const int32_t tex_height = 32; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2486 | |
| 2487 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2488 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 2489 | image_create_info.pNext = NULL; |
| 2490 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2491 | image_create_info.format = tex_format; |
| 2492 | image_create_info.extent.width = tex_width; |
| 2493 | image_create_info.extent.height = tex_height; |
| 2494 | image_create_info.extent.depth = 1; |
| 2495 | image_create_info.mipLevels = 1; |
| 2496 | image_create_info.arrayLayers = 1; |
| 2497 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 2498 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 2499 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 2500 | image_create_info.flags = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2501 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2502 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2503 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 2504 | mem_alloc.pNext = NULL; |
| 2505 | mem_alloc.allocationSize = 0; |
| 2506 | mem_alloc.memoryTypeIndex = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2507 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2508 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2509 | ASSERT_VK_SUCCESS(err); |
| 2510 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2511 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2512 | |
| 2513 | mem_alloc.allocationSize = mem_reqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2514 | pass = |
| 2515 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 2516 | ASSERT_TRUE(pass); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2517 | |
| 2518 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2519 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2520 | ASSERT_VK_SUCCESS(err); |
| 2521 | |
| 2522 | // Introduce validation failure, destroy Image object before binding |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2523 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2524 | ASSERT_VK_SUCCESS(err); |
| 2525 | |
| 2526 | // Now Try to bind memory to this destroyed object |
| 2527 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 2528 | // This may very well return an error. |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2529 | (void)err; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2530 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2531 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2532 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2533 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2534 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 2535 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 2536 | #endif // OBJ_TRACKER_TESTS |
| 2537 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 2538 | #if DRAW_STATE_TESTS |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 2539 | |
| 2540 | // This is a positive test. No errors should be generated. |
| 2541 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceQWI) { |
| 2542 | |
| 2543 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 2544 | "submitted on separate queues followed by a QueueWaitIdle."); |
| 2545 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 2546 | if ((m_device->queue_props.empty()) || |
| 2547 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 2548 | return; |
| 2549 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 2550 | m_errorMonitor->ExpectSuccess(); |
| 2551 | |
| 2552 | VkSemaphore semaphore; |
| 2553 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 2554 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 2555 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 2556 | &semaphore); |
| 2557 | |
| 2558 | VkCommandPool command_pool; |
| 2559 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2560 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2561 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2562 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2563 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2564 | &command_pool); |
| 2565 | |
| 2566 | VkCommandBuffer command_buffer[2]; |
| 2567 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2568 | command_buffer_allocate_info.sType = |
| 2569 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2570 | command_buffer_allocate_info.commandPool = command_pool; |
| 2571 | command_buffer_allocate_info.commandBufferCount = 2; |
| 2572 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2573 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2574 | command_buffer); |
| 2575 | |
| 2576 | VkQueue queue = VK_NULL_HANDLE; |
| 2577 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 2578 | 1, &queue); |
| 2579 | |
| 2580 | { |
| 2581 | VkCommandBufferBeginInfo begin_info{}; |
| 2582 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2583 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2584 | |
| 2585 | vkCmdPipelineBarrier(command_buffer[0], |
| 2586 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2587 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 2588 | 0, nullptr, 0, nullptr); |
| 2589 | |
| 2590 | VkViewport viewport{}; |
| 2591 | viewport.maxDepth = 1.0f; |
| 2592 | viewport.minDepth = 0.0f; |
| 2593 | viewport.width = 512; |
| 2594 | viewport.height = 512; |
| 2595 | viewport.x = 0; |
| 2596 | viewport.y = 0; |
| 2597 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 2598 | vkEndCommandBuffer(command_buffer[0]); |
| 2599 | } |
| 2600 | { |
| 2601 | VkCommandBufferBeginInfo begin_info{}; |
| 2602 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2603 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 2604 | |
| 2605 | VkViewport viewport{}; |
| 2606 | viewport.maxDepth = 1.0f; |
| 2607 | viewport.minDepth = 0.0f; |
| 2608 | viewport.width = 512; |
| 2609 | viewport.height = 512; |
| 2610 | viewport.x = 0; |
| 2611 | viewport.y = 0; |
| 2612 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 2613 | vkEndCommandBuffer(command_buffer[1]); |
| 2614 | } |
| 2615 | { |
| 2616 | VkSubmitInfo submit_info{}; |
| 2617 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2618 | submit_info.commandBufferCount = 1; |
| 2619 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 2620 | submit_info.signalSemaphoreCount = 1; |
| 2621 | submit_info.pSignalSemaphores = &semaphore; |
| 2622 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2623 | } |
| 2624 | { |
| 2625 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 2626 | VkSubmitInfo submit_info{}; |
| 2627 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2628 | submit_info.commandBufferCount = 1; |
| 2629 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 2630 | submit_info.waitSemaphoreCount = 1; |
| 2631 | submit_info.pWaitSemaphores = &semaphore; |
| 2632 | submit_info.pWaitDstStageMask = flags; |
| 2633 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2634 | } |
| 2635 | |
| 2636 | vkQueueWaitIdle(m_device->m_queue); |
| 2637 | |
| 2638 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 2639 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 2640 | &command_buffer[0]); |
| 2641 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2642 | |
| 2643 | m_errorMonitor->VerifyNotFound(); |
| 2644 | } |
| 2645 | |
| 2646 | // This is a positive test. No errors should be generated. |
| 2647 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceQWIFence) { |
| 2648 | |
| 2649 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 2650 | "submitted on separate queues, the second having a fence" |
| 2651 | "followed by a QueueWaitIdle."); |
| 2652 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 2653 | if ((m_device->queue_props.empty()) || |
| 2654 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 2655 | return; |
| 2656 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 2657 | m_errorMonitor->ExpectSuccess(); |
| 2658 | |
| 2659 | VkFence fence; |
| 2660 | VkFenceCreateInfo fence_create_info{}; |
| 2661 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2662 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 2663 | |
| 2664 | VkSemaphore semaphore; |
| 2665 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 2666 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 2667 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 2668 | &semaphore); |
| 2669 | |
| 2670 | VkCommandPool command_pool; |
| 2671 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2672 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2673 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2674 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2675 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2676 | &command_pool); |
| 2677 | |
| 2678 | VkCommandBuffer command_buffer[2]; |
| 2679 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2680 | command_buffer_allocate_info.sType = |
| 2681 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2682 | command_buffer_allocate_info.commandPool = command_pool; |
| 2683 | command_buffer_allocate_info.commandBufferCount = 2; |
| 2684 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2685 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2686 | command_buffer); |
| 2687 | |
| 2688 | VkQueue queue = VK_NULL_HANDLE; |
| 2689 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 2690 | 1, &queue); |
| 2691 | |
| 2692 | { |
| 2693 | VkCommandBufferBeginInfo begin_info{}; |
| 2694 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2695 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2696 | |
| 2697 | vkCmdPipelineBarrier(command_buffer[0], |
| 2698 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2699 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 2700 | 0, nullptr, 0, nullptr); |
| 2701 | |
| 2702 | VkViewport viewport{}; |
| 2703 | viewport.maxDepth = 1.0f; |
| 2704 | viewport.minDepth = 0.0f; |
| 2705 | viewport.width = 512; |
| 2706 | viewport.height = 512; |
| 2707 | viewport.x = 0; |
| 2708 | viewport.y = 0; |
| 2709 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 2710 | vkEndCommandBuffer(command_buffer[0]); |
| 2711 | } |
| 2712 | { |
| 2713 | VkCommandBufferBeginInfo begin_info{}; |
| 2714 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2715 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 2716 | |
| 2717 | VkViewport viewport{}; |
| 2718 | viewport.maxDepth = 1.0f; |
| 2719 | viewport.minDepth = 0.0f; |
| 2720 | viewport.width = 512; |
| 2721 | viewport.height = 512; |
| 2722 | viewport.x = 0; |
| 2723 | viewport.y = 0; |
| 2724 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 2725 | vkEndCommandBuffer(command_buffer[1]); |
| 2726 | } |
| 2727 | { |
| 2728 | VkSubmitInfo submit_info{}; |
| 2729 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2730 | submit_info.commandBufferCount = 1; |
| 2731 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 2732 | submit_info.signalSemaphoreCount = 1; |
| 2733 | submit_info.pSignalSemaphores = &semaphore; |
| 2734 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2735 | } |
| 2736 | { |
| 2737 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 2738 | VkSubmitInfo submit_info{}; |
| 2739 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2740 | submit_info.commandBufferCount = 1; |
| 2741 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 2742 | submit_info.waitSemaphoreCount = 1; |
| 2743 | submit_info.pWaitSemaphores = &semaphore; |
| 2744 | submit_info.pWaitDstStageMask = flags; |
| 2745 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 2746 | } |
| 2747 | |
| 2748 | vkQueueWaitIdle(m_device->m_queue); |
| 2749 | |
| 2750 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 2751 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 2752 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 2753 | &command_buffer[0]); |
| 2754 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2755 | |
| 2756 | m_errorMonitor->VerifyNotFound(); |
| 2757 | } |
| 2758 | |
| 2759 | // This is a positive test. No errors should be generated. |
| 2760 | TEST_F(VkLayerTest, |
| 2761 | TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceTwoWFF) { |
| 2762 | |
| 2763 | TEST_DESCRIPTION( |
| 2764 | "Two command buffers, each in a separate QueueSubmit call " |
| 2765 | "submitted on separate queues, the second having a fence" |
| 2766 | "followed by two consecutive WaitForFences calls on the same fence."); |
| 2767 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 2768 | if ((m_device->queue_props.empty()) || |
| 2769 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 2770 | return; |
| 2771 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 2772 | m_errorMonitor->ExpectSuccess(); |
| 2773 | |
| 2774 | VkFence fence; |
| 2775 | VkFenceCreateInfo fence_create_info{}; |
| 2776 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2777 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 2778 | |
| 2779 | VkSemaphore semaphore; |
| 2780 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 2781 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 2782 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 2783 | &semaphore); |
| 2784 | |
| 2785 | VkCommandPool command_pool; |
| 2786 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2787 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2788 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2789 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2790 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2791 | &command_pool); |
| 2792 | |
| 2793 | VkCommandBuffer command_buffer[2]; |
| 2794 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2795 | command_buffer_allocate_info.sType = |
| 2796 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2797 | command_buffer_allocate_info.commandPool = command_pool; |
| 2798 | command_buffer_allocate_info.commandBufferCount = 2; |
| 2799 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2800 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2801 | command_buffer); |
| 2802 | |
| 2803 | VkQueue queue = VK_NULL_HANDLE; |
| 2804 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 2805 | 1, &queue); |
| 2806 | |
| 2807 | { |
| 2808 | VkCommandBufferBeginInfo begin_info{}; |
| 2809 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2810 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2811 | |
| 2812 | vkCmdPipelineBarrier(command_buffer[0], |
| 2813 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2814 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 2815 | 0, nullptr, 0, nullptr); |
| 2816 | |
| 2817 | VkViewport viewport{}; |
| 2818 | viewport.maxDepth = 1.0f; |
| 2819 | viewport.minDepth = 0.0f; |
| 2820 | viewport.width = 512; |
| 2821 | viewport.height = 512; |
| 2822 | viewport.x = 0; |
| 2823 | viewport.y = 0; |
| 2824 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 2825 | vkEndCommandBuffer(command_buffer[0]); |
| 2826 | } |
| 2827 | { |
| 2828 | VkCommandBufferBeginInfo begin_info{}; |
| 2829 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2830 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 2831 | |
| 2832 | VkViewport viewport{}; |
| 2833 | viewport.maxDepth = 1.0f; |
| 2834 | viewport.minDepth = 0.0f; |
| 2835 | viewport.width = 512; |
| 2836 | viewport.height = 512; |
| 2837 | viewport.x = 0; |
| 2838 | viewport.y = 0; |
| 2839 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 2840 | vkEndCommandBuffer(command_buffer[1]); |
| 2841 | } |
| 2842 | { |
| 2843 | VkSubmitInfo submit_info{}; |
| 2844 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2845 | submit_info.commandBufferCount = 1; |
| 2846 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 2847 | submit_info.signalSemaphoreCount = 1; |
| 2848 | submit_info.pSignalSemaphores = &semaphore; |
| 2849 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2850 | } |
| 2851 | { |
| 2852 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 2853 | VkSubmitInfo submit_info{}; |
| 2854 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2855 | submit_info.commandBufferCount = 1; |
| 2856 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 2857 | submit_info.waitSemaphoreCount = 1; |
| 2858 | submit_info.pWaitSemaphores = &semaphore; |
| 2859 | submit_info.pWaitDstStageMask = flags; |
| 2860 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 2861 | } |
| 2862 | |
| 2863 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 2864 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 2865 | |
| 2866 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 2867 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 2868 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 2869 | &command_buffer[0]); |
| 2870 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2871 | |
| 2872 | m_errorMonitor->VerifyNotFound(); |
| 2873 | } |
| 2874 | |
| 2875 | // This is a positive test. No errors should be generated. |
| 2876 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFence) { |
| 2877 | |
| 2878 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 2879 | "submitted on separate queues, the second having a fence, " |
| 2880 | "followed by a WaitForFences call."); |
| 2881 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 2882 | if ((m_device->queue_props.empty()) || |
| 2883 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 2884 | return; |
| 2885 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 2886 | m_errorMonitor->ExpectSuccess(); |
| 2887 | |
| 2888 | VkFence fence; |
| 2889 | VkFenceCreateInfo fence_create_info{}; |
| 2890 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2891 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 2892 | |
| 2893 | VkSemaphore semaphore; |
| 2894 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 2895 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 2896 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 2897 | &semaphore); |
| 2898 | |
| 2899 | VkCommandPool command_pool; |
| 2900 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2901 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2902 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2903 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2904 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2905 | &command_pool); |
| 2906 | |
| 2907 | VkCommandBuffer command_buffer[2]; |
| 2908 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2909 | command_buffer_allocate_info.sType = |
| 2910 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2911 | command_buffer_allocate_info.commandPool = command_pool; |
| 2912 | command_buffer_allocate_info.commandBufferCount = 2; |
| 2913 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2914 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2915 | command_buffer); |
| 2916 | |
| 2917 | VkQueue queue = VK_NULL_HANDLE; |
| 2918 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 2919 | 1, &queue); |
| 2920 | |
| 2921 | |
| 2922 | { |
| 2923 | VkCommandBufferBeginInfo begin_info{}; |
| 2924 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2925 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2926 | |
| 2927 | vkCmdPipelineBarrier(command_buffer[0], |
| 2928 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2929 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 2930 | 0, nullptr, 0, nullptr); |
| 2931 | |
| 2932 | VkViewport viewport{}; |
| 2933 | viewport.maxDepth = 1.0f; |
| 2934 | viewport.minDepth = 0.0f; |
| 2935 | viewport.width = 512; |
| 2936 | viewport.height = 512; |
| 2937 | viewport.x = 0; |
| 2938 | viewport.y = 0; |
| 2939 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 2940 | vkEndCommandBuffer(command_buffer[0]); |
| 2941 | } |
| 2942 | { |
| 2943 | VkCommandBufferBeginInfo begin_info{}; |
| 2944 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2945 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 2946 | |
| 2947 | VkViewport viewport{}; |
| 2948 | viewport.maxDepth = 1.0f; |
| 2949 | viewport.minDepth = 0.0f; |
| 2950 | viewport.width = 512; |
| 2951 | viewport.height = 512; |
| 2952 | viewport.x = 0; |
| 2953 | viewport.y = 0; |
| 2954 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 2955 | vkEndCommandBuffer(command_buffer[1]); |
| 2956 | } |
| 2957 | { |
| 2958 | VkSubmitInfo submit_info{}; |
| 2959 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2960 | submit_info.commandBufferCount = 1; |
| 2961 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 2962 | submit_info.signalSemaphoreCount = 1; |
| 2963 | submit_info.pSignalSemaphores = &semaphore; |
| 2964 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2965 | } |
| 2966 | { |
| 2967 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 2968 | VkSubmitInfo submit_info{}; |
| 2969 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2970 | submit_info.commandBufferCount = 1; |
| 2971 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 2972 | submit_info.waitSemaphoreCount = 1; |
| 2973 | submit_info.pWaitSemaphores = &semaphore; |
| 2974 | submit_info.pWaitDstStageMask = flags; |
| 2975 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 2976 | } |
| 2977 | |
| 2978 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 2979 | |
| 2980 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 2981 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 2982 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 2983 | &command_buffer[0]); |
| 2984 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2985 | |
| 2986 | m_errorMonitor->VerifyNotFound(); |
| 2987 | } |
| 2988 | |
| 2989 | // This is a positive test. No errors should be generated. |
| 2990 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueWithSemaphoreAndOneFence) { |
| 2991 | |
| 2992 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 2993 | "on the same queue, sharing a signal/wait semaphore, the " |
| 2994 | "second having a fence, " |
| 2995 | "followed by a WaitForFences call."); |
| 2996 | |
| 2997 | m_errorMonitor->ExpectSuccess(); |
| 2998 | |
| 2999 | VkFence fence; |
| 3000 | VkFenceCreateInfo fence_create_info{}; |
| 3001 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3002 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3003 | |
| 3004 | VkSemaphore semaphore; |
| 3005 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 3006 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 3007 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 3008 | &semaphore); |
| 3009 | |
| 3010 | VkCommandPool command_pool; |
| 3011 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3012 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3013 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3014 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3015 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3016 | &command_pool); |
| 3017 | |
| 3018 | VkCommandBuffer command_buffer[2]; |
| 3019 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3020 | command_buffer_allocate_info.sType = |
| 3021 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3022 | command_buffer_allocate_info.commandPool = command_pool; |
| 3023 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3024 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3025 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3026 | command_buffer); |
| 3027 | |
| 3028 | { |
| 3029 | VkCommandBufferBeginInfo begin_info{}; |
| 3030 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3031 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3032 | |
| 3033 | vkCmdPipelineBarrier(command_buffer[0], |
| 3034 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3035 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3036 | 0, nullptr, 0, nullptr); |
| 3037 | |
| 3038 | VkViewport viewport{}; |
| 3039 | viewport.maxDepth = 1.0f; |
| 3040 | viewport.minDepth = 0.0f; |
| 3041 | viewport.width = 512; |
| 3042 | viewport.height = 512; |
| 3043 | viewport.x = 0; |
| 3044 | viewport.y = 0; |
| 3045 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3046 | vkEndCommandBuffer(command_buffer[0]); |
| 3047 | } |
| 3048 | { |
| 3049 | VkCommandBufferBeginInfo begin_info{}; |
| 3050 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3051 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3052 | |
| 3053 | VkViewport viewport{}; |
| 3054 | viewport.maxDepth = 1.0f; |
| 3055 | viewport.minDepth = 0.0f; |
| 3056 | viewport.width = 512; |
| 3057 | viewport.height = 512; |
| 3058 | viewport.x = 0; |
| 3059 | viewport.y = 0; |
| 3060 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3061 | vkEndCommandBuffer(command_buffer[1]); |
| 3062 | } |
| 3063 | { |
| 3064 | VkSubmitInfo submit_info{}; |
| 3065 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3066 | submit_info.commandBufferCount = 1; |
| 3067 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3068 | submit_info.signalSemaphoreCount = 1; |
| 3069 | submit_info.pSignalSemaphores = &semaphore; |
| 3070 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3071 | } |
| 3072 | { |
| 3073 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3074 | VkSubmitInfo submit_info{}; |
| 3075 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3076 | submit_info.commandBufferCount = 1; |
| 3077 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3078 | submit_info.waitSemaphoreCount = 1; |
| 3079 | submit_info.pWaitSemaphores = &semaphore; |
| 3080 | submit_info.pWaitDstStageMask = flags; |
| 3081 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 3082 | } |
| 3083 | |
| 3084 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3085 | |
| 3086 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3087 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 3088 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3089 | &command_buffer[0]); |
| 3090 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3091 | |
| 3092 | m_errorMonitor->VerifyNotFound(); |
| 3093 | } |
| 3094 | |
| 3095 | // This is a positive test. No errors should be generated. |
| 3096 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueNullQueueSubmitWithFence) { |
| 3097 | |
| 3098 | TEST_DESCRIPTION( |
| 3099 | "Two command buffers, each in a separate QueueSubmit call " |
| 3100 | "on the same queue, no fences, followed by a third QueueSubmit with NO " |
| 3101 | "SubmitInfos but with a fence, followed by a WaitForFences call."); |
| 3102 | |
| 3103 | m_errorMonitor->ExpectSuccess(); |
| 3104 | |
| 3105 | VkFence fence; |
| 3106 | VkFenceCreateInfo fence_create_info{}; |
| 3107 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3108 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3109 | |
| 3110 | VkCommandPool command_pool; |
| 3111 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3112 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3113 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3114 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3115 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3116 | &command_pool); |
| 3117 | |
| 3118 | VkCommandBuffer command_buffer[2]; |
| 3119 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3120 | command_buffer_allocate_info.sType = |
| 3121 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3122 | command_buffer_allocate_info.commandPool = command_pool; |
| 3123 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3124 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3125 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3126 | command_buffer); |
| 3127 | |
| 3128 | { |
| 3129 | VkCommandBufferBeginInfo begin_info{}; |
| 3130 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3131 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3132 | |
| 3133 | vkCmdPipelineBarrier(command_buffer[0], |
| 3134 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3135 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3136 | 0, nullptr, 0, nullptr); |
| 3137 | |
| 3138 | VkViewport viewport{}; |
| 3139 | viewport.maxDepth = 1.0f; |
| 3140 | viewport.minDepth = 0.0f; |
| 3141 | viewport.width = 512; |
| 3142 | viewport.height = 512; |
| 3143 | viewport.x = 0; |
| 3144 | viewport.y = 0; |
| 3145 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3146 | vkEndCommandBuffer(command_buffer[0]); |
| 3147 | } |
| 3148 | { |
| 3149 | VkCommandBufferBeginInfo begin_info{}; |
| 3150 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3151 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3152 | |
| 3153 | VkViewport viewport{}; |
| 3154 | viewport.maxDepth = 1.0f; |
| 3155 | viewport.minDepth = 0.0f; |
| 3156 | viewport.width = 512; |
| 3157 | viewport.height = 512; |
| 3158 | viewport.x = 0; |
| 3159 | viewport.y = 0; |
| 3160 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3161 | vkEndCommandBuffer(command_buffer[1]); |
| 3162 | } |
| 3163 | { |
| 3164 | VkSubmitInfo submit_info{}; |
| 3165 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3166 | submit_info.commandBufferCount = 1; |
| 3167 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3168 | submit_info.signalSemaphoreCount = 0; |
| 3169 | submit_info.pSignalSemaphores = VK_NULL_HANDLE; |
| 3170 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3171 | } |
| 3172 | { |
| 3173 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3174 | VkSubmitInfo submit_info{}; |
| 3175 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3176 | submit_info.commandBufferCount = 1; |
| 3177 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3178 | submit_info.waitSemaphoreCount = 0; |
| 3179 | submit_info.pWaitSemaphores = VK_NULL_HANDLE; |
| 3180 | submit_info.pWaitDstStageMask = flags; |
| 3181 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3182 | } |
| 3183 | |
| 3184 | vkQueueSubmit(m_device->m_queue, 0, NULL, fence); |
| 3185 | |
| 3186 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3187 | |
| 3188 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3189 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3190 | &command_buffer[0]); |
| 3191 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3192 | |
| 3193 | m_errorMonitor->VerifyNotFound(); |
| 3194 | } |
| 3195 | |
| 3196 | // This is a positive test. No errors should be generated. |
| 3197 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueOneFence) { |
| 3198 | |
| 3199 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 3200 | "on the same queue, the second having a fence, followed " |
| 3201 | "by a WaitForFences call."); |
| 3202 | |
| 3203 | m_errorMonitor->ExpectSuccess(); |
| 3204 | |
| 3205 | VkFence fence; |
| 3206 | VkFenceCreateInfo fence_create_info{}; |
| 3207 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3208 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3209 | |
| 3210 | VkCommandPool command_pool; |
| 3211 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3212 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3213 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3214 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3215 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3216 | &command_pool); |
| 3217 | |
| 3218 | VkCommandBuffer command_buffer[2]; |
| 3219 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3220 | command_buffer_allocate_info.sType = |
| 3221 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3222 | command_buffer_allocate_info.commandPool = command_pool; |
| 3223 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3224 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3225 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3226 | command_buffer); |
| 3227 | |
| 3228 | { |
| 3229 | VkCommandBufferBeginInfo begin_info{}; |
| 3230 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3231 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3232 | |
| 3233 | vkCmdPipelineBarrier(command_buffer[0], |
| 3234 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3235 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3236 | 0, nullptr, 0, nullptr); |
| 3237 | |
| 3238 | VkViewport viewport{}; |
| 3239 | viewport.maxDepth = 1.0f; |
| 3240 | viewport.minDepth = 0.0f; |
| 3241 | viewport.width = 512; |
| 3242 | viewport.height = 512; |
| 3243 | viewport.x = 0; |
| 3244 | viewport.y = 0; |
| 3245 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3246 | vkEndCommandBuffer(command_buffer[0]); |
| 3247 | } |
| 3248 | { |
| 3249 | VkCommandBufferBeginInfo begin_info{}; |
| 3250 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3251 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3252 | |
| 3253 | VkViewport viewport{}; |
| 3254 | viewport.maxDepth = 1.0f; |
| 3255 | viewport.minDepth = 0.0f; |
| 3256 | viewport.width = 512; |
| 3257 | viewport.height = 512; |
| 3258 | viewport.x = 0; |
| 3259 | viewport.y = 0; |
| 3260 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3261 | vkEndCommandBuffer(command_buffer[1]); |
| 3262 | } |
| 3263 | { |
| 3264 | VkSubmitInfo submit_info{}; |
| 3265 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3266 | submit_info.commandBufferCount = 1; |
| 3267 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3268 | submit_info.signalSemaphoreCount = 0; |
| 3269 | submit_info.pSignalSemaphores = VK_NULL_HANDLE; |
| 3270 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3271 | } |
| 3272 | { |
| 3273 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3274 | VkSubmitInfo submit_info{}; |
| 3275 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3276 | submit_info.commandBufferCount = 1; |
| 3277 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3278 | submit_info.waitSemaphoreCount = 0; |
| 3279 | submit_info.pWaitSemaphores = VK_NULL_HANDLE; |
| 3280 | submit_info.pWaitDstStageMask = flags; |
| 3281 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 3282 | } |
| 3283 | |
| 3284 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3285 | |
| 3286 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3287 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3288 | &command_buffer[0]); |
| 3289 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3290 | |
| 3291 | m_errorMonitor->VerifyNotFound(); |
| 3292 | } |
| 3293 | |
| 3294 | // This is a positive test. No errors should be generated. |
| 3295 | TEST_F(VkLayerTest, TwoSubmitInfosWithSemaphoreOneQueueSubmitsOneFence) { |
| 3296 | |
| 3297 | TEST_DESCRIPTION( |
| 3298 | "Two command buffers each in a separate SubmitInfo sent in a single " |
| 3299 | "QueueSubmit call followed by a WaitForFences call."); |
| 3300 | |
| 3301 | m_errorMonitor->ExpectSuccess(); |
| 3302 | |
| 3303 | VkFence fence; |
| 3304 | VkFenceCreateInfo fence_create_info{}; |
| 3305 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3306 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3307 | |
| 3308 | VkSemaphore semaphore; |
| 3309 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 3310 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 3311 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 3312 | &semaphore); |
| 3313 | |
| 3314 | VkCommandPool command_pool; |
| 3315 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3316 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3317 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3318 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3319 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3320 | &command_pool); |
| 3321 | |
| 3322 | VkCommandBuffer command_buffer[2]; |
| 3323 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3324 | command_buffer_allocate_info.sType = |
| 3325 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3326 | command_buffer_allocate_info.commandPool = command_pool; |
| 3327 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3328 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3329 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3330 | command_buffer); |
| 3331 | |
| 3332 | { |
| 3333 | VkCommandBufferBeginInfo begin_info{}; |
| 3334 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3335 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3336 | |
| 3337 | vkCmdPipelineBarrier(command_buffer[0], |
| 3338 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3339 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3340 | 0, nullptr, 0, nullptr); |
| 3341 | |
| 3342 | VkViewport viewport{}; |
| 3343 | viewport.maxDepth = 1.0f; |
| 3344 | viewport.minDepth = 0.0f; |
| 3345 | viewport.width = 512; |
| 3346 | viewport.height = 512; |
| 3347 | viewport.x = 0; |
| 3348 | viewport.y = 0; |
| 3349 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3350 | vkEndCommandBuffer(command_buffer[0]); |
| 3351 | } |
| 3352 | { |
| 3353 | VkCommandBufferBeginInfo begin_info{}; |
| 3354 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3355 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3356 | |
| 3357 | VkViewport viewport{}; |
| 3358 | viewport.maxDepth = 1.0f; |
| 3359 | viewport.minDepth = 0.0f; |
| 3360 | viewport.width = 512; |
| 3361 | viewport.height = 512; |
| 3362 | viewport.x = 0; |
| 3363 | viewport.y = 0; |
| 3364 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3365 | vkEndCommandBuffer(command_buffer[1]); |
| 3366 | } |
| 3367 | { |
| 3368 | VkSubmitInfo submit_info[2]; |
| 3369 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3370 | |
| 3371 | submit_info[0].sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3372 | submit_info[0].pNext = NULL; |
| 3373 | submit_info[0].commandBufferCount = 1; |
| 3374 | submit_info[0].pCommandBuffers = &command_buffer[0]; |
| 3375 | submit_info[0].signalSemaphoreCount = 1; |
| 3376 | submit_info[0].pSignalSemaphores = &semaphore; |
| 3377 | submit_info[0].waitSemaphoreCount = 0; |
| 3378 | submit_info[0].pWaitSemaphores = NULL; |
| 3379 | submit_info[0].pWaitDstStageMask = 0; |
| 3380 | |
| 3381 | submit_info[1].sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3382 | submit_info[1].pNext = NULL; |
| 3383 | submit_info[1].commandBufferCount = 1; |
| 3384 | submit_info[1].pCommandBuffers = &command_buffer[1]; |
| 3385 | submit_info[1].waitSemaphoreCount = 1; |
| 3386 | submit_info[1].pWaitSemaphores = &semaphore; |
| 3387 | submit_info[1].pWaitDstStageMask = flags; |
| 3388 | submit_info[1].signalSemaphoreCount = 0; |
| 3389 | submit_info[1].pSignalSemaphores = NULL; |
| 3390 | vkQueueSubmit(m_device->m_queue, 2, &submit_info[0], fence); |
| 3391 | } |
| 3392 | |
| 3393 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3394 | |
| 3395 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3396 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3397 | &command_buffer[0]); |
| 3398 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3399 | |
| 3400 | m_errorMonitor->VerifyNotFound(); |
| 3401 | } |
| 3402 | |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 3403 | TEST_F(VkLayerTest, DynamicStatesNotBound) { |
| 3404 | TEST_DESCRIPTION( |
| 3405 | "Run a series of simple draw calls to validate all the different " |
| 3406 | "failure cases that can occur when dynamic state is required but not " |
| 3407 | "correctly bound." |
| 3408 | "Here are the different dynamic state cases verified by this test:\n" |
| 3409 | "-Line Width\n-Depth Bias\n-Viewport State\n-Scissor State\n-Blend " |
| 3410 | "State\n-Depth Bounds\n-Stencil Read Mask\n-Stencil Write " |
| 3411 | "Mask\n-Stencil Reference"); |
| 3412 | |
| 3413 | // Dynamic line width |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3414 | m_errorMonitor->SetDesiredFailureMsg( |
| 3415 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3416 | "Dynamic line width state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3417 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 3418 | BsoFailLineWidth); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3419 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 3420 | // Dynamic depth bias |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3421 | m_errorMonitor->SetDesiredFailureMsg( |
| 3422 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3423 | "Dynamic depth bias state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3424 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 3425 | BsoFailDepthBias); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3426 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 3427 | // Dynamic viewport state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3428 | m_errorMonitor->SetDesiredFailureMsg( |
| 3429 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3430 | "Dynamic viewport state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3431 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 3432 | BsoFailViewport); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3433 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 3434 | // Dynamic scissor state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3435 | m_errorMonitor->SetDesiredFailureMsg( |
| 3436 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3437 | "Dynamic scissor state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3438 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 3439 | BsoFailScissor); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3440 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 3441 | // Dynamic blend state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3442 | m_errorMonitor->SetDesiredFailureMsg( |
| 3443 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3444 | "Dynamic depth bounds state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3445 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 3446 | BsoFailDepthBounds); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3447 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 3448 | // Dynamic stencil read mask |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3449 | m_errorMonitor->SetDesiredFailureMsg( |
| 3450 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3451 | "Dynamic stencil read mask state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3452 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 3453 | BsoFailStencilReadMask); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3454 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 3455 | // Dynamic stencil write mask |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3456 | m_errorMonitor->SetDesiredFailureMsg( |
| 3457 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3458 | "Dynamic stencil write mask state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3459 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 3460 | BsoFailStencilWriteMask); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3461 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 3462 | // Dynamic stencil reference |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3463 | m_errorMonitor->SetDesiredFailureMsg( |
| 3464 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3465 | "Dynamic stencil reference state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3466 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 3467 | BsoFailStencilReference); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3468 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 3469 | } |
| 3470 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3471 | TEST_F(VkLayerTest, CommandBufferTwoSubmits) { |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 3472 | vk_testing::Fence testFence; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3473 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3474 | m_errorMonitor->SetDesiredFailureMsg( |
| 3475 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3476 | "was begun w/ VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set, but has " |
| 3477 | "been submitted"); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 3478 | |
| 3479 | VkFenceCreateInfo fenceInfo = {}; |
| 3480 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3481 | fenceInfo.pNext = NULL; |
| 3482 | fenceInfo.flags = 0; |
| 3483 | |
| 3484 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3485 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 3486 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3487 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3488 | // We luck out b/c by default the framework creates CB w/ the |
| 3489 | // VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 3490 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3491 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 3492 | m_stencil_clear_color, NULL); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 3493 | EndCommandBuffer(); |
| 3494 | |
| 3495 | testFence.init(*m_device, fenceInfo); |
| 3496 | |
| 3497 | // Bypass framework since it does the waits automatically |
| 3498 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 3499 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 3500 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3501 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3502 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 3503 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 3504 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3505 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3506 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3507 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 3508 | submit_info.pSignalSemaphores = NULL; |
| 3509 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3510 | err = vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
| 3511 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 3512 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3513 | // Cause validation error by re-submitting cmd buffer that should only be |
| 3514 | // submitted once |
| 3515 | err = vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 3516 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3517 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 3518 | } |
| 3519 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3520 | TEST_F(VkLayerTest, AllocDescriptorFromEmptyPool) { |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 3521 | // Initiate Draw w/o a PSO bound |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3522 | VkResult err; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 3523 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3524 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3525 | "Unable to allocate 1 descriptors of " |
| 3526 | "type " |
| 3527 | "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3528 | |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 3529 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3530 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 3531 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3532 | // Create Pool w/ 1 Sampler descriptor, but try to alloc Uniform Buffer |
| 3533 | // descriptor from it |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3534 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3535 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 3536 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 3537 | |
| 3538 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3539 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3540 | ds_pool_ci.pNext = NULL; |
| 3541 | ds_pool_ci.flags = 0; |
| 3542 | ds_pool_ci.maxSets = 1; |
| 3543 | ds_pool_ci.poolSizeCount = 1; |
| 3544 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 3545 | |
| 3546 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3547 | err = |
| 3548 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 3549 | ASSERT_VK_SUCCESS(err); |
| 3550 | |
| 3551 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3552 | dsl_binding.binding = 0; |
| 3553 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3554 | dsl_binding.descriptorCount = 1; |
| 3555 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3556 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 3557 | |
| 3558 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3559 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3560 | ds_layout_ci.pNext = NULL; |
| 3561 | ds_layout_ci.bindingCount = 1; |
| 3562 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 3563 | |
| 3564 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3565 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3566 | &ds_layout); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 3567 | ASSERT_VK_SUCCESS(err); |
| 3568 | |
| 3569 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3570 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3571 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3572 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3573 | alloc_info.descriptorPool = ds_pool; |
| 3574 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3575 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3576 | &descriptorSet); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 3577 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3578 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 3579 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3580 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3581 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 3582 | } |
| 3583 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3584 | TEST_F(VkLayerTest, FreeDescriptorFromOneShotPool) { |
| 3585 | VkResult err; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3586 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3587 | m_errorMonitor->SetDesiredFailureMsg( |
| 3588 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3589 | "It is invalid to call vkFreeDescriptorSets() with a pool created " |
| 3590 | "without setting VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3591 | |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3592 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3593 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3594 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3595 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3596 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3597 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3598 | |
| 3599 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3600 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3601 | ds_pool_ci.pNext = NULL; |
| 3602 | ds_pool_ci.maxSets = 1; |
| 3603 | ds_pool_ci.poolSizeCount = 1; |
| 3604 | ds_pool_ci.flags = 0; |
| 3605 | // Not specifying VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT means |
| 3606 | // app can only call vkResetDescriptorPool on this pool.; |
| 3607 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3608 | |
| 3609 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3610 | err = |
| 3611 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3612 | ASSERT_VK_SUCCESS(err); |
| 3613 | |
| 3614 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3615 | dsl_binding.binding = 0; |
| 3616 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3617 | dsl_binding.descriptorCount = 1; |
| 3618 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3619 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3620 | |
| 3621 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3622 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3623 | ds_layout_ci.pNext = NULL; |
| 3624 | ds_layout_ci.bindingCount = 1; |
| 3625 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3626 | |
| 3627 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3628 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3629 | &ds_layout); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3630 | ASSERT_VK_SUCCESS(err); |
| 3631 | |
| 3632 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3633 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3634 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3635 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3636 | alloc_info.descriptorPool = ds_pool; |
| 3637 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3638 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3639 | &descriptorSet); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3640 | ASSERT_VK_SUCCESS(err); |
| 3641 | |
| 3642 | err = vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptorSet); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3643 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3644 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3645 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3646 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3647 | } |
| 3648 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3649 | TEST_F(VkLayerTest, InvalidDescriptorPool) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3650 | // Attempt to clear Descriptor Pool with bad object. |
| 3651 | // ObjectTracker should catch this. |
| 3652 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3653 | "Invalid VkDescriptorPool Object 0xbaad6001"); |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 3654 | uint64_t fake_pool_handle = 0xbaad6001; |
| 3655 | VkDescriptorPool bad_pool = reinterpret_cast<VkDescriptorPool &>(fake_pool_handle); |
| 3656 | vkResetDescriptorPool(device(), bad_pool, 0); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3657 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3658 | } |
| 3659 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3660 | TEST_F(VkLayerTest, InvalidDescriptorSet) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3661 | // Attempt to bind an invalid Descriptor Set to a valid Command Buffer |
| 3662 | // ObjectTracker should catch this. |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3663 | // Create a valid cmd buffer |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3664 | // call vkCmdBindDescriptorSets w/ false Descriptor Set |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 3665 | |
| 3666 | uint64_t fake_set_handle = 0xbaad6001; |
| 3667 | VkDescriptorSet bad_set = reinterpret_cast<VkDescriptorSet &>(fake_set_handle); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3668 | VkResult err; |
| 3669 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3670 | "Invalid VkDescriptorSet Object 0xbaad6001"); |
| 3671 | |
| 3672 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3673 | |
| 3674 | VkDescriptorSetLayoutBinding layout_bindings[1] = {}; |
| 3675 | layout_bindings[0].binding = 0; |
| 3676 | layout_bindings[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3677 | layout_bindings[0].descriptorCount = 1; |
| 3678 | layout_bindings[0].stageFlags = VK_SHADER_STAGE_VERTEX_BIT; |
| 3679 | layout_bindings[0].pImmutableSamplers = NULL; |
| 3680 | |
| 3681 | VkDescriptorSetLayout descriptor_set_layout; |
| 3682 | VkDescriptorSetLayoutCreateInfo dslci = {}; |
| 3683 | dslci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3684 | dslci.pNext = NULL; |
| 3685 | dslci.bindingCount = 1; |
| 3686 | dslci.pBindings = layout_bindings; |
| 3687 | err = vkCreateDescriptorSetLayout(device(), &dslci, NULL, &descriptor_set_layout); |
Karl Schultz | 5cb2111 | 2016-04-21 17:17:40 -0600 | [diff] [blame] | 3688 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3689 | |
| 3690 | VkPipelineLayout pipeline_layout; |
| 3691 | VkPipelineLayoutCreateInfo plci = {}; |
| 3692 | plci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3693 | plci.pNext = NULL; |
| 3694 | plci.setLayoutCount = 1; |
| 3695 | plci.pSetLayouts = &descriptor_set_layout; |
| 3696 | err = vkCreatePipelineLayout(device(), &plci, NULL, &pipeline_layout); |
Karl Schultz | 5cb2111 | 2016-04-21 17:17:40 -0600 | [diff] [blame] | 3697 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3698 | |
| 3699 | BeginCommandBuffer(); |
| 3700 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 3701 | pipeline_layout, 0, 1, &bad_set, 0, NULL); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3702 | m_errorMonitor->VerifyFound(); |
| 3703 | EndCommandBuffer(); |
| 3704 | vkDestroyPipelineLayout(device(), pipeline_layout, NULL); |
| 3705 | vkDestroyDescriptorSetLayout(device(), descriptor_set_layout, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3706 | } |
| 3707 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3708 | TEST_F(VkLayerTest, InvalidDescriptorSetLayout) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3709 | // Attempt to create a Pipeline Layout with an invalid Descriptor Set Layout. |
| 3710 | // ObjectTracker should catch this. |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 3711 | uint64_t fake_layout_handle = 0xbaad6001; |
| 3712 | VkDescriptorSetLayout bad_layout = reinterpret_cast<VkDescriptorSetLayout &>(fake_layout_handle); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3713 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3714 | "Invalid VkDescriptorSetLayout Object 0xbaad6001"); |
| 3715 | |
| 3716 | VkPipelineLayout pipeline_layout; |
| 3717 | VkPipelineLayoutCreateInfo plci = {}; |
| 3718 | plci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3719 | plci.pNext = NULL; |
| 3720 | plci.setLayoutCount = 1; |
| 3721 | plci.pSetLayouts = &bad_layout; |
| 3722 | vkCreatePipelineLayout(device(), &plci, NULL, &pipeline_layout); |
| 3723 | |
| 3724 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3725 | } |
| 3726 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3727 | TEST_F(VkLayerTest, InvalidPipeline) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3728 | // Attempt to bind an invalid Pipeline to a valid Command Buffer |
| 3729 | // ObjectTracker should catch this. |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3730 | // Create a valid cmd buffer |
| 3731 | // call vkCmdBindPipeline w/ false Pipeline |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 3732 | uint64_t fake_pipeline_handle = 0xbaad6001; |
| 3733 | VkPipeline bad_pipeline = reinterpret_cast<VkPipeline &>(fake_pipeline_handle); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3734 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3735 | "Invalid VkPipeline Object 0xbaad6001"); |
| 3736 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3737 | BeginCommandBuffer(); |
| 3738 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 3739 | VK_PIPELINE_BIND_POINT_GRAPHICS, bad_pipeline); |
| 3740 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b8b6b27 | 2016-05-02 13:26:06 -0600 | [diff] [blame] | 3741 | |
| 3742 | // Now issue a draw call with no pipeline bound |
| 3743 | m_errorMonitor->SetDesiredFailureMsg( |
| 3744 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3745 | "At Draw/Dispatch time no valid VkPipeline is bound!"); |
| 3746 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3747 | BeginCommandBuffer(); |
| 3748 | Draw(1, 0, 0, 0); |
| 3749 | m_errorMonitor->VerifyFound(); |
| 3750 | // Finally same check once more but with Dispatch/Compute |
| 3751 | m_errorMonitor->SetDesiredFailureMsg( |
| 3752 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3753 | "At Draw/Dispatch time no valid VkPipeline is bound!"); |
| 3754 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3755 | BeginCommandBuffer(); |
| 3756 | vkCmdDispatch(m_commandBuffer->GetBufferHandle(), 0, 0, 0); |
| 3757 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3758 | } |
| 3759 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3760 | TEST_F(VkLayerTest, DescriptorSetNotUpdated) { |
| 3761 | // Create and update CommandBuffer then call QueueSubmit w/o calling End on |
| 3762 | // CommandBuffer |
| 3763 | VkResult err; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3764 | |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 3765 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3766 | " bound but it was never updated. "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3767 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3768 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 3769 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 3770 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3771 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3772 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3773 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3774 | |
| 3775 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3776 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3777 | ds_pool_ci.pNext = NULL; |
| 3778 | ds_pool_ci.maxSets = 1; |
| 3779 | ds_pool_ci.poolSizeCount = 1; |
| 3780 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 3781 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3782 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3783 | err = |
| 3784 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3785 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3786 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3787 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3788 | dsl_binding.binding = 0; |
| 3789 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3790 | dsl_binding.descriptorCount = 1; |
| 3791 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3792 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3793 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3794 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3795 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3796 | ds_layout_ci.pNext = NULL; |
| 3797 | ds_layout_ci.bindingCount = 1; |
| 3798 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3799 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3800 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3801 | &ds_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3802 | ASSERT_VK_SUCCESS(err); |
| 3803 | |
| 3804 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3805 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3806 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3807 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3808 | alloc_info.descriptorPool = ds_pool; |
| 3809 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3810 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3811 | &descriptorSet); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3812 | ASSERT_VK_SUCCESS(err); |
| 3813 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3814 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3815 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3816 | pipeline_layout_ci.pNext = NULL; |
| 3817 | pipeline_layout_ci.setLayoutCount = 1; |
| 3818 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3819 | |
| 3820 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3821 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3822 | &pipeline_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3823 | ASSERT_VK_SUCCESS(err); |
| 3824 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3825 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 3826 | VK_SHADER_STAGE_VERTEX_BIT, this); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3827 | // 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] | 3828 | // on more devices |
| 3829 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 3830 | VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3831 | |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 3832 | VkPipelineObj pipe(m_device); |
| 3833 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 3834 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 3835 | pipe.AddColorAttachment(); |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 3836 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 3837 | |
| 3838 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3839 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 3840 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 3841 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3842 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3843 | 1, &descriptorSet, 0, NULL); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3844 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3845 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3846 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3847 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3848 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3849 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3850 | } |
| 3851 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3852 | TEST_F(VkLayerTest, InvalidBufferViewObject) { |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3853 | // Create a single TEXEL_BUFFER descriptor and send it an invalid bufferView |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3854 | VkResult err; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3855 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3856 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 3857 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Attempted write update to texel buffer " |
| 3858 | "descriptor with invalid buffer view"); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3859 | |
| 3860 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3861 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3862 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 3863 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3864 | |
| 3865 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3866 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3867 | ds_pool_ci.pNext = NULL; |
| 3868 | ds_pool_ci.maxSets = 1; |
| 3869 | ds_pool_ci.poolSizeCount = 1; |
| 3870 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3871 | |
| 3872 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3873 | err = |
| 3874 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3875 | ASSERT_VK_SUCCESS(err); |
| 3876 | |
| 3877 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3878 | dsl_binding.binding = 0; |
| 3879 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 3880 | dsl_binding.descriptorCount = 1; |
| 3881 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3882 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3883 | |
| 3884 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3885 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3886 | ds_layout_ci.pNext = NULL; |
| 3887 | ds_layout_ci.bindingCount = 1; |
| 3888 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3889 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3890 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3891 | &ds_layout); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3892 | ASSERT_VK_SUCCESS(err); |
| 3893 | |
| 3894 | VkDescriptorSet descriptorSet; |
| 3895 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3896 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3897 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3898 | alloc_info.descriptorPool = ds_pool; |
| 3899 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3900 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3901 | &descriptorSet); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3902 | ASSERT_VK_SUCCESS(err); |
| 3903 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3904 | VkBufferView view = |
| 3905 | (VkBufferView)((size_t)0xbaadbeef); // invalid bufferView object |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3906 | VkWriteDescriptorSet descriptor_write; |
| 3907 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3908 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 3909 | descriptor_write.dstSet = descriptorSet; |
| 3910 | descriptor_write.dstBinding = 0; |
| 3911 | descriptor_write.descriptorCount = 1; |
| 3912 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 3913 | descriptor_write.pTexelBufferView = &view; |
| 3914 | |
| 3915 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3916 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3917 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3918 | |
| 3919 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3920 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 3921 | } |
| 3922 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3923 | TEST_F(VkLayerTest, InvalidDynamicOffsetCases) { |
| 3924 | // Create a descriptorSet w/ dynamic descriptor and then hit 3 offset error |
| 3925 | // cases: |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3926 | // 1. No dynamicOffset supplied |
| 3927 | // 2. Too many dynamicOffsets supplied |
| 3928 | // 3. Dynamic offset oversteps buffer being updated |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3929 | VkResult err; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3930 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3931 | " requires 1 dynamicOffsets, but only " |
| 3932 | "0 dynamicOffsets are left in " |
| 3933 | "pDynamicOffsets "); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3934 | |
| 3935 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3936 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 3937 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3938 | |
| 3939 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3940 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 3941 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3942 | |
| 3943 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3944 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3945 | ds_pool_ci.pNext = NULL; |
| 3946 | ds_pool_ci.maxSets = 1; |
| 3947 | ds_pool_ci.poolSizeCount = 1; |
| 3948 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3949 | |
| 3950 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3951 | err = |
| 3952 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3953 | ASSERT_VK_SUCCESS(err); |
| 3954 | |
| 3955 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3956 | dsl_binding.binding = 0; |
| 3957 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 3958 | dsl_binding.descriptorCount = 1; |
| 3959 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3960 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3961 | |
| 3962 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3963 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3964 | ds_layout_ci.pNext = NULL; |
| 3965 | ds_layout_ci.bindingCount = 1; |
| 3966 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3967 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3968 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3969 | &ds_layout); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3970 | ASSERT_VK_SUCCESS(err); |
| 3971 | |
| 3972 | VkDescriptorSet descriptorSet; |
| 3973 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3974 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3975 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3976 | alloc_info.descriptorPool = ds_pool; |
| 3977 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3978 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3979 | &descriptorSet); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3980 | ASSERT_VK_SUCCESS(err); |
| 3981 | |
| 3982 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3983 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3984 | pipeline_layout_ci.pNext = NULL; |
| 3985 | pipeline_layout_ci.setLayoutCount = 1; |
| 3986 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3987 | |
| 3988 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3989 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3990 | &pipeline_layout); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3991 | ASSERT_VK_SUCCESS(err); |
| 3992 | |
| 3993 | // Create a buffer to update the descriptor with |
| 3994 | uint32_t qfi = 0; |
| 3995 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3996 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 3997 | buffCI.size = 1024; |
| 3998 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 3999 | buffCI.queueFamilyIndexCount = 1; |
| 4000 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4001 | |
| 4002 | VkBuffer dyub; |
| 4003 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 4004 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4005 | // Allocate memory and bind to buffer so we can make it to the appropriate |
| 4006 | // error |
| 4007 | VkMemoryAllocateInfo mem_alloc = {}; |
| 4008 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 4009 | mem_alloc.pNext = NULL; |
| 4010 | mem_alloc.allocationSize = 1024; |
Chris Forbes | b6116cc | 2016-05-08 11:39:59 +1200 | [diff] [blame] | 4011 | mem_alloc.memoryTypeIndex = 0; |
| 4012 | |
| 4013 | VkMemoryRequirements memReqs; |
| 4014 | vkGetBufferMemoryRequirements(m_device->device(), dyub, &memReqs); |
| 4015 | bool pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &mem_alloc, |
| 4016 | 0); |
| 4017 | if (!pass) { |
| 4018 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
| 4019 | return; |
| 4020 | } |
| 4021 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4022 | VkDeviceMemory mem; |
| 4023 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
| 4024 | ASSERT_VK_SUCCESS(err); |
| 4025 | err = vkBindBufferMemory(m_device->device(), dyub, mem, 0); |
| 4026 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4027 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 4028 | VkDescriptorBufferInfo buffInfo = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4029 | buffInfo.buffer = dyub; |
| 4030 | buffInfo.offset = 0; |
| 4031 | buffInfo.range = 1024; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4032 | |
| 4033 | VkWriteDescriptorSet descriptor_write; |
| 4034 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 4035 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 4036 | descriptor_write.dstSet = descriptorSet; |
| 4037 | descriptor_write.dstBinding = 0; |
| 4038 | descriptor_write.descriptorCount = 1; |
| 4039 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 4040 | descriptor_write.pBufferInfo = &buffInfo; |
| 4041 | |
| 4042 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 4043 | |
| 4044 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4045 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 4046 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 4047 | 1, &descriptorSet, 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4048 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4049 | uint32_t pDynOff[2] = {512, 756}; |
| 4050 | // 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] | 4051 | m_errorMonitor->SetDesiredFailureMsg( |
| 4052 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4053 | "Attempting to bind 1 descriptorSets with 1 dynamic descriptors, but "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4054 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 4055 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 4056 | 1, &descriptorSet, 2, pDynOff); |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 4057 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4058 | // Finally cause error due to dynamicOffset being too big |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4059 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4060 | " dynamic offset 512 combined with " |
| 4061 | "offset 0 and range 1024 that " |
| 4062 | "oversteps the buffer size of 1024"); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4063 | // Create PSO to be used for draw-time errors below |
| 4064 | char const *vsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 4065 | "#version 450\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4066 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 4067 | "out gl_PerVertex { \n" |
| 4068 | " vec4 gl_Position;\n" |
| 4069 | "};\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4070 | "void main(){\n" |
| 4071 | " gl_Position = vec4(1);\n" |
| 4072 | "}\n"; |
| 4073 | char const *fsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 4074 | "#version 450\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4075 | "\n" |
| 4076 | "layout(location=0) out vec4 x;\n" |
| 4077 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 4078 | "void main(){\n" |
| 4079 | " x = vec4(bar.y);\n" |
| 4080 | "}\n"; |
| 4081 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4082 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 4083 | VkPipelineObj pipe(m_device); |
| 4084 | pipe.AddShader(&vs); |
| 4085 | pipe.AddShader(&fs); |
| 4086 | pipe.AddColorAttachment(); |
| 4087 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 4088 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4089 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4090 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 4091 | // This update should succeed, but offset size of 512 will overstep buffer |
| 4092 | // /w range 1024 & size 1024 |
| 4093 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 4094 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 4095 | 1, &descriptorSet, 1, pDynOff); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4096 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4097 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4098 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4099 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
Tobin Ehlis | 512098e | 2016-05-05 09:06:12 -0600 | [diff] [blame] | 4100 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4101 | |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4102 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4103 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 4104 | } |
| 4105 | |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4106 | TEST_F(VkLayerTest, InvalidPushConstants) { |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4107 | VkResult err; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4108 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4109 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 4110 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4111 | |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4112 | VkPipelineLayout pipeline_layout; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4113 | VkPushConstantRange pc_range = {}; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4114 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 4115 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4116 | pipeline_layout_ci.pushConstantRangeCount = 1; |
| 4117 | pipeline_layout_ci.pPushConstantRanges = &pc_range; |
| 4118 | |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4119 | // |
| 4120 | // Check for invalid push constant ranges in pipeline layouts. |
| 4121 | // |
| 4122 | struct PipelineLayoutTestCase { |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4123 | VkPushConstantRange const range; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4124 | char const *msg; |
| 4125 | }; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4126 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4127 | const uint32_t too_big = m_device->props.limits.maxPushConstantsSize + 0x4; |
| 4128 | const std::array<PipelineLayoutTestCase, 10> range_tests = {{ |
| 4129 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 0}, |
| 4130 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 4131 | "size 0."}, |
| 4132 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 1}, |
| 4133 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 4134 | "size 1."}, |
| 4135 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 1}, |
| 4136 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 4137 | "size 1."}, |
| 4138 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 0}, |
| 4139 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 4140 | "size 0."}, |
| 4141 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 4}, |
| 4142 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 4143 | "offset 1. Offset must"}, |
| 4144 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, too_big}, |
| 4145 | "vkCreatePipelineLayout() call has push constants index 0 " |
| 4146 | "with offset "}, |
| 4147 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, too_big}, |
| 4148 | "vkCreatePipelineLayout() call has push constants " |
| 4149 | "index 0 with offset "}, |
| 4150 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, 0}, |
| 4151 | "vkCreatePipelineLayout() call has push constants index 0 " |
| 4152 | "with offset "}, |
| 4153 | {{VK_SHADER_STAGE_VERTEX_BIT, 0xFFFFFFF0, 0x00000020}, |
| 4154 | "vkCreatePipelineLayout() call has push " |
| 4155 | "constants index 0 with offset "}, |
| 4156 | {{VK_SHADER_STAGE_VERTEX_BIT, 0x00000020, 0xFFFFFFF0}, |
| 4157 | "vkCreatePipelineLayout() call has push " |
| 4158 | "constants index 0 with offset "}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4159 | }}; |
| 4160 | |
| 4161 | // Check for invalid offset and size |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4162 | for (const auto &iter : range_tests) { |
| 4163 | pc_range = iter.range; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4164 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4165 | iter.msg); |
| 4166 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, |
| 4167 | NULL, &pipeline_layout); |
| 4168 | m_errorMonitor->VerifyFound(); |
| 4169 | if (VK_SUCCESS == err) { |
| 4170 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4171 | } |
| 4172 | } |
| 4173 | |
| 4174 | // Check for invalid stage flag |
| 4175 | pc_range.offset = 0; |
| 4176 | pc_range.size = 16; |
| 4177 | pc_range.stageFlags = 0; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4178 | m_errorMonitor->SetDesiredFailureMsg( |
| 4179 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4180 | "vkCreatePipelineLayout() call has no stageFlags set."); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4181 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4182 | &pipeline_layout); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4183 | m_errorMonitor->VerifyFound(); |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4184 | if (VK_SUCCESS == err) { |
| 4185 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4186 | } |
| 4187 | |
| 4188 | // Check for overlapping ranges |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4189 | const uint32_t ranges_per_test = 5; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4190 | struct OverlappingRangeTestCase { |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4191 | VkPushConstantRange const ranges[ranges_per_test]; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4192 | char const *msg; |
| 4193 | }; |
| 4194 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4195 | const std::array<OverlappingRangeTestCase, 5> overlapping_range_tests = { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4196 | {{{{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4197 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4198 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4199 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4200 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, |
| 4201 | "vkCreatePipelineLayout() call has push constants with overlapping " |
| 4202 | "ranges: 0:[0, 4), 1:[0, 4)"}, |
| 4203 | { |
| 4204 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4205 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, |
| 4206 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, |
| 4207 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 8}, |
| 4208 | {VK_SHADER_STAGE_VERTEX_BIT, 16, 4}}, |
| 4209 | "vkCreatePipelineLayout() call has push constants with " |
| 4210 | "overlapping " |
| 4211 | "ranges: 3:[12, 20), 4:[16, 20)", |
| 4212 | }, |
| 4213 | { |
| 4214 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, |
| 4215 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 8}, |
| 4216 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, |
| 4217 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, |
| 4218 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, |
| 4219 | "vkCreatePipelineLayout() call has push constants with " |
| 4220 | "overlapping " |
| 4221 | "ranges: 0:[16, 20), 1:[12, 20)", |
| 4222 | }, |
| 4223 | { |
| 4224 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, |
| 4225 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, |
| 4226 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, |
| 4227 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 8}, |
| 4228 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, |
| 4229 | "vkCreatePipelineLayout() call has push constants with " |
| 4230 | "overlapping " |
| 4231 | "ranges: 0:[16, 20), 3:[12, 20)", |
| 4232 | }, |
| 4233 | { |
| 4234 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, |
| 4235 | {VK_SHADER_STAGE_VERTEX_BIT, 32, 4}, |
| 4236 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 96}, |
| 4237 | {VK_SHADER_STAGE_VERTEX_BIT, 40, 8}, |
| 4238 | {VK_SHADER_STAGE_VERTEX_BIT, 52, 4}}, |
| 4239 | "vkCreatePipelineLayout() call has push constants with " |
| 4240 | "overlapping " |
| 4241 | "ranges: 0:[16, 20), 2:[4, 100)", |
| 4242 | }}}; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4243 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4244 | for (const auto &iter : overlapping_range_tests) { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4245 | pipeline_layout_ci.pPushConstantRanges = iter.ranges; |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4246 | pipeline_layout_ci.pushConstantRangeCount = ranges_per_test; |
| 4247 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4248 | iter.msg); |
| 4249 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, |
| 4250 | NULL, &pipeline_layout); |
| 4251 | m_errorMonitor->VerifyFound(); |
| 4252 | if (VK_SUCCESS == err) { |
| 4253 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4254 | } |
| 4255 | } |
| 4256 | |
| 4257 | // 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] | 4258 | const std::array<OverlappingRangeTestCase, 2> overlapping_range_tests_pos = |
| 4259 | {{{{{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4260 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, |
| 4261 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, |
| 4262 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 4}, |
| 4263 | {VK_SHADER_STAGE_VERTEX_BIT, 16, 4}}, |
| 4264 | ""}, |
| 4265 | {{{VK_SHADER_STAGE_VERTEX_BIT, 92, 24}, |
| 4266 | {VK_SHADER_STAGE_VERTEX_BIT, 80, 4}, |
| 4267 | {VK_SHADER_STAGE_VERTEX_BIT, 64, 8}, |
| 4268 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 16}, |
| 4269 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, |
| 4270 | ""}}}; |
| 4271 | for (const auto &iter : overlapping_range_tests_pos) { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4272 | pipeline_layout_ci.pPushConstantRanges = iter.ranges; |
| 4273 | m_errorMonitor->ExpectSuccess(); |
| 4274 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, |
| 4275 | NULL, &pipeline_layout); |
| 4276 | m_errorMonitor->VerifyNotFound(); |
| 4277 | if (VK_SUCCESS == err) { |
| 4278 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4279 | } |
| 4280 | } |
| 4281 | |
| 4282 | // |
| 4283 | // CmdPushConstants tests |
| 4284 | // |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4285 | const uint8_t dummy_values[100] = {}; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4286 | |
| 4287 | // 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] | 4288 | const std::array<PipelineLayoutTestCase, 16> cmd_range_tests = {{ |
| 4289 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 0}, |
| 4290 | "vkCmdPushConstants() call has push constants with size 0. Size " |
| 4291 | "must be greater than zero and a multiple of 4."}, |
| 4292 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 1}, |
| 4293 | "vkCmdPushConstants() call has push constants with size 1. Size " |
| 4294 | "must be greater than zero and a multiple of 4."}, |
| 4295 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 1}, |
| 4296 | "vkCmdPushConstants() call has push constants with size 1. Size " |
| 4297 | "must be greater than zero and a multiple of 4."}, |
| 4298 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 0}, |
| 4299 | "vkCmdPushConstants() call has push constants with offset 1. " |
| 4300 | "Offset must be a multiple of 4."}, |
| 4301 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 4}, |
| 4302 | "vkCmdPushConstants() call has push constants with offset 1. " |
| 4303 | "Offset must be a multiple of 4."}, |
| 4304 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 20}, |
| 4305 | "vkCmdPushConstants() Push constant range [0, 20) with stageFlags = " |
| 4306 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4307 | {{VK_SHADER_STAGE_VERTEX_BIT, 60, 8}, |
| 4308 | "vkCmdPushConstants() Push constant range [60, 68) with stageFlags = " |
| 4309 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4310 | {{VK_SHADER_STAGE_VERTEX_BIT, 76, 8}, |
| 4311 | "vkCmdPushConstants() Push constant range [76, 84) with stageFlags = " |
| 4312 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4313 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 80}, |
| 4314 | "vkCmdPushConstants() Push constant range [0, 80) with stageFlags = " |
| 4315 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4316 | {{VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, 0, 4}, |
| 4317 | "vkCmdPushConstants() stageFlags = 0x2 do not match the stageFlags in " |
| 4318 | "any of the ranges in pipeline layout"}, |
| 4319 | {{VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, |
| 4320 | 0, 16}, |
| 4321 | "vkCmdPushConstants() stageFlags = 0x3 do not match the stageFlags in " |
| 4322 | "any of the ranges in pipeline layout"}, |
| 4323 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, too_big}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4324 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4325 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, too_big}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4326 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4327 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, 0}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4328 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4329 | {{VK_SHADER_STAGE_VERTEX_BIT, 0xFFFFFFF0, 0x00000020}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4330 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4331 | {{VK_SHADER_STAGE_VERTEX_BIT, 0x00000020, 0xFFFFFFF0}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4332 | "vkCmdPushConstants() call has push constants with offset "}, |
| 4333 | }}; |
| 4334 | |
| 4335 | // Two ranges for testing robustness |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4336 | const VkPushConstantRange pc_range2[] = { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4337 | {VK_SHADER_STAGE_VERTEX_BIT, 64, 16}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4338 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4339 | }; |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4340 | pipeline_layout_ci.pushConstantRangeCount = |
| 4341 | sizeof(pc_range2) / sizeof(VkPushConstantRange); |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4342 | pipeline_layout_ci.pPushConstantRanges = pc_range2; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4343 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4344 | &pipeline_layout); |
| 4345 | ASSERT_VK_SUCCESS(err); |
| 4346 | BeginCommandBuffer(); |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4347 | for (const auto &iter : cmd_range_tests) { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4348 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4349 | iter.msg); |
| 4350 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4351 | iter.range.stageFlags, iter.range.offset, |
| 4352 | iter.range.size, dummy_values); |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4353 | m_errorMonitor->VerifyFound(); |
| 4354 | } |
| 4355 | |
| 4356 | // Check for invalid stage flag |
| 4357 | m_errorMonitor->SetDesiredFailureMsg( |
| 4358 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4359 | "vkCmdPushConstants() call has no stageFlags set."); |
| 4360 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, 0, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4361 | 0, 16, dummy_values); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4362 | m_errorMonitor->VerifyFound(); |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4363 | EndCommandBuffer(); |
| 4364 | vkResetCommandBuffer(m_commandBuffer->GetBufferHandle(), 0); |
| 4365 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4366 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4367 | // overlapping range tests with cmd |
| 4368 | const std::array<PipelineLayoutTestCase, 3> cmd_overlap_tests = {{ |
| 4369 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 20}, |
| 4370 | "vkCmdPushConstants() Push constant range [0, 20) with stageFlags = " |
| 4371 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4372 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, |
| 4373 | "vkCmdPushConstants() Push constant range [16, 20) with stageFlags = " |
| 4374 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4375 | {{VK_SHADER_STAGE_VERTEX_BIT, 40, 16}, |
| 4376 | "vkCmdPushConstants() Push constant range [40, 56) with stageFlags = " |
| 4377 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4378 | }}; |
| 4379 | const VkPushConstantRange pc_range3[] = { |
| 4380 | {VK_SHADER_STAGE_VERTEX_BIT, 20, 16}, |
| 4381 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, |
| 4382 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4383 | {VK_SHADER_STAGE_VERTEX_BIT, 44, 8}, |
| 4384 | {VK_SHADER_STAGE_VERTEX_BIT, 80, 12}, |
| 4385 | {VK_SHADER_STAGE_VERTEX_BIT, 36, 8}, |
| 4386 | {VK_SHADER_STAGE_VERTEX_BIT, 56, 28}, |
| 4387 | }; |
| 4388 | pipeline_layout_ci.pushConstantRangeCount = |
| 4389 | sizeof(pc_range3) / sizeof(VkPushConstantRange); |
| 4390 | pipeline_layout_ci.pPushConstantRanges = pc_range3; |
| 4391 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4392 | &pipeline_layout); |
| 4393 | ASSERT_VK_SUCCESS(err); |
| 4394 | BeginCommandBuffer(); |
| 4395 | for (const auto &iter : cmd_overlap_tests) { |
| 4396 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4397 | iter.msg); |
| 4398 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, |
| 4399 | iter.range.stageFlags, iter.range.offset, |
| 4400 | iter.range.size, dummy_values); |
| 4401 | m_errorMonitor->VerifyFound(); |
| 4402 | } |
| 4403 | EndCommandBuffer(); |
| 4404 | vkResetCommandBuffer(m_commandBuffer->GetBufferHandle(), 0); |
| 4405 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4406 | |
| 4407 | // positive overlapping range tests with cmd |
| 4408 | const std::array<PipelineLayoutTestCase, 4> cmd_overlap_tests_pos = {{ |
| 4409 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, ""}, |
| 4410 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, ""}, |
| 4411 | {{VK_SHADER_STAGE_VERTEX_BIT, 20, 12}, ""}, |
| 4412 | {{VK_SHADER_STAGE_VERTEX_BIT, 56, 36}, ""}, |
| 4413 | }}; |
| 4414 | const VkPushConstantRange pc_range4[] = { |
| 4415 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 64}, |
| 4416 | {VK_SHADER_STAGE_VERTEX_BIT, 20, 16}, |
| 4417 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, |
| 4418 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4419 | {VK_SHADER_STAGE_VERTEX_BIT, 44, 8}, |
| 4420 | {VK_SHADER_STAGE_VERTEX_BIT, 80, 12}, |
| 4421 | {VK_SHADER_STAGE_VERTEX_BIT, 36, 8}, |
| 4422 | {VK_SHADER_STAGE_VERTEX_BIT, 56, 28}, |
| 4423 | }; |
| 4424 | pipeline_layout_ci.pushConstantRangeCount = |
| 4425 | sizeof(pc_range4) / sizeof(VkPushConstantRange); |
| 4426 | pipeline_layout_ci.pPushConstantRanges = pc_range4; |
| 4427 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4428 | &pipeline_layout); |
| 4429 | ASSERT_VK_SUCCESS(err); |
| 4430 | BeginCommandBuffer(); |
| 4431 | for (const auto &iter : cmd_overlap_tests_pos) { |
| 4432 | m_errorMonitor->ExpectSuccess(); |
| 4433 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, |
| 4434 | iter.range.stageFlags, iter.range.offset, |
| 4435 | iter.range.size, dummy_values); |
| 4436 | m_errorMonitor->VerifyNotFound(); |
| 4437 | } |
| 4438 | EndCommandBuffer(); |
| 4439 | vkResetCommandBuffer(m_commandBuffer->GetBufferHandle(), 0); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4440 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4441 | } |
| 4442 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4443 | TEST_F(VkLayerTest, DescriptorSetCompatibility) { |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4444 | // Test various desriptorSet errors with bad binding combinations |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4445 | VkResult err; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4446 | |
| 4447 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4448 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 4449 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4450 | |
| 4451 | static const uint32_t NUM_DESCRIPTOR_TYPES = 5; |
| 4452 | VkDescriptorPoolSize ds_type_count[NUM_DESCRIPTOR_TYPES] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4453 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4454 | ds_type_count[0].descriptorCount = 10; |
| 4455 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 4456 | ds_type_count[1].descriptorCount = 2; |
| 4457 | ds_type_count[2].type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 4458 | ds_type_count[2].descriptorCount = 2; |
| 4459 | ds_type_count[3].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 4460 | ds_type_count[3].descriptorCount = 5; |
| 4461 | // TODO : LunarG ILO driver currently asserts in desc.c w/ INPUT_ATTACHMENT |
| 4462 | // type |
| 4463 | // ds_type_count[4].type = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; |
| 4464 | ds_type_count[4].type = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
| 4465 | ds_type_count[4].descriptorCount = 2; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4466 | |
| 4467 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4468 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4469 | ds_pool_ci.pNext = NULL; |
| 4470 | ds_pool_ci.maxSets = 5; |
| 4471 | ds_pool_ci.poolSizeCount = NUM_DESCRIPTOR_TYPES; |
| 4472 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4473 | |
| 4474 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4475 | err = |
| 4476 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4477 | ASSERT_VK_SUCCESS(err); |
| 4478 | |
| 4479 | static const uint32_t MAX_DS_TYPES_IN_LAYOUT = 2; |
| 4480 | VkDescriptorSetLayoutBinding dsl_binding[MAX_DS_TYPES_IN_LAYOUT] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4481 | dsl_binding[0].binding = 0; |
| 4482 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4483 | dsl_binding[0].descriptorCount = 5; |
| 4484 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 4485 | dsl_binding[0].pImmutableSamplers = NULL; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4486 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4487 | // Create layout identical to set0 layout but w/ different stageFlags |
| 4488 | VkDescriptorSetLayoutBinding dsl_fs_stage_only = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4489 | dsl_fs_stage_only.binding = 0; |
| 4490 | dsl_fs_stage_only.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4491 | dsl_fs_stage_only.descriptorCount = 5; |
| 4492 | dsl_fs_stage_only.stageFlags = |
| 4493 | VK_SHADER_STAGE_FRAGMENT_BIT; // Different stageFlags to cause error at |
| 4494 | // bind time |
| 4495 | dsl_fs_stage_only.pImmutableSamplers = NULL; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4496 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4497 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4498 | ds_layout_ci.pNext = NULL; |
| 4499 | ds_layout_ci.bindingCount = 1; |
| 4500 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4501 | static const uint32_t NUM_LAYOUTS = 4; |
| 4502 | VkDescriptorSetLayout ds_layout[NUM_LAYOUTS] = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4503 | VkDescriptorSetLayout ds_layout_fs_only = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4504 | // Create 4 unique layouts for full pipelineLayout, and 1 special fs-only |
| 4505 | // layout for error case |
| 4506 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4507 | &ds_layout[0]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4508 | ASSERT_VK_SUCCESS(err); |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 4509 | ds_layout_ci.pBindings = &dsl_fs_stage_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4510 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4511 | &ds_layout_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4512 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4513 | dsl_binding[0].binding = 0; |
| 4514 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4515 | dsl_binding[0].descriptorCount = 2; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 4516 | dsl_binding[1].binding = 1; |
| 4517 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 4518 | dsl_binding[1].descriptorCount = 2; |
| 4519 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 4520 | dsl_binding[1].pImmutableSamplers = NULL; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 4521 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4522 | ds_layout_ci.bindingCount = 2; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4523 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4524 | &ds_layout[1]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4525 | ASSERT_VK_SUCCESS(err); |
| 4526 | dsl_binding[0].binding = 0; |
| 4527 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4528 | dsl_binding[0].descriptorCount = 5; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4529 | ds_layout_ci.bindingCount = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4530 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4531 | &ds_layout[2]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4532 | ASSERT_VK_SUCCESS(err); |
| 4533 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4534 | dsl_binding[0].descriptorCount = 2; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4535 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4536 | &ds_layout[3]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4537 | ASSERT_VK_SUCCESS(err); |
| 4538 | |
| 4539 | static const uint32_t NUM_SETS = 4; |
| 4540 | VkDescriptorSet descriptorSet[NUM_SETS] = {}; |
| 4541 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4542 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4543 | alloc_info.descriptorSetCount = NUM_LAYOUTS; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4544 | alloc_info.descriptorPool = ds_pool; |
| 4545 | alloc_info.pSetLayouts = ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4546 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4547 | descriptorSet); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4548 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4549 | VkDescriptorSet ds0_fs_only = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4550 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4551 | alloc_info.pSetLayouts = &ds_layout_fs_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4552 | err = |
| 4553 | vkAllocateDescriptorSets(m_device->device(), &alloc_info, &ds0_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4554 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4555 | |
| 4556 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4557 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4558 | pipeline_layout_ci.pNext = NULL; |
| 4559 | pipeline_layout_ci.setLayoutCount = NUM_LAYOUTS; |
| 4560 | pipeline_layout_ci.pSetLayouts = ds_layout; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4561 | |
| 4562 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4563 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4564 | &pipeline_layout); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4565 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4566 | // Create pipelineLayout with only one setLayout |
| 4567 | pipeline_layout_ci.setLayoutCount = 1; |
| 4568 | VkPipelineLayout single_pipe_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4569 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4570 | &single_pipe_layout); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4571 | ASSERT_VK_SUCCESS(err); |
| 4572 | // Create pipelineLayout with 2 descriptor setLayout at index 0 |
| 4573 | pipeline_layout_ci.pSetLayouts = &ds_layout[3]; |
| 4574 | VkPipelineLayout pipe_layout_one_desc; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4575 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4576 | &pipe_layout_one_desc); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4577 | ASSERT_VK_SUCCESS(err); |
| 4578 | // Create pipelineLayout with 5 SAMPLER descriptor setLayout at index 0 |
| 4579 | pipeline_layout_ci.pSetLayouts = &ds_layout[2]; |
| 4580 | VkPipelineLayout pipe_layout_five_samp; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4581 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4582 | &pipe_layout_five_samp); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4583 | ASSERT_VK_SUCCESS(err); |
| 4584 | // Create pipelineLayout with UB type, but stageFlags for FS only |
| 4585 | pipeline_layout_ci.pSetLayouts = &ds_layout_fs_only; |
| 4586 | VkPipelineLayout pipe_layout_fs_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4587 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4588 | &pipe_layout_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4589 | ASSERT_VK_SUCCESS(err); |
| 4590 | // Create pipelineLayout w/ incompatible set0 layout, but set1 is fine |
| 4591 | VkDescriptorSetLayout pl_bad_s0[2] = {}; |
| 4592 | pl_bad_s0[0] = ds_layout_fs_only; |
| 4593 | pl_bad_s0[1] = ds_layout[1]; |
| 4594 | pipeline_layout_ci.setLayoutCount = 2; |
| 4595 | pipeline_layout_ci.pSetLayouts = pl_bad_s0; |
| 4596 | VkPipelineLayout pipe_layout_bad_set0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4597 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4598 | &pipe_layout_bad_set0); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4599 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4600 | |
| 4601 | // Create a buffer to update the descriptor with |
| 4602 | uint32_t qfi = 0; |
| 4603 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4604 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 4605 | buffCI.size = 1024; |
| 4606 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 4607 | buffCI.queueFamilyIndexCount = 1; |
| 4608 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4609 | |
| 4610 | VkBuffer dyub; |
| 4611 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 4612 | ASSERT_VK_SUCCESS(err); |
| 4613 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 4614 | static const uint32_t NUM_BUFFS = 5; |
| 4615 | VkDescriptorBufferInfo buffInfo[NUM_BUFFS] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4616 | for (uint32_t i = 0; i < NUM_BUFFS; ++i) { |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4617 | buffInfo[i].buffer = dyub; |
| 4618 | buffInfo[i].offset = 0; |
| 4619 | buffInfo[i].range = 1024; |
| 4620 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4621 | VkImage image; |
| 4622 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 4623 | const int32_t tex_width = 32; |
| 4624 | const int32_t tex_height = 32; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4625 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4626 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4627 | image_create_info.pNext = NULL; |
| 4628 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4629 | image_create_info.format = tex_format; |
| 4630 | image_create_info.extent.width = tex_width; |
| 4631 | image_create_info.extent.height = tex_height; |
| 4632 | image_create_info.extent.depth = 1; |
| 4633 | image_create_info.mipLevels = 1; |
| 4634 | image_create_info.arrayLayers = 1; |
| 4635 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 4636 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 4637 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 4638 | image_create_info.flags = 0; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4639 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 4640 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4641 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4642 | VkMemoryRequirements memReqs; |
| 4643 | VkDeviceMemory imageMem; |
| 4644 | bool pass; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 4645 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4646 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 4647 | memAlloc.pNext = NULL; |
| 4648 | memAlloc.allocationSize = 0; |
| 4649 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 4650 | vkGetImageMemoryRequirements(m_device->device(), image, &memReqs); |
| 4651 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4652 | pass = |
| 4653 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 4654 | ASSERT_TRUE(pass); |
| 4655 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &imageMem); |
| 4656 | ASSERT_VK_SUCCESS(err); |
| 4657 | err = vkBindImageMemory(m_device->device(), image, imageMem, 0); |
| 4658 | ASSERT_VK_SUCCESS(err); |
| 4659 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4660 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4661 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 4662 | image_view_create_info.image = image; |
| 4663 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 4664 | image_view_create_info.format = tex_format; |
| 4665 | image_view_create_info.subresourceRange.layerCount = 1; |
| 4666 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 4667 | image_view_create_info.subresourceRange.levelCount = 1; |
| 4668 | image_view_create_info.subresourceRange.aspectMask = |
| 4669 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4670 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4671 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4672 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 4673 | &view); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4674 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 4675 | VkDescriptorImageInfo imageInfo[4] = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4676 | imageInfo[0].imageView = view; |
| 4677 | imageInfo[0].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 4678 | imageInfo[1].imageView = view; |
| 4679 | imageInfo[1].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 4680 | imageInfo[2].imageView = view; |
| 4681 | imageInfo[2].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 4682 | imageInfo[3].imageView = view; |
| 4683 | imageInfo[3].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4684 | |
| 4685 | static const uint32_t NUM_SET_UPDATES = 3; |
| 4686 | VkWriteDescriptorSet descriptor_write[NUM_SET_UPDATES] = {}; |
| 4687 | descriptor_write[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 4688 | descriptor_write[0].dstSet = descriptorSet[0]; |
| 4689 | descriptor_write[0].dstBinding = 0; |
| 4690 | descriptor_write[0].descriptorCount = 5; |
| 4691 | descriptor_write[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4692 | descriptor_write[0].pBufferInfo = buffInfo; |
| 4693 | descriptor_write[1].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 4694 | descriptor_write[1].dstSet = descriptorSet[1]; |
| 4695 | descriptor_write[1].dstBinding = 0; |
| 4696 | descriptor_write[1].descriptorCount = 2; |
| 4697 | descriptor_write[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 4698 | descriptor_write[1].pImageInfo = imageInfo; |
| 4699 | descriptor_write[2].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 4700 | descriptor_write[2].dstSet = descriptorSet[1]; |
| 4701 | descriptor_write[2].dstBinding = 1; |
| 4702 | descriptor_write[2].descriptorCount = 2; |
| 4703 | descriptor_write[2].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 4704 | descriptor_write[2].pImageInfo = &imageInfo[2]; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4705 | |
| 4706 | vkUpdateDescriptorSets(m_device->device(), 3, descriptor_write, 0, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4707 | |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 4708 | // Create PSO to be used for draw-time errors below |
| 4709 | char const *vsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 4710 | "#version 450\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 4711 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 4712 | "out gl_PerVertex {\n" |
| 4713 | " vec4 gl_Position;\n" |
| 4714 | "};\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 4715 | "void main(){\n" |
| 4716 | " gl_Position = vec4(1);\n" |
| 4717 | "}\n"; |
| 4718 | char const *fsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 4719 | "#version 450\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 4720 | "\n" |
| 4721 | "layout(location=0) out vec4 x;\n" |
| 4722 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 4723 | "void main(){\n" |
| 4724 | " x = vec4(bar.y);\n" |
| 4725 | "}\n"; |
| 4726 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4727 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4728 | VkPipelineObj pipe(m_device); |
| 4729 | pipe.AddShader(&vs); |
| 4730 | pipe.AddShader(&fs); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 4731 | pipe.AddColorAttachment(); |
| 4732 | pipe.CreateVKPipeline(pipe_layout_fs_only, renderPass()); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4733 | |
| 4734 | BeginCommandBuffer(); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 4735 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4736 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4737 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 4738 | // NOTE : I believe LunarG ilo driver has bug (LX#189) that requires binding |
| 4739 | // of PSO |
| 4740 | // here before binding DSs. Otherwise we assert in cmd_copy_dset_data() of |
| 4741 | // cmd_pipeline.c |
| 4742 | // due to the fact that cmd_alloc_dset_data() has not been called in |
| 4743 | // cmd_bind_graphics_pipeline() |
| 4744 | // TODO : Want to cause various binding incompatibility issues here to test |
| 4745 | // DrawState |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4746 | // First cause various verify_layout_compatibility() fails |
| 4747 | // Second disturb early and late sets and verify INFO msgs |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4748 | // verify_set_layout_compatibility fail cases: |
| 4749 | // 1. invalid VkPipelineLayout (layout) passed into vkCmdBindDescriptorSets |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4750 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4751 | " due to: invalid VkPipelineLayout "); |
| 4752 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 4753 | VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 4754 | (VkPipelineLayout)((size_t)0xbaadb1be), 0, 1, |
| 4755 | &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4756 | m_errorMonitor->VerifyFound(); |
| 4757 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4758 | // 2. layoutIndex exceeds # of layouts in layout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4759 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4760 | " attempting to bind set to index 1"); |
| 4761 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 4762 | VK_PIPELINE_BIND_POINT_GRAPHICS, single_pipe_layout, |
| 4763 | 0, 2, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4764 | m_errorMonitor->VerifyFound(); |
| 4765 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4766 | vkDestroyPipelineLayout(m_device->device(), single_pipe_layout, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4767 | // 3. Pipeline setLayout[0] has 2 descriptors, but set being bound has 5 |
| 4768 | // descriptors |
| 4769 | m_errorMonitor->SetDesiredFailureMsg( |
| 4770 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 4771 | " has 2 descriptors, but DescriptorSetLayout "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4772 | vkCmdBindDescriptorSets( |
| 4773 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 4774 | pipe_layout_one_desc, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4775 | m_errorMonitor->VerifyFound(); |
| 4776 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4777 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_one_desc, NULL); |
| 4778 | // 4. same # of descriptors but mismatch in type |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4779 | m_errorMonitor->SetDesiredFailureMsg( |
| 4780 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 4781 | " is type 'VK_DESCRIPTOR_TYPE_SAMPLER' but binding "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4782 | vkCmdBindDescriptorSets( |
| 4783 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 4784 | pipe_layout_five_samp, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4785 | m_errorMonitor->VerifyFound(); |
| 4786 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4787 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_five_samp, NULL); |
| 4788 | // 5. same # of descriptors but mismatch in stageFlags |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4789 | m_errorMonitor->SetDesiredFailureMsg( |
| 4790 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 4791 | " has stageFlags 16 but binding 0 for DescriptorSetLayout "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4792 | vkCmdBindDescriptorSets( |
| 4793 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 4794 | pipe_layout_fs_only, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4795 | m_errorMonitor->VerifyFound(); |
| 4796 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4797 | // Cause INFO messages due to disturbing previously bound Sets |
| 4798 | // First bind sets 0 & 1 |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4799 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 4800 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 4801 | 2, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4802 | // 1. Disturb bound set0 by re-binding set1 w/ updated pipelineLayout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4803 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 4804 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4805 | " previously bound as set #0 was disturbed "); |
| 4806 | vkCmdBindDescriptorSets( |
| 4807 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 4808 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4809 | m_errorMonitor->VerifyFound(); |
| 4810 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4811 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 4812 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 4813 | 2, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4814 | // 2. Disturb set after last bound set |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 4815 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4816 | " newly bound as set #0 so set #1 and " |
| 4817 | "any subsequent sets were disturbed "); |
| 4818 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 4819 | VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 4820 | pipe_layout_fs_only, 0, 1, &ds0_fs_only, 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4821 | m_errorMonitor->VerifyFound(); |
| 4822 | |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 4823 | // Cause draw-time errors due to PSO incompatibilities |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4824 | // 1. Error due to not binding required set (we actually use same code as |
| 4825 | // above to disturb set0) |
| 4826 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 4827 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 4828 | 2, &descriptorSet[0], 0, NULL); |
| 4829 | vkCmdBindDescriptorSets( |
| 4830 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 4831 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
| 4832 | m_errorMonitor->SetDesiredFailureMsg( |
| 4833 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4834 | " uses set #0 but that set is not bound."); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 4835 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4836 | m_errorMonitor->VerifyFound(); |
| 4837 | |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 4838 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_bad_set0, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4839 | // 2. Error due to bound set not being compatible with PSO's |
| 4840 | // VkPipelineLayout (diff stageFlags in this case) |
| 4841 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 4842 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 4843 | 2, &descriptorSet[0], 0, NULL); |
| 4844 | m_errorMonitor->SetDesiredFailureMsg( |
| 4845 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4846 | " bound as set #0 is not compatible with "); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 4847 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4848 | m_errorMonitor->VerifyFound(); |
| 4849 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4850 | // Remaining clean-up |
| 4851 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_fs_only, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4852 | for (uint32_t i = 0; i < NUM_LAYOUTS; ++i) { |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4853 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout[i], NULL); |
| 4854 | } |
| 4855 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout_fs_only, NULL); |
Tobin Ehlis | 9bfd449 | 2016-05-05 15:09:11 -0600 | [diff] [blame] | 4856 | vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &ds0_fs_only); |
| 4857 | vkFreeDescriptorSets(m_device->device(), ds_pool, NUM_SETS, descriptorSet); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4858 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4859 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4860 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 4861 | } |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4862 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4863 | TEST_F(VkLayerTest, NoBeginCommandBuffer) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4864 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4865 | m_errorMonitor->SetDesiredFailureMsg( |
| 4866 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4867 | "You must call vkBeginCommandBuffer() before this call to "); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4868 | |
| 4869 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4870 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4871 | // Call EndCommandBuffer() w/o calling BeginCommandBuffer() |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4872 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4873 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4874 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4875 | } |
| 4876 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4877 | TEST_F(VkLayerTest, SecondaryCommandBufferNullRenderpass) { |
| 4878 | VkResult err; |
| 4879 | VkCommandBuffer draw_cmd; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4880 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4881 | m_errorMonitor->SetDesiredFailureMsg( |
| 4882 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 61b36f3 | 2015-12-16 08:19:42 -0700 | [diff] [blame] | 4883 | " must specify a valid renderpass parameter."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4884 | |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 4885 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 4886 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4887 | VkCommandBufferAllocateInfo cmd = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4888 | cmd.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 4889 | cmd.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4890 | cmd.commandPool = m_commandPool; |
| 4891 | cmd.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4892 | cmd.commandBufferCount = 1; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 4893 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4894 | err = vkAllocateCommandBuffers(m_device->device(), &cmd, &draw_cmd); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 4895 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 4896 | |
| 4897 | // Force the failure by not setting the Renderpass and Framebuffer fields |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4898 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4899 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4900 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 4901 | cmd_buf_info.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4902 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT | |
| 4903 | VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4904 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 4905 | |
| 4906 | // The error should be caught by validation of the BeginCommandBuffer call |
| 4907 | vkBeginCommandBuffer(draw_cmd, &cmd_buf_info); |
| 4908 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4909 | m_errorMonitor->VerifyFound(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4910 | vkFreeCommandBuffers(m_device->device(), m_commandPool, 1, &draw_cmd); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 4911 | } |
| 4912 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4913 | TEST_F(VkLayerTest, CommandBufferResetErrors) { |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 4914 | // Cause error due to Begin while recording CB |
| 4915 | // Then cause 2 errors for attempting to reset CB w/o having |
| 4916 | // VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT set for the pool from |
| 4917 | // which CBs were allocated. Note that this bit is off by default. |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4918 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4919 | "Cannot call Begin on CB"); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 4920 | |
| 4921 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4922 | |
| 4923 | // Calls AllocateCommandBuffers |
| 4924 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
| 4925 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4926 | // Force the failure by setting the Renderpass and Framebuffer fields with |
| 4927 | // (fake) data |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 4928 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4929 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 4930 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 4931 | cmd_buf_info.pNext = NULL; |
| 4932 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4933 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 4934 | |
| 4935 | // Begin CB to transition to recording state |
| 4936 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
| 4937 | // Can't re-begin. This should trigger error |
| 4938 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4939 | m_errorMonitor->VerifyFound(); |
| 4940 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4941 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4942 | "Attempt to reset command buffer "); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 4943 | VkCommandBufferResetFlags flags = 0; // Don't care about flags for this test |
| 4944 | // Reset attempt will trigger error due to incorrect CommandPool state |
| 4945 | vkResetCommandBuffer(commandBuffer.GetBufferHandle(), flags); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4946 | m_errorMonitor->VerifyFound(); |
| 4947 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4948 | m_errorMonitor->SetDesiredFailureMsg( |
| 4949 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4950 | " attempts to implicitly reset cmdBuffer created from "); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 4951 | // Transition CB to RECORDED state |
| 4952 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
| 4953 | // Now attempting to Begin will implicitly reset, which triggers error |
| 4954 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4955 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 4956 | } |
| 4957 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4958 | TEST_F(VkLayerTest, InvalidPipelineCreateState) { |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4959 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4960 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4961 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4962 | m_errorMonitor->SetDesiredFailureMsg( |
| 4963 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4964 | "Invalid Pipeline CreateInfo State: Vtx Shader required"); |
| 4965 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4966 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4967 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4968 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4969 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4970 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4971 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4972 | |
| 4973 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4974 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4975 | ds_pool_ci.pNext = NULL; |
| 4976 | ds_pool_ci.maxSets = 1; |
| 4977 | ds_pool_ci.poolSizeCount = 1; |
| 4978 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4979 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4980 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4981 | err = |
| 4982 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4983 | ASSERT_VK_SUCCESS(err); |
| 4984 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4985 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4986 | dsl_binding.binding = 0; |
| 4987 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4988 | dsl_binding.descriptorCount = 1; |
| 4989 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4990 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4991 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4992 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4993 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4994 | ds_layout_ci.pNext = NULL; |
| 4995 | ds_layout_ci.bindingCount = 1; |
| 4996 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4997 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4998 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4999 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5000 | &ds_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5001 | ASSERT_VK_SUCCESS(err); |
| 5002 | |
| 5003 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5004 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5005 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5006 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5007 | alloc_info.descriptorPool = ds_pool; |
| 5008 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5009 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5010 | &descriptorSet); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5011 | ASSERT_VK_SUCCESS(err); |
| 5012 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5013 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5014 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5015 | pipeline_layout_ci.setLayoutCount = 1; |
| 5016 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5017 | |
| 5018 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5019 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5020 | &pipeline_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5021 | ASSERT_VK_SUCCESS(err); |
| 5022 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5023 | VkViewport vp = {}; // Just need dummy vp to point to |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5024 | VkRect2D sc = {}; // dummy scissor to point to |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5025 | |
| 5026 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5027 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 5028 | vp_state_ci.scissorCount = 1; |
| 5029 | vp_state_ci.pScissors = ≻ |
| 5030 | vp_state_ci.viewportCount = 1; |
| 5031 | vp_state_ci.pViewports = &vp; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5032 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 5033 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 5034 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 5035 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 5036 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 5037 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 5038 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 5039 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 5040 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 5041 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5042 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5043 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 5044 | gp_ci.pViewportState = &vp_state_ci; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 5045 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5046 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 5047 | gp_ci.layout = pipeline_layout; |
| 5048 | gp_ci.renderPass = renderPass(); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5049 | |
| 5050 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5051 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 5052 | pc_ci.initialDataSize = 0; |
| 5053 | pc_ci.pInitialData = 0; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5054 | |
| 5055 | VkPipeline pipeline; |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 5056 | VkPipelineCache pipelineCache; |
| 5057 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5058 | err = |
| 5059 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 5060 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5061 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 5062 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 5063 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5064 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5065 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5066 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 5067 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5068 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5069 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5070 | } |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5071 | /*// TODO : This test should be good, but needs Tess support in compiler to run |
| 5072 | TEST_F(VkLayerTest, InvalidPatchControlPoints) |
| 5073 | { |
| 5074 | // Attempt to Create Gfx Pipeline w/o a VS |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5075 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5076 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5077 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5078 | "Invalid Pipeline CreateInfo State: VK_PRIMITIVE_TOPOLOGY_PATCH |
| 5079 | primitive "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5080 | |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5081 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5082 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5083 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5084 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5085 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5086 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5087 | |
| 5088 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 5089 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5090 | ds_pool_ci.pNext = NULL; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5091 | ds_pool_ci.poolSizeCount = 1; |
| 5092 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5093 | |
| 5094 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5095 | err = vkCreateDescriptorPool(m_device->device(), |
| 5096 | 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] | 5097 | ASSERT_VK_SUCCESS(err); |
| 5098 | |
| 5099 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5100 | dsl_binding.binding = 0; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5101 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 5102 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5103 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5104 | dsl_binding.pImmutableSamplers = NULL; |
| 5105 | |
| 5106 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5107 | ds_layout_ci.sType = |
| 5108 | VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5109 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5110 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 5111 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5112 | |
| 5113 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5114 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5115 | &ds_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5116 | ASSERT_VK_SUCCESS(err); |
| 5117 | |
| 5118 | VkDescriptorSet descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5119 | err = vkAllocateDescriptorSets(m_device->device(), ds_pool, |
| 5120 | VK_DESCRIPTOR_SET_USAGE_NON_FREE, 1, &ds_layout, &descriptorSet); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5121 | ASSERT_VK_SUCCESS(err); |
| 5122 | |
| 5123 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5124 | pipeline_layout_ci.sType = |
| 5125 | VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5126 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5127 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5128 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 5129 | |
| 5130 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5131 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5132 | &pipeline_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5133 | ASSERT_VK_SUCCESS(err); |
| 5134 | |
| 5135 | VkPipelineShaderStageCreateInfo shaderStages[3]; |
| 5136 | memset(&shaderStages, 0, 3 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 5137 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5138 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, |
| 5139 | this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5140 | // 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] | 5141 | VkShaderObj |
| 5142 | tc(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, |
| 5143 | this); |
| 5144 | VkShaderObj |
| 5145 | te(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, |
| 5146 | this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5147 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5148 | shaderStages[0].sType = |
| 5149 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5150 | shaderStages[0].stage = VK_SHADER_STAGE_VERTEX_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5151 | shaderStages[0].shader = vs.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5152 | shaderStages[1].sType = |
| 5153 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5154 | shaderStages[1].stage = VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5155 | shaderStages[1].shader = tc.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5156 | shaderStages[2].sType = |
| 5157 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5158 | shaderStages[2].stage = VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5159 | shaderStages[2].shader = te.handle(); |
| 5160 | |
| 5161 | VkPipelineInputAssemblyStateCreateInfo iaCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5162 | iaCI.sType = |
| 5163 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
Chia-I Wu | 515eb8f | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5164 | iaCI.topology = VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5165 | |
| 5166 | VkPipelineTessellationStateCreateInfo tsCI = {}; |
| 5167 | tsCI.sType = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO; |
| 5168 | tsCI.patchControlPoints = 0; // This will cause an error |
| 5169 | |
| 5170 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 5171 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 5172 | gp_ci.pNext = NULL; |
| 5173 | gp_ci.stageCount = 3; |
| 5174 | gp_ci.pStages = shaderStages; |
| 5175 | gp_ci.pVertexInputState = NULL; |
| 5176 | gp_ci.pInputAssemblyState = &iaCI; |
| 5177 | gp_ci.pTessellationState = &tsCI; |
| 5178 | gp_ci.pViewportState = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5179 | gp_ci.pRasterizationState = NULL; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5180 | gp_ci.pMultisampleState = NULL; |
| 5181 | gp_ci.pDepthStencilState = NULL; |
| 5182 | gp_ci.pColorBlendState = NULL; |
| 5183 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 5184 | gp_ci.layout = pipeline_layout; |
| 5185 | gp_ci.renderPass = renderPass(); |
| 5186 | |
| 5187 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 5188 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 5189 | pc_ci.pNext = NULL; |
| 5190 | pc_ci.initialSize = 0; |
| 5191 | pc_ci.initialData = 0; |
| 5192 | pc_ci.maxSize = 0; |
| 5193 | |
| 5194 | VkPipeline pipeline; |
| 5195 | VkPipelineCache pipelineCache; |
| 5196 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5197 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, |
| 5198 | &pipelineCache); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5199 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5200 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 5201 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5202 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5203 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5204 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5205 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 5206 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5207 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5208 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5209 | } |
| 5210 | */ |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5211 | // Set scissor and viewport counts to different numbers |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5212 | TEST_F(VkLayerTest, PSOViewportScissorCountMismatch) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5213 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5214 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5215 | m_errorMonitor->SetDesiredFailureMsg( |
| 5216 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5217 | "Gfx Pipeline viewport count (1) must match scissor count (0)."); |
| 5218 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5219 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5220 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5221 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5222 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5223 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5224 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5225 | |
| 5226 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5227 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5228 | ds_pool_ci.maxSets = 1; |
| 5229 | ds_pool_ci.poolSizeCount = 1; |
| 5230 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5231 | |
| 5232 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5233 | err = |
| 5234 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5235 | ASSERT_VK_SUCCESS(err); |
| 5236 | |
| 5237 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5238 | dsl_binding.binding = 0; |
| 5239 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5240 | dsl_binding.descriptorCount = 1; |
| 5241 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5242 | |
| 5243 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5244 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5245 | ds_layout_ci.bindingCount = 1; |
| 5246 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5247 | |
| 5248 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5249 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5250 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5251 | ASSERT_VK_SUCCESS(err); |
| 5252 | |
| 5253 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5254 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5255 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5256 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5257 | alloc_info.descriptorPool = ds_pool; |
| 5258 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5259 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5260 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5261 | ASSERT_VK_SUCCESS(err); |
| 5262 | |
| 5263 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5264 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5265 | pipeline_layout_ci.setLayoutCount = 1; |
| 5266 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5267 | |
| 5268 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5269 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5270 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5271 | ASSERT_VK_SUCCESS(err); |
| 5272 | |
| 5273 | VkViewport vp = {}; // Just need dummy vp to point to |
| 5274 | |
| 5275 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5276 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 5277 | vp_state_ci.scissorCount = 0; |
| 5278 | vp_state_ci.viewportCount = 1; // Count mismatch should cause error |
| 5279 | vp_state_ci.pViewports = &vp; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5280 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 5281 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 5282 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 5283 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 5284 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 5285 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 5286 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 5287 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 5288 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 5289 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 5290 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5291 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5292 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5293 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 5294 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5295 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 5296 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 5297 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5298 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5299 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 5300 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5301 | |
| 5302 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5303 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 5304 | gp_ci.stageCount = 2; |
| 5305 | gp_ci.pStages = shaderStages; |
| 5306 | gp_ci.pViewportState = &vp_state_ci; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 5307 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5308 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 5309 | gp_ci.layout = pipeline_layout; |
| 5310 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5311 | |
| 5312 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5313 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5314 | |
| 5315 | VkPipeline pipeline; |
| 5316 | VkPipelineCache pipelineCache; |
| 5317 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5318 | err = |
| 5319 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5320 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5321 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 5322 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5323 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5324 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5325 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5326 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 5327 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5328 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5329 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5330 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5331 | // Don't set viewport state in PSO. This is an error b/c we always need this |
| 5332 | // state |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 5333 | // 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] | 5334 | TEST_F(VkLayerTest, PSOViewportStateNotSet) { |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5335 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5336 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5337 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5338 | m_errorMonitor->SetDesiredFailureMsg( |
| 5339 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5340 | "Gfx Pipeline pViewportState is null. Even if "); |
| 5341 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5342 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5343 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5344 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5345 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5346 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5347 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5348 | |
| 5349 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5350 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5351 | ds_pool_ci.maxSets = 1; |
| 5352 | ds_pool_ci.poolSizeCount = 1; |
| 5353 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5354 | |
| 5355 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5356 | err = |
| 5357 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5358 | ASSERT_VK_SUCCESS(err); |
| 5359 | |
| 5360 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5361 | dsl_binding.binding = 0; |
| 5362 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5363 | dsl_binding.descriptorCount = 1; |
| 5364 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5365 | |
| 5366 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5367 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5368 | ds_layout_ci.bindingCount = 1; |
| 5369 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5370 | |
| 5371 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5372 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5373 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5374 | ASSERT_VK_SUCCESS(err); |
| 5375 | |
| 5376 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5377 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5378 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5379 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5380 | alloc_info.descriptorPool = ds_pool; |
| 5381 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5382 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5383 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5384 | ASSERT_VK_SUCCESS(err); |
| 5385 | |
| 5386 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5387 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5388 | pipeline_layout_ci.setLayoutCount = 1; |
| 5389 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5390 | |
| 5391 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5392 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5393 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5394 | ASSERT_VK_SUCCESS(err); |
| 5395 | |
| 5396 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 5397 | // Set scissor as dynamic to avoid second error |
| 5398 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5399 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 5400 | dyn_state_ci.dynamicStateCount = 1; |
| 5401 | dyn_state_ci.pDynamicStates = &sc_state; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5402 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 5403 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5404 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5405 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5406 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 5407 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5408 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 5409 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 5410 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5411 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5412 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 5413 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5414 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 5415 | |
| 5416 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 5417 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 5418 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 5419 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 5420 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 5421 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 5422 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 5423 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 5424 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5425 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5426 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 5427 | gp_ci.stageCount = 2; |
| 5428 | gp_ci.pStages = shaderStages; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 5429 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5430 | gp_ci.pViewportState = NULL; // Not setting VP state w/o dynamic vp state |
| 5431 | // should cause validation error |
| 5432 | gp_ci.pDynamicState = &dyn_state_ci; |
| 5433 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 5434 | gp_ci.layout = pipeline_layout; |
| 5435 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5436 | |
| 5437 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5438 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5439 | |
| 5440 | VkPipeline pipeline; |
| 5441 | VkPipelineCache pipelineCache; |
| 5442 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5443 | err = |
| 5444 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5445 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5446 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 5447 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5448 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5449 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5450 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5451 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 5452 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5453 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5454 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5455 | } |
| 5456 | // Create PSO w/o non-zero viewportCount but no viewport data |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5457 | // Then run second test where dynamic scissor count doesn't match PSO scissor |
| 5458 | // count |
| 5459 | TEST_F(VkLayerTest, PSOViewportCountWithoutDataAndDynScissorMismatch) { |
| 5460 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5461 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5462 | m_errorMonitor->SetDesiredFailureMsg( |
| 5463 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5464 | "Gfx Pipeline viewportCount is 1, but pViewports is NULL. "); |
| 5465 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5466 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5467 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5468 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5469 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5470 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5471 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5472 | |
| 5473 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5474 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5475 | ds_pool_ci.maxSets = 1; |
| 5476 | ds_pool_ci.poolSizeCount = 1; |
| 5477 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5478 | |
| 5479 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5480 | err = |
| 5481 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5482 | ASSERT_VK_SUCCESS(err); |
| 5483 | |
| 5484 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5485 | dsl_binding.binding = 0; |
| 5486 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5487 | dsl_binding.descriptorCount = 1; |
| 5488 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5489 | |
| 5490 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5491 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5492 | ds_layout_ci.bindingCount = 1; |
| 5493 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5494 | |
| 5495 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5496 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5497 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5498 | ASSERT_VK_SUCCESS(err); |
| 5499 | |
| 5500 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5501 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5502 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5503 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5504 | alloc_info.descriptorPool = ds_pool; |
| 5505 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5506 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5507 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5508 | ASSERT_VK_SUCCESS(err); |
| 5509 | |
| 5510 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5511 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5512 | pipeline_layout_ci.setLayoutCount = 1; |
| 5513 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5514 | |
| 5515 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5516 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5517 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5518 | ASSERT_VK_SUCCESS(err); |
| 5519 | |
| 5520 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5521 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 5522 | vp_state_ci.viewportCount = 1; |
| 5523 | vp_state_ci.pViewports = NULL; // Null vp w/ count of 1 should cause error |
| 5524 | vp_state_ci.scissorCount = 1; |
| 5525 | vp_state_ci.pScissors = |
| 5526 | NULL; // Scissor is dynamic (below) so this won't cause error |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5527 | |
| 5528 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 5529 | // Set scissor as dynamic to avoid that error |
| 5530 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5531 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 5532 | dyn_state_ci.dynamicStateCount = 1; |
| 5533 | dyn_state_ci.pDynamicStates = &sc_state; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5534 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 5535 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5536 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5537 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5538 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 5539 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5540 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 5541 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 5542 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5543 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5544 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 5545 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5546 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 5547 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 5548 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 5549 | vi_ci.pNext = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5550 | vi_ci.vertexBindingDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 5551 | vi_ci.pVertexBindingDescriptions = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5552 | vi_ci.vertexAttributeDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 5553 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 5554 | |
| 5555 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 5556 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 5557 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 5558 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5559 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5560 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 5561 | rs_ci.pNext = nullptr; |
| 5562 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 5563 | VkPipelineColorBlendAttachmentState att = {}; |
| 5564 | att.blendEnable = VK_FALSE; |
| 5565 | att.colorWriteMask = 0xf; |
| 5566 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 5567 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 5568 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 5569 | cb_ci.pNext = nullptr; |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 5570 | cb_ci.attachmentCount = 1; |
| 5571 | cb_ci.pAttachments = &att; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 5572 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5573 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5574 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 5575 | gp_ci.stageCount = 2; |
| 5576 | gp_ci.pStages = shaderStages; |
| 5577 | gp_ci.pVertexInputState = &vi_ci; |
| 5578 | gp_ci.pInputAssemblyState = &ia_ci; |
| 5579 | gp_ci.pViewportState = &vp_state_ci; |
| 5580 | gp_ci.pRasterizationState = &rs_ci; |
| 5581 | gp_ci.pColorBlendState = &cb_ci; |
| 5582 | gp_ci.pDynamicState = &dyn_state_ci; |
| 5583 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 5584 | gp_ci.layout = pipeline_layout; |
| 5585 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5586 | |
| 5587 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5588 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5589 | |
| 5590 | VkPipeline pipeline; |
| 5591 | VkPipelineCache pipelineCache; |
| 5592 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5593 | err = |
| 5594 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5595 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5596 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 5597 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5598 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5599 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5600 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 5601 | // 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] | 5602 | // First need to successfully create the PSO from above by setting |
| 5603 | // pViewports |
| 5604 | m_errorMonitor->SetDesiredFailureMsg( |
| 5605 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5606 | "Dynamic scissorCount from vkCmdSetScissor() is 2, but PSO " |
| 5607 | "scissorCount is 1. These counts must match."); |
| 5608 | |
| 5609 | VkViewport vp = {}; // Just need dummy vp to point to |
| 5610 | vp_state_ci.pViewports = &vp; |
| 5611 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 5612 | &gp_ci, NULL, &pipeline); |
| 5613 | ASSERT_VK_SUCCESS(err); |
| 5614 | BeginCommandBuffer(); |
| 5615 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 5616 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
| 5617 | VkRect2D scissors[2] = {}; // don't care about data |
| 5618 | // Count of 2 doesn't match PSO count of 1 |
| 5619 | vkCmdSetScissor(m_commandBuffer->GetBufferHandle(), 0, 2, scissors); |
| 5620 | Draw(1, 0, 0, 0); |
| 5621 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5622 | m_errorMonitor->VerifyFound(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5623 | |
| 5624 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 5625 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5626 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5627 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 5628 | } |
| 5629 | // Create PSO w/o non-zero scissorCount but no scissor data |
| 5630 | // Then run second test where dynamic viewportCount doesn't match PSO |
| 5631 | // viewportCount |
| 5632 | TEST_F(VkLayerTest, PSOScissorCountWithoutDataAndDynViewportMismatch) { |
| 5633 | VkResult err; |
| 5634 | |
| 5635 | m_errorMonitor->SetDesiredFailureMsg( |
| 5636 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5637 | "Gfx Pipeline scissorCount is 1, but pScissors is NULL. "); |
| 5638 | |
| 5639 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5640 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5641 | |
| 5642 | VkDescriptorPoolSize ds_type_count = {}; |
| 5643 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5644 | ds_type_count.descriptorCount = 1; |
| 5645 | |
| 5646 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 5647 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5648 | ds_pool_ci.maxSets = 1; |
| 5649 | ds_pool_ci.poolSizeCount = 1; |
| 5650 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 5651 | |
| 5652 | VkDescriptorPool ds_pool; |
| 5653 | err = |
| 5654 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 5655 | ASSERT_VK_SUCCESS(err); |
| 5656 | |
| 5657 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 5658 | dsl_binding.binding = 0; |
| 5659 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5660 | dsl_binding.descriptorCount = 1; |
| 5661 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5662 | |
| 5663 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 5664 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5665 | ds_layout_ci.bindingCount = 1; |
| 5666 | ds_layout_ci.pBindings = &dsl_binding; |
| 5667 | |
| 5668 | VkDescriptorSetLayout ds_layout; |
| 5669 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5670 | &ds_layout); |
| 5671 | ASSERT_VK_SUCCESS(err); |
| 5672 | |
| 5673 | VkDescriptorSet descriptorSet; |
| 5674 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 5675 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 5676 | alloc_info.descriptorSetCount = 1; |
| 5677 | alloc_info.descriptorPool = ds_pool; |
| 5678 | alloc_info.pSetLayouts = &ds_layout; |
| 5679 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5680 | &descriptorSet); |
| 5681 | ASSERT_VK_SUCCESS(err); |
| 5682 | |
| 5683 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 5684 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5685 | pipeline_layout_ci.setLayoutCount = 1; |
| 5686 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 5687 | |
| 5688 | VkPipelineLayout pipeline_layout; |
| 5689 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5690 | &pipeline_layout); |
| 5691 | ASSERT_VK_SUCCESS(err); |
| 5692 | |
| 5693 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 5694 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 5695 | vp_state_ci.scissorCount = 1; |
| 5696 | vp_state_ci.pScissors = |
| 5697 | NULL; // Null scissor w/ count of 1 should cause error |
| 5698 | vp_state_ci.viewportCount = 1; |
| 5699 | vp_state_ci.pViewports = |
| 5700 | NULL; // vp is dynamic (below) so this won't cause error |
| 5701 | |
| 5702 | VkDynamicState vp_state = VK_DYNAMIC_STATE_VIEWPORT; |
| 5703 | // Set scissor as dynamic to avoid that error |
| 5704 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 5705 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 5706 | dyn_state_ci.dynamicStateCount = 1; |
| 5707 | dyn_state_ci.pDynamicStates = &vp_state; |
| 5708 | |
| 5709 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 5710 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 5711 | |
| 5712 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 5713 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5714 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 5715 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 5716 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5717 | // but add it to be able to run on more devices |
| 5718 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 5719 | shaderStages[1] = fs.GetStageCreateInfo(); |
| 5720 | |
| 5721 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 5722 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 5723 | vi_ci.pNext = nullptr; |
| 5724 | vi_ci.vertexBindingDescriptionCount = 0; |
| 5725 | vi_ci.pVertexBindingDescriptions = nullptr; |
| 5726 | vi_ci.vertexAttributeDescriptionCount = 0; |
| 5727 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 5728 | |
| 5729 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 5730 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 5731 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 5732 | |
| 5733 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
| 5734 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 5735 | rs_ci.pNext = nullptr; |
| 5736 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 5737 | VkPipelineColorBlendAttachmentState att = {}; |
| 5738 | att.blendEnable = VK_FALSE; |
| 5739 | att.colorWriteMask = 0xf; |
| 5740 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5741 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 5742 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 5743 | cb_ci.pNext = nullptr; |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 5744 | cb_ci.attachmentCount = 1; |
| 5745 | cb_ci.pAttachments = &att; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5746 | |
| 5747 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 5748 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 5749 | gp_ci.stageCount = 2; |
| 5750 | gp_ci.pStages = shaderStages; |
| 5751 | gp_ci.pVertexInputState = &vi_ci; |
| 5752 | gp_ci.pInputAssemblyState = &ia_ci; |
| 5753 | gp_ci.pViewportState = &vp_state_ci; |
| 5754 | gp_ci.pRasterizationState = &rs_ci; |
| 5755 | gp_ci.pColorBlendState = &cb_ci; |
| 5756 | gp_ci.pDynamicState = &dyn_state_ci; |
| 5757 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 5758 | gp_ci.layout = pipeline_layout; |
| 5759 | gp_ci.renderPass = renderPass(); |
| 5760 | |
| 5761 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 5762 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 5763 | |
| 5764 | VkPipeline pipeline; |
| 5765 | VkPipelineCache pipelineCache; |
| 5766 | |
| 5767 | err = |
| 5768 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 5769 | ASSERT_VK_SUCCESS(err); |
| 5770 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 5771 | &gp_ci, NULL, &pipeline); |
| 5772 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5773 | m_errorMonitor->VerifyFound(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5774 | |
| 5775 | // Now hit second fail case where we set scissor w/ different count than PSO |
| 5776 | // First need to successfully create the PSO from above by setting |
| 5777 | // pViewports |
| 5778 | m_errorMonitor->SetDesiredFailureMsg( |
| 5779 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5780 | "Dynamic viewportCount from vkCmdSetViewport() is 2, but PSO " |
| 5781 | "viewportCount is 1. These counts must match."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5782 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 5783 | VkRect2D sc = {}; // Just need dummy vp to point to |
| 5784 | vp_state_ci.pScissors = ≻ |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5785 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 5786 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 5787 | ASSERT_VK_SUCCESS(err); |
| 5788 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5789 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 5790 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 5791 | VkViewport viewports[2] = {}; // don't care about data |
| 5792 | // Count of 2 doesn't match PSO count of 1 |
Jon Ashburn | 19d3bf1 | 2015-12-30 14:06:55 -0700 | [diff] [blame] | 5793 | vkCmdSetViewport(m_commandBuffer->GetBufferHandle(), 0, 2, viewports); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 5794 | Draw(1, 0, 0, 0); |
| 5795 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5796 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5797 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5798 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 5799 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5800 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5801 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5802 | } |
| 5803 | |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 5804 | TEST_F(VkLayerTest, PSOLineWidthInvalid) { |
| 5805 | VkResult err; |
| 5806 | |
| 5807 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 5808 | "Attempt to set lineWidth to -1"); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 5809 | |
| 5810 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5811 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5812 | |
| 5813 | VkDescriptorPoolSize ds_type_count = {}; |
| 5814 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5815 | ds_type_count.descriptorCount = 1; |
| 5816 | |
| 5817 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 5818 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5819 | ds_pool_ci.maxSets = 1; |
| 5820 | ds_pool_ci.poolSizeCount = 1; |
| 5821 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 5822 | |
| 5823 | VkDescriptorPool ds_pool; |
| 5824 | err = |
| 5825 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 5826 | ASSERT_VK_SUCCESS(err); |
| 5827 | |
| 5828 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 5829 | dsl_binding.binding = 0; |
| 5830 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5831 | dsl_binding.descriptorCount = 1; |
| 5832 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5833 | |
| 5834 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 5835 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5836 | ds_layout_ci.bindingCount = 1; |
| 5837 | ds_layout_ci.pBindings = &dsl_binding; |
| 5838 | |
| 5839 | VkDescriptorSetLayout ds_layout; |
| 5840 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5841 | &ds_layout); |
| 5842 | ASSERT_VK_SUCCESS(err); |
| 5843 | |
| 5844 | VkDescriptorSet descriptorSet; |
| 5845 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 5846 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 5847 | alloc_info.descriptorSetCount = 1; |
| 5848 | alloc_info.descriptorPool = ds_pool; |
| 5849 | alloc_info.pSetLayouts = &ds_layout; |
| 5850 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5851 | &descriptorSet); |
| 5852 | ASSERT_VK_SUCCESS(err); |
| 5853 | |
| 5854 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 5855 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5856 | pipeline_layout_ci.setLayoutCount = 1; |
| 5857 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 5858 | |
| 5859 | VkPipelineLayout pipeline_layout; |
| 5860 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5861 | &pipeline_layout); |
| 5862 | ASSERT_VK_SUCCESS(err); |
| 5863 | |
| 5864 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 5865 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 5866 | vp_state_ci.scissorCount = 1; |
| 5867 | vp_state_ci.pScissors = NULL; |
| 5868 | vp_state_ci.viewportCount = 1; |
| 5869 | vp_state_ci.pViewports = NULL; |
| 5870 | |
| 5871 | VkDynamicState dynamic_states[3] = {VK_DYNAMIC_STATE_VIEWPORT, |
| 5872 | VK_DYNAMIC_STATE_SCISSOR, |
| 5873 | VK_DYNAMIC_STATE_LINE_WIDTH}; |
| 5874 | // Set scissor as dynamic to avoid that error |
| 5875 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 5876 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 5877 | dyn_state_ci.dynamicStateCount = 2; |
| 5878 | dyn_state_ci.pDynamicStates = dynamic_states; |
| 5879 | |
| 5880 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 5881 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 5882 | |
| 5883 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 5884 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5885 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 5886 | VK_SHADER_STAGE_FRAGMENT_BIT, |
| 5887 | this); // TODO - We shouldn't need a fragment shader |
| 5888 | // but add it to be able to run on more devices |
| 5889 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 5890 | shaderStages[1] = fs.GetStageCreateInfo(); |
| 5891 | |
| 5892 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 5893 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 5894 | vi_ci.pNext = nullptr; |
| 5895 | vi_ci.vertexBindingDescriptionCount = 0; |
| 5896 | vi_ci.pVertexBindingDescriptions = nullptr; |
| 5897 | vi_ci.vertexAttributeDescriptionCount = 0; |
| 5898 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 5899 | |
| 5900 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 5901 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 5902 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 5903 | |
| 5904 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
| 5905 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 5906 | rs_ci.pNext = nullptr; |
| 5907 | |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 5908 | // Check too low (line width of -1.0f). |
| 5909 | rs_ci.lineWidth = -1.0f; |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 5910 | |
| 5911 | VkPipelineColorBlendAttachmentState att = {}; |
| 5912 | att.blendEnable = VK_FALSE; |
| 5913 | att.colorWriteMask = 0xf; |
| 5914 | |
| 5915 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 5916 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 5917 | cb_ci.pNext = nullptr; |
| 5918 | cb_ci.attachmentCount = 1; |
| 5919 | cb_ci.pAttachments = &att; |
| 5920 | |
| 5921 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 5922 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 5923 | gp_ci.stageCount = 2; |
| 5924 | gp_ci.pStages = shaderStages; |
| 5925 | gp_ci.pVertexInputState = &vi_ci; |
| 5926 | gp_ci.pInputAssemblyState = &ia_ci; |
| 5927 | gp_ci.pViewportState = &vp_state_ci; |
| 5928 | gp_ci.pRasterizationState = &rs_ci; |
| 5929 | gp_ci.pColorBlendState = &cb_ci; |
| 5930 | gp_ci.pDynamicState = &dyn_state_ci; |
| 5931 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 5932 | gp_ci.layout = pipeline_layout; |
| 5933 | gp_ci.renderPass = renderPass(); |
| 5934 | |
| 5935 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 5936 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 5937 | |
| 5938 | VkPipeline pipeline; |
| 5939 | VkPipelineCache pipelineCache; |
| 5940 | |
| 5941 | err = |
| 5942 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 5943 | ASSERT_VK_SUCCESS(err); |
| 5944 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 5945 | &gp_ci, NULL, &pipeline); |
| 5946 | |
| 5947 | m_errorMonitor->VerifyFound(); |
| 5948 | |
| 5949 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5950 | "Attempt to set lineWidth to 65536"); |
| 5951 | |
| 5952 | // Check too high (line width of 65536.0f). |
| 5953 | rs_ci.lineWidth = 65536.0f; |
| 5954 | |
| 5955 | err = |
| 5956 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 5957 | ASSERT_VK_SUCCESS(err); |
| 5958 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 5959 | &gp_ci, NULL, &pipeline); |
| 5960 | |
| 5961 | m_errorMonitor->VerifyFound(); |
| 5962 | |
| 5963 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 5964 | "Attempt to set lineWidth to -1"); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 5965 | |
| 5966 | dyn_state_ci.dynamicStateCount = 3; |
| 5967 | |
| 5968 | rs_ci.lineWidth = 1.0f; |
| 5969 | |
| 5970 | err = |
| 5971 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 5972 | ASSERT_VK_SUCCESS(err); |
| 5973 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 5974 | &gp_ci, NULL, &pipeline); |
| 5975 | BeginCommandBuffer(); |
| 5976 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 5977 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
| 5978 | |
| 5979 | // Check too low with dynamic setting. |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 5980 | vkCmdSetLineWidth(m_commandBuffer->GetBufferHandle(), -1.0f); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 5981 | m_errorMonitor->VerifyFound(); |
| 5982 | |
| 5983 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5984 | "Attempt to set lineWidth to 65536"); |
| 5985 | |
| 5986 | // Check too high with dynamic setting. |
| 5987 | vkCmdSetLineWidth(m_commandBuffer->GetBufferHandle(), 65536.0f); |
| 5988 | m_errorMonitor->VerifyFound(); |
| 5989 | EndCommandBuffer(); |
| 5990 | |
| 5991 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 5992 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5993 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5994 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 5995 | } |
| 5996 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5997 | TEST_F(VkLayerTest, NullRenderPass) { |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 5998 | // Bind a NULL RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5999 | m_errorMonitor->SetDesiredFailureMsg( |
| 6000 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6001 | "You cannot use a NULL RenderPass object in vkCmdBeginRenderPass()"); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 6002 | |
| 6003 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6004 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 6005 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 6006 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6007 | // Don't care about RenderPass handle b/c error should be flagged before |
| 6008 | // that |
| 6009 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), NULL, |
| 6010 | VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 6011 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6012 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 6013 | } |
| 6014 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6015 | TEST_F(VkLayerTest, RenderPassWithinRenderPass) { |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6016 | // Bind a BeginRenderPass within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6017 | m_errorMonitor->SetDesiredFailureMsg( |
| 6018 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6019 | "It is invalid to issue this call inside an active render pass"); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6020 | |
| 6021 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6022 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6023 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 6024 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6025 | // Just create a dummy Renderpass that's non-NULL so we can get to the |
| 6026 | // proper error |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6027 | VkRenderPassBeginInfo rp_begin = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6028 | rp_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; |
| 6029 | rp_begin.pNext = NULL; |
| 6030 | rp_begin.renderPass = renderPass(); |
| 6031 | rp_begin.framebuffer = framebuffer(); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6032 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6033 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &rp_begin, |
| 6034 | VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6035 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6036 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 6037 | } |
| 6038 | |
Cody Northrop | 3bb4d96 | 2016-05-09 16:15:57 -0600 | [diff] [blame] | 6039 | TEST_F(VkLayerTest, EndCommandBufferWithinRenderPass) { |
| 6040 | |
| 6041 | TEST_DESCRIPTION("End a command buffer with an active render pass"); |
| 6042 | |
| 6043 | m_errorMonitor->SetDesiredFailureMsg( |
| 6044 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6045 | "It is invalid to issue this call inside an active render pass"); |
| 6046 | |
| 6047 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6048 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6049 | |
| 6050 | // The framework's BeginCommandBuffer calls CreateRenderPass |
| 6051 | BeginCommandBuffer(); |
| 6052 | |
| 6053 | // Call directly into vkEndCommandBuffer instead of the |
| 6054 | // the framework's EndCommandBuffer, which inserts a |
| 6055 | // vkEndRenderPass |
| 6056 | vkEndCommandBuffer(m_commandBuffer->GetBufferHandle()); |
| 6057 | |
| 6058 | m_errorMonitor->VerifyFound(); |
| 6059 | |
| 6060 | // TODO: Add test for VK_COMMAND_BUFFER_LEVEL_SECONDARY |
| 6061 | // TODO: Add test for VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT |
| 6062 | } |
| 6063 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6064 | TEST_F(VkLayerTest, FillBufferWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6065 | // Call CmdFillBuffer within an active renderpass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6066 | m_errorMonitor->SetDesiredFailureMsg( |
| 6067 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6068 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6069 | |
| 6070 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6071 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6072 | |
| 6073 | // Renderpass is started here |
| 6074 | BeginCommandBuffer(); |
| 6075 | |
| 6076 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6077 | vk_testing::Buffer dstBuffer; |
| 6078 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6079 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6080 | m_commandBuffer->FillBuffer(dstBuffer.handle(), 0, 4, 0x11111111); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6081 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6082 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6083 | } |
| 6084 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6085 | TEST_F(VkLayerTest, UpdateBufferWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6086 | // Call CmdUpdateBuffer within an active renderpass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6087 | m_errorMonitor->SetDesiredFailureMsg( |
| 6088 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6089 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6090 | |
| 6091 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6092 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6093 | |
| 6094 | // Renderpass is started here |
| 6095 | BeginCommandBuffer(); |
| 6096 | |
| 6097 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6098 | vk_testing::Buffer dstBuffer; |
| 6099 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6100 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6101 | VkDeviceSize dstOffset = 0; |
| 6102 | VkDeviceSize dataSize = 1024; |
| 6103 | const uint32_t *pData = NULL; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6104 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6105 | vkCmdUpdateBuffer(m_commandBuffer->GetBufferHandle(), dstBuffer.handle(), |
| 6106 | dstOffset, dataSize, pData); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6107 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6108 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6109 | } |
| 6110 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6111 | TEST_F(VkLayerTest, ClearColorImageWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6112 | // Call CmdClearColorImage within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6113 | m_errorMonitor->SetDesiredFailureMsg( |
| 6114 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6115 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6116 | |
| 6117 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6118 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6119 | |
| 6120 | // Renderpass is started here |
| 6121 | BeginCommandBuffer(); |
| 6122 | |
Michael Lentine | 0a369f6 | 2016-02-03 16:51:46 -0600 | [diff] [blame] | 6123 | VkClearColorValue clear_color; |
| 6124 | memset(clear_color.uint32, 0, sizeof(uint32_t) * 4); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6125 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 6126 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6127 | const int32_t tex_width = 32; |
| 6128 | const int32_t tex_height = 32; |
| 6129 | VkImageCreateInfo image_create_info = {}; |
| 6130 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6131 | image_create_info.pNext = NULL; |
| 6132 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6133 | image_create_info.format = tex_format; |
| 6134 | image_create_info.extent.width = tex_width; |
| 6135 | image_create_info.extent.height = tex_height; |
| 6136 | image_create_info.extent.depth = 1; |
| 6137 | image_create_info.mipLevels = 1; |
| 6138 | image_create_info.arrayLayers = 1; |
| 6139 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 6140 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 6141 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6142 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6143 | vk_testing::Image dstImage; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6144 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 6145 | reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6146 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6147 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
| 6148 | image_create_info, VK_IMAGE_ASPECT_COLOR_BIT); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6149 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6150 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), dstImage.handle(), |
| 6151 | VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1, &range); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6152 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6153 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6154 | } |
| 6155 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6156 | TEST_F(VkLayerTest, ClearDepthStencilImageWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6157 | // Call CmdClearDepthStencilImage within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6158 | m_errorMonitor->SetDesiredFailureMsg( |
| 6159 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6160 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6161 | |
| 6162 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6163 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6164 | |
| 6165 | // Renderpass is started here |
| 6166 | BeginCommandBuffer(); |
| 6167 | |
| 6168 | VkClearDepthStencilValue clear_value = {0}; |
Dustin Graves | a2e5c94 | 2016-02-11 18:28:06 -0700 | [diff] [blame] | 6169 | VkMemoryPropertyFlags reqs = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6170 | VkImageCreateInfo image_create_info = vk_testing::Image::create_info(); |
| 6171 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6172 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 6173 | image_create_info.extent.width = 64; |
| 6174 | image_create_info.extent.height = 64; |
| 6175 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 6176 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6177 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6178 | vk_testing::Image dstImage; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6179 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 6180 | reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6181 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6182 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
| 6183 | image_create_info, VK_IMAGE_ASPECT_DEPTH_BIT); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6184 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6185 | vkCmdClearDepthStencilImage( |
| 6186 | m_commandBuffer->GetBufferHandle(), dstImage.handle(), |
| 6187 | VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, &clear_value, 1, |
| 6188 | &range); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6189 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6190 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6191 | } |
| 6192 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6193 | TEST_F(VkLayerTest, ClearColorAttachmentsOutsideRenderPass) { |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 6194 | // Call CmdClearAttachmentss outside of an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6195 | VkResult err; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6196 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6197 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6198 | "vkCmdClearAttachments: This call " |
| 6199 | "must be issued inside an active " |
| 6200 | "render pass"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6201 | |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6202 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6203 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6204 | |
| 6205 | // Start no RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6206 | err = m_commandBuffer->BeginCommandBuffer(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6207 | ASSERT_VK_SUCCESS(err); |
| 6208 | |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 6209 | VkClearAttachment color_attachment; |
| 6210 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 6211 | color_attachment.clearValue.color.float32[0] = 0; |
| 6212 | color_attachment.clearValue.color.float32[1] = 0; |
| 6213 | color_attachment.clearValue.color.float32[2] = 0; |
| 6214 | color_attachment.clearValue.color.float32[3] = 0; |
| 6215 | color_attachment.colorAttachment = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6216 | VkClearRect clear_rect = {{{0, 0}, {32, 32}}}; |
| 6217 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
| 6218 | &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6219 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6220 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6221 | } |
| 6222 | |
Karl Schultz | 9e66a29 | 2016-04-21 15:57:51 -0600 | [diff] [blame] | 6223 | TEST_F(VkLayerTest, BufferMemoryBarrierNoBuffer) { |
| 6224 | // Try to add a buffer memory barrier with no buffer. |
| 6225 | m_errorMonitor->SetDesiredFailureMsg( |
| 6226 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6227 | "required parameter pBufferMemoryBarriers[i].buffer specified as VK_NULL_HANDLE"); |
| 6228 | |
| 6229 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6230 | BeginCommandBuffer(); |
| 6231 | |
| 6232 | VkBufferMemoryBarrier buf_barrier = {}; |
| 6233 | buf_barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; |
| 6234 | buf_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 6235 | buf_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 6236 | buf_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 6237 | buf_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 6238 | buf_barrier.buffer = VK_NULL_HANDLE; |
| 6239 | buf_barrier.offset = 0; |
| 6240 | buf_barrier.size = VK_WHOLE_SIZE; |
| 6241 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6242 | VK_PIPELINE_STAGE_HOST_BIT, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, |
| 6243 | 0, 0, nullptr, 1, &buf_barrier, 0, nullptr); |
| 6244 | |
| 6245 | m_errorMonitor->VerifyFound(); |
| 6246 | } |
| 6247 | |
Tony Barbour | 7fd5c0f | 2016-05-03 16:11:53 -0600 | [diff] [blame] | 6248 | TEST_F(VkLayerTest, InvalidBarriers) { |
| 6249 | TEST_DESCRIPTION("A variety of ways to get VK_INVALID_BARRIER "); |
| 6250 | |
| 6251 | m_errorMonitor->SetDesiredFailureMsg( |
| 6252 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Barriers cannot be set during subpass"); |
| 6253 | |
| 6254 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6255 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6256 | |
| 6257 | VkMemoryBarrier mem_barrier = {}; |
| 6258 | mem_barrier.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER; |
| 6259 | mem_barrier.pNext = NULL; |
| 6260 | mem_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 6261 | mem_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 6262 | BeginCommandBuffer(); |
| 6263 | // BeginCommandBuffer() starts a render pass |
| 6264 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6265 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6266 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 1, |
| 6267 | &mem_barrier, 0, nullptr, 0, nullptr); |
| 6268 | m_errorMonitor->VerifyFound(); |
| 6269 | |
| 6270 | m_errorMonitor->SetDesiredFailureMsg( |
| 6271 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6272 | "Image Layout cannot be transitioned to UNDEFINED"); |
| 6273 | VkImageObj image(m_device); |
| 6274 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 6275 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
| 6276 | ASSERT_TRUE(image.initialized()); |
| 6277 | VkImageMemoryBarrier img_barrier = {}; |
| 6278 | img_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; |
| 6279 | img_barrier.pNext = NULL; |
| 6280 | img_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 6281 | img_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 6282 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 6283 | // New layout can't be UNDEFINED |
| 6284 | img_barrier.newLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 6285 | img_barrier.image = image.handle(); |
| 6286 | img_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 6287 | img_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 6288 | img_barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 6289 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 6290 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 6291 | img_barrier.subresourceRange.layerCount = 1; |
| 6292 | img_barrier.subresourceRange.levelCount = 1; |
| 6293 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6294 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6295 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 6296 | nullptr, 1, &img_barrier); |
| 6297 | m_errorMonitor->VerifyFound(); |
| 6298 | img_barrier.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 6299 | |
| 6300 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6301 | "Subresource must have the sum of the " |
| 6302 | "baseArrayLayer"); |
| 6303 | // baseArrayLayer + layerCount must be <= image's arrayLayers |
| 6304 | img_barrier.subresourceRange.baseArrayLayer = 1; |
| 6305 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6306 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6307 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 6308 | nullptr, 1, &img_barrier); |
| 6309 | m_errorMonitor->VerifyFound(); |
| 6310 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 6311 | |
| 6312 | m_errorMonitor->SetDesiredFailureMsg( |
| 6313 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6314 | "Subresource must have the sum of the baseMipLevel"); |
| 6315 | // baseMipLevel + levelCount must be <= image's mipLevels |
| 6316 | img_barrier.subresourceRange.baseMipLevel = 1; |
| 6317 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6318 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6319 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 6320 | nullptr, 1, &img_barrier); |
| 6321 | m_errorMonitor->VerifyFound(); |
| 6322 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 6323 | |
| 6324 | m_errorMonitor->SetDesiredFailureMsg( |
| 6325 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6326 | "Buffer Barriers cannot be used during a render pass"); |
| 6327 | vk_testing::Buffer buffer; |
| 6328 | buffer.init(*m_device, 256); |
| 6329 | VkBufferMemoryBarrier buf_barrier = {}; |
| 6330 | buf_barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; |
| 6331 | buf_barrier.pNext = NULL; |
| 6332 | buf_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 6333 | buf_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 6334 | buf_barrier.buffer = buffer.handle(); |
| 6335 | buf_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 6336 | buf_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 6337 | buf_barrier.offset = 0; |
| 6338 | buf_barrier.size = VK_WHOLE_SIZE; |
| 6339 | // Can't send buffer barrier during a render pass |
| 6340 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6341 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6342 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 6343 | &buf_barrier, 0, nullptr); |
| 6344 | m_errorMonitor->VerifyFound(); |
| 6345 | vkCmdEndRenderPass(m_commandBuffer->GetBufferHandle()); |
| 6346 | |
| 6347 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6348 | "which is not less than total size"); |
| 6349 | buf_barrier.offset = 257; |
| 6350 | // Offset greater than total size |
| 6351 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6352 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6353 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 6354 | &buf_barrier, 0, nullptr); |
| 6355 | m_errorMonitor->VerifyFound(); |
| 6356 | buf_barrier.offset = 0; |
| 6357 | |
| 6358 | m_errorMonitor->SetDesiredFailureMsg( |
| 6359 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "whose sum is greater than total size"); |
| 6360 | buf_barrier.size = 257; |
| 6361 | // Size greater than total size |
| 6362 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6363 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6364 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 6365 | &buf_barrier, 0, nullptr); |
| 6366 | m_errorMonitor->VerifyFound(); |
| 6367 | buf_barrier.size = VK_WHOLE_SIZE; |
| 6368 | |
| 6369 | m_errorMonitor->SetDesiredFailureMsg( |
| 6370 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6371 | "Image is a depth and stencil format and thus must " |
| 6372 | "have both VK_IMAGE_ASPECT_DEPTH_BIT and " |
| 6373 | "VK_IMAGE_ASPECT_STENCIL_BIT set."); |
| 6374 | VkDepthStencilObj ds_image(m_device); |
| 6375 | ds_image.Init(m_device, 128, 128, VK_FORMAT_D24_UNORM_S8_UINT); |
| 6376 | ASSERT_TRUE(ds_image.initialized()); |
| 6377 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 6378 | img_barrier.newLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; |
| 6379 | img_barrier.image = ds_image.handle(); |
| 6380 | // Leave aspectMask at COLOR on purpose |
| 6381 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6382 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6383 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 6384 | nullptr, 1, &img_barrier); |
| 6385 | m_errorMonitor->VerifyFound(); |
| 6386 | } |
| 6387 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6388 | TEST_F(VkLayerTest, IdxBufferAlignmentError) { |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 6389 | // Bind a BeginRenderPass within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6390 | VkResult err; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 6391 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6392 | m_errorMonitor->SetDesiredFailureMsg( |
| 6393 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6394 | "vkCmdBindIndexBuffer() offset (0x7) does not fall on "); |
| 6395 | |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 6396 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6397 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 6398 | uint32_t qfi = 0; |
| 6399 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6400 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 6401 | buffCI.size = 1024; |
| 6402 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
| 6403 | buffCI.queueFamilyIndexCount = 1; |
| 6404 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 6405 | |
| 6406 | VkBuffer ib; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6407 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 6408 | ASSERT_VK_SUCCESS(err); |
| 6409 | |
| 6410 | BeginCommandBuffer(); |
| 6411 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6412 | // vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 6413 | // VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 6414 | // 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] | 6415 | vkCmdBindIndexBuffer(m_commandBuffer->GetBufferHandle(), ib, 7, |
| 6416 | VK_INDEX_TYPE_UINT16); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 6417 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6418 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 6419 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6420 | vkDestroyBuffer(m_device->device(), ib, NULL); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 6421 | } |
| 6422 | |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 6423 | TEST_F(VkLayerTest, InvalidQueueFamilyIndex) { |
| 6424 | // Create an out-of-range queueFamilyIndex |
| 6425 | m_errorMonitor->SetDesiredFailureMsg( |
| 6426 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Dustin Graves | de62853 | 2016-04-21 16:30:17 -0600 | [diff] [blame] | 6427 | "vkCreateBuffer: pCreateInfo->pQueueFamilyIndices[0] (777) must be one " |
| 6428 | "of the indices specified when the device was created, via the " |
| 6429 | "VkDeviceQueueCreateInfo structure."); |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 6430 | |
| 6431 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6432 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6433 | VkBufferCreateInfo buffCI = {}; |
| 6434 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 6435 | buffCI.size = 1024; |
| 6436 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
| 6437 | buffCI.queueFamilyIndexCount = 1; |
| 6438 | // Introduce failure by specifying invalid queue_family_index |
| 6439 | uint32_t qfi = 777; |
| 6440 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 6441 | buffCI.sharingMode = VK_SHARING_MODE_CONCURRENT; // qfi only matters in CONCURRENT mode |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 6442 | |
| 6443 | VkBuffer ib; |
| 6444 | vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
| 6445 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6446 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 6447 | } |
| 6448 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6449 | TEST_F(VkLayerTest, ExecuteCommandsPrimaryCB) { |
| 6450 | // Attempt vkCmdExecuteCommands w/ a primary cmd buffer (should only be |
| 6451 | // secondary) |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6452 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6453 | m_errorMonitor->SetDesiredFailureMsg( |
| 6454 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6455 | "vkCmdExecuteCommands() called w/ Primary Cmd Buffer "); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 6456 | |
| 6457 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6458 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 6459 | |
| 6460 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6461 | // ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6462 | VkCommandBuffer primCB = m_commandBuffer->GetBufferHandle(); |
| 6463 | vkCmdExecuteCommands(m_commandBuffer->GetBufferHandle(), 1, &primCB); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 6464 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6465 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 6466 | } |
| 6467 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6468 | TEST_F(VkLayerTest, DSTypeMismatch) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 6469 | // 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] | 6470 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6471 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6472 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 6473 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6474 | " binding #0 with type VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER but update " |
| 6475 | "type is VK_DESCRIPTOR_TYPE_SAMPLER"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6476 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6477 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6478 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6479 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6480 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6481 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6482 | |
| 6483 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6484 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6485 | ds_pool_ci.pNext = NULL; |
| 6486 | ds_pool_ci.maxSets = 1; |
| 6487 | ds_pool_ci.poolSizeCount = 1; |
| 6488 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6489 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6490 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6491 | err = |
| 6492 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6493 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6494 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6495 | dsl_binding.binding = 0; |
| 6496 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6497 | dsl_binding.descriptorCount = 1; |
| 6498 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6499 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6500 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6501 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6502 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6503 | ds_layout_ci.pNext = NULL; |
| 6504 | ds_layout_ci.bindingCount = 1; |
| 6505 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6506 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6507 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6508 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6509 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6510 | ASSERT_VK_SUCCESS(err); |
| 6511 | |
| 6512 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6513 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6514 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6515 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 6516 | alloc_info.descriptorPool = ds_pool; |
| 6517 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6518 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6519 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6520 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6521 | |
Tobin Ehlis | 30db8f8 | 2016-05-05 08:19:48 -0600 | [diff] [blame] | 6522 | VkSamplerCreateInfo sampler_ci = {}; |
| 6523 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 6524 | sampler_ci.pNext = NULL; |
| 6525 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 6526 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 6527 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 6528 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 6529 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 6530 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 6531 | sampler_ci.mipLodBias = 1.0; |
| 6532 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 6533 | sampler_ci.maxAnisotropy = 1; |
| 6534 | sampler_ci.compareEnable = VK_FALSE; |
| 6535 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 6536 | sampler_ci.minLod = 1.0; |
| 6537 | sampler_ci.maxLod = 1.0; |
| 6538 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 6539 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
| 6540 | VkSampler sampler; |
| 6541 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
| 6542 | ASSERT_VK_SUCCESS(err); |
| 6543 | |
| 6544 | VkDescriptorImageInfo info = {}; |
| 6545 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 6546 | |
| 6547 | VkWriteDescriptorSet descriptor_write; |
| 6548 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 6549 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6550 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6551 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6552 | // This is a mismatched type for the layout which expects BUFFER |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 6553 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 6554 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 6555 | |
| 6556 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 6557 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6558 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 6559 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6560 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 6561 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6562 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 6563 | } |
| 6564 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6565 | TEST_F(VkLayerTest, DSUpdateOutOfBounds) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 6566 | // For overlapping Update, have arrayIndex exceed that of layout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6567 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6568 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6569 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 6570 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6571 | " binding #0 with 1 total descriptors but update of 1 descriptors " |
| 6572 | "starting at binding offset of 0 combined with update array element " |
| 6573 | "offset of 1 oversteps the size of this descriptor set."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6574 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6575 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6576 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6577 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6578 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6579 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6580 | |
| 6581 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6582 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6583 | ds_pool_ci.pNext = NULL; |
| 6584 | ds_pool_ci.maxSets = 1; |
| 6585 | ds_pool_ci.poolSizeCount = 1; |
| 6586 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6587 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6588 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6589 | err = |
| 6590 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6591 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6592 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6593 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6594 | dsl_binding.binding = 0; |
| 6595 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6596 | dsl_binding.descriptorCount = 1; |
| 6597 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6598 | dsl_binding.pImmutableSamplers = NULL; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6599 | |
| 6600 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6601 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6602 | ds_layout_ci.pNext = NULL; |
| 6603 | ds_layout_ci.bindingCount = 1; |
| 6604 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6605 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6606 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6607 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6608 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6609 | ASSERT_VK_SUCCESS(err); |
| 6610 | |
| 6611 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6612 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6613 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6614 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 6615 | alloc_info.descriptorPool = ds_pool; |
| 6616 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6617 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6618 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6619 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6620 | |
Tobin Ehlis | 30db8f8 | 2016-05-05 08:19:48 -0600 | [diff] [blame] | 6621 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 6622 | VkDescriptorBufferInfo buff_info = {}; |
| 6623 | buff_info.buffer = |
| 6624 | VkBuffer(0); // Don't care about buffer handle for this test |
| 6625 | buff_info.offset = 0; |
| 6626 | buff_info.range = 1024; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 6627 | |
| 6628 | VkWriteDescriptorSet descriptor_write; |
| 6629 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 6630 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6631 | descriptor_write.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6632 | descriptor_write.dstArrayElement = |
| 6633 | 1; /* This index out of bounds for the update */ |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6634 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 6635 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6636 | descriptor_write.pBufferInfo = &buff_info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 6637 | |
| 6638 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 6639 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6640 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 6641 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6642 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6643 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 6644 | } |
| 6645 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6646 | TEST_F(VkLayerTest, InvalidDSUpdateIndex) { |
| 6647 | // Create layout w/ count of 1 and attempt update to that layout w/ binding |
| 6648 | // index 2 |
| 6649 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6650 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 6651 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6652 | " does not have binding 2."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6653 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6654 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6655 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6656 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6657 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6658 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6659 | |
| 6660 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6661 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6662 | ds_pool_ci.pNext = NULL; |
| 6663 | ds_pool_ci.maxSets = 1; |
| 6664 | ds_pool_ci.poolSizeCount = 1; |
| 6665 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 6666 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6667 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6668 | err = |
| 6669 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6670 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6671 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6672 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6673 | dsl_binding.binding = 0; |
| 6674 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6675 | dsl_binding.descriptorCount = 1; |
| 6676 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6677 | dsl_binding.pImmutableSamplers = NULL; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6678 | |
| 6679 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6680 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6681 | ds_layout_ci.pNext = NULL; |
| 6682 | ds_layout_ci.bindingCount = 1; |
| 6683 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6684 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6685 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6686 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6687 | ASSERT_VK_SUCCESS(err); |
| 6688 | |
| 6689 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6690 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6691 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6692 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 6693 | alloc_info.descriptorPool = ds_pool; |
| 6694 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6695 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6696 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6697 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6698 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6699 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6700 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 6701 | sampler_ci.pNext = NULL; |
| 6702 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 6703 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 6704 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 6705 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 6706 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 6707 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 6708 | sampler_ci.mipLodBias = 1.0; |
| 6709 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 6710 | sampler_ci.maxAnisotropy = 1; |
| 6711 | sampler_ci.compareEnable = VK_FALSE; |
| 6712 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 6713 | sampler_ci.minLod = 1.0; |
| 6714 | sampler_ci.maxLod = 1.0; |
| 6715 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 6716 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6717 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6718 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6719 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6720 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 6721 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 6722 | VkDescriptorImageInfo info = {}; |
| 6723 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 6724 | |
| 6725 | VkWriteDescriptorSet descriptor_write; |
| 6726 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 6727 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6728 | descriptor_write.dstSet = descriptorSet; |
| 6729 | descriptor_write.dstBinding = 2; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6730 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6731 | // 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] | 6732 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 6733 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 6734 | |
| 6735 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 6736 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6737 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 6738 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6739 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 6740 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6741 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 6742 | } |
| 6743 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6744 | TEST_F(VkLayerTest, InvalidDSUpdateStruct) { |
| 6745 | // Call UpdateDS w/ struct type other than valid VK_STRUCTUR_TYPE_UPDATE_* |
| 6746 | // types |
| 6747 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6748 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6749 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6750 | "Unexpected UPDATE struct of type "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6751 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6752 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6753 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6754 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6755 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6756 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6757 | |
| 6758 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6759 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6760 | ds_pool_ci.pNext = NULL; |
| 6761 | ds_pool_ci.maxSets = 1; |
| 6762 | ds_pool_ci.poolSizeCount = 1; |
| 6763 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 6764 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6765 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6766 | err = |
| 6767 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6768 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6769 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6770 | dsl_binding.binding = 0; |
| 6771 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6772 | dsl_binding.descriptorCount = 1; |
| 6773 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6774 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6775 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6776 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6777 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6778 | ds_layout_ci.pNext = NULL; |
| 6779 | ds_layout_ci.bindingCount = 1; |
| 6780 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6781 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6782 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6783 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6784 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6785 | ASSERT_VK_SUCCESS(err); |
| 6786 | |
| 6787 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6788 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6789 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6790 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 6791 | alloc_info.descriptorPool = ds_pool; |
| 6792 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6793 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6794 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6795 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6796 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6797 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6798 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 6799 | sampler_ci.pNext = NULL; |
| 6800 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 6801 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 6802 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 6803 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 6804 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 6805 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 6806 | sampler_ci.mipLodBias = 1.0; |
| 6807 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 6808 | sampler_ci.maxAnisotropy = 1; |
| 6809 | sampler_ci.compareEnable = VK_FALSE; |
| 6810 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 6811 | sampler_ci.minLod = 1.0; |
| 6812 | sampler_ci.maxLod = 1.0; |
| 6813 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 6814 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6815 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6816 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6817 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 6818 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 6819 | VkDescriptorImageInfo info = {}; |
| 6820 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 6821 | |
| 6822 | VkWriteDescriptorSet descriptor_write; |
| 6823 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6824 | descriptor_write.sType = |
| 6825 | (VkStructureType)0x99999999; /* Intentionally broken struct type */ |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6826 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6827 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6828 | // 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] | 6829 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 6830 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 6831 | |
| 6832 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 6833 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6834 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 6835 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6836 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 6837 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6838 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 6839 | } |
| 6840 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6841 | TEST_F(VkLayerTest, SampleDescriptorUpdateError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6842 | // Create a single Sampler descriptor and send it an invalid Sampler |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6843 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6844 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6845 | m_errorMonitor->SetDesiredFailureMsg( |
| 6846 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 6847 | "Attempted write update to sampler descriptor with invalid sampler"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6848 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6849 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6850 | // TODO : Farm Descriptor setup code to helper function(s) to reduce copied |
| 6851 | // code |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6852 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6853 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 6854 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6855 | |
| 6856 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6857 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6858 | ds_pool_ci.pNext = NULL; |
| 6859 | ds_pool_ci.maxSets = 1; |
| 6860 | ds_pool_ci.poolSizeCount = 1; |
| 6861 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6862 | |
| 6863 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6864 | err = |
| 6865 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6866 | ASSERT_VK_SUCCESS(err); |
| 6867 | |
| 6868 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6869 | dsl_binding.binding = 0; |
| 6870 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 6871 | dsl_binding.descriptorCount = 1; |
| 6872 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6873 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6874 | |
| 6875 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6876 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6877 | ds_layout_ci.pNext = NULL; |
| 6878 | ds_layout_ci.bindingCount = 1; |
| 6879 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6880 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6881 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6882 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6883 | ASSERT_VK_SUCCESS(err); |
| 6884 | |
| 6885 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6886 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6887 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6888 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6889 | alloc_info.descriptorPool = ds_pool; |
| 6890 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6891 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6892 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6893 | ASSERT_VK_SUCCESS(err); |
| 6894 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6895 | VkSampler sampler = |
| 6896 | (VkSampler)((size_t)0xbaadbeef); // Sampler with invalid handle |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6897 | |
| 6898 | VkDescriptorImageInfo descriptor_info; |
| 6899 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 6900 | descriptor_info.sampler = sampler; |
| 6901 | |
| 6902 | VkWriteDescriptorSet descriptor_write; |
| 6903 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 6904 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6905 | descriptor_write.dstSet = descriptorSet; |
| 6906 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6907 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6908 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 6909 | descriptor_write.pImageInfo = &descriptor_info; |
| 6910 | |
| 6911 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 6912 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6913 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6914 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6915 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6916 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6917 | } |
| 6918 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6919 | TEST_F(VkLayerTest, ImageViewDescriptorUpdateError) { |
| 6920 | // Create a single combined Image/Sampler descriptor and send it an invalid |
| 6921 | // imageView |
| 6922 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6923 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 6924 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6925 | "Attempted write update to combined " |
| 6926 | "image sampler descriptor failed due " |
Tobin Ehlis | 63c4b8a | 2016-05-09 10:29:34 -0600 | [diff] [blame] | 6927 | "to: Invalid VkImageView:"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6928 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6929 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6930 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6931 | ds_type_count.type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 6932 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6933 | |
| 6934 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6935 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6936 | ds_pool_ci.pNext = NULL; |
| 6937 | ds_pool_ci.maxSets = 1; |
| 6938 | ds_pool_ci.poolSizeCount = 1; |
| 6939 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6940 | |
| 6941 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6942 | err = |
| 6943 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6944 | ASSERT_VK_SUCCESS(err); |
| 6945 | |
| 6946 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6947 | dsl_binding.binding = 0; |
| 6948 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 6949 | dsl_binding.descriptorCount = 1; |
| 6950 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6951 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6952 | |
| 6953 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6954 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6955 | ds_layout_ci.pNext = NULL; |
| 6956 | ds_layout_ci.bindingCount = 1; |
| 6957 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6958 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6959 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6960 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6961 | ASSERT_VK_SUCCESS(err); |
| 6962 | |
| 6963 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6964 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6965 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6966 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6967 | alloc_info.descriptorPool = ds_pool; |
| 6968 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6969 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6970 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6971 | ASSERT_VK_SUCCESS(err); |
| 6972 | |
| 6973 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6974 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 6975 | sampler_ci.pNext = NULL; |
| 6976 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 6977 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 6978 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 6979 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 6980 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 6981 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 6982 | sampler_ci.mipLodBias = 1.0; |
| 6983 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 6984 | sampler_ci.maxAnisotropy = 1; |
| 6985 | sampler_ci.compareEnable = VK_FALSE; |
| 6986 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 6987 | sampler_ci.minLod = 1.0; |
| 6988 | sampler_ci.maxLod = 1.0; |
| 6989 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 6990 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6991 | |
| 6992 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6993 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6994 | ASSERT_VK_SUCCESS(err); |
| 6995 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6996 | VkImageView view = |
| 6997 | (VkImageView)((size_t)0xbaadbeef); // invalid imageView object |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6998 | |
| 6999 | VkDescriptorImageInfo descriptor_info; |
| 7000 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 7001 | descriptor_info.sampler = sampler; |
| 7002 | descriptor_info.imageView = view; |
| 7003 | |
| 7004 | VkWriteDescriptorSet descriptor_write; |
| 7005 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 7006 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7007 | descriptor_write.dstSet = descriptorSet; |
| 7008 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7009 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7010 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 7011 | descriptor_write.pImageInfo = &descriptor_info; |
| 7012 | |
| 7013 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 7014 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7015 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7016 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7017 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 7018 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7019 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7020 | } |
| 7021 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7022 | TEST_F(VkLayerTest, CopyDescriptorUpdateErrors) { |
| 7023 | // Create DS w/ layout of 2 types, write update 1 and attempt to copy-update |
| 7024 | // into the other |
| 7025 | VkResult err; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7026 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7027 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7028 | " binding #1 with type " |
| 7029 | "VK_DESCRIPTOR_TYPE_SAMPLER. Types do " |
| 7030 | "not match."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7031 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7032 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7033 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7034 | VkDescriptorPoolSize ds_type_count[2] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7035 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7036 | ds_type_count[0].descriptorCount = 1; |
| 7037 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 7038 | ds_type_count[1].descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7039 | |
| 7040 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7041 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7042 | ds_pool_ci.pNext = NULL; |
| 7043 | ds_pool_ci.maxSets = 1; |
| 7044 | ds_pool_ci.poolSizeCount = 2; |
| 7045 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7046 | |
| 7047 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7048 | err = |
| 7049 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7050 | ASSERT_VK_SUCCESS(err); |
| 7051 | VkDescriptorSetLayoutBinding dsl_binding[2] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7052 | dsl_binding[0].binding = 0; |
| 7053 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7054 | dsl_binding[0].descriptorCount = 1; |
| 7055 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 7056 | dsl_binding[0].pImmutableSamplers = NULL; |
| 7057 | dsl_binding[1].binding = 1; |
| 7058 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 7059 | dsl_binding[1].descriptorCount = 1; |
| 7060 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 7061 | dsl_binding[1].pImmutableSamplers = NULL; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7062 | |
| 7063 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7064 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7065 | ds_layout_ci.pNext = NULL; |
| 7066 | ds_layout_ci.bindingCount = 2; |
| 7067 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7068 | |
| 7069 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7070 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7071 | &ds_layout); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7072 | ASSERT_VK_SUCCESS(err); |
| 7073 | |
| 7074 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7075 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7076 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7077 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7078 | alloc_info.descriptorPool = ds_pool; |
| 7079 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7080 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7081 | &descriptorSet); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7082 | ASSERT_VK_SUCCESS(err); |
| 7083 | |
| 7084 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7085 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 7086 | sampler_ci.pNext = NULL; |
| 7087 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 7088 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 7089 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 7090 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7091 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7092 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7093 | sampler_ci.mipLodBias = 1.0; |
| 7094 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 7095 | sampler_ci.maxAnisotropy = 1; |
| 7096 | sampler_ci.compareEnable = VK_FALSE; |
| 7097 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 7098 | sampler_ci.minLod = 1.0; |
| 7099 | sampler_ci.maxLod = 1.0; |
| 7100 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 7101 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7102 | |
| 7103 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7104 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7105 | ASSERT_VK_SUCCESS(err); |
| 7106 | |
| 7107 | VkDescriptorImageInfo info = {}; |
| 7108 | info.sampler = sampler; |
| 7109 | |
| 7110 | VkWriteDescriptorSet descriptor_write; |
| 7111 | memset(&descriptor_write, 0, sizeof(VkWriteDescriptorSet)); |
| 7112 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7113 | descriptor_write.dstSet = descriptorSet; |
| 7114 | descriptor_write.dstBinding = 1; // SAMPLER binding from layout above |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7115 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7116 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 7117 | descriptor_write.pImageInfo = &info; |
| 7118 | // This write update should succeed |
| 7119 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 7120 | // Now perform a copy update that fails due to type mismatch |
| 7121 | VkCopyDescriptorSet copy_ds_update; |
| 7122 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 7123 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 7124 | copy_ds_update.srcSet = descriptorSet; |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 7125 | copy_ds_update.srcBinding = 1; // Copy from SAMPLER binding |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7126 | copy_ds_update.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7127 | copy_ds_update.dstBinding = 0; // ERROR : copy to UNIFORM binding |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7128 | copy_ds_update.descriptorCount = 1; // copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7129 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 7130 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7131 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7132 | // 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] | 7133 | m_errorMonitor->SetDesiredFailureMsg( |
| 7134 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7135 | " does not have copy update src binding of 3."); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7136 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 7137 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 7138 | copy_ds_update.srcSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7139 | copy_ds_update.srcBinding = |
| 7140 | 3; // ERROR : Invalid binding for matching layout |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7141 | copy_ds_update.dstSet = descriptorSet; |
| 7142 | copy_ds_update.dstBinding = 0; |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 7143 | copy_ds_update.descriptorCount = 1; // Copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7144 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 7145 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7146 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7147 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7148 | // 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] | 7149 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7150 | VK_DEBUG_REPORT_ERROR_BIT_EXT, " binding#1 with offset index of 1 plus " |
| 7151 | "update array offset of 0 and update of " |
| 7152 | "5 descriptors oversteps total number " |
| 7153 | "of descriptors in set: 2."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7154 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7155 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 7156 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 7157 | copy_ds_update.srcSet = descriptorSet; |
| 7158 | copy_ds_update.srcBinding = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7159 | copy_ds_update.dstSet = descriptorSet; |
| 7160 | copy_ds_update.dstBinding = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7161 | copy_ds_update.descriptorCount = |
| 7162 | 5; // ERROR copy 5 descriptors (out of bounds for layout) |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7163 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 7164 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7165 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7166 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7167 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 7168 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7169 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7170 | } |
| 7171 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7172 | TEST_F(VkLayerTest, NumSamplesMismatch) { |
| 7173 | // Create CommandBuffer where MSAA samples doesn't match RenderPass |
| 7174 | // sampleCount |
| 7175 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7176 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7177 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7178 | "Num samples mismatch! "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7179 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7180 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7181 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7182 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7183 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7184 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7185 | |
| 7186 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7187 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7188 | ds_pool_ci.pNext = NULL; |
| 7189 | ds_pool_ci.maxSets = 1; |
| 7190 | ds_pool_ci.poolSizeCount = 1; |
| 7191 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 7192 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7193 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7194 | err = |
| 7195 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7196 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7197 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7198 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 7199 | dsl_binding.binding = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7200 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 7201 | dsl_binding.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7202 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7203 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7204 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7205 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 7206 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7207 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7208 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 7209 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7210 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7211 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7212 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7213 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7214 | ASSERT_VK_SUCCESS(err); |
| 7215 | |
| 7216 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7217 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7218 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7219 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 7220 | alloc_info.descriptorPool = ds_pool; |
| 7221 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7222 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7223 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7224 | ASSERT_VK_SUCCESS(err); |
| 7225 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7226 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7227 | pipe_ms_state_ci.sType = |
| 7228 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 7229 | pipe_ms_state_ci.pNext = NULL; |
| 7230 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
| 7231 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 7232 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 7233 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7234 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7235 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7236 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 7237 | pipeline_layout_ci.pNext = NULL; |
| 7238 | pipeline_layout_ci.setLayoutCount = 1; |
| 7239 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7240 | |
| 7241 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7242 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 7243 | &pipeline_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7244 | ASSERT_VK_SUCCESS(err); |
| 7245 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7246 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 7247 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7248 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 7249 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 7250 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7251 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 7252 | VkPipelineObj pipe(m_device); |
| 7253 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 7254 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 7255 | pipe.AddColorAttachment(); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 7256 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 7257 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7258 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 7259 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7260 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 7261 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7262 | |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 7263 | // Render triangle (the error should trigger on the attempt to draw). |
| 7264 | Draw(3, 1, 0, 0); |
| 7265 | |
| 7266 | // Finalize recording of the command buffer |
| 7267 | EndCommandBuffer(); |
| 7268 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7269 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7270 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7271 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 7272 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7273 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 7274 | } |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 7275 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 7276 | TEST_F(VkLayerTest, NumBlendAttachMismatch) { |
| 7277 | // Create Pipeline where the number of blend attachments doesn't match the |
| 7278 | // number of color attachments. In this case, we don't add any color |
| 7279 | // blend attachments even though we have a color attachment. |
| 7280 | VkResult err; |
| 7281 | |
| 7282 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 7283 | "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] | 7284 | |
| 7285 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7286 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7287 | VkDescriptorPoolSize ds_type_count = {}; |
| 7288 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7289 | ds_type_count.descriptorCount = 1; |
| 7290 | |
| 7291 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 7292 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7293 | ds_pool_ci.pNext = NULL; |
| 7294 | ds_pool_ci.maxSets = 1; |
| 7295 | ds_pool_ci.poolSizeCount = 1; |
| 7296 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 7297 | |
| 7298 | VkDescriptorPool ds_pool; |
| 7299 | err = |
| 7300 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 7301 | ASSERT_VK_SUCCESS(err); |
| 7302 | |
| 7303 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 7304 | dsl_binding.binding = 0; |
| 7305 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7306 | dsl_binding.descriptorCount = 1; |
| 7307 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7308 | dsl_binding.pImmutableSamplers = NULL; |
| 7309 | |
| 7310 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 7311 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7312 | ds_layout_ci.pNext = NULL; |
| 7313 | ds_layout_ci.bindingCount = 1; |
| 7314 | ds_layout_ci.pBindings = &dsl_binding; |
| 7315 | |
| 7316 | VkDescriptorSetLayout ds_layout; |
| 7317 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7318 | &ds_layout); |
| 7319 | ASSERT_VK_SUCCESS(err); |
| 7320 | |
| 7321 | VkDescriptorSet descriptorSet; |
| 7322 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 7323 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 7324 | alloc_info.descriptorSetCount = 1; |
| 7325 | alloc_info.descriptorPool = ds_pool; |
| 7326 | alloc_info.pSetLayouts = &ds_layout; |
| 7327 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7328 | &descriptorSet); |
| 7329 | ASSERT_VK_SUCCESS(err); |
| 7330 | |
| 7331 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 7332 | pipe_ms_state_ci.sType = |
| 7333 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 7334 | pipe_ms_state_ci.pNext = NULL; |
| 7335 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 7336 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 7337 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 7338 | pipe_ms_state_ci.pSampleMask = NULL; |
| 7339 | |
| 7340 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 7341 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 7342 | pipeline_layout_ci.pNext = NULL; |
| 7343 | pipeline_layout_ci.setLayoutCount = 1; |
| 7344 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 7345 | |
| 7346 | VkPipelineLayout pipeline_layout; |
| 7347 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 7348 | &pipeline_layout); |
| 7349 | ASSERT_VK_SUCCESS(err); |
| 7350 | |
| 7351 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 7352 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7353 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 7354 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 7355 | this); // We shouldn't need a fragment shader |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 7356 | // but add it to be able to run on more devices |
| 7357 | VkPipelineObj pipe(m_device); |
| 7358 | pipe.AddShader(&vs); |
| 7359 | pipe.AddShader(&fs); |
| 7360 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 7361 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 7362 | |
| 7363 | BeginCommandBuffer(); |
| 7364 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 7365 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 7366 | |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 7367 | // Render triangle (the error should trigger on the attempt to draw). |
| 7368 | Draw(3, 1, 0, 0); |
| 7369 | |
| 7370 | // Finalize recording of the command buffer |
| 7371 | EndCommandBuffer(); |
| 7372 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7373 | m_errorMonitor->VerifyFound(); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 7374 | |
| 7375 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 7376 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7377 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 7378 | } |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 7379 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7380 | TEST_F(VkLayerTest, ClearCmdNoDraw) { |
| 7381 | // Create CommandBuffer where we add ClearCmd for FB Color attachment prior |
| 7382 | // to issuing a Draw |
| 7383 | VkResult err; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7384 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7385 | m_errorMonitor->SetDesiredFailureMsg( |
Tony Barbour | 7e56d30 | 2016-03-02 15:12:01 -0700 | [diff] [blame] | 7386 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7387 | "vkCmdClearAttachments() issued on CB object "); |
| 7388 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7389 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7390 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7391 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7392 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7393 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7394 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7395 | |
| 7396 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7397 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7398 | ds_pool_ci.pNext = NULL; |
| 7399 | ds_pool_ci.maxSets = 1; |
| 7400 | ds_pool_ci.poolSizeCount = 1; |
| 7401 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7402 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7403 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7404 | err = |
| 7405 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7406 | ASSERT_VK_SUCCESS(err); |
| 7407 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7408 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7409 | dsl_binding.binding = 0; |
| 7410 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7411 | dsl_binding.descriptorCount = 1; |
| 7412 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7413 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7414 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7415 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7416 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7417 | ds_layout_ci.pNext = NULL; |
| 7418 | ds_layout_ci.bindingCount = 1; |
| 7419 | ds_layout_ci.pBindings = &dsl_binding; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 7420 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7421 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7422 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7423 | &ds_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7424 | ASSERT_VK_SUCCESS(err); |
| 7425 | |
| 7426 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7427 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7428 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7429 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 7430 | alloc_info.descriptorPool = ds_pool; |
| 7431 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7432 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7433 | &descriptorSet); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7434 | ASSERT_VK_SUCCESS(err); |
| 7435 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7436 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7437 | pipe_ms_state_ci.sType = |
| 7438 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 7439 | pipe_ms_state_ci.pNext = NULL; |
| 7440 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
| 7441 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 7442 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 7443 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7444 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7445 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7446 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 7447 | pipeline_layout_ci.pNext = NULL; |
| 7448 | pipeline_layout_ci.setLayoutCount = 1; |
| 7449 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7450 | |
| 7451 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7452 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 7453 | &pipeline_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7454 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 7455 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7456 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 7457 | VK_SHADER_STAGE_VERTEX_BIT, this); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 7458 | // 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] | 7459 | // on more devices |
| 7460 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 7461 | VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7462 | |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 7463 | VkPipelineObj pipe(m_device); |
| 7464 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 7465 | pipe.AddShader(&fs); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 7466 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 7467 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 7468 | |
| 7469 | BeginCommandBuffer(); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7470 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7471 | // Main thing we care about for this test is that the VkImage obj we're |
| 7472 | // clearing matches Color Attachment of FB |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7473 | // Also pass down other dummy params to keep driver and paramchecker happy |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 7474 | VkClearAttachment color_attachment; |
| 7475 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 7476 | color_attachment.clearValue.color.float32[0] = 1.0; |
| 7477 | color_attachment.clearValue.color.float32[1] = 1.0; |
| 7478 | color_attachment.clearValue.color.float32[2] = 1.0; |
| 7479 | color_attachment.clearValue.color.float32[3] = 1.0; |
| 7480 | color_attachment.colorAttachment = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7481 | VkClearRect clear_rect = { |
| 7482 | {{0, 0}, {(uint32_t)m_width, (uint32_t)m_height}}}; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7483 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7484 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
| 7485 | &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7486 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7487 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7488 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7489 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 7490 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7491 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7492 | } |
| 7493 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7494 | TEST_F(VkLayerTest, VtxBufferBadIndex) { |
| 7495 | VkResult err; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 7496 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7497 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 7498 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | dfcd9b6 | 2015-12-14 15:14:10 -0700 | [diff] [blame] | 7499 | "but no vertex buffers are attached to this Pipeline State Object"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7500 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 7501 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 7502 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 7503 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7504 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7505 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7506 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7507 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7508 | |
| 7509 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7510 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7511 | ds_pool_ci.pNext = NULL; |
| 7512 | ds_pool_ci.maxSets = 1; |
| 7513 | ds_pool_ci.poolSizeCount = 1; |
| 7514 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7515 | |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 7516 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7517 | err = |
| 7518 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 7519 | ASSERT_VK_SUCCESS(err); |
| 7520 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7521 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7522 | dsl_binding.binding = 0; |
| 7523 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7524 | dsl_binding.descriptorCount = 1; |
| 7525 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7526 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 7527 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7528 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7529 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7530 | ds_layout_ci.pNext = NULL; |
| 7531 | ds_layout_ci.bindingCount = 1; |
| 7532 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7533 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 7534 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7535 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7536 | &ds_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 7537 | ASSERT_VK_SUCCESS(err); |
| 7538 | |
| 7539 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7540 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7541 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7542 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 7543 | alloc_info.descriptorPool = ds_pool; |
| 7544 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7545 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7546 | &descriptorSet); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 7547 | ASSERT_VK_SUCCESS(err); |
| 7548 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7549 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7550 | pipe_ms_state_ci.sType = |
| 7551 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 7552 | pipe_ms_state_ci.pNext = NULL; |
| 7553 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 7554 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 7555 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 7556 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 7557 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7558 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7559 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 7560 | pipeline_layout_ci.pNext = NULL; |
| 7561 | pipeline_layout_ci.setLayoutCount = 1; |
| 7562 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 7563 | VkPipelineLayout pipeline_layout; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 7564 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7565 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 7566 | &pipeline_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 7567 | ASSERT_VK_SUCCESS(err); |
| 7568 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7569 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 7570 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7571 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 7572 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 7573 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7574 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 7575 | VkPipelineObj pipe(m_device); |
| 7576 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 7577 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 7578 | pipe.AddColorAttachment(); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 7579 | pipe.SetMSAA(&pipe_ms_state_ci); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 7580 | pipe.SetViewport(m_viewports); |
| 7581 | pipe.SetScissor(m_scissors); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 7582 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 7583 | |
| 7584 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7585 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 7586 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 7587 | // Don't care about actual data, just need to get to draw to flag error |
| 7588 | static const float vbo_data[3] = {1.f, 0.f, 1.f}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7589 | VkConstantBufferObj vbo(m_device, sizeof(vbo_data), sizeof(float), |
| 7590 | (const void *)&vbo_data); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 7591 | 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] | 7592 | Draw(1, 0, 0, 0); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 7593 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7594 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7595 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7596 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 7597 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7598 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 7599 | } |
Tobin Ehlis | c555a3c | 2016-05-04 14:08:34 -0600 | [diff] [blame] | 7600 | // INVALID_IMAGE_LAYOUT tests (one other case is hit by MapMemWithoutHostVisibleBit and not here) |
| 7601 | TEST_F(VkLayerTest, InvalidImageLayout) { |
| 7602 | TEST_DESCRIPTION("Hit all possible validation checks associated with the " |
| 7603 | "DRAWSTATE_INVALID_IMAGE_LAYOUT enum. Generally these involve having" |
| 7604 | "images in the wrong layout when they're copied or transitioned."); |
| 7605 | // 3 in ValidateCmdBufImageLayouts |
| 7606 | // * -1 Attempt to submit cmd buf w/ deleted image |
| 7607 | // * -2 Cmd buf submit of image w/ layout not matching first use w/ subresource |
| 7608 | // * -3 Cmd buf submit of image w/ layout not matching first use w/o subresource |
| 7609 | m_errorMonitor->SetDesiredFailureMsg( |
| 7610 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 7611 | "Layout for input image should be TRANSFER_SRC_OPTIMAL instead of GENERAL."); |
| 7612 | |
| 7613 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7614 | // Create src & dst images to use for copy operations |
| 7615 | VkImage src_image; |
| 7616 | VkImage dst_image; |
| 7617 | |
| 7618 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 7619 | const int32_t tex_width = 32; |
| 7620 | const int32_t tex_height = 32; |
| 7621 | |
| 7622 | VkImageCreateInfo image_create_info = {}; |
| 7623 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 7624 | image_create_info.pNext = NULL; |
| 7625 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 7626 | image_create_info.format = tex_format; |
| 7627 | image_create_info.extent.width = tex_width; |
| 7628 | image_create_info.extent.height = tex_height; |
| 7629 | image_create_info.extent.depth = 1; |
| 7630 | image_create_info.mipLevels = 1; |
| 7631 | image_create_info.arrayLayers = 4; |
| 7632 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 7633 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 7634 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 7635 | image_create_info.flags = 0; |
| 7636 | |
| 7637 | VkResult err = vkCreateImage(m_device->device(), &image_create_info, NULL, &src_image); |
| 7638 | ASSERT_VK_SUCCESS(err); |
| 7639 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dst_image); |
| 7640 | ASSERT_VK_SUCCESS(err); |
| 7641 | |
| 7642 | BeginCommandBuffer(); |
| 7643 | VkImageCopy copyRegion; |
| 7644 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 7645 | copyRegion.srcSubresource.mipLevel = 0; |
| 7646 | copyRegion.srcSubresource.baseArrayLayer = 0; |
| 7647 | copyRegion.srcSubresource.layerCount = 1; |
| 7648 | copyRegion.srcOffset.x = 0; |
| 7649 | copyRegion.srcOffset.y = 0; |
| 7650 | copyRegion.srcOffset.z = 0; |
| 7651 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 7652 | copyRegion.dstSubresource.mipLevel = 0; |
| 7653 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 7654 | copyRegion.dstSubresource.layerCount = 1; |
| 7655 | copyRegion.dstOffset.x = 0; |
| 7656 | copyRegion.dstOffset.y = 0; |
| 7657 | copyRegion.dstOffset.z = 0; |
| 7658 | copyRegion.extent.width = 1; |
| 7659 | copyRegion.extent.height = 1; |
| 7660 | copyRegion.extent.depth = 1; |
| 7661 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 7662 | m_errorMonitor->VerifyFound(); |
| 7663 | // Now cause error due to src image layout changing |
| 7664 | m_errorMonitor->SetDesiredFailureMsg( |
| 7665 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7666 | "Cannot copy from an image whose source layout is VK_IMAGE_LAYOUT_UNDEFINED and doesn't match the current layout VK_IMAGE_LAYOUT_GENERAL."); |
| 7667 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_UNDEFINED, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 7668 | m_errorMonitor->VerifyFound(); |
| 7669 | // Final src error is due to bad layout type |
| 7670 | m_errorMonitor->SetDesiredFailureMsg( |
| 7671 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7672 | "Layout for input image is VK_IMAGE_LAYOUT_UNDEFINED but can only be TRANSFER_SRC_OPTIMAL or GENERAL."); |
| 7673 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_UNDEFINED, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 7674 | m_errorMonitor->VerifyFound(); |
| 7675 | // Now verify same checks for dst |
| 7676 | m_errorMonitor->SetDesiredFailureMsg( |
| 7677 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 7678 | "Layout for output image should be TRANSFER_DST_OPTIMAL instead of GENERAL."); |
| 7679 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 7680 | m_errorMonitor->VerifyFound(); |
| 7681 | // Now cause error due to src image layout changing |
| 7682 | m_errorMonitor->SetDesiredFailureMsg( |
| 7683 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7684 | "Cannot copy from an image whose dest layout is VK_IMAGE_LAYOUT_UNDEFINED and doesn't match the current layout VK_IMAGE_LAYOUT_GENERAL."); |
| 7685 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_UNDEFINED, 1, ©Region); |
| 7686 | m_errorMonitor->VerifyFound(); |
| 7687 | m_errorMonitor->SetDesiredFailureMsg( |
| 7688 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7689 | "Layout for output image is VK_IMAGE_LAYOUT_UNDEFINED but can only be TRANSFER_DST_OPTIMAL or GENERAL."); |
| 7690 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_UNDEFINED, 1, ©Region); |
| 7691 | m_errorMonitor->VerifyFound(); |
| 7692 | // Now cause error due to bad image layout transition in PipelineBarrier |
| 7693 | VkImageMemoryBarrier image_barrier[1] = {}; |
| 7694 | image_barrier[0].oldLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; |
| 7695 | image_barrier[0].image = src_image; |
| 7696 | image_barrier[0].subresourceRange.layerCount = 2; |
| 7697 | image_barrier[0].subresourceRange.levelCount = 2; |
| 7698 | image_barrier[0].subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 7699 | m_errorMonitor->SetDesiredFailureMsg( |
| 7700 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7701 | "You cannot transition the layout from VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL when current layout is VK_IMAGE_LAYOUT_GENERAL."); |
| 7702 | vkCmdPipelineBarrier(m_commandBuffer->handle(), VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, NULL, 0, NULL, 1, image_barrier); |
| 7703 | m_errorMonitor->VerifyFound(); |
| 7704 | |
| 7705 | // Finally some layout errors at RenderPass create time |
| 7706 | // Just hacking in specific state to get to the errors we want so don't copy this unless you know what you're doing. |
| 7707 | VkAttachmentReference attach = {}; |
| 7708 | // perf warning for GENERAL layout w/ non-DS input attachment |
| 7709 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 7710 | VkSubpassDescription subpass = {}; |
| 7711 | subpass.inputAttachmentCount = 1; |
| 7712 | subpass.pInputAttachments = &attach; |
| 7713 | VkRenderPassCreateInfo rpci = {}; |
| 7714 | rpci.subpassCount = 1; |
| 7715 | rpci.pSubpasses = &subpass; |
| 7716 | rpci.attachmentCount = 1; |
| 7717 | VkAttachmentDescription attach_desc = {}; |
| 7718 | attach_desc.format = VK_FORMAT_UNDEFINED; |
| 7719 | rpci.pAttachments = &attach_desc; |
Tobin Ehlis | 1efce02 | 2016-05-11 10:40:34 -0600 | [diff] [blame] | 7720 | rpci.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; |
Tobin Ehlis | c555a3c | 2016-05-04 14:08:34 -0600 | [diff] [blame] | 7721 | VkRenderPass rp; |
| 7722 | m_errorMonitor->SetDesiredFailureMsg( |
| 7723 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 7724 | "Layout for input attachment is GENERAL but should be READ_ONLY_OPTIMAL."); |
| 7725 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 7726 | m_errorMonitor->VerifyFound(); |
| 7727 | // error w/ non-general layout |
| 7728 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; |
| 7729 | |
| 7730 | m_errorMonitor->SetDesiredFailureMsg( |
| 7731 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7732 | "Layout for input attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be READ_ONLY_OPTIMAL or GENERAL."); |
| 7733 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 7734 | m_errorMonitor->VerifyFound(); |
| 7735 | subpass.inputAttachmentCount = 0; |
| 7736 | subpass.colorAttachmentCount = 1; |
| 7737 | subpass.pColorAttachments = &attach; |
| 7738 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 7739 | // perf warning for GENERAL layout on color attachment |
| 7740 | m_errorMonitor->SetDesiredFailureMsg( |
| 7741 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 7742 | "Layout for color attachment is GENERAL but should be COLOR_ATTACHMENT_OPTIMAL."); |
| 7743 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 7744 | m_errorMonitor->VerifyFound(); |
| 7745 | // error w/ non-color opt or GENERAL layout for color attachment |
| 7746 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; |
| 7747 | m_errorMonitor->SetDesiredFailureMsg( |
| 7748 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7749 | "Layout for color attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be COLOR_ATTACHMENT_OPTIMAL or GENERAL."); |
| 7750 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 7751 | m_errorMonitor->VerifyFound(); |
| 7752 | subpass.colorAttachmentCount = 0; |
| 7753 | subpass.pDepthStencilAttachment = &attach; |
| 7754 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 7755 | // perf warning for GENERAL layout on DS attachment |
| 7756 | m_errorMonitor->SetDesiredFailureMsg( |
| 7757 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 7758 | "Layout for depth attachment is GENERAL but should be DEPTH_STENCIL_ATTACHMENT_OPTIMAL."); |
| 7759 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 7760 | m_errorMonitor->VerifyFound(); |
| 7761 | // error w/ non-ds opt or GENERAL layout for color attachment |
| 7762 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; |
| 7763 | m_errorMonitor->SetDesiredFailureMsg( |
| 7764 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7765 | "Layout for depth attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be DEPTH_STENCIL_ATTACHMENT_OPTIMAL or GENERAL."); |
| 7766 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 7767 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 1efce02 | 2016-05-11 10:40:34 -0600 | [diff] [blame] | 7768 | // For this error we need a valid renderpass so create default one |
| 7769 | attach.layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; |
| 7770 | attach.attachment = 0; |
| 7771 | attach_desc.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 7772 | attach_desc.samples = VK_SAMPLE_COUNT_1_BIT; |
| 7773 | attach_desc.storeOp = VK_ATTACHMENT_STORE_OP_STORE; |
| 7774 | attach_desc.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; |
| 7775 | attach_desc.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; |
| 7776 | // Can't do a CLEAR load on READ_ONLY initialLayout |
| 7777 | attach_desc.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; |
| 7778 | attach_desc.initialLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; |
| 7779 | attach_desc.finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 7780 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7781 | " with invalid first layout " |
| 7782 | "VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_" |
| 7783 | "ONLY_OPTIMAL"); |
| 7784 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 7785 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | c555a3c | 2016-05-04 14:08:34 -0600 | [diff] [blame] | 7786 | |
| 7787 | vkDestroyImage(m_device->device(), src_image, NULL); |
| 7788 | vkDestroyImage(m_device->device(), dst_image, NULL); |
| 7789 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 7790 | #endif // DRAW_STATE_TESTS |
| 7791 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 7792 | #if THREADING_TESTS |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 7793 | #if GTEST_IS_THREADSAFE |
| 7794 | struct thread_data_struct { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7795 | VkCommandBuffer commandBuffer; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 7796 | VkEvent event; |
| 7797 | bool bailout; |
| 7798 | }; |
| 7799 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7800 | extern "C" void *AddToCommandBuffer(void *arg) { |
| 7801 | struct thread_data_struct *data = (struct thread_data_struct *)arg; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 7802 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7803 | for (int i = 0; i < 10000; i++) { |
| 7804 | vkCmdSetEvent(data->commandBuffer, data->event, |
| 7805 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 7806 | if (data->bailout) { |
| 7807 | break; |
| 7808 | } |
| 7809 | } |
| 7810 | return NULL; |
| 7811 | } |
| 7812 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7813 | TEST_F(VkLayerTest, ThreadCommandBufferCollision) { |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 7814 | test_platform_thread thread; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 7815 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7816 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7817 | "THREADING ERROR"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7818 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 7819 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7820 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 7821 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7822 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7823 | // Calls AllocateCommandBuffers |
| 7824 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 7825 | |
| 7826 | // Avoid creating RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7827 | commandBuffer.BeginCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 7828 | |
| 7829 | VkEventCreateInfo event_info; |
| 7830 | VkEvent event; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 7831 | VkResult err; |
| 7832 | |
| 7833 | memset(&event_info, 0, sizeof(event_info)); |
| 7834 | event_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 7835 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7836 | err = vkCreateEvent(device(), &event_info, NULL, &event); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 7837 | ASSERT_VK_SUCCESS(err); |
| 7838 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 7839 | err = vkResetEvent(device(), event); |
| 7840 | ASSERT_VK_SUCCESS(err); |
| 7841 | |
| 7842 | struct thread_data_struct data; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7843 | data.commandBuffer = commandBuffer.GetBufferHandle(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 7844 | data.event = event; |
| 7845 | data.bailout = false; |
| 7846 | m_errorMonitor->SetBailout(&data.bailout); |
| 7847 | // Add many entries to command buffer from another thread. |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 7848 | test_platform_thread_create(&thread, AddToCommandBuffer, (void *)&data); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 7849 | // Add many entries to command buffer from this thread at the same time. |
| 7850 | AddToCommandBuffer(&data); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 7851 | |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 7852 | test_platform_thread_join(thread, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7853 | commandBuffer.EndCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 7854 | |
Mike Stroyan | 10b8cb7 | 2016-01-22 15:22:03 -0700 | [diff] [blame] | 7855 | m_errorMonitor->SetBailout(NULL); |
| 7856 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7857 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 7858 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7859 | vkDestroyEvent(device(), event, NULL); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 7860 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 7861 | #endif // GTEST_IS_THREADSAFE |
| 7862 | #endif // THREADING_TESTS |
| 7863 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 7864 | #if SHADER_CHECKER_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7865 | TEST_F(VkLayerTest, InvalidSPIRVCodeSize) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7866 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 7867 | "Invalid SPIR-V header"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7868 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 7869 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7870 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7871 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 7872 | VkShaderModule module; |
| 7873 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 7874 | struct icd_spv_header spv; |
| 7875 | |
| 7876 | spv.magic = ICD_SPV_MAGIC; |
| 7877 | spv.version = ICD_SPV_VERSION; |
| 7878 | spv.gen_magic = 0; |
| 7879 | |
| 7880 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 7881 | moduleCreateInfo.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7882 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 7883 | moduleCreateInfo.codeSize = 4; |
| 7884 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7885 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 7886 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7887 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 7888 | } |
| 7889 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7890 | TEST_F(VkLayerTest, InvalidSPIRVMagic) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7891 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 7892 | "Invalid SPIR-V magic number"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7893 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 7894 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7895 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7896 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 7897 | VkShaderModule module; |
| 7898 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 7899 | struct icd_spv_header spv; |
| 7900 | |
| 7901 | spv.magic = ~ICD_SPV_MAGIC; |
| 7902 | spv.version = ICD_SPV_VERSION; |
| 7903 | spv.gen_magic = 0; |
| 7904 | |
| 7905 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 7906 | moduleCreateInfo.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7907 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 7908 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 7909 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7910 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 7911 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7912 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 7913 | } |
| 7914 | |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 7915 | #if 0 |
| 7916 | // Not currently covered by SPIRV-Tools validator |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7917 | TEST_F(VkLayerTest, InvalidSPIRVVersion) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7918 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 7919 | "Invalid SPIR-V header"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7920 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 7921 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7922 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7923 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 7924 | VkShaderModule module; |
| 7925 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 7926 | struct icd_spv_header spv; |
| 7927 | |
| 7928 | spv.magic = ICD_SPV_MAGIC; |
| 7929 | spv.version = ~ICD_SPV_VERSION; |
| 7930 | spv.gen_magic = 0; |
| 7931 | |
| 7932 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 7933 | moduleCreateInfo.pNext = NULL; |
| 7934 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7935 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 7936 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 7937 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7938 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 7939 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7940 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 7941 | } |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 7942 | #endif |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 7943 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7944 | TEST_F(VkLayerTest, CreatePipelineVertexOutputNotConsumed) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 7945 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7946 | "not consumed by fragment shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7947 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 7948 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 7949 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 7950 | |
| 7951 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7952 | "#version 450\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 7953 | "\n" |
| 7954 | "layout(location=0) out float x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7955 | "out gl_PerVertex {\n" |
| 7956 | " vec4 gl_Position;\n" |
| 7957 | "};\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 7958 | "void main(){\n" |
| 7959 | " gl_Position = vec4(1);\n" |
| 7960 | " x = 0;\n" |
| 7961 | "}\n"; |
| 7962 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7963 | "#version 450\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 7964 | "\n" |
| 7965 | "layout(location=0) out vec4 color;\n" |
| 7966 | "void main(){\n" |
| 7967 | " color = vec4(1);\n" |
| 7968 | "}\n"; |
| 7969 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 7970 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7971 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 7972 | |
| 7973 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 7974 | pipe.AddColorAttachment(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 7975 | pipe.AddShader(&vs); |
| 7976 | pipe.AddShader(&fs); |
| 7977 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 7978 | VkDescriptorSetObj descriptorSet(m_device); |
| 7979 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7980 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 7981 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 7982 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 7983 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7984 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 7985 | } |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 7986 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7987 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvided) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7988 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7989 | "not written by vertex shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7990 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 7991 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 7992 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 7993 | |
| 7994 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7995 | "#version 450\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 7996 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7997 | "out gl_PerVertex {\n" |
| 7998 | " vec4 gl_Position;\n" |
| 7999 | "};\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8000 | "void main(){\n" |
| 8001 | " gl_Position = vec4(1);\n" |
| 8002 | "}\n"; |
| 8003 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8004 | "#version 450\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8005 | "\n" |
| 8006 | "layout(location=0) in float x;\n" |
| 8007 | "layout(location=0) out vec4 color;\n" |
| 8008 | "void main(){\n" |
| 8009 | " color = vec4(x);\n" |
| 8010 | "}\n"; |
| 8011 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8012 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8013 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8014 | |
| 8015 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 8016 | pipe.AddColorAttachment(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8017 | pipe.AddShader(&vs); |
| 8018 | pipe.AddShader(&fs); |
| 8019 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8020 | VkDescriptorSetObj descriptorSet(m_device); |
| 8021 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8022 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8023 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 8024 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8025 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8026 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8027 | } |
| 8028 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8029 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvidedInBlock) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8030 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8031 | "not written by vertex shader"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8032 | |
| 8033 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8034 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8035 | |
| 8036 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8037 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8038 | "\n" |
| 8039 | "out gl_PerVertex {\n" |
| 8040 | " vec4 gl_Position;\n" |
| 8041 | "};\n" |
| 8042 | "void main(){\n" |
| 8043 | " gl_Position = vec4(1);\n" |
| 8044 | "}\n"; |
| 8045 | char const *fsSource = |
| 8046 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8047 | "\n" |
| 8048 | "in block { layout(location=0) float x; } ins;\n" |
| 8049 | "layout(location=0) out vec4 color;\n" |
| 8050 | "void main(){\n" |
| 8051 | " color = vec4(ins.x);\n" |
| 8052 | "}\n"; |
| 8053 | |
| 8054 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8055 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8056 | |
| 8057 | VkPipelineObj pipe(m_device); |
| 8058 | pipe.AddColorAttachment(); |
| 8059 | pipe.AddShader(&vs); |
| 8060 | pipe.AddShader(&fs); |
| 8061 | |
| 8062 | VkDescriptorSetObj descriptorSet(m_device); |
| 8063 | descriptorSet.AppendDummy(); |
| 8064 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8065 | |
| 8066 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8067 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8068 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8069 | } |
| 8070 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8071 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchArraySize) { |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 8072 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 8073 | "Type mismatch on location 0.0: 'ptr to " |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8074 | "output arr[2] of float32' vs 'ptr to " |
| 8075 | "input arr[3] of float32'"); |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 8076 | |
| 8077 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8078 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8079 | |
| 8080 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8081 | "#version 450\n" |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 8082 | "\n" |
| 8083 | "layout(location=0) out float x[2];\n" |
| 8084 | "out gl_PerVertex {\n" |
| 8085 | " vec4 gl_Position;\n" |
| 8086 | "};\n" |
| 8087 | "void main(){\n" |
| 8088 | " x[0] = 0; x[1] = 0;\n" |
| 8089 | " gl_Position = vec4(1);\n" |
| 8090 | "}\n"; |
| 8091 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8092 | "#version 450\n" |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 8093 | "\n" |
| 8094 | "layout(location=0) in float x[3];\n" |
| 8095 | "layout(location=0) out vec4 color;\n" |
| 8096 | "void main(){\n" |
| 8097 | " color = vec4(x[0] + x[1] + x[2]);\n" |
| 8098 | "}\n"; |
| 8099 | |
| 8100 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8101 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8102 | |
| 8103 | VkPipelineObj pipe(m_device); |
| 8104 | pipe.AddColorAttachment(); |
| 8105 | pipe.AddShader(&vs); |
| 8106 | pipe.AddShader(&fs); |
| 8107 | |
| 8108 | VkDescriptorSetObj descriptorSet(m_device); |
| 8109 | descriptorSet.AppendDummy(); |
| 8110 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8111 | |
| 8112 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8113 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8114 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 8115 | } |
| 8116 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8117 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatch) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8118 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8119 | "Type mismatch on location 0"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8120 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8121 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 8122 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8123 | |
| 8124 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8125 | "#version 450\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8126 | "\n" |
| 8127 | "layout(location=0) out int x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8128 | "out gl_PerVertex {\n" |
| 8129 | " vec4 gl_Position;\n" |
| 8130 | "};\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8131 | "void main(){\n" |
| 8132 | " x = 0;\n" |
| 8133 | " gl_Position = vec4(1);\n" |
| 8134 | "}\n"; |
| 8135 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8136 | "#version 450\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8137 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8138 | "layout(location=0) in float x;\n" /* VS writes int */ |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8139 | "layout(location=0) out vec4 color;\n" |
| 8140 | "void main(){\n" |
| 8141 | " color = vec4(x);\n" |
| 8142 | "}\n"; |
| 8143 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8144 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8145 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8146 | |
| 8147 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 8148 | pipe.AddColorAttachment(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8149 | pipe.AddShader(&vs); |
| 8150 | pipe.AddShader(&fs); |
| 8151 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8152 | VkDescriptorSetObj descriptorSet(m_device); |
| 8153 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8154 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8155 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 8156 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8157 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8158 | m_errorMonitor->VerifyFound(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8159 | } |
| 8160 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8161 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchInBlock) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8162 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8163 | "Type mismatch on location 0"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8164 | |
| 8165 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8166 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8167 | |
| 8168 | char const *vsSource = |
| 8169 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8170 | "\n" |
| 8171 | "out block { layout(location=0) int x; } outs;\n" |
| 8172 | "out gl_PerVertex {\n" |
| 8173 | " vec4 gl_Position;\n" |
| 8174 | "};\n" |
| 8175 | "void main(){\n" |
| 8176 | " outs.x = 0;\n" |
| 8177 | " gl_Position = vec4(1);\n" |
| 8178 | "}\n"; |
| 8179 | char const *fsSource = |
| 8180 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8181 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8182 | "in block { layout(location=0) float x; } ins;\n" /* VS writes int */ |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8183 | "layout(location=0) out vec4 color;\n" |
| 8184 | "void main(){\n" |
| 8185 | " color = vec4(ins.x);\n" |
| 8186 | "}\n"; |
| 8187 | |
| 8188 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8189 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8190 | |
| 8191 | VkPipelineObj pipe(m_device); |
| 8192 | pipe.AddColorAttachment(); |
| 8193 | pipe.AddShader(&vs); |
| 8194 | pipe.AddShader(&fs); |
| 8195 | |
| 8196 | VkDescriptorSetObj descriptorSet(m_device); |
| 8197 | descriptorSet.AppendDummy(); |
| 8198 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8199 | |
| 8200 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8201 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8202 | m_errorMonitor->VerifyFound(); |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 8203 | } |
| 8204 | |
| 8205 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByLocation) { |
| 8206 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8207 | "location 0.0 which is not written by vertex shader"); |
| 8208 | |
| 8209 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8210 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8211 | |
| 8212 | char const *vsSource = |
| 8213 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 8214 | "\n" |
| 8215 | "out block { layout(location=1) float x; } outs;\n" |
| 8216 | "out gl_PerVertex {\n" |
| 8217 | " vec4 gl_Position;\n" |
| 8218 | "};\n" |
| 8219 | "void main(){\n" |
| 8220 | " outs.x = 0;\n" |
| 8221 | " gl_Position = vec4(1);\n" |
| 8222 | "}\n"; |
| 8223 | char const *fsSource = |
| 8224 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 8225 | "\n" |
| 8226 | "in block { layout(location=0) float x; } ins;\n" |
| 8227 | "layout(location=0) out vec4 color;\n" |
| 8228 | "void main(){\n" |
| 8229 | " color = vec4(ins.x);\n" |
| 8230 | "}\n"; |
| 8231 | |
| 8232 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8233 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8234 | |
| 8235 | VkPipelineObj pipe(m_device); |
| 8236 | pipe.AddColorAttachment(); |
| 8237 | pipe.AddShader(&vs); |
| 8238 | pipe.AddShader(&fs); |
| 8239 | |
| 8240 | VkDescriptorSetObj descriptorSet(m_device); |
| 8241 | descriptorSet.AppendDummy(); |
| 8242 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8243 | |
| 8244 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8245 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8246 | m_errorMonitor->VerifyFound(); |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 8247 | } |
| 8248 | |
| 8249 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByComponent) { |
| 8250 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8251 | "location 0.1 which is not written by vertex shader"); |
| 8252 | |
| 8253 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8254 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8255 | |
| 8256 | char const *vsSource = |
| 8257 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 8258 | "\n" |
| 8259 | "out block { layout(location=0, component=0) float x; } outs;\n" |
| 8260 | "out gl_PerVertex {\n" |
| 8261 | " vec4 gl_Position;\n" |
| 8262 | "};\n" |
| 8263 | "void main(){\n" |
| 8264 | " outs.x = 0;\n" |
| 8265 | " gl_Position = vec4(1);\n" |
| 8266 | "}\n"; |
| 8267 | char const *fsSource = |
| 8268 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 8269 | "\n" |
| 8270 | "in block { layout(location=0, component=1) float x; } ins;\n" |
| 8271 | "layout(location=0) out vec4 color;\n" |
| 8272 | "void main(){\n" |
| 8273 | " color = vec4(ins.x);\n" |
| 8274 | "}\n"; |
| 8275 | |
| 8276 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8277 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8278 | |
| 8279 | VkPipelineObj pipe(m_device); |
| 8280 | pipe.AddColorAttachment(); |
| 8281 | pipe.AddShader(&vs); |
| 8282 | pipe.AddShader(&fs); |
| 8283 | |
| 8284 | VkDescriptorSetObj descriptorSet(m_device); |
| 8285 | descriptorSet.AppendDummy(); |
| 8286 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8287 | |
| 8288 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8289 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8290 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8291 | } |
| 8292 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8293 | TEST_F(VkLayerTest, CreatePipelineAttribNotConsumed) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 8294 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8295 | "location 0 not consumed by VS"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8296 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8297 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 8298 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8299 | |
| 8300 | VkVertexInputBindingDescription input_binding; |
| 8301 | memset(&input_binding, 0, sizeof(input_binding)); |
| 8302 | |
| 8303 | VkVertexInputAttributeDescription input_attrib; |
| 8304 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 8305 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 8306 | |
| 8307 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8308 | "#version 450\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8309 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8310 | "out gl_PerVertex {\n" |
| 8311 | " vec4 gl_Position;\n" |
| 8312 | "};\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8313 | "void main(){\n" |
| 8314 | " gl_Position = vec4(1);\n" |
| 8315 | "}\n"; |
| 8316 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8317 | "#version 450\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8318 | "\n" |
| 8319 | "layout(location=0) out vec4 color;\n" |
| 8320 | "void main(){\n" |
| 8321 | " color = vec4(1);\n" |
| 8322 | "}\n"; |
| 8323 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8324 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8325 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8326 | |
| 8327 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 8328 | pipe.AddColorAttachment(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8329 | pipe.AddShader(&vs); |
| 8330 | pipe.AddShader(&fs); |
| 8331 | |
| 8332 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 8333 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 8334 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8335 | VkDescriptorSetObj descriptorSet(m_device); |
| 8336 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8337 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8338 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 8339 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8340 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8341 | m_errorMonitor->VerifyFound(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8342 | } |
| 8343 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8344 | TEST_F(VkLayerTest, CreatePipelineAttribLocationMismatch) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 8345 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8346 | "location 0 not consumed by VS"); |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 8347 | |
| 8348 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8349 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8350 | |
| 8351 | VkVertexInputBindingDescription input_binding; |
| 8352 | memset(&input_binding, 0, sizeof(input_binding)); |
| 8353 | |
| 8354 | VkVertexInputAttributeDescription input_attrib; |
| 8355 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 8356 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 8357 | |
| 8358 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8359 | "#version 450\n" |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 8360 | "\n" |
| 8361 | "layout(location=1) in float x;\n" |
| 8362 | "out gl_PerVertex {\n" |
| 8363 | " vec4 gl_Position;\n" |
| 8364 | "};\n" |
| 8365 | "void main(){\n" |
| 8366 | " gl_Position = vec4(x);\n" |
| 8367 | "}\n"; |
| 8368 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8369 | "#version 450\n" |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 8370 | "\n" |
| 8371 | "layout(location=0) out vec4 color;\n" |
| 8372 | "void main(){\n" |
| 8373 | " color = vec4(1);\n" |
| 8374 | "}\n"; |
| 8375 | |
| 8376 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8377 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8378 | |
| 8379 | VkPipelineObj pipe(m_device); |
| 8380 | pipe.AddColorAttachment(); |
| 8381 | pipe.AddShader(&vs); |
| 8382 | pipe.AddShader(&fs); |
| 8383 | |
| 8384 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 8385 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 8386 | |
| 8387 | VkDescriptorSetObj descriptorSet(m_device); |
| 8388 | descriptorSet.AppendDummy(); |
| 8389 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8390 | |
| 8391 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8392 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8393 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 8394 | } |
| 8395 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8396 | TEST_F(VkLayerTest, CreatePipelineAttribNotProvided) { |
| 8397 | m_errorMonitor->SetDesiredFailureMsg( |
| 8398 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8399 | "VS consumes input at location 0 but not provided"); |
| 8400 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8401 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 8402 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8403 | |
| 8404 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8405 | "#version 450\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8406 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8407 | "layout(location=0) in vec4 x;\n" /* not provided */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8408 | "out gl_PerVertex {\n" |
| 8409 | " vec4 gl_Position;\n" |
| 8410 | "};\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8411 | "void main(){\n" |
| 8412 | " gl_Position = x;\n" |
| 8413 | "}\n"; |
| 8414 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8415 | "#version 450\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8416 | "\n" |
| 8417 | "layout(location=0) out vec4 color;\n" |
| 8418 | "void main(){\n" |
| 8419 | " color = vec4(1);\n" |
| 8420 | "}\n"; |
| 8421 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8422 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8423 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8424 | |
| 8425 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 8426 | pipe.AddColorAttachment(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8427 | pipe.AddShader(&vs); |
| 8428 | pipe.AddShader(&fs); |
| 8429 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8430 | VkDescriptorSetObj descriptorSet(m_device); |
| 8431 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8432 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8433 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 8434 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8435 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8436 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8437 | } |
| 8438 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8439 | TEST_F(VkLayerTest, CreatePipelineAttribTypeMismatch) { |
| 8440 | m_errorMonitor->SetDesiredFailureMsg( |
| 8441 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8442 | "location 0 does not match VS input type"); |
| 8443 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 8444 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 8445 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 8446 | |
| 8447 | VkVertexInputBindingDescription input_binding; |
| 8448 | memset(&input_binding, 0, sizeof(input_binding)); |
| 8449 | |
| 8450 | VkVertexInputAttributeDescription input_attrib; |
| 8451 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 8452 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 8453 | |
| 8454 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8455 | "#version 450\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 8456 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8457 | "layout(location=0) in int x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8458 | "out gl_PerVertex {\n" |
| 8459 | " vec4 gl_Position;\n" |
| 8460 | "};\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 8461 | "void main(){\n" |
| 8462 | " gl_Position = vec4(x);\n" |
| 8463 | "}\n"; |
| 8464 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8465 | "#version 450\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 8466 | "\n" |
| 8467 | "layout(location=0) out vec4 color;\n" |
| 8468 | "void main(){\n" |
| 8469 | " color = vec4(1);\n" |
| 8470 | "}\n"; |
| 8471 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8472 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8473 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 8474 | |
| 8475 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 8476 | pipe.AddColorAttachment(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 8477 | pipe.AddShader(&vs); |
| 8478 | pipe.AddShader(&fs); |
| 8479 | |
| 8480 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 8481 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 8482 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 8483 | VkDescriptorSetObj descriptorSet(m_device); |
| 8484 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8485 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 8486 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 8487 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 8488 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8489 | m_errorMonitor->VerifyFound(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 8490 | } |
| 8491 | |
Chris Forbes | c68b43c | 2016-04-06 11:18:47 +1200 | [diff] [blame] | 8492 | TEST_F(VkLayerTest, CreatePipelineDuplicateStage) { |
| 8493 | m_errorMonitor->SetDesiredFailureMsg( |
| 8494 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8495 | "Multiple shaders provided for stage VK_SHADER_STAGE_VERTEX_BIT"); |
| 8496 | |
| 8497 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8498 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8499 | |
| 8500 | char const *vsSource = |
| 8501 | "#version 450\n" |
| 8502 | "\n" |
| 8503 | "out gl_PerVertex {\n" |
| 8504 | " vec4 gl_Position;\n" |
| 8505 | "};\n" |
| 8506 | "void main(){\n" |
| 8507 | " gl_Position = vec4(1);\n" |
| 8508 | "}\n"; |
| 8509 | char const *fsSource = |
| 8510 | "#version 450\n" |
| 8511 | "\n" |
| 8512 | "layout(location=0) out vec4 color;\n" |
| 8513 | "void main(){\n" |
| 8514 | " color = vec4(1);\n" |
| 8515 | "}\n"; |
| 8516 | |
| 8517 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8518 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8519 | |
| 8520 | VkPipelineObj pipe(m_device); |
| 8521 | pipe.AddColorAttachment(); |
| 8522 | pipe.AddShader(&vs); |
| 8523 | pipe.AddShader(&vs); |
| 8524 | pipe.AddShader(&fs); |
| 8525 | |
| 8526 | VkDescriptorSetObj descriptorSet(m_device); |
| 8527 | descriptorSet.AppendDummy(); |
| 8528 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8529 | |
| 8530 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8531 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8532 | m_errorMonitor->VerifyFound(); |
Chris Forbes | c68b43c | 2016-04-06 11:18:47 +1200 | [diff] [blame] | 8533 | } |
| 8534 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8535 | TEST_F(VkLayerTest, CreatePipelineAttribMatrixType) { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8536 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 8537 | |
| 8538 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8539 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8540 | |
| 8541 | VkVertexInputBindingDescription input_binding; |
| 8542 | memset(&input_binding, 0, sizeof(input_binding)); |
| 8543 | |
| 8544 | VkVertexInputAttributeDescription input_attribs[2]; |
| 8545 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 8546 | |
| 8547 | for (int i = 0; i < 2; i++) { |
| 8548 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 8549 | input_attribs[i].location = i; |
| 8550 | } |
| 8551 | |
| 8552 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8553 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 8554 | "\n" |
| 8555 | "layout(location=0) in mat2x4 x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8556 | "out gl_PerVertex {\n" |
| 8557 | " vec4 gl_Position;\n" |
| 8558 | "};\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 8559 | "void main(){\n" |
| 8560 | " gl_Position = x[0] + x[1];\n" |
| 8561 | "}\n"; |
| 8562 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8563 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 8564 | "\n" |
| 8565 | "layout(location=0) out vec4 color;\n" |
| 8566 | "void main(){\n" |
| 8567 | " color = vec4(1);\n" |
| 8568 | "}\n"; |
| 8569 | |
| 8570 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8571 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8572 | |
| 8573 | VkPipelineObj pipe(m_device); |
| 8574 | pipe.AddColorAttachment(); |
| 8575 | pipe.AddShader(&vs); |
| 8576 | pipe.AddShader(&fs); |
| 8577 | |
| 8578 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 8579 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 8580 | |
| 8581 | VkDescriptorSetObj descriptorSet(m_device); |
| 8582 | descriptorSet.AppendDummy(); |
| 8583 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8584 | |
| 8585 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8586 | |
| 8587 | /* expect success */ |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8588 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 8589 | } |
| 8590 | |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 8591 | TEST_F(VkLayerTest, CreatePipelineAttribArrayType) |
| 8592 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8593 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 8594 | |
| 8595 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8596 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8597 | |
| 8598 | VkVertexInputBindingDescription input_binding; |
| 8599 | memset(&input_binding, 0, sizeof(input_binding)); |
| 8600 | |
| 8601 | VkVertexInputAttributeDescription input_attribs[2]; |
| 8602 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 8603 | |
| 8604 | for (int i = 0; i < 2; i++) { |
| 8605 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 8606 | input_attribs[i].location = i; |
| 8607 | } |
| 8608 | |
| 8609 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8610 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 8611 | "\n" |
| 8612 | "layout(location=0) in vec4 x[2];\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8613 | "out gl_PerVertex {\n" |
| 8614 | " vec4 gl_Position;\n" |
| 8615 | "};\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 8616 | "void main(){\n" |
| 8617 | " gl_Position = x[0] + x[1];\n" |
| 8618 | "}\n"; |
| 8619 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8620 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 8621 | "\n" |
| 8622 | "layout(location=0) out vec4 color;\n" |
| 8623 | "void main(){\n" |
| 8624 | " color = vec4(1);\n" |
| 8625 | "}\n"; |
| 8626 | |
| 8627 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8628 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8629 | |
| 8630 | VkPipelineObj pipe(m_device); |
| 8631 | pipe.AddColorAttachment(); |
| 8632 | pipe.AddShader(&vs); |
| 8633 | pipe.AddShader(&fs); |
| 8634 | |
| 8635 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 8636 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 8637 | |
| 8638 | VkDescriptorSetObj descriptorSet(m_device); |
| 8639 | descriptorSet.AppendDummy(); |
| 8640 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8641 | |
| 8642 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8643 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8644 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 8645 | } |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 8646 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 8647 | TEST_F(VkLayerTest, CreatePipelineSimplePositive) |
| 8648 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8649 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 8650 | |
| 8651 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8652 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8653 | |
| 8654 | char const *vsSource = |
| 8655 | "#version 450\n" |
| 8656 | "out gl_PerVertex {\n" |
| 8657 | " vec4 gl_Position;\n" |
| 8658 | "};\n" |
| 8659 | "void main(){\n" |
| 8660 | " gl_Position = vec4(0);\n" |
| 8661 | "}\n"; |
| 8662 | char const *fsSource = |
| 8663 | "#version 450\n" |
| 8664 | "\n" |
| 8665 | "layout(location=0) out vec4 color;\n" |
| 8666 | "void main(){\n" |
| 8667 | " color = vec4(1);\n" |
| 8668 | "}\n"; |
| 8669 | |
| 8670 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8671 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8672 | |
| 8673 | VkPipelineObj pipe(m_device); |
| 8674 | pipe.AddColorAttachment(); |
| 8675 | pipe.AddShader(&vs); |
| 8676 | pipe.AddShader(&fs); |
| 8677 | |
| 8678 | VkDescriptorSetObj descriptorSet(m_device); |
| 8679 | descriptorSet.AppendDummy(); |
| 8680 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8681 | |
| 8682 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8683 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8684 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 8685 | } |
| 8686 | |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 8687 | TEST_F(VkLayerTest, CreatePipelineRelaxedTypeMatch) |
| 8688 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8689 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 8690 | |
| 8691 | // VK 1.0.8 Specification, 14.1.3 "Additionally,..." block |
| 8692 | |
| 8693 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8694 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8695 | |
| 8696 | char const *vsSource = |
| 8697 | "#version 450\n" |
| 8698 | "out gl_PerVertex {\n" |
| 8699 | " vec4 gl_Position;\n" |
| 8700 | "};\n" |
| 8701 | "layout(location=0) out vec3 x;\n" |
| 8702 | "layout(location=1) out ivec3 y;\n" |
| 8703 | "layout(location=2) out vec3 z;\n" |
| 8704 | "void main(){\n" |
| 8705 | " gl_Position = vec4(0);\n" |
| 8706 | " x = vec3(0); y = ivec3(0); z = vec3(0);\n" |
| 8707 | "}\n"; |
| 8708 | char const *fsSource = |
| 8709 | "#version 450\n" |
| 8710 | "\n" |
| 8711 | "layout(location=0) out vec4 color;\n" |
| 8712 | "layout(location=0) in float x;\n" |
| 8713 | "layout(location=1) flat in int y;\n" |
| 8714 | "layout(location=2) in vec2 z;\n" |
| 8715 | "void main(){\n" |
| 8716 | " color = vec4(1 + x + y + z.x);\n" |
| 8717 | "}\n"; |
| 8718 | |
| 8719 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8720 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8721 | |
| 8722 | VkPipelineObj pipe(m_device); |
| 8723 | pipe.AddColorAttachment(); |
| 8724 | pipe.AddShader(&vs); |
| 8725 | pipe.AddShader(&fs); |
| 8726 | |
| 8727 | VkDescriptorSetObj descriptorSet(m_device); |
| 8728 | descriptorSet.AppendDummy(); |
| 8729 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8730 | |
| 8731 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8732 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8733 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 8734 | } |
| 8735 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 8736 | TEST_F(VkLayerTest, CreatePipelineTessPerVertex) |
| 8737 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8738 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 8739 | |
| 8740 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8741 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8742 | |
Chris Forbes | c1e852d | 2016-04-04 19:26:42 +1200 | [diff] [blame] | 8743 | if (!m_device->phy().features().tessellationShader) { |
| 8744 | printf("Device does not support tessellation shaders; skipped.\n"); |
| 8745 | return; |
| 8746 | } |
| 8747 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 8748 | char const *vsSource = |
| 8749 | "#version 450\n" |
| 8750 | "void main(){}\n"; |
| 8751 | char const *tcsSource = |
| 8752 | "#version 450\n" |
| 8753 | "layout(location=0) out int x[];\n" |
| 8754 | "layout(vertices=3) out;\n" |
| 8755 | "void main(){\n" |
| 8756 | " gl_TessLevelOuter[0] = gl_TessLevelOuter[1] = gl_TessLevelOuter[2] = 1;\n" |
| 8757 | " gl_TessLevelInner[0] = 1;\n" |
| 8758 | " x[gl_InvocationID] = gl_InvocationID;\n" |
| 8759 | "}\n"; |
| 8760 | char const *tesSource = |
| 8761 | "#version 450\n" |
| 8762 | "layout(triangles, equal_spacing, cw) in;\n" |
| 8763 | "layout(location=0) in int x[];\n" |
| 8764 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 8765 | "void main(){\n" |
| 8766 | " gl_Position.xyz = gl_TessCoord;\n" |
| 8767 | " gl_Position.w = x[0] + x[1] + x[2];\n" |
| 8768 | "}\n"; |
| 8769 | char const *fsSource = |
| 8770 | "#version 450\n" |
| 8771 | "layout(location=0) out vec4 color;\n" |
| 8772 | "void main(){\n" |
| 8773 | " color = vec4(1);\n" |
| 8774 | "}\n"; |
| 8775 | |
| 8776 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8777 | VkShaderObj tcs(m_device, tcsSource, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 8778 | VkShaderObj tes(m_device, tesSource, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
| 8779 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8780 | |
| 8781 | VkPipelineInputAssemblyStateCreateInfo iasci{ |
| 8782 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, |
| 8783 | nullptr, |
| 8784 | 0, |
| 8785 | VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, |
| 8786 | VK_FALSE}; |
| 8787 | |
Chris Forbes | b4cacb6 | 2016-04-04 19:15:00 +1200 | [diff] [blame] | 8788 | VkPipelineTessellationStateCreateInfo tsci{ |
| 8789 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, |
| 8790 | nullptr, |
| 8791 | 0, |
| 8792 | 3}; |
| 8793 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 8794 | VkPipelineObj pipe(m_device); |
| 8795 | pipe.SetInputAssembly(&iasci); |
Chris Forbes | b4cacb6 | 2016-04-04 19:15:00 +1200 | [diff] [blame] | 8796 | pipe.SetTessellation(&tsci); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 8797 | pipe.AddColorAttachment(); |
| 8798 | pipe.AddShader(&vs); |
| 8799 | pipe.AddShader(&tcs); |
| 8800 | pipe.AddShader(&tes); |
| 8801 | pipe.AddShader(&fs); |
| 8802 | |
| 8803 | VkDescriptorSetObj descriptorSet(m_device); |
| 8804 | descriptorSet.AppendDummy(); |
| 8805 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8806 | |
| 8807 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8808 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8809 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 8810 | } |
| 8811 | |
Chris Forbes | a0ab815 | 2016-04-20 13:34:27 +1200 | [diff] [blame] | 8812 | TEST_F(VkLayerTest, CreatePipelineGeometryInputBlockPositive) |
| 8813 | { |
| 8814 | m_errorMonitor->ExpectSuccess(); |
| 8815 | |
| 8816 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8817 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8818 | |
| 8819 | if (!m_device->phy().features().geometryShader) { |
| 8820 | printf("Device does not support geometry shaders; skipped.\n"); |
| 8821 | return; |
| 8822 | } |
| 8823 | |
| 8824 | char const *vsSource = |
| 8825 | "#version 450\n" |
| 8826 | "layout(location=0) out VertexData { vec4 x; } vs_out;\n" |
| 8827 | "void main(){\n" |
| 8828 | " vs_out.x = vec4(1);\n" |
| 8829 | "}\n"; |
| 8830 | char const *gsSource = |
| 8831 | "#version 450\n" |
| 8832 | "layout(triangles) in;\n" |
| 8833 | "layout(triangle_strip, max_vertices=3) out;\n" |
| 8834 | "layout(location=0) in VertexData { vec4 x; } gs_in[];\n" |
| 8835 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 8836 | "void main() {\n" |
| 8837 | " gl_Position = gs_in[0].x;\n" |
| 8838 | " EmitVertex();\n" |
| 8839 | "}\n"; |
| 8840 | char const *fsSource = |
| 8841 | "#version 450\n" |
| 8842 | "layout(location=0) out vec4 color;\n" |
| 8843 | "void main(){\n" |
| 8844 | " color = vec4(1);\n" |
| 8845 | "}\n"; |
| 8846 | |
| 8847 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8848 | VkShaderObj gs(m_device, gsSource, VK_SHADER_STAGE_GEOMETRY_BIT, this); |
| 8849 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8850 | |
| 8851 | VkPipelineObj pipe(m_device); |
| 8852 | pipe.AddColorAttachment(); |
| 8853 | pipe.AddShader(&vs); |
| 8854 | pipe.AddShader(&gs); |
| 8855 | pipe.AddShader(&fs); |
| 8856 | |
| 8857 | VkDescriptorSetObj descriptorSet(m_device); |
| 8858 | descriptorSet.AppendDummy(); |
| 8859 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8860 | |
| 8861 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8862 | |
| 8863 | m_errorMonitor->VerifyNotFound(); |
| 8864 | } |
| 8865 | |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 8866 | TEST_F(VkLayerTest, CreatePipelineTessPatchDecorationMismatch) |
| 8867 | { |
| 8868 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8869 | "is per-vertex in tessellation control shader stage " |
| 8870 | "but per-patch in tessellation evaluation shader stage"); |
| 8871 | |
| 8872 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8873 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8874 | |
Chris Forbes | c1e852d | 2016-04-04 19:26:42 +1200 | [diff] [blame] | 8875 | if (!m_device->phy().features().tessellationShader) { |
| 8876 | printf("Device does not support tessellation shaders; skipped.\n"); |
| 8877 | return; |
| 8878 | } |
| 8879 | |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 8880 | char const *vsSource = |
| 8881 | "#version 450\n" |
| 8882 | "void main(){}\n"; |
| 8883 | char const *tcsSource = |
| 8884 | "#version 450\n" |
| 8885 | "layout(location=0) out int x[];\n" |
| 8886 | "layout(vertices=3) out;\n" |
| 8887 | "void main(){\n" |
| 8888 | " gl_TessLevelOuter[0] = gl_TessLevelOuter[1] = gl_TessLevelOuter[2] = 1;\n" |
| 8889 | " gl_TessLevelInner[0] = 1;\n" |
| 8890 | " x[gl_InvocationID] = gl_InvocationID;\n" |
| 8891 | "}\n"; |
| 8892 | char const *tesSource = |
| 8893 | "#version 450\n" |
| 8894 | "layout(triangles, equal_spacing, cw) in;\n" |
| 8895 | "layout(location=0) patch in int x;\n" |
| 8896 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 8897 | "void main(){\n" |
| 8898 | " gl_Position.xyz = gl_TessCoord;\n" |
| 8899 | " gl_Position.w = x;\n" |
| 8900 | "}\n"; |
| 8901 | char const *fsSource = |
| 8902 | "#version 450\n" |
| 8903 | "layout(location=0) out vec4 color;\n" |
| 8904 | "void main(){\n" |
| 8905 | " color = vec4(1);\n" |
| 8906 | "}\n"; |
| 8907 | |
| 8908 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8909 | VkShaderObj tcs(m_device, tcsSource, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 8910 | VkShaderObj tes(m_device, tesSource, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
| 8911 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8912 | |
| 8913 | VkPipelineInputAssemblyStateCreateInfo iasci{ |
| 8914 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, |
| 8915 | nullptr, |
| 8916 | 0, |
| 8917 | VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, |
| 8918 | VK_FALSE}; |
| 8919 | |
| 8920 | VkPipelineTessellationStateCreateInfo tsci{ |
| 8921 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, |
| 8922 | nullptr, |
| 8923 | 0, |
| 8924 | 3}; |
| 8925 | |
| 8926 | VkPipelineObj pipe(m_device); |
| 8927 | pipe.SetInputAssembly(&iasci); |
| 8928 | pipe.SetTessellation(&tsci); |
| 8929 | pipe.AddColorAttachment(); |
| 8930 | pipe.AddShader(&vs); |
| 8931 | pipe.AddShader(&tcs); |
| 8932 | pipe.AddShader(&tes); |
| 8933 | pipe.AddShader(&fs); |
| 8934 | |
| 8935 | VkDescriptorSetObj descriptorSet(m_device); |
| 8936 | descriptorSet.AppendDummy(); |
| 8937 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8938 | |
| 8939 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8940 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8941 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 8942 | } |
| 8943 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8944 | TEST_F(VkLayerTest, CreatePipelineAttribBindingConflict) { |
| 8945 | m_errorMonitor->SetDesiredFailureMsg( |
| 8946 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8947 | "Duplicate vertex input binding descriptions for binding 0"); |
| 8948 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 8949 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 8950 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 8951 | |
| 8952 | /* Two binding descriptions for binding 0 */ |
| 8953 | VkVertexInputBindingDescription input_bindings[2]; |
| 8954 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 8955 | |
| 8956 | VkVertexInputAttributeDescription input_attrib; |
| 8957 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 8958 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 8959 | |
| 8960 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8961 | "#version 450\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 8962 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8963 | "layout(location=0) in float x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8964 | "out gl_PerVertex {\n" |
| 8965 | " vec4 gl_Position;\n" |
| 8966 | "};\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 8967 | "void main(){\n" |
| 8968 | " gl_Position = vec4(x);\n" |
| 8969 | "}\n"; |
| 8970 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8971 | "#version 450\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 8972 | "\n" |
| 8973 | "layout(location=0) out vec4 color;\n" |
| 8974 | "void main(){\n" |
| 8975 | " color = vec4(1);\n" |
| 8976 | "}\n"; |
| 8977 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8978 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8979 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 8980 | |
| 8981 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 8982 | pipe.AddColorAttachment(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 8983 | pipe.AddShader(&vs); |
| 8984 | pipe.AddShader(&fs); |
| 8985 | |
| 8986 | pipe.AddVertexInputBindings(input_bindings, 2); |
| 8987 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 8988 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 8989 | VkDescriptorSetObj descriptorSet(m_device); |
| 8990 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8991 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 8992 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 8993 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 8994 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8995 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 8996 | } |
Chris Forbes | 8f68b56 | 2015-05-25 11:13:32 +1200 | [diff] [blame] | 8997 | |
Chris Forbes | 35efec7 | 2016-04-21 14:32:08 +1200 | [diff] [blame] | 8998 | TEST_F(VkLayerTest, CreatePipeline64BitAttributesPositive) { |
| 8999 | m_errorMonitor->ExpectSuccess(); |
| 9000 | |
| 9001 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9002 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9003 | |
| 9004 | if (!m_device->phy().features().tessellationShader) { |
| 9005 | printf("Device does not support 64bit vertex attributes; skipped.\n"); |
| 9006 | return; |
| 9007 | } |
| 9008 | |
| 9009 | VkVertexInputBindingDescription input_bindings[1]; |
| 9010 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 9011 | |
| 9012 | VkVertexInputAttributeDescription input_attribs[4]; |
| 9013 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 9014 | input_attribs[0].location = 0; |
| 9015 | input_attribs[0].offset = 0; |
| 9016 | input_attribs[0].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 9017 | input_attribs[1].location = 2; |
| 9018 | input_attribs[1].offset = 32; |
| 9019 | input_attribs[1].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 9020 | input_attribs[2].location = 4; |
| 9021 | input_attribs[2].offset = 64; |
| 9022 | input_attribs[2].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 9023 | input_attribs[3].location = 6; |
| 9024 | input_attribs[3].offset = 96; |
| 9025 | input_attribs[3].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 9026 | |
| 9027 | char const *vsSource = |
| 9028 | "#version 450\n" |
| 9029 | "\n" |
| 9030 | "layout(location=0) in dmat4 x;\n" |
| 9031 | "out gl_PerVertex {\n" |
| 9032 | " vec4 gl_Position;\n" |
| 9033 | "};\n" |
| 9034 | "void main(){\n" |
| 9035 | " gl_Position = vec4(x[0][0]);\n" |
| 9036 | "}\n"; |
| 9037 | char const *fsSource = |
| 9038 | "#version 450\n" |
| 9039 | "\n" |
| 9040 | "layout(location=0) out vec4 color;\n" |
| 9041 | "void main(){\n" |
| 9042 | " color = vec4(1);\n" |
| 9043 | "}\n"; |
| 9044 | |
| 9045 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9046 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9047 | |
| 9048 | VkPipelineObj pipe(m_device); |
| 9049 | pipe.AddColorAttachment(); |
| 9050 | pipe.AddShader(&vs); |
| 9051 | pipe.AddShader(&fs); |
| 9052 | |
| 9053 | pipe.AddVertexInputBindings(input_bindings, 1); |
| 9054 | pipe.AddVertexInputAttribs(input_attribs, 4); |
| 9055 | |
| 9056 | VkDescriptorSetObj descriptorSet(m_device); |
| 9057 | descriptorSet.AppendDummy(); |
| 9058 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9059 | |
| 9060 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9061 | |
| 9062 | m_errorMonitor->VerifyNotFound(); |
| 9063 | } |
| 9064 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9065 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotWritten) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9066 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9067 | "Attachment 0 not written by FS"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9068 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9069 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9070 | |
| 9071 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9072 | "#version 450\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9073 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9074 | "out gl_PerVertex {\n" |
| 9075 | " vec4 gl_Position;\n" |
| 9076 | "};\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9077 | "void main(){\n" |
| 9078 | " gl_Position = vec4(1);\n" |
| 9079 | "}\n"; |
| 9080 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9081 | "#version 450\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9082 | "\n" |
| 9083 | "void main(){\n" |
| 9084 | "}\n"; |
| 9085 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9086 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9087 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9088 | |
| 9089 | VkPipelineObj pipe(m_device); |
| 9090 | pipe.AddShader(&vs); |
| 9091 | pipe.AddShader(&fs); |
| 9092 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9093 | /* set up CB 0, not written */ |
| 9094 | pipe.AddColorAttachment(); |
| 9095 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9096 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9097 | VkDescriptorSetObj descriptorSet(m_device); |
| 9098 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9099 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9100 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9101 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9102 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9103 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9104 | } |
| 9105 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9106 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotConsumed) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9107 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 9108 | VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9109 | "FS writes to output location 1 with no matching attachment"); |
| 9110 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9111 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9112 | |
| 9113 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9114 | "#version 450\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9115 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9116 | "out gl_PerVertex {\n" |
| 9117 | " vec4 gl_Position;\n" |
| 9118 | "};\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9119 | "void main(){\n" |
| 9120 | " gl_Position = vec4(1);\n" |
| 9121 | "}\n"; |
| 9122 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9123 | "#version 450\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9124 | "\n" |
| 9125 | "layout(location=0) out vec4 x;\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9126 | "layout(location=1) out vec4 y;\n" /* no matching attachment for this */ |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9127 | "void main(){\n" |
| 9128 | " x = vec4(1);\n" |
| 9129 | " y = vec4(1);\n" |
| 9130 | "}\n"; |
| 9131 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9132 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9133 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9134 | |
| 9135 | VkPipelineObj pipe(m_device); |
| 9136 | pipe.AddShader(&vs); |
| 9137 | pipe.AddShader(&fs); |
| 9138 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9139 | /* set up CB 0, not written */ |
| 9140 | pipe.AddColorAttachment(); |
| 9141 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9142 | /* FS writes CB 1, but we don't configure it */ |
| 9143 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9144 | VkDescriptorSetObj descriptorSet(m_device); |
| 9145 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9146 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9147 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9148 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9149 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9150 | m_errorMonitor->VerifyFound(); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9151 | } |
| 9152 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9153 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputTypeMismatch) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9154 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9155 | "does not match FS output type"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9156 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9157 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9158 | |
| 9159 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9160 | "#version 450\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9161 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9162 | "out gl_PerVertex {\n" |
| 9163 | " vec4 gl_Position;\n" |
| 9164 | "};\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9165 | "void main(){\n" |
| 9166 | " gl_Position = vec4(1);\n" |
| 9167 | "}\n"; |
| 9168 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9169 | "#version 450\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9170 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9171 | "layout(location=0) out ivec4 x;\n" /* not UNORM */ |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9172 | "void main(){\n" |
| 9173 | " x = ivec4(1);\n" |
| 9174 | "}\n"; |
| 9175 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9176 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9177 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9178 | |
| 9179 | VkPipelineObj pipe(m_device); |
| 9180 | pipe.AddShader(&vs); |
| 9181 | pipe.AddShader(&fs); |
| 9182 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9183 | /* set up CB 0; type is UNORM by default */ |
| 9184 | pipe.AddColorAttachment(); |
| 9185 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9186 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9187 | VkDescriptorSetObj descriptorSet(m_device); |
| 9188 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9189 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9190 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9191 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9192 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9193 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9194 | } |
Chris Forbes | 7b1b893 | 2015-06-05 14:43:36 +1200 | [diff] [blame] | 9195 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9196 | TEST_F(VkLayerTest, CreatePipelineUniformBlockNotProvided) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9197 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9198 | "not declared in pipeline layout"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9199 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 9200 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 9201 | |
| 9202 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9203 | "#version 450\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 9204 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9205 | "out gl_PerVertex {\n" |
| 9206 | " vec4 gl_Position;\n" |
| 9207 | "};\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 9208 | "void main(){\n" |
| 9209 | " gl_Position = vec4(1);\n" |
| 9210 | "}\n"; |
| 9211 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9212 | "#version 450\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 9213 | "\n" |
| 9214 | "layout(location=0) out vec4 x;\n" |
| 9215 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 9216 | "void main(){\n" |
| 9217 | " x = vec4(bar.y);\n" |
| 9218 | "}\n"; |
| 9219 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9220 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9221 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 9222 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 9223 | VkPipelineObj pipe(m_device); |
| 9224 | pipe.AddShader(&vs); |
| 9225 | pipe.AddShader(&fs); |
| 9226 | |
| 9227 | /* set up CB 0; type is UNORM by default */ |
| 9228 | pipe.AddColorAttachment(); |
| 9229 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9230 | |
| 9231 | VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9232 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 9233 | |
| 9234 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9235 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9236 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 9237 | } |
| 9238 | |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 9239 | TEST_F(VkLayerTest, CreatePipelinePushConstantsNotInLayout) { |
| 9240 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9241 | "not declared in layout"); |
| 9242 | |
| 9243 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9244 | |
| 9245 | char const *vsSource = |
| 9246 | "#version 450\n" |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 9247 | "\n" |
| 9248 | "layout(push_constant, std430) uniform foo { float x; } consts;\n" |
| 9249 | "out gl_PerVertex {\n" |
| 9250 | " vec4 gl_Position;\n" |
| 9251 | "};\n" |
| 9252 | "void main(){\n" |
| 9253 | " gl_Position = vec4(consts.x);\n" |
| 9254 | "}\n"; |
| 9255 | char const *fsSource = |
| 9256 | "#version 450\n" |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 9257 | "\n" |
| 9258 | "layout(location=0) out vec4 x;\n" |
| 9259 | "void main(){\n" |
| 9260 | " x = vec4(1);\n" |
| 9261 | "}\n"; |
| 9262 | |
| 9263 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9264 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9265 | |
| 9266 | VkPipelineObj pipe(m_device); |
| 9267 | pipe.AddShader(&vs); |
| 9268 | pipe.AddShader(&fs); |
| 9269 | |
| 9270 | /* set up CB 0; type is UNORM by default */ |
| 9271 | pipe.AddColorAttachment(); |
| 9272 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9273 | |
| 9274 | VkDescriptorSetObj descriptorSet(m_device); |
| 9275 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9276 | |
| 9277 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9278 | |
| 9279 | /* should have generated an error -- no push constant ranges provided! */ |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9280 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 9281 | } |
| 9282 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 9283 | #endif // SHADER_CHECKER_TESTS |
| 9284 | |
| 9285 | #if DEVICE_LIMITS_TESTS |
Mark Young | c48c4c1 | 2016-04-11 14:26:49 -0600 | [diff] [blame] | 9286 | TEST_F(VkLayerTest, CreateImageLimitsViolationMaxWidth) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9287 | m_errorMonitor->SetDesiredFailureMsg( |
| 9288 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9289 | "CreateImage extents exceed allowable limits for format"); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 9290 | |
| 9291 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 9292 | |
| 9293 | // Create an image |
| 9294 | VkImage image; |
| 9295 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9296 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 9297 | const int32_t tex_width = 32; |
| 9298 | const int32_t tex_height = 32; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 9299 | |
| 9300 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9301 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9302 | image_create_info.pNext = NULL; |
| 9303 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 9304 | image_create_info.format = tex_format; |
| 9305 | image_create_info.extent.width = tex_width; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 9306 | image_create_info.extent.height = tex_height; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9307 | image_create_info.extent.depth = 1; |
| 9308 | image_create_info.mipLevels = 1; |
| 9309 | image_create_info.arrayLayers = 1; |
| 9310 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 9311 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 9312 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 9313 | image_create_info.flags = 0; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 9314 | |
| 9315 | // Introduce error by sending down a bogus width extent |
| 9316 | image_create_info.extent.width = 65536; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9317 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 9318 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9319 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 9320 | } |
| 9321 | |
Mark Young | c48c4c1 | 2016-04-11 14:26:49 -0600 | [diff] [blame] | 9322 | TEST_F(VkLayerTest, CreateImageLimitsViolationMinWidth) { |
| 9323 | m_errorMonitor->SetDesiredFailureMsg( |
| 9324 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9325 | "CreateImage extents is 0 for at least one required dimension"); |
| 9326 | |
| 9327 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9328 | |
| 9329 | // Create an image |
| 9330 | VkImage image; |
| 9331 | |
| 9332 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 9333 | const int32_t tex_width = 32; |
| 9334 | const int32_t tex_height = 32; |
| 9335 | |
| 9336 | VkImageCreateInfo image_create_info = {}; |
| 9337 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9338 | image_create_info.pNext = NULL; |
| 9339 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 9340 | image_create_info.format = tex_format; |
| 9341 | image_create_info.extent.width = tex_width; |
| 9342 | image_create_info.extent.height = tex_height; |
| 9343 | image_create_info.extent.depth = 1; |
| 9344 | image_create_info.mipLevels = 1; |
| 9345 | image_create_info.arrayLayers = 1; |
| 9346 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 9347 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 9348 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 9349 | image_create_info.flags = 0; |
| 9350 | |
| 9351 | // Introduce error by sending down a bogus width extent |
| 9352 | image_create_info.extent.width = 0; |
| 9353 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 9354 | |
| 9355 | m_errorMonitor->VerifyFound(); |
| 9356 | } |
| 9357 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9358 | TEST_F(VkLayerTest, UpdateBufferAlignment) { |
| 9359 | uint32_t updateData[] = {1, 2, 3, 4, 5, 6, 7, 8}; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9360 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9361 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9362 | "dstOffset, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9363 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9364 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9365 | |
| 9366 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 9367 | vk_testing::Buffer buffer; |
| 9368 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 9369 | |
| 9370 | BeginCommandBuffer(); |
| 9371 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9372 | m_commandBuffer->UpdateBuffer(buffer.handle(), 1, 4, updateData); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9373 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9374 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9375 | // Introduce failure by using size that is not multiple of 4 |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9376 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9377 | "dataSize, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9378 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9379 | m_commandBuffer->UpdateBuffer(buffer.handle(), 0, 6, updateData); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9380 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9381 | EndCommandBuffer(); |
| 9382 | } |
| 9383 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9384 | TEST_F(VkLayerTest, FillBufferAlignment) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9385 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9386 | "dstOffset, is not a multiple of 4"); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9387 | |
| 9388 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9389 | |
| 9390 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 9391 | vk_testing::Buffer buffer; |
| 9392 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 9393 | |
| 9394 | BeginCommandBuffer(); |
| 9395 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9396 | m_commandBuffer->FillBuffer(buffer.handle(), 1, 4, 0x11111111); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9397 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9398 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9399 | // Introduce failure by using size that is not multiple of 4 |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9400 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9401 | "size, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9402 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9403 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 6, 0x11111111); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9404 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9405 | m_errorMonitor->VerifyFound(); |
| 9406 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9407 | EndCommandBuffer(); |
| 9408 | } |
| 9409 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 9410 | #endif // DEVICE_LIMITS_TESTS |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9411 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 9412 | #if IMAGE_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9413 | TEST_F(VkLayerTest, InvalidImageView) { |
| 9414 | VkResult err; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 9415 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9416 | m_errorMonitor->SetDesiredFailureMsg( |
| 9417 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9418 | "vkCreateImageView called with baseMipLevel 10 "); |
| 9419 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 9420 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 9421 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9422 | // Create an image and try to create a view with bad baseMipLevel |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9423 | VkImage image; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 9424 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9425 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 9426 | const int32_t tex_width = 32; |
| 9427 | const int32_t tex_height = 32; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 9428 | |
| 9429 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9430 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9431 | image_create_info.pNext = NULL; |
| 9432 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 9433 | image_create_info.format = tex_format; |
| 9434 | image_create_info.extent.width = tex_width; |
| 9435 | image_create_info.extent.height = tex_height; |
| 9436 | image_create_info.extent.depth = 1; |
| 9437 | image_create_info.mipLevels = 1; |
| 9438 | image_create_info.arrayLayers = 1; |
| 9439 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 9440 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 9441 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 9442 | image_create_info.flags = 0; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 9443 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9444 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 9445 | ASSERT_VK_SUCCESS(err); |
| 9446 | |
| 9447 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9448 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9449 | image_view_create_info.image = image; |
| 9450 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 9451 | image_view_create_info.format = tex_format; |
| 9452 | image_view_create_info.subresourceRange.layerCount = 1; |
| 9453 | image_view_create_info.subresourceRange.baseMipLevel = 10; // cause an error |
| 9454 | image_view_create_info.subresourceRange.levelCount = 1; |
| 9455 | image_view_create_info.subresourceRange.aspectMask = |
| 9456 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 9457 | |
| 9458 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9459 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 9460 | &view); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 9461 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9462 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 9463 | } |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9464 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9465 | TEST_F(VkLayerTest, InvalidImageViewAspect) { |
| 9466 | VkResult err; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 9467 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9468 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9469 | "vkCreateImageView: Color image " |
| 9470 | "formats must have ONLY the " |
| 9471 | "VK_IMAGE_ASPECT_COLOR_BIT set"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9472 | |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 9473 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 9474 | |
| 9475 | // Create an image and try to create a view with an invalid aspectMask |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9476 | VkImage image; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 9477 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9478 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 9479 | const int32_t tex_width = 32; |
| 9480 | const int32_t tex_height = 32; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 9481 | |
| 9482 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9483 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9484 | image_create_info.pNext = NULL; |
| 9485 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 9486 | image_create_info.format = tex_format; |
| 9487 | image_create_info.extent.width = tex_width; |
| 9488 | image_create_info.extent.height = tex_height; |
| 9489 | image_create_info.extent.depth = 1; |
| 9490 | image_create_info.mipLevels = 1; |
| 9491 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 9492 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 9493 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 9494 | image_create_info.flags = 0; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 9495 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9496 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 9497 | ASSERT_VK_SUCCESS(err); |
| 9498 | |
| 9499 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9500 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9501 | image_view_create_info.image = image; |
| 9502 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 9503 | image_view_create_info.format = tex_format; |
| 9504 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 9505 | image_view_create_info.subresourceRange.levelCount = 1; |
| 9506 | // Cause an error by setting an invalid image aspect |
| 9507 | image_view_create_info.subresourceRange.aspectMask = |
| 9508 | VK_IMAGE_ASPECT_METADATA_BIT; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 9509 | |
| 9510 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9511 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 9512 | &view); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 9513 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9514 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 9515 | } |
| 9516 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 9517 | TEST_F(VkLayerTest, CopyImageLayerCountMismatch) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9518 | VkResult err; |
| 9519 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9520 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9521 | m_errorMonitor->SetDesiredFailureMsg( |
| 9522 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 9523 | "vkCmdCopyImage: number of layers in source and destination subresources for pRegions"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9524 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9525 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9526 | |
| 9527 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9528 | VkImage srcImage; |
| 9529 | VkImage dstImage; |
| 9530 | VkDeviceMemory srcMem; |
| 9531 | VkDeviceMemory destMem; |
| 9532 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9533 | |
| 9534 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9535 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9536 | image_create_info.pNext = NULL; |
| 9537 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 9538 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 9539 | image_create_info.extent.width = 32; |
| 9540 | image_create_info.extent.height = 32; |
| 9541 | image_create_info.extent.depth = 1; |
| 9542 | image_create_info.mipLevels = 1; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 9543 | image_create_info.arrayLayers = 4; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9544 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 9545 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 9546 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 9547 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9548 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9549 | err = |
| 9550 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9551 | ASSERT_VK_SUCCESS(err); |
| 9552 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9553 | err = |
| 9554 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9555 | ASSERT_VK_SUCCESS(err); |
| 9556 | |
| 9557 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9558 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9559 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 9560 | memAlloc.pNext = NULL; |
| 9561 | memAlloc.allocationSize = 0; |
| 9562 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9563 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 9564 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9565 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9566 | pass = |
| 9567 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 9568 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9569 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9570 | ASSERT_VK_SUCCESS(err); |
| 9571 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9572 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9573 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9574 | pass = |
| 9575 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9576 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9577 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9578 | ASSERT_VK_SUCCESS(err); |
| 9579 | |
| 9580 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 9581 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9582 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9583 | ASSERT_VK_SUCCESS(err); |
| 9584 | |
| 9585 | BeginCommandBuffer(); |
| 9586 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 9587 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9588 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 9589 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 9590 | copyRegion.srcSubresource.layerCount = 1; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9591 | copyRegion.srcOffset.x = 0; |
| 9592 | copyRegion.srcOffset.y = 0; |
| 9593 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 9594 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9595 | copyRegion.dstSubresource.mipLevel = 0; |
| 9596 | copyRegion.dstSubresource.baseArrayLayer = 0; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 9597 | // Introduce failure by forcing the dst layerCount to differ from src |
| 9598 | copyRegion.dstSubresource.layerCount = 3; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9599 | copyRegion.dstOffset.x = 0; |
| 9600 | copyRegion.dstOffset.y = 0; |
| 9601 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9602 | copyRegion.extent.width = 1; |
| 9603 | copyRegion.extent.height = 1; |
| 9604 | copyRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9605 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 9606 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9607 | EndCommandBuffer(); |
| 9608 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9609 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9610 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9611 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9612 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9613 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 9614 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9615 | } |
| 9616 | |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 9617 | TEST_F(VkLayerTest, ImageLayerUnsupportedFormat) { |
| 9618 | |
| 9619 | TEST_DESCRIPTION("Creating images with unsuported formats "); |
| 9620 | |
| 9621 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9622 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9623 | VkImageObj image(m_device); |
| 9624 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 9625 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 9626 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 9627 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 9628 | ASSERT_TRUE(image.initialized()); |
| 9629 | |
| 9630 | VkFormat unsupported = VK_FORMAT_UNDEFINED; |
| 9631 | for (int f = VK_FORMAT_BEGIN_RANGE; f <= VK_FORMAT_END_RANGE; f++) { |
| 9632 | VkFormat format = static_cast<VkFormat>(f); |
| 9633 | VkFormatProperties fProps = m_device->format_properties(format); |
| 9634 | if (format != VK_FORMAT_UNDEFINED && fProps.linearTilingFeatures == 0 && |
| 9635 | fProps.optimalTilingFeatures == 0) { |
| 9636 | unsupported = format; |
| 9637 | break; |
| 9638 | } |
| 9639 | } |
| 9640 | if (unsupported != VK_FORMAT_UNDEFINED) { |
| 9641 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9642 | "vkCreateImage parameter, " |
| 9643 | "VkFormat pCreateInfo->format, " |
| 9644 | "contains unsupported format"); |
| 9645 | // Create image with unsupported format - Expect FORMAT_UNSUPPORTED |
| 9646 | VkImageCreateInfo image_create_info; |
| 9647 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9648 | image_create_info.pNext = NULL; |
| 9649 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 9650 | image_create_info.format = unsupported; |
| 9651 | image_create_info.extent.width = 32; |
| 9652 | image_create_info.extent.height = 32; |
| 9653 | image_create_info.extent.depth = 1; |
| 9654 | image_create_info.mipLevels = 1; |
| 9655 | image_create_info.arrayLayers = 1; |
| 9656 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 9657 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 9658 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 9659 | image_create_info.flags = 0; |
| 9660 | |
| 9661 | VkImage localImage; |
| 9662 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &localImage); |
| 9663 | m_errorMonitor->VerifyFound(); |
| 9664 | |
| 9665 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9666 | "vkCreateRenderPass parameter, " |
| 9667 | "VkFormat in " |
| 9668 | "pCreateInfo->pAttachments"); |
| 9669 | // Create renderpass with unsupported format - Expect FORMAT_UNSUPPORTED |
| 9670 | VkAttachmentDescription att; |
| 9671 | att.format = unsupported; |
| 9672 | att.samples = VK_SAMPLE_COUNT_1_BIT; |
| 9673 | att.loadOp = VK_ATTACHMENT_LOAD_OP_LOAD; |
| 9674 | att.storeOp = VK_ATTACHMENT_STORE_OP_STORE; |
| 9675 | att.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; |
| 9676 | att.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; |
| 9677 | att.initialLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 9678 | att.finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 9679 | |
| 9680 | VkRenderPassCreateInfo rp_info = {}; |
| 9681 | VkRenderPass rp; |
| 9682 | rp_info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; |
| 9683 | rp_info.attachmentCount = 1; |
| 9684 | rp_info.pAttachments = &att; |
| 9685 | rp_info.subpassCount = 0; |
| 9686 | rp_info.pSubpasses = NULL; |
| 9687 | vkCreateRenderPass(m_device->handle(), &rp_info, NULL, &rp); |
| 9688 | m_errorMonitor->VerifyFound(); |
| 9689 | } |
| 9690 | } |
| 9691 | |
| 9692 | TEST_F(VkLayerTest, ImageLayerViewTests) { |
| 9693 | VkResult ret; |
| 9694 | TEST_DESCRIPTION("Passing bad parameters to CreateImageView"); |
| 9695 | |
| 9696 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9697 | |
| 9698 | VkImageObj image(m_device); |
| 9699 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 9700 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 9701 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 9702 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 9703 | ASSERT_TRUE(image.initialized()); |
| 9704 | |
| 9705 | VkImageView imgView; |
| 9706 | VkImageViewCreateInfo imgViewInfo = {}; |
| 9707 | imgViewInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 9708 | imgViewInfo.image = image.handle(); |
| 9709 | imgViewInfo.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 9710 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 9711 | imgViewInfo.subresourceRange.layerCount = 1; |
| 9712 | imgViewInfo.subresourceRange.baseMipLevel = 0; |
| 9713 | imgViewInfo.subresourceRange.levelCount = 1; |
| 9714 | imgViewInfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 9715 | |
| 9716 | m_errorMonitor->SetDesiredFailureMsg( |
| 9717 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9718 | "vkCreateImageView called with baseMipLevel"); |
| 9719 | // View can't have baseMipLevel >= image's mipLevels - Expect |
| 9720 | // VIEW_CREATE_ERROR |
| 9721 | imgViewInfo.subresourceRange.baseMipLevel = 1; |
| 9722 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 9723 | m_errorMonitor->VerifyFound(); |
| 9724 | imgViewInfo.subresourceRange.baseMipLevel = 0; |
| 9725 | |
| 9726 | m_errorMonitor->SetDesiredFailureMsg( |
| 9727 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9728 | "vkCreateImageView called with baseArrayLayer"); |
| 9729 | // View can't have baseArrayLayer >= image's arraySize - Expect |
| 9730 | // VIEW_CREATE_ERROR |
| 9731 | imgViewInfo.subresourceRange.baseArrayLayer = 1; |
| 9732 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 9733 | m_errorMonitor->VerifyFound(); |
| 9734 | imgViewInfo.subresourceRange.baseArrayLayer = 0; |
| 9735 | |
| 9736 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9737 | "vkCreateImageView called with 0 in " |
| 9738 | "pCreateInfo->subresourceRange." |
| 9739 | "levelCount"); |
| 9740 | // View's levelCount can't be 0 - Expect VIEW_CREATE_ERROR |
| 9741 | imgViewInfo.subresourceRange.levelCount = 0; |
| 9742 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 9743 | m_errorMonitor->VerifyFound(); |
| 9744 | imgViewInfo.subresourceRange.levelCount = 1; |
| 9745 | |
| 9746 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9747 | "vkCreateImageView called with 0 in " |
| 9748 | "pCreateInfo->subresourceRange." |
| 9749 | "layerCount"); |
| 9750 | // View's layerCount can't be 0 - Expect VIEW_CREATE_ERROR |
| 9751 | imgViewInfo.subresourceRange.layerCount = 0; |
| 9752 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 9753 | m_errorMonitor->VerifyFound(); |
| 9754 | imgViewInfo.subresourceRange.layerCount = 1; |
| 9755 | |
| 9756 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9757 | "but both must be color formats"); |
| 9758 | // Can't use depth format for view into color image - Expect INVALID_FORMAT |
| 9759 | imgViewInfo.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 9760 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 9761 | m_errorMonitor->VerifyFound(); |
| 9762 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 9763 | |
| 9764 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9765 | "Formats MUST be IDENTICAL unless " |
| 9766 | "VK_IMAGE_CREATE_MUTABLE_FORMAT BIT " |
| 9767 | "was set on image creation."); |
| 9768 | // Same compatibility class but no MUTABLE_FORMAT bit - Expect |
| 9769 | // VIEW_CREATE_ERROR |
| 9770 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UINT; |
| 9771 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 9772 | m_errorMonitor->VerifyFound(); |
| 9773 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 9774 | |
| 9775 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9776 | "can support ImageViews with " |
| 9777 | "differing formats but they must be " |
| 9778 | "in the same compatibility class."); |
| 9779 | // Have MUTABLE_FORMAT bit but not in same compatibility class - Expect |
| 9780 | // VIEW_CREATE_ERROR |
| 9781 | VkImageCreateInfo mutImgInfo = image.create_info(); |
| 9782 | VkImage mutImage; |
| 9783 | mutImgInfo.format = VK_FORMAT_R8_UINT; |
| 9784 | assert( |
| 9785 | m_device->format_properties(VK_FORMAT_R8_UINT).optimalTilingFeatures & |
| 9786 | VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT); |
| 9787 | mutImgInfo.flags = VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT; |
| 9788 | mutImgInfo.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 9789 | ret = vkCreateImage(m_device->handle(), &mutImgInfo, NULL, &mutImage); |
| 9790 | ASSERT_VK_SUCCESS(ret); |
| 9791 | imgViewInfo.image = mutImage; |
| 9792 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 9793 | m_errorMonitor->VerifyFound(); |
| 9794 | imgViewInfo.image = image.handle(); |
| 9795 | vkDestroyImage(m_device->handle(), mutImage, NULL); |
| 9796 | } |
| 9797 | |
| 9798 | TEST_F(VkLayerTest, MiscImageLayerTests) { |
| 9799 | |
| 9800 | TEST_DESCRIPTION("Image layer tests that don't belong elsewhare"); |
| 9801 | |
| 9802 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9803 | |
| 9804 | VkImageObj image(m_device); |
| 9805 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 9806 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 9807 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 9808 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 9809 | ASSERT_TRUE(image.initialized()); |
| 9810 | |
| 9811 | m_errorMonitor->SetDesiredFailureMsg( |
| 9812 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9813 | "number of layers in image subresource is zero"); |
| 9814 | vk_testing::Buffer buffer; |
| 9815 | VkMemoryPropertyFlags reqs = 0; |
| 9816 | buffer.init_as_src(*m_device, 128 * 128 * 4, reqs); |
| 9817 | VkBufferImageCopy region = {}; |
| 9818 | region.bufferRowLength = 128; |
| 9819 | region.bufferImageHeight = 128; |
| 9820 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 9821 | // layerCount can't be 0 - Expect MISMATCHED_IMAGE_ASPECT |
| 9822 | region.imageSubresource.layerCount = 0; |
| 9823 | region.imageExtent.height = 4; |
| 9824 | region.imageExtent.width = 4; |
| 9825 | region.imageExtent.depth = 1; |
| 9826 | m_commandBuffer->BeginCommandBuffer(); |
| 9827 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 9828 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 9829 | 1, ®ion); |
| 9830 | m_errorMonitor->VerifyFound(); |
| 9831 | region.imageSubresource.layerCount = 1; |
| 9832 | |
| 9833 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9834 | "aspectMasks for each region must " |
| 9835 | "specify only COLOR or DEPTH or " |
| 9836 | "STENCIL"); |
| 9837 | // Expect MISMATCHED_IMAGE_ASPECT |
| 9838 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_METADATA_BIT; |
| 9839 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 9840 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 9841 | 1, ®ion); |
| 9842 | m_errorMonitor->VerifyFound(); |
| 9843 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 9844 | |
| 9845 | m_errorMonitor->SetDesiredFailureMsg( |
| 9846 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9847 | "If the format of srcImage is a depth, stencil, depth stencil or " |
| 9848 | "integer-based format then filter must be VK_FILTER_NEAREST"); |
| 9849 | // Expect INVALID_FILTER |
| 9850 | VkImageObj intImage1(m_device); |
| 9851 | intImage1.init(128, 128, VK_FORMAT_R8_UINT, |
| 9852 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, |
| 9853 | 0); |
| 9854 | VkImageObj intImage2(m_device); |
| 9855 | intImage2.init(128, 128, VK_FORMAT_R8_UINT, |
| 9856 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, |
| 9857 | 0); |
| 9858 | VkImageBlit blitRegion = {}; |
| 9859 | blitRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 9860 | blitRegion.srcSubresource.baseArrayLayer = 0; |
| 9861 | blitRegion.srcSubresource.layerCount = 1; |
| 9862 | blitRegion.srcSubresource.mipLevel = 0; |
| 9863 | blitRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 9864 | blitRegion.dstSubresource.baseArrayLayer = 0; |
| 9865 | blitRegion.dstSubresource.layerCount = 1; |
| 9866 | blitRegion.dstSubresource.mipLevel = 0; |
| 9867 | |
| 9868 | vkCmdBlitImage(m_commandBuffer->GetBufferHandle(), intImage1.handle(), |
| 9869 | intImage1.layout(), intImage2.handle(), intImage2.layout(), |
| 9870 | 16, &blitRegion, VK_FILTER_LINEAR); |
| 9871 | m_errorMonitor->VerifyFound(); |
| 9872 | |
| 9873 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9874 | "called with 0 in ppMemoryBarriers"); |
| 9875 | VkImageMemoryBarrier img_barrier; |
| 9876 | img_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; |
| 9877 | img_barrier.pNext = NULL; |
| 9878 | img_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 9879 | img_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 9880 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 9881 | img_barrier.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 9882 | img_barrier.image = image.handle(); |
| 9883 | img_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 9884 | img_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 9885 | img_barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 9886 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 9887 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 9888 | // layerCount should not be 0 - Expect INVALID_IMAGE_RESOURCE |
| 9889 | img_barrier.subresourceRange.layerCount = 0; |
| 9890 | img_barrier.subresourceRange.levelCount = 1; |
| 9891 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 9892 | VK_PIPELINE_STAGE_HOST_BIT, |
| 9893 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 9894 | nullptr, 1, &img_barrier); |
| 9895 | m_errorMonitor->VerifyFound(); |
| 9896 | img_barrier.subresourceRange.layerCount = 1; |
| 9897 | } |
| 9898 | |
| 9899 | TEST_F(VkLayerTest, ImageFormatLimits) { |
| 9900 | |
| 9901 | TEST_DESCRIPTION("Exceed the limits of image format "); |
| 9902 | |
| 9903 | m_errorMonitor->SetDesiredFailureMsg( |
| 9904 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9905 | "CreateImage extents exceed allowable limits for format"); |
| 9906 | VkImageCreateInfo image_create_info = {}; |
| 9907 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9908 | image_create_info.pNext = NULL; |
| 9909 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 9910 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 9911 | image_create_info.extent.width = 32; |
| 9912 | image_create_info.extent.height = 32; |
| 9913 | image_create_info.extent.depth = 1; |
| 9914 | image_create_info.mipLevels = 1; |
| 9915 | image_create_info.arrayLayers = 1; |
| 9916 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 9917 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 9918 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 9919 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 9920 | image_create_info.flags = 0; |
| 9921 | |
| 9922 | VkImage nullImg; |
| 9923 | VkImageFormatProperties imgFmtProps; |
| 9924 | vkGetPhysicalDeviceImageFormatProperties( |
| 9925 | gpu(), image_create_info.format, image_create_info.imageType, |
| 9926 | image_create_info.tiling, image_create_info.usage, |
| 9927 | image_create_info.flags, &imgFmtProps); |
| 9928 | image_create_info.extent.depth = imgFmtProps.maxExtent.depth + 1; |
| 9929 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 9930 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 9931 | m_errorMonitor->VerifyFound(); |
| 9932 | image_create_info.extent.depth = 1; |
| 9933 | |
| 9934 | m_errorMonitor->SetDesiredFailureMsg( |
| 9935 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9936 | "exceeds allowable maximum supported by format of"); |
| 9937 | image_create_info.mipLevels = imgFmtProps.maxMipLevels + 1; |
| 9938 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 9939 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 9940 | m_errorMonitor->VerifyFound(); |
| 9941 | image_create_info.mipLevels = 1; |
| 9942 | |
| 9943 | m_errorMonitor->SetDesiredFailureMsg( |
| 9944 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9945 | "exceeds allowable maximum supported by format of"); |
| 9946 | image_create_info.arrayLayers = imgFmtProps.maxArrayLayers + 1; |
| 9947 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 9948 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 9949 | m_errorMonitor->VerifyFound(); |
| 9950 | image_create_info.arrayLayers = 1; |
| 9951 | |
| 9952 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9953 | "is not supported by format"); |
| 9954 | int samples = imgFmtProps.sampleCounts >> 1; |
| 9955 | image_create_info.samples = (VkSampleCountFlagBits)samples; |
| 9956 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 9957 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 9958 | m_errorMonitor->VerifyFound(); |
| 9959 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 9960 | |
| 9961 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9962 | "pCreateInfo->initialLayout, must be " |
| 9963 | "VK_IMAGE_LAYOUT_UNDEFINED or " |
| 9964 | "VK_IMAGE_LAYOUT_PREINITIALIZED"); |
| 9965 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 9966 | // Expect INVALID_LAYOUT |
| 9967 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 9968 | m_errorMonitor->VerifyFound(); |
| 9969 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 9970 | } |
| 9971 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9972 | TEST_F(VkLayerTest, CopyImageFormatSizeMismatch) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 9973 | VkResult err; |
| 9974 | bool pass; |
| 9975 | |
| 9976 | // Create color images with different format sizes and try to copy between them |
| 9977 | m_errorMonitor->SetDesiredFailureMsg( |
| 9978 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9979 | "vkCmdCopyImage called with unmatched source and dest image format sizes"); |
| 9980 | |
| 9981 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9982 | |
| 9983 | // Create two images of different types and try to copy between them |
| 9984 | VkImage srcImage; |
| 9985 | VkImage dstImage; |
| 9986 | VkDeviceMemory srcMem; |
| 9987 | VkDeviceMemory destMem; |
| 9988 | VkMemoryRequirements memReqs; |
| 9989 | |
| 9990 | VkImageCreateInfo image_create_info = {}; |
| 9991 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9992 | image_create_info.pNext = NULL; |
| 9993 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 9994 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 9995 | image_create_info.extent.width = 32; |
| 9996 | image_create_info.extent.height = 32; |
| 9997 | image_create_info.extent.depth = 1; |
| 9998 | image_create_info.mipLevels = 1; |
| 9999 | image_create_info.arrayLayers = 1; |
| 10000 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10001 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 10002 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 10003 | image_create_info.flags = 0; |
| 10004 | |
| 10005 | err = |
| 10006 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
| 10007 | ASSERT_VK_SUCCESS(err); |
| 10008 | |
| 10009 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 10010 | // Introduce failure by creating second image with a different-sized format. |
| 10011 | image_create_info.format = VK_FORMAT_R5G5B5A1_UNORM_PACK16; |
| 10012 | |
| 10013 | err = |
| 10014 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
| 10015 | ASSERT_VK_SUCCESS(err); |
| 10016 | |
| 10017 | // Allocate memory |
| 10018 | VkMemoryAllocateInfo memAlloc = {}; |
| 10019 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 10020 | memAlloc.pNext = NULL; |
| 10021 | memAlloc.allocationSize = 0; |
| 10022 | memAlloc.memoryTypeIndex = 0; |
| 10023 | |
| 10024 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
| 10025 | memAlloc.allocationSize = memReqs.size; |
| 10026 | pass = |
| 10027 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 10028 | ASSERT_TRUE(pass); |
| 10029 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
| 10030 | ASSERT_VK_SUCCESS(err); |
| 10031 | |
| 10032 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
| 10033 | memAlloc.allocationSize = memReqs.size; |
| 10034 | pass = |
| 10035 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 10036 | ASSERT_TRUE(pass); |
| 10037 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
| 10038 | ASSERT_VK_SUCCESS(err); |
| 10039 | |
| 10040 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 10041 | ASSERT_VK_SUCCESS(err); |
| 10042 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
| 10043 | ASSERT_VK_SUCCESS(err); |
| 10044 | |
| 10045 | BeginCommandBuffer(); |
| 10046 | VkImageCopy copyRegion; |
| 10047 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10048 | copyRegion.srcSubresource.mipLevel = 0; |
| 10049 | copyRegion.srcSubresource.baseArrayLayer = 0; |
| 10050 | copyRegion.srcSubresource.layerCount = 0; |
| 10051 | copyRegion.srcOffset.x = 0; |
| 10052 | copyRegion.srcOffset.y = 0; |
| 10053 | copyRegion.srcOffset.z = 0; |
| 10054 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10055 | copyRegion.dstSubresource.mipLevel = 0; |
| 10056 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 10057 | copyRegion.dstSubresource.layerCount = 0; |
| 10058 | copyRegion.dstOffset.x = 0; |
| 10059 | copyRegion.dstOffset.y = 0; |
| 10060 | copyRegion.dstOffset.z = 0; |
| 10061 | copyRegion.extent.width = 1; |
| 10062 | copyRegion.extent.height = 1; |
| 10063 | copyRegion.extent.depth = 1; |
| 10064 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 10065 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 10066 | EndCommandBuffer(); |
| 10067 | |
| 10068 | m_errorMonitor->VerifyFound(); |
| 10069 | |
| 10070 | vkDestroyImage(m_device->device(), srcImage, NULL); |
| 10071 | vkDestroyImage(m_device->device(), dstImage, NULL); |
| 10072 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 10073 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10074 | } |
| 10075 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10076 | TEST_F(VkLayerTest, CopyImageDepthStencilFormatMismatch) { |
| 10077 | VkResult err; |
| 10078 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10079 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10080 | // 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] | 10081 | m_errorMonitor->SetDesiredFailureMsg( |
| 10082 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10083 | "vkCmdCopyImage called with unmatched source and dest image depth"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10084 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10085 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10086 | |
| 10087 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10088 | VkImage srcImage; |
| 10089 | VkImage dstImage; |
| 10090 | VkDeviceMemory srcMem; |
| 10091 | VkDeviceMemory destMem; |
| 10092 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10093 | |
| 10094 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10095 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10096 | image_create_info.pNext = NULL; |
| 10097 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10098 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10099 | image_create_info.extent.width = 32; |
| 10100 | image_create_info.extent.height = 32; |
| 10101 | image_create_info.extent.depth = 1; |
| 10102 | image_create_info.mipLevels = 1; |
| 10103 | image_create_info.arrayLayers = 1; |
| 10104 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10105 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 10106 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 10107 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10108 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10109 | err = |
| 10110 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10111 | ASSERT_VK_SUCCESS(err); |
| 10112 | |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 10113 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 10114 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10115 | // Introduce failure by creating second image with a depth/stencil format |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10116 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10117 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 10118 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10119 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10120 | err = |
| 10121 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10122 | ASSERT_VK_SUCCESS(err); |
| 10123 | |
| 10124 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10125 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10126 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 10127 | memAlloc.pNext = NULL; |
| 10128 | memAlloc.allocationSize = 0; |
| 10129 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10130 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 10131 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10132 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10133 | pass = |
| 10134 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10135 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10136 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10137 | ASSERT_VK_SUCCESS(err); |
| 10138 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10139 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10140 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10141 | pass = |
| 10142 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10143 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10144 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10145 | ASSERT_VK_SUCCESS(err); |
| 10146 | |
| 10147 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 10148 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10149 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10150 | ASSERT_VK_SUCCESS(err); |
| 10151 | |
| 10152 | BeginCommandBuffer(); |
| 10153 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10154 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10155 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 10156 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10157 | copyRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10158 | copyRegion.srcOffset.x = 0; |
| 10159 | copyRegion.srcOffset.y = 0; |
| 10160 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10161 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10162 | copyRegion.dstSubresource.mipLevel = 0; |
| 10163 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 10164 | copyRegion.dstSubresource.layerCount = 0; |
| 10165 | copyRegion.dstOffset.x = 0; |
| 10166 | copyRegion.dstOffset.y = 0; |
| 10167 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10168 | copyRegion.extent.width = 1; |
| 10169 | copyRegion.extent.height = 1; |
| 10170 | copyRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10171 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 10172 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10173 | EndCommandBuffer(); |
| 10174 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10175 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10176 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10177 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10178 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10179 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 10180 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10181 | } |
| 10182 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10183 | TEST_F(VkLayerTest, ResolveImageLowSampleCount) { |
| 10184 | VkResult err; |
| 10185 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10186 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10187 | m_errorMonitor->SetDesiredFailureMsg( |
| 10188 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10189 | "vkCmdResolveImage called with source sample count less than 2."); |
| 10190 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10191 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10192 | |
| 10193 | // 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] | 10194 | VkImage srcImage; |
| 10195 | VkImage dstImage; |
| 10196 | VkDeviceMemory srcMem; |
| 10197 | VkDeviceMemory destMem; |
| 10198 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10199 | |
| 10200 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10201 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10202 | image_create_info.pNext = NULL; |
| 10203 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10204 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10205 | image_create_info.extent.width = 32; |
| 10206 | image_create_info.extent.height = 1; |
| 10207 | image_create_info.extent.depth = 1; |
| 10208 | image_create_info.mipLevels = 1; |
| 10209 | image_create_info.arrayLayers = 1; |
| 10210 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10211 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 10212 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 10213 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10214 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10215 | err = |
| 10216 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10217 | ASSERT_VK_SUCCESS(err); |
| 10218 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10219 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10220 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10221 | err = |
| 10222 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10223 | ASSERT_VK_SUCCESS(err); |
| 10224 | |
| 10225 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10226 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10227 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 10228 | memAlloc.pNext = NULL; |
| 10229 | memAlloc.allocationSize = 0; |
| 10230 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10231 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 10232 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10233 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10234 | pass = |
| 10235 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10236 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10237 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10238 | ASSERT_VK_SUCCESS(err); |
| 10239 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10240 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10241 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10242 | pass = |
| 10243 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10244 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10245 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10246 | ASSERT_VK_SUCCESS(err); |
| 10247 | |
| 10248 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 10249 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10250 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10251 | ASSERT_VK_SUCCESS(err); |
| 10252 | |
| 10253 | BeginCommandBuffer(); |
| 10254 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10255 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 10256 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10257 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10258 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10259 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 10260 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10261 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10262 | resolveRegion.srcOffset.x = 0; |
| 10263 | resolveRegion.srcOffset.y = 0; |
| 10264 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10265 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10266 | resolveRegion.dstSubresource.mipLevel = 0; |
| 10267 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 10268 | resolveRegion.dstSubresource.layerCount = 0; |
| 10269 | resolveRegion.dstOffset.x = 0; |
| 10270 | resolveRegion.dstOffset.y = 0; |
| 10271 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10272 | resolveRegion.extent.width = 1; |
| 10273 | resolveRegion.extent.height = 1; |
| 10274 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10275 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 10276 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10277 | EndCommandBuffer(); |
| 10278 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10279 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10280 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10281 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10282 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10283 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 10284 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10285 | } |
| 10286 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10287 | TEST_F(VkLayerTest, ResolveImageHighSampleCount) { |
| 10288 | VkResult err; |
| 10289 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10290 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10291 | m_errorMonitor->SetDesiredFailureMsg( |
| 10292 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10293 | "vkCmdResolveImage called with dest sample count greater than 1."); |
| 10294 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10295 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10296 | |
Chris Forbes | a753069 | 2016-05-08 12:35:39 +1200 | [diff] [blame] | 10297 | // 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] | 10298 | VkImage srcImage; |
| 10299 | VkImage dstImage; |
| 10300 | VkDeviceMemory srcMem; |
| 10301 | VkDeviceMemory destMem; |
| 10302 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10303 | |
| 10304 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10305 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10306 | image_create_info.pNext = NULL; |
| 10307 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10308 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10309 | image_create_info.extent.width = 32; |
| 10310 | image_create_info.extent.height = 1; |
| 10311 | image_create_info.extent.depth = 1; |
| 10312 | image_create_info.mipLevels = 1; |
| 10313 | image_create_info.arrayLayers = 1; |
Chris Forbes | a753069 | 2016-05-08 12:35:39 +1200 | [diff] [blame] | 10314 | image_create_info.samples = VK_SAMPLE_COUNT_4_BIT; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10315 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 10316 | // Note: Some implementations expect color attachment usage for any |
| 10317 | // multisample surface |
| 10318 | image_create_info.usage = |
| 10319 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 10320 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10321 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10322 | err = |
| 10323 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10324 | ASSERT_VK_SUCCESS(err); |
| 10325 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10326 | // Note: Some implementations expect color attachment usage for any |
| 10327 | // multisample surface |
| 10328 | image_create_info.usage = |
| 10329 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10330 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10331 | err = |
| 10332 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10333 | ASSERT_VK_SUCCESS(err); |
| 10334 | |
| 10335 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10336 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10337 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 10338 | memAlloc.pNext = NULL; |
| 10339 | memAlloc.allocationSize = 0; |
| 10340 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10341 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 10342 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10343 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10344 | pass = |
| 10345 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10346 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10347 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10348 | ASSERT_VK_SUCCESS(err); |
| 10349 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10350 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10351 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10352 | pass = |
| 10353 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10354 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10355 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10356 | ASSERT_VK_SUCCESS(err); |
| 10357 | |
| 10358 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 10359 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10360 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10361 | ASSERT_VK_SUCCESS(err); |
| 10362 | |
| 10363 | BeginCommandBuffer(); |
| 10364 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10365 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 10366 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10367 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10368 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10369 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 10370 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10371 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10372 | resolveRegion.srcOffset.x = 0; |
| 10373 | resolveRegion.srcOffset.y = 0; |
| 10374 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10375 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10376 | resolveRegion.dstSubresource.mipLevel = 0; |
| 10377 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 10378 | resolveRegion.dstSubresource.layerCount = 0; |
| 10379 | resolveRegion.dstOffset.x = 0; |
| 10380 | resolveRegion.dstOffset.y = 0; |
| 10381 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10382 | resolveRegion.extent.width = 1; |
| 10383 | resolveRegion.extent.height = 1; |
| 10384 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10385 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 10386 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10387 | EndCommandBuffer(); |
| 10388 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10389 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10390 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10391 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10392 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10393 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 10394 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10395 | } |
| 10396 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10397 | TEST_F(VkLayerTest, ResolveImageFormatMismatch) { |
| 10398 | VkResult err; |
| 10399 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10400 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10401 | m_errorMonitor->SetDesiredFailureMsg( |
| 10402 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10403 | "vkCmdResolveImage called with unmatched source and dest formats."); |
| 10404 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10405 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10406 | |
| 10407 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10408 | VkImage srcImage; |
| 10409 | VkImage dstImage; |
| 10410 | VkDeviceMemory srcMem; |
| 10411 | VkDeviceMemory destMem; |
| 10412 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10413 | |
| 10414 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10415 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10416 | image_create_info.pNext = NULL; |
| 10417 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10418 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10419 | image_create_info.extent.width = 32; |
| 10420 | image_create_info.extent.height = 1; |
| 10421 | image_create_info.extent.depth = 1; |
| 10422 | image_create_info.mipLevels = 1; |
| 10423 | image_create_info.arrayLayers = 1; |
| 10424 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 10425 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 10426 | // Note: Some implementations expect color attachment usage for any |
| 10427 | // multisample surface |
| 10428 | image_create_info.usage = |
| 10429 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 10430 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10431 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10432 | err = |
| 10433 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10434 | ASSERT_VK_SUCCESS(err); |
| 10435 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10436 | // Set format to something other than source image |
| 10437 | image_create_info.format = VK_FORMAT_R32_SFLOAT; |
| 10438 | // Note: Some implementations expect color attachment usage for any |
| 10439 | // multisample surface |
| 10440 | image_create_info.usage = |
| 10441 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 10442 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10443 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10444 | err = |
| 10445 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10446 | ASSERT_VK_SUCCESS(err); |
| 10447 | |
| 10448 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10449 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10450 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 10451 | memAlloc.pNext = NULL; |
| 10452 | memAlloc.allocationSize = 0; |
| 10453 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10454 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 10455 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10456 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10457 | pass = |
| 10458 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10459 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10460 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10461 | ASSERT_VK_SUCCESS(err); |
| 10462 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10463 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10464 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10465 | pass = |
| 10466 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10467 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10468 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10469 | ASSERT_VK_SUCCESS(err); |
| 10470 | |
| 10471 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 10472 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10473 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10474 | ASSERT_VK_SUCCESS(err); |
| 10475 | |
| 10476 | BeginCommandBuffer(); |
| 10477 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10478 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 10479 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10480 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10481 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10482 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 10483 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10484 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10485 | resolveRegion.srcOffset.x = 0; |
| 10486 | resolveRegion.srcOffset.y = 0; |
| 10487 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10488 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10489 | resolveRegion.dstSubresource.mipLevel = 0; |
| 10490 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 10491 | resolveRegion.dstSubresource.layerCount = 0; |
| 10492 | resolveRegion.dstOffset.x = 0; |
| 10493 | resolveRegion.dstOffset.y = 0; |
| 10494 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10495 | resolveRegion.extent.width = 1; |
| 10496 | resolveRegion.extent.height = 1; |
| 10497 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10498 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 10499 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10500 | EndCommandBuffer(); |
| 10501 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10502 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10503 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10504 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10505 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10506 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 10507 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10508 | } |
| 10509 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10510 | TEST_F(VkLayerTest, ResolveImageTypeMismatch) { |
| 10511 | VkResult err; |
| 10512 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10513 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10514 | m_errorMonitor->SetDesiredFailureMsg( |
| 10515 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10516 | "vkCmdResolveImage called with unmatched source and dest image types."); |
| 10517 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10518 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10519 | |
| 10520 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10521 | VkImage srcImage; |
| 10522 | VkImage dstImage; |
| 10523 | VkDeviceMemory srcMem; |
| 10524 | VkDeviceMemory destMem; |
| 10525 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10526 | |
| 10527 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10528 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10529 | image_create_info.pNext = NULL; |
| 10530 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10531 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10532 | image_create_info.extent.width = 32; |
| 10533 | image_create_info.extent.height = 1; |
| 10534 | image_create_info.extent.depth = 1; |
| 10535 | image_create_info.mipLevels = 1; |
| 10536 | image_create_info.arrayLayers = 1; |
| 10537 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 10538 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 10539 | // Note: Some implementations expect color attachment usage for any |
| 10540 | // multisample surface |
| 10541 | image_create_info.usage = |
| 10542 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 10543 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10544 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10545 | err = |
| 10546 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10547 | ASSERT_VK_SUCCESS(err); |
| 10548 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10549 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 10550 | // Note: Some implementations expect color attachment usage for any |
| 10551 | // multisample surface |
| 10552 | image_create_info.usage = |
| 10553 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 10554 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10555 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10556 | err = |
| 10557 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10558 | ASSERT_VK_SUCCESS(err); |
| 10559 | |
| 10560 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10561 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10562 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 10563 | memAlloc.pNext = NULL; |
| 10564 | memAlloc.allocationSize = 0; |
| 10565 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10566 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 10567 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10568 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10569 | pass = |
| 10570 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10571 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10572 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10573 | ASSERT_VK_SUCCESS(err); |
| 10574 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10575 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10576 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10577 | pass = |
| 10578 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10579 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10580 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10581 | ASSERT_VK_SUCCESS(err); |
| 10582 | |
| 10583 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 10584 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10585 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10586 | ASSERT_VK_SUCCESS(err); |
| 10587 | |
| 10588 | BeginCommandBuffer(); |
| 10589 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10590 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 10591 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10592 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10593 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10594 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 10595 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10596 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10597 | resolveRegion.srcOffset.x = 0; |
| 10598 | resolveRegion.srcOffset.y = 0; |
| 10599 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10600 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10601 | resolveRegion.dstSubresource.mipLevel = 0; |
| 10602 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 10603 | resolveRegion.dstSubresource.layerCount = 0; |
| 10604 | resolveRegion.dstOffset.x = 0; |
| 10605 | resolveRegion.dstOffset.y = 0; |
| 10606 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10607 | resolveRegion.extent.width = 1; |
| 10608 | resolveRegion.extent.height = 1; |
| 10609 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10610 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 10611 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10612 | EndCommandBuffer(); |
| 10613 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10614 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10615 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10616 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10617 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10618 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 10619 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10620 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10621 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10622 | TEST_F(VkLayerTest, DepthStencilImageViewWithColorAspectBitError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10623 | // 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] | 10624 | // to using a DS format, then cause it to hit error due to COLOR_BIT not |
| 10625 | // set in aspect |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10626 | // The image format check comes 2nd in validation so we trigger it first, |
| 10627 | // 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] | 10628 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10629 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10630 | m_errorMonitor->SetDesiredFailureMsg( |
| 10631 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10632 | "Combination depth/stencil image formats can have only the "); |
| 10633 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10634 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10635 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 10636 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10637 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 10638 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10639 | |
| 10640 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10641 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 10642 | ds_pool_ci.pNext = NULL; |
| 10643 | ds_pool_ci.maxSets = 1; |
| 10644 | ds_pool_ci.poolSizeCount = 1; |
| 10645 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10646 | |
| 10647 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10648 | err = |
| 10649 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10650 | ASSERT_VK_SUCCESS(err); |
| 10651 | |
| 10652 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10653 | dsl_binding.binding = 0; |
| 10654 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 10655 | dsl_binding.descriptorCount = 1; |
| 10656 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 10657 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10658 | |
| 10659 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10660 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 10661 | ds_layout_ci.pNext = NULL; |
| 10662 | ds_layout_ci.bindingCount = 1; |
| 10663 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10664 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10665 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 10666 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10667 | ASSERT_VK_SUCCESS(err); |
| 10668 | |
| 10669 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10670 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 10671 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 10672 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10673 | alloc_info.descriptorPool = ds_pool; |
| 10674 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10675 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 10676 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10677 | ASSERT_VK_SUCCESS(err); |
| 10678 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10679 | VkImage image_bad; |
| 10680 | VkImage image_good; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10681 | // One bad format and one good format for Color attachment |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10682 | const VkFormat tex_format_bad = VK_FORMAT_D32_SFLOAT_S8_UINT; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10683 | const VkFormat tex_format_good = VK_FORMAT_B8G8R8A8_UNORM; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10684 | const int32_t tex_width = 32; |
| 10685 | const int32_t tex_height = 32; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10686 | |
| 10687 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10688 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10689 | image_create_info.pNext = NULL; |
| 10690 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10691 | image_create_info.format = tex_format_bad; |
| 10692 | image_create_info.extent.width = tex_width; |
| 10693 | image_create_info.extent.height = tex_height; |
| 10694 | image_create_info.extent.depth = 1; |
| 10695 | image_create_info.mipLevels = 1; |
| 10696 | image_create_info.arrayLayers = 1; |
| 10697 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10698 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 10699 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT | |
| 10700 | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 10701 | image_create_info.flags = 0; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10702 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10703 | err = |
| 10704 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image_bad); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10705 | ASSERT_VK_SUCCESS(err); |
| 10706 | image_create_info.format = tex_format_good; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10707 | image_create_info.usage = |
| 10708 | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 10709 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, |
| 10710 | &image_good); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10711 | ASSERT_VK_SUCCESS(err); |
| 10712 | |
| 10713 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10714 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10715 | image_view_create_info.image = image_bad; |
| 10716 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 10717 | image_view_create_info.format = tex_format_bad; |
| 10718 | image_view_create_info.subresourceRange.baseArrayLayer = 0; |
| 10719 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 10720 | image_view_create_info.subresourceRange.layerCount = 1; |
| 10721 | image_view_create_info.subresourceRange.levelCount = 1; |
| 10722 | image_view_create_info.subresourceRange.aspectMask = |
| 10723 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10724 | |
| 10725 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10726 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 10727 | &view); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10728 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10729 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10730 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10731 | vkDestroyImage(m_device->device(), image_bad, NULL); |
| 10732 | vkDestroyImage(m_device->device(), image_good, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10733 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 10734 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10735 | } |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10736 | #endif // IMAGE_TESTS |
| 10737 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 10738 | int main(int argc, char **argv) { |
| 10739 | int result; |
| 10740 | |
Cody Northrop | 8e54a40 | 2016-03-08 22:25:52 -0700 | [diff] [blame] | 10741 | #ifdef ANDROID |
| 10742 | int vulkanSupport = InitVulkan(); |
| 10743 | if (vulkanSupport == 0) |
| 10744 | return 1; |
| 10745 | #endif |
| 10746 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 10747 | ::testing::InitGoogleTest(&argc, argv); |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 10748 | VkTestFramework::InitArgs(&argc, argv); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 10749 | |
| 10750 | ::testing::AddGlobalTestEnvironment(new TestEnvironment); |
| 10751 | |
| 10752 | result = RUN_ALL_TESTS(); |
| 10753 | |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 10754 | VkTestFramework::Finish(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 10755 | return result; |
| 10756 | } |