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 | |
Tobin Ehlis | f11be98 | 2016-05-11 13:52:53 -0600 | [diff] [blame] | 1141 | TEST_F(VkLayerTest, InvalidMemoryAliasing) { |
| 1142 | TEST_DESCRIPTION("Create a buffer and image, allocate memory, and bind the " |
| 1143 | "buffer and image to memory such that they will alias."); |
| 1144 | VkResult err; |
| 1145 | bool pass; |
| 1146 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1147 | |
| 1148 | VkBuffer buffer; |
| 1149 | VkImage image; |
| 1150 | VkDeviceMemory mem; // buffer will be bound first |
| 1151 | VkDeviceMemory mem_img; // image bound first |
| 1152 | VkMemoryRequirements mem_reqs; |
| 1153 | |
| 1154 | VkBufferCreateInfo buf_info = {}; |
| 1155 | buf_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 1156 | buf_info.pNext = NULL; |
| 1157 | buf_info.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 1158 | buf_info.size = 256; |
| 1159 | buf_info.queueFamilyIndexCount = 0; |
| 1160 | buf_info.pQueueFamilyIndices = NULL; |
| 1161 | buf_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 1162 | buf_info.flags = 0; |
| 1163 | err = vkCreateBuffer(m_device->device(), &buf_info, NULL, &buffer); |
| 1164 | ASSERT_VK_SUCCESS(err); |
| 1165 | |
| 1166 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &mem_reqs); |
| 1167 | VkMemoryAllocateInfo alloc_info = {}; |
| 1168 | alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1169 | alloc_info.pNext = NULL; |
| 1170 | alloc_info.memoryTypeIndex = 0; |
| 1171 | |
| 1172 | // Ensure memory is big enough for both bindings |
| 1173 | alloc_info.allocationSize = 0x10000; |
| 1174 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &alloc_info, |
| 1175 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 1176 | if (!pass) { |
| 1177 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 1178 | return; |
| 1179 | } |
| 1180 | err = vkAllocateMemory(m_device->device(), &alloc_info, NULL, &mem); |
| 1181 | ASSERT_VK_SUCCESS(err); |
| 1182 | |
| 1183 | uint8_t *pData; |
| 1184 | err = vkMapMemory(m_device->device(), mem, 0, mem_reqs.size, 0, |
| 1185 | (void **)&pData); |
| 1186 | ASSERT_VK_SUCCESS(err); |
| 1187 | memset(pData, 0xCADECADE, static_cast<size_t>(mem_reqs.size)); |
| 1188 | vkUnmapMemory(m_device->device(), mem); |
| 1189 | err = vkBindBufferMemory(m_device->device(), buffer, mem, 0); |
| 1190 | ASSERT_VK_SUCCESS(err); |
| 1191 | |
| 1192 | VkImageCreateInfo image_create_info = {}; |
| 1193 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1194 | image_create_info.pNext = NULL; |
| 1195 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1196 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 1197 | image_create_info.extent.width = 64; |
| 1198 | image_create_info.extent.height = 64; |
| 1199 | image_create_info.extent.depth = 1; |
| 1200 | image_create_info.mipLevels = 1; |
| 1201 | image_create_info.arrayLayers = 1; |
| 1202 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1203 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1204 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_PREINITIALIZED; |
| 1205 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 1206 | image_create_info.queueFamilyIndexCount = 0; |
| 1207 | image_create_info.pQueueFamilyIndices = NULL; |
| 1208 | image_create_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 1209 | image_create_info.flags = 0; |
| 1210 | |
| 1211 | VkMemoryAllocateInfo mem_alloc = {}; |
| 1212 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1213 | mem_alloc.pNext = NULL; |
| 1214 | mem_alloc.allocationSize = 0; |
| 1215 | mem_alloc.memoryTypeIndex = 0; |
| 1216 | |
| 1217 | /* Create a mappable image. It will be the texture if linear images are ok |
| 1218 | * to be textures or it will be the staging image if they are not. |
| 1219 | */ |
| 1220 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 1221 | ASSERT_VK_SUCCESS(err); |
| 1222 | |
| 1223 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
| 1224 | mem_alloc.allocationSize = mem_reqs.size; |
| 1225 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, |
| 1226 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 1227 | if (!pass) { |
| 1228 | vkDestroyImage(m_device->device(), image, NULL); |
| 1229 | return; |
| 1230 | } |
| 1231 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1232 | " is aliased with buffer 0x"); |
| 1233 | // VALDIATION FAILURE due to image mapping overlapping buffer mapping |
| 1234 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 1235 | m_errorMonitor->VerifyFound(); |
| 1236 | |
| 1237 | // Now correctly bind image to second mem allocation before incorrectly |
| 1238 | // aliasing buffer |
| 1239 | err = vkAllocateMemory(m_device->device(), &alloc_info, NULL, &mem_img); |
| 1240 | ASSERT_VK_SUCCESS(err); |
| 1241 | err = vkBindImageMemory(m_device->device(), image, mem_img, 0); |
| 1242 | ASSERT_VK_SUCCESS(err); |
| 1243 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1244 | " is aliased with image 0x"); |
| 1245 | err = vkBindBufferMemory(m_device->device(), buffer, mem_img, 0); |
| 1246 | m_errorMonitor->VerifyFound(); |
| 1247 | |
| 1248 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 1249 | vkDestroyImage(m_device->device(), image, NULL); |
| 1250 | vkFreeMemory(m_device->device(), mem, NULL); |
| 1251 | vkFreeMemory(m_device->device(), mem_img, NULL); |
| 1252 | } |
| 1253 | |
Tobin Ehlis | 3537252 | 2016-05-12 08:32:31 -0600 | [diff] [blame] | 1254 | TEST_F(VkLayerTest, InvalidMemoryMapping) { |
| 1255 | TEST_DESCRIPTION("Attempt to map memory in a number of incorrect ways"); |
| 1256 | VkResult err; |
| 1257 | bool pass; |
| 1258 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1259 | |
| 1260 | VkBuffer buffer; |
| 1261 | VkDeviceMemory mem; |
| 1262 | VkMemoryRequirements mem_reqs; |
| 1263 | |
| 1264 | VkBufferCreateInfo buf_info = {}; |
| 1265 | buf_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 1266 | buf_info.pNext = NULL; |
| 1267 | buf_info.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 1268 | buf_info.size = 256; |
| 1269 | buf_info.queueFamilyIndexCount = 0; |
| 1270 | buf_info.pQueueFamilyIndices = NULL; |
| 1271 | buf_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 1272 | buf_info.flags = 0; |
| 1273 | err = vkCreateBuffer(m_device->device(), &buf_info, NULL, &buffer); |
| 1274 | ASSERT_VK_SUCCESS(err); |
| 1275 | |
| 1276 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &mem_reqs); |
| 1277 | VkMemoryAllocateInfo alloc_info = {}; |
| 1278 | alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1279 | alloc_info.pNext = NULL; |
| 1280 | alloc_info.memoryTypeIndex = 0; |
| 1281 | |
| 1282 | // Ensure memory is big enough for both bindings |
| 1283 | static const VkDeviceSize allocation_size = 0x10000; |
| 1284 | alloc_info.allocationSize = allocation_size; |
| 1285 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &alloc_info, |
| 1286 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 1287 | if (!pass) { |
| 1288 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 1289 | return; |
| 1290 | } |
| 1291 | err = vkAllocateMemory(m_device->device(), &alloc_info, NULL, &mem); |
| 1292 | ASSERT_VK_SUCCESS(err); |
| 1293 | |
| 1294 | uint8_t *pData; |
| 1295 | // Attempt to map memory size 0 is invalid |
| 1296 | m_errorMonitor->SetDesiredFailureMsg( |
| 1297 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1298 | "VkMapMemory: Attempting to map memory range of size zero"); |
| 1299 | err = vkMapMemory(m_device->device(), mem, 0, 0, 0, (void **)&pData); |
| 1300 | m_errorMonitor->VerifyFound(); |
| 1301 | // Map memory twice |
| 1302 | err = vkMapMemory(m_device->device(), mem, 0, mem_reqs.size, 0, |
| 1303 | (void **)&pData); |
| 1304 | ASSERT_VK_SUCCESS(err); |
| 1305 | m_errorMonitor->SetDesiredFailureMsg( |
| 1306 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1307 | "VkMapMemory: Attempting to map memory on an already-mapped object "); |
| 1308 | err = vkMapMemory(m_device->device(), mem, 0, mem_reqs.size, 0, |
| 1309 | (void **)&pData); |
| 1310 | m_errorMonitor->VerifyFound(); |
| 1311 | |
| 1312 | // Unmap the memory to avoid re-map error |
| 1313 | vkUnmapMemory(m_device->device(), mem); |
| 1314 | // overstep allocation with VK_WHOLE_SIZE |
| 1315 | m_errorMonitor->SetDesiredFailureMsg( |
| 1316 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1317 | " with size of VK_WHOLE_SIZE oversteps total array size 0x"); |
| 1318 | err = vkMapMemory(m_device->device(), mem, allocation_size + 1, |
| 1319 | VK_WHOLE_SIZE, 0, (void **)&pData); |
| 1320 | m_errorMonitor->VerifyFound(); |
| 1321 | // overstep allocation w/o VK_WHOLE_SIZE |
| 1322 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1323 | " oversteps total array size 0x"); |
| 1324 | err = vkMapMemory(m_device->device(), mem, 1, allocation_size, 0, |
| 1325 | (void **)&pData); |
| 1326 | m_errorMonitor->VerifyFound(); |
| 1327 | // Now error due to unmapping memory that's not mapped |
| 1328 | m_errorMonitor->SetDesiredFailureMsg( |
| 1329 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1330 | "Unmapping Memory without memory being mapped: "); |
| 1331 | vkUnmapMemory(m_device->device(), mem); |
| 1332 | m_errorMonitor->VerifyFound(); |
| 1333 | // Now map memory and cause errors due to flushing invalid ranges |
| 1334 | err = vkMapMemory(m_device->device(), mem, 16, VK_WHOLE_SIZE, 0, |
| 1335 | (void **)&pData); |
| 1336 | ASSERT_VK_SUCCESS(err); |
| 1337 | VkMappedMemoryRange mmr = {}; |
| 1338 | mmr.memory = mem; |
| 1339 | mmr.offset = 15; // Error b/c offset less than offset of mapped mem |
| 1340 | m_errorMonitor->SetDesiredFailureMsg( |
| 1341 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1342 | ") is less than Memory Object's offset ("); |
| 1343 | vkFlushMappedMemoryRanges(m_device->device(), 1, &mmr); |
| 1344 | m_errorMonitor->VerifyFound(); |
| 1345 | // Now flush range that oversteps mapped range |
| 1346 | vkUnmapMemory(m_device->device(), mem); |
| 1347 | err = vkMapMemory(m_device->device(), mem, 0, 256, 0, (void **)&pData); |
| 1348 | ASSERT_VK_SUCCESS(err); |
| 1349 | mmr.offset = 16; |
| 1350 | mmr.size = 256; // flushing bounds (272) exceed mapped bounds (256) |
| 1351 | m_errorMonitor->SetDesiredFailureMsg( |
| 1352 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1353 | ") exceeds the Memory Object's upper-bound ("); |
| 1354 | vkFlushMappedMemoryRanges(m_device->device(), 1, &mmr); |
| 1355 | m_errorMonitor->VerifyFound(); |
| 1356 | |
| 1357 | pass = |
| 1358 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &alloc_info, |
| 1359 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, |
| 1360 | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT); |
| 1361 | if (!pass) { |
| 1362 | vkFreeMemory(m_device->device(), mem, NULL); |
| 1363 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 1364 | return; |
| 1365 | } |
| 1366 | // TODO : If we can get HOST_VISIBLE w/o HOST_COHERENT we can test cases of |
| 1367 | // MEMTRACK_INVALID_MAP in validateAndCopyNoncoherentMemoryToDriver() |
| 1368 | |
| 1369 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 1370 | vkFreeMemory(m_device->device(), mem, NULL); |
| 1371 | } |
| 1372 | |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1373 | TEST_F(VkLayerTest, EnableWsiBeforeUse) { |
| 1374 | VkResult err; |
| 1375 | bool pass; |
| 1376 | |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1377 | // FIXME: After we turn on this code for non-Linux platforms, uncomment the |
| 1378 | // following declaration (which is temporarily being moved below): |
| 1379 | // VkSurfaceKHR surface = VK_NULL_HANDLE; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1380 | VkSwapchainKHR swapchain = VK_NULL_HANDLE; |
| 1381 | VkSwapchainCreateInfoKHR swapchain_create_info = {}; |
| 1382 | uint32_t swapchain_image_count = 0; |
| 1383 | // VkImage swapchain_images[1] = {VK_NULL_HANDLE}; |
| 1384 | uint32_t image_index = 0; |
| 1385 | // VkPresentInfoKHR present_info = {}; |
| 1386 | |
| 1387 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1388 | |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1389 | #ifdef NEED_TO_TEST_THIS_ON_PLATFORM |
| 1390 | #if defined(VK_USE_PLATFORM_ANDROID_KHR) |
| 1391 | // Use the functions from the VK_KHR_android_surface extension without |
| 1392 | // enabling that extension: |
| 1393 | |
| 1394 | // Create a surface: |
| 1395 | VkAndroidSurfaceCreateInfoKHR android_create_info = {}; |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1396 | m_errorMonitor->SetDesiredFailureMsg( |
| 1397 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1398 | "extension was not enabled for this"); |
| 1399 | err = vkCreateAndroidSurfaceKHR(instance(), &android_create_info, NULL, |
| 1400 | &surface); |
| 1401 | pass = (err != VK_SUCCESS); |
| 1402 | ASSERT_TRUE(pass); |
| 1403 | m_errorMonitor->VerifyFound(); |
| 1404 | #endif // VK_USE_PLATFORM_ANDROID_KHR |
| 1405 | |
| 1406 | |
| 1407 | #if defined(VK_USE_PLATFORM_MIR_KHR) |
| 1408 | // Use the functions from the VK_KHR_mir_surface extension without enabling |
| 1409 | // that extension: |
| 1410 | |
| 1411 | // Create a surface: |
| 1412 | VkMirSurfaceCreateInfoKHR mir_create_info = {}; |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1413 | m_errorMonitor->SetDesiredFailureMsg( |
| 1414 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1415 | "extension was not enabled for this"); |
| 1416 | err = vkCreateMirSurfaceKHR(instance(), &mir_create_info, NULL, &surface); |
| 1417 | pass = (err != VK_SUCCESS); |
| 1418 | ASSERT_TRUE(pass); |
| 1419 | m_errorMonitor->VerifyFound(); |
| 1420 | |
| 1421 | // Tell whether an mir_connection supports presentation: |
| 1422 | MirConnection *mir_connection = NULL; |
| 1423 | m_errorMonitor->SetDesiredFailureMsg( |
| 1424 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1425 | "extension was not enabled for this"); |
| 1426 | vkGetPhysicalDeviceMirPresentationSupportKHR(gpu(), 0, mir_connection, |
| 1427 | visual_id); |
| 1428 | m_errorMonitor->VerifyFound(); |
| 1429 | #endif // VK_USE_PLATFORM_MIR_KHR |
| 1430 | |
| 1431 | |
| 1432 | #if defined(VK_USE_PLATFORM_WAYLAND_KHR) |
| 1433 | // Use the functions from the VK_KHR_wayland_surface extension without |
| 1434 | // enabling that extension: |
| 1435 | |
| 1436 | // Create a surface: |
| 1437 | VkWaylandSurfaceCreateInfoKHR wayland_create_info = {}; |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1438 | m_errorMonitor->SetDesiredFailureMsg( |
| 1439 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1440 | "extension was not enabled for this"); |
| 1441 | err = vkCreateWaylandSurfaceKHR(instance(), &wayland_create_info, NULL, |
| 1442 | &surface); |
| 1443 | pass = (err != VK_SUCCESS); |
| 1444 | ASSERT_TRUE(pass); |
| 1445 | m_errorMonitor->VerifyFound(); |
| 1446 | |
| 1447 | // Tell whether an wayland_display supports presentation: |
| 1448 | struct wl_display wayland_display = {}; |
| 1449 | m_errorMonitor->SetDesiredFailureMsg( |
| 1450 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1451 | "extension was not enabled for this"); |
| 1452 | vkGetPhysicalDeviceWaylandPresentationSupportKHR(gpu(), 0, |
| 1453 | &wayland_display); |
| 1454 | m_errorMonitor->VerifyFound(); |
| 1455 | #endif // VK_USE_PLATFORM_WAYLAND_KHR |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1456 | #endif // NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1457 | |
| 1458 | |
| 1459 | #if defined(VK_USE_PLATFORM_WIN32_KHR) |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1460 | // FIXME: REMOVE THIS HERE, AND UNCOMMENT ABOVE, WHEN THIS TEST HAS BEEN PORTED |
| 1461 | // TO NON-LINUX PLATFORMS: |
| 1462 | VkSurfaceKHR surface = VK_NULL_HANDLE; |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1463 | // Use the functions from the VK_KHR_win32_surface extension without |
| 1464 | // enabling that extension: |
| 1465 | |
| 1466 | // Create a surface: |
| 1467 | VkWin32SurfaceCreateInfoKHR win32_create_info = {}; |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1468 | m_errorMonitor->SetDesiredFailureMsg( |
| 1469 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1470 | "extension was not enabled for this"); |
| 1471 | err = vkCreateWin32SurfaceKHR(instance(), &win32_create_info, NULL, |
| 1472 | &surface); |
| 1473 | pass = (err != VK_SUCCESS); |
| 1474 | ASSERT_TRUE(pass); |
| 1475 | m_errorMonitor->VerifyFound(); |
| 1476 | |
| 1477 | // Tell whether win32 supports presentation: |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1478 | m_errorMonitor->SetDesiredFailureMsg( |
| 1479 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1480 | "extension was not enabled for this"); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1481 | vkGetPhysicalDeviceWin32PresentationSupportKHR(gpu(), 0); |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1482 | m_errorMonitor->VerifyFound(); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1483 | // Set this (for now, until all platforms are supported and tested): |
| 1484 | #define NEED_TO_TEST_THIS_ON_PLATFORM |
| 1485 | #endif // VK_USE_PLATFORM_WIN32_KHR |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1486 | |
| 1487 | |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1488 | #if defined(VK_USE_PLATFORM_XCB_KHR) |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1489 | // FIXME: REMOVE THIS HERE, AND UNCOMMENT ABOVE, WHEN THIS TEST HAS BEEN PORTED |
| 1490 | // TO NON-LINUX PLATFORMS: |
| 1491 | VkSurfaceKHR surface = VK_NULL_HANDLE; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1492 | // Use the functions from the VK_KHR_xcb_surface extension without enabling |
| 1493 | // that extension: |
| 1494 | |
| 1495 | // Create a surface: |
| 1496 | VkXcbSurfaceCreateInfoKHR xcb_create_info = {}; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1497 | m_errorMonitor->SetDesiredFailureMsg( |
| 1498 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1499 | "extension was not enabled for this"); |
| 1500 | err = vkCreateXcbSurfaceKHR(instance(), &xcb_create_info, NULL, &surface); |
| 1501 | pass = (err != VK_SUCCESS); |
| 1502 | ASSERT_TRUE(pass); |
| 1503 | m_errorMonitor->VerifyFound(); |
| 1504 | |
| 1505 | // Tell whether an xcb_visualid_t supports presentation: |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1506 | xcb_connection_t *xcb_connection = NULL; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1507 | xcb_visualid_t visual_id = 0; |
| 1508 | m_errorMonitor->SetDesiredFailureMsg( |
| 1509 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1510 | "extension was not enabled for this"); |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1511 | vkGetPhysicalDeviceXcbPresentationSupportKHR(gpu(), 0, xcb_connection, |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1512 | visual_id); |
| 1513 | m_errorMonitor->VerifyFound(); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1514 | // Set this (for now, until all platforms are supported and tested): |
| 1515 | #define NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1516 | #endif // VK_USE_PLATFORM_XCB_KHR |
| 1517 | |
| 1518 | |
Ian Elliott | 1263081 | 2016-04-29 14:35:43 -0600 | [diff] [blame] | 1519 | #if defined(VK_USE_PLATFORM_XLIB_KHR) |
| 1520 | // Use the functions from the VK_KHR_xlib_surface extension without enabling |
| 1521 | // that extension: |
| 1522 | |
| 1523 | // Create a surface: |
| 1524 | VkXlibSurfaceCreateInfoKHR xlib_create_info = {}; |
Ian Elliott | 1263081 | 2016-04-29 14:35:43 -0600 | [diff] [blame] | 1525 | m_errorMonitor->SetDesiredFailureMsg( |
| 1526 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1527 | "extension was not enabled for this"); |
| 1528 | err = vkCreateXlibSurfaceKHR(instance(), &xlib_create_info, NULL, &surface); |
| 1529 | pass = (err != VK_SUCCESS); |
| 1530 | ASSERT_TRUE(pass); |
| 1531 | m_errorMonitor->VerifyFound(); |
| 1532 | |
| 1533 | // Tell whether an Xlib VisualID supports presentation: |
| 1534 | Display *dpy = NULL; |
| 1535 | VisualID visual = 0; |
| 1536 | m_errorMonitor->SetDesiredFailureMsg( |
| 1537 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1538 | "extension was not enabled for this"); |
| 1539 | vkGetPhysicalDeviceXlibPresentationSupportKHR(gpu(), 0, dpy, visual); |
| 1540 | m_errorMonitor->VerifyFound(); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1541 | // Set this (for now, until all platforms are supported and tested): |
| 1542 | #define NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1263081 | 2016-04-29 14:35:43 -0600 | [diff] [blame] | 1543 | #endif // VK_USE_PLATFORM_XLIB_KHR |
| 1544 | |
| 1545 | |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1546 | // Use the functions from the VK_KHR_surface extension without enabling |
| 1547 | // that extension: |
| 1548 | |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1549 | #ifdef NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1550 | // Destroy a surface: |
| 1551 | m_errorMonitor->SetDesiredFailureMsg( |
| 1552 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1553 | "extension was not enabled for this"); |
| 1554 | vkDestroySurfaceKHR(instance(), surface, NULL); |
| 1555 | m_errorMonitor->VerifyFound(); |
| 1556 | |
| 1557 | // Check if surface supports presentation: |
| 1558 | VkBool32 supported = false; |
| 1559 | m_errorMonitor->SetDesiredFailureMsg( |
| 1560 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1561 | "extension was not enabled for this"); |
| 1562 | err = vkGetPhysicalDeviceSurfaceSupportKHR(gpu(), 0, surface, &supported); |
| 1563 | pass = (err != VK_SUCCESS); |
| 1564 | ASSERT_TRUE(pass); |
| 1565 | m_errorMonitor->VerifyFound(); |
| 1566 | |
| 1567 | // Check surface capabilities: |
| 1568 | VkSurfaceCapabilitiesKHR capabilities = {}; |
| 1569 | m_errorMonitor->SetDesiredFailureMsg( |
| 1570 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1571 | "extension was not enabled for this"); |
| 1572 | err = vkGetPhysicalDeviceSurfaceCapabilitiesKHR(gpu(), surface, |
| 1573 | &capabilities); |
| 1574 | pass = (err != VK_SUCCESS); |
| 1575 | ASSERT_TRUE(pass); |
| 1576 | m_errorMonitor->VerifyFound(); |
| 1577 | |
| 1578 | // Check surface formats: |
| 1579 | uint32_t format_count = 0; |
| 1580 | VkSurfaceFormatKHR *formats = NULL; |
| 1581 | m_errorMonitor->SetDesiredFailureMsg( |
| 1582 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1583 | "extension was not enabled for this"); |
| 1584 | err = vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, |
| 1585 | &format_count, formats); |
| 1586 | pass = (err != VK_SUCCESS); |
| 1587 | ASSERT_TRUE(pass); |
| 1588 | m_errorMonitor->VerifyFound(); |
| 1589 | |
| 1590 | // Check surface present modes: |
| 1591 | uint32_t present_mode_count = 0; |
| 1592 | VkSurfaceFormatKHR *present_modes = NULL; |
| 1593 | m_errorMonitor->SetDesiredFailureMsg( |
| 1594 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1595 | "extension was not enabled for this"); |
| 1596 | err = vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, |
| 1597 | &present_mode_count, present_modes); |
| 1598 | pass = (err != VK_SUCCESS); |
| 1599 | ASSERT_TRUE(pass); |
| 1600 | m_errorMonitor->VerifyFound(); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1601 | #endif // NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1602 | |
| 1603 | |
| 1604 | // Use the functions from the VK_KHR_swapchain extension without enabling |
| 1605 | // that extension: |
| 1606 | |
| 1607 | // Create a swapchain: |
| 1608 | m_errorMonitor->SetDesiredFailureMsg( |
| 1609 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1610 | "extension was not enabled for this"); |
| 1611 | swapchain_create_info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR; |
| 1612 | swapchain_create_info.pNext = NULL; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1613 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, |
| 1614 | NULL, &swapchain); |
| 1615 | pass = (err != VK_SUCCESS); |
| 1616 | ASSERT_TRUE(pass); |
| 1617 | m_errorMonitor->VerifyFound(); |
| 1618 | |
| 1619 | // Get the images from the swapchain: |
| 1620 | m_errorMonitor->SetDesiredFailureMsg( |
| 1621 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1622 | "extension was not enabled for this"); |
| 1623 | err = vkGetSwapchainImagesKHR(m_device->device(), swapchain, |
| 1624 | &swapchain_image_count, NULL); |
| 1625 | pass = (err != VK_SUCCESS); |
| 1626 | ASSERT_TRUE(pass); |
| 1627 | m_errorMonitor->VerifyFound(); |
| 1628 | |
| 1629 | // Try to acquire an image: |
| 1630 | m_errorMonitor->SetDesiredFailureMsg( |
| 1631 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1632 | "extension was not enabled for this"); |
| 1633 | err = vkAcquireNextImageKHR(m_device->device(), swapchain, 0, |
| 1634 | VK_NULL_HANDLE, VK_NULL_HANDLE, &image_index); |
| 1635 | pass = (err != VK_SUCCESS); |
| 1636 | ASSERT_TRUE(pass); |
| 1637 | m_errorMonitor->VerifyFound(); |
| 1638 | |
| 1639 | // Try to present an image: |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1640 | // |
| 1641 | // NOTE: Currently can't test this because a real swapchain is needed (as |
| 1642 | // opposed to the fake one we created) in order for the layer to lookup the |
| 1643 | // VkDevice used to enable the extension: |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1644 | |
| 1645 | // Destroy the swapchain: |
| 1646 | m_errorMonitor->SetDesiredFailureMsg( |
| 1647 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1648 | "extension was not enabled for this"); |
| 1649 | vkDestroySwapchainKHR(m_device->device(), swapchain, NULL); |
| 1650 | m_errorMonitor->VerifyFound(); |
| 1651 | } |
| 1652 | |
Ian Elliott | 2c1daf5 | 2016-05-12 09:41:46 -0600 | [diff] [blame] | 1653 | TEST_F(VkWsiEnabledLayerTest, TestEnabledWsi) { |
| 1654 | VkResult err; |
| 1655 | bool pass; |
| 1656 | |
| 1657 | VkSurfaceKHR surface = VK_NULL_HANDLE; |
| 1658 | #if defined(VK_USE_PLATFORM_XCB_KHR) |
| 1659 | VkSwapchainKHR swapchain = VK_NULL_HANDLE; |
| 1660 | VkSwapchainCreateInfoKHR swapchain_create_info = {}; |
| 1661 | // uint32_t swapchain_image_count = 0; |
| 1662 | // VkImage swapchain_images[1] = {VK_NULL_HANDLE}; |
| 1663 | // uint32_t image_index = 0; |
| 1664 | // VkPresentInfoKHR present_info = {}; |
| 1665 | |
| 1666 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1667 | |
| 1668 | // Use the create function from one of the VK_KHR_*_surface extension in |
| 1669 | // order to create a surface, testing all known errors in the process, |
| 1670 | // before successfully creating a surface: |
| 1671 | // First, try to create a surface without a VkXcbSurfaceCreateInfoKHR: |
| 1672 | m_errorMonitor->SetDesiredFailureMsg( |
| 1673 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1674 | "called with NULL pointer"); |
| 1675 | err = vkCreateXcbSurfaceKHR(instance(), NULL, NULL, &surface); |
| 1676 | pass = (err != VK_SUCCESS); |
| 1677 | ASSERT_TRUE(pass); |
| 1678 | m_errorMonitor->VerifyFound(); |
| 1679 | |
| 1680 | // Next, try to create a surface with the wrong |
| 1681 | // VkXcbSurfaceCreateInfoKHR::sType: |
| 1682 | VkXcbSurfaceCreateInfoKHR xcb_create_info = {}; |
| 1683 | xcb_create_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; |
| 1684 | m_errorMonitor->SetDesiredFailureMsg( |
| 1685 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1686 | "called with the wrong value for"); |
| 1687 | err = vkCreateXcbSurfaceKHR(instance(), &xcb_create_info, NULL, &surface); |
| 1688 | pass = (err != VK_SUCCESS); |
| 1689 | ASSERT_TRUE(pass); |
| 1690 | m_errorMonitor->VerifyFound(); |
| 1691 | |
| 1692 | |
| 1693 | // Create a native window, and then correctly create a surface: |
| 1694 | xcb_connection_t *connection; |
| 1695 | xcb_screen_t *screen; |
| 1696 | xcb_window_t xcb_window; |
| 1697 | xcb_intern_atom_reply_t *atom_wm_delete_window; |
| 1698 | |
| 1699 | const xcb_setup_t *setup; |
| 1700 | xcb_screen_iterator_t iter; |
| 1701 | int scr; |
| 1702 | uint32_t value_mask, value_list[32]; |
| 1703 | int width = 1; |
| 1704 | int height = 1; |
| 1705 | |
| 1706 | connection = xcb_connect(NULL, &scr); |
| 1707 | ASSERT_TRUE(connection != NULL); |
| 1708 | setup = xcb_get_setup(connection); |
| 1709 | iter = xcb_setup_roots_iterator(setup); |
| 1710 | while (scr-- > 0) |
| 1711 | xcb_screen_next(&iter); |
| 1712 | screen = iter.data; |
| 1713 | |
| 1714 | xcb_window = xcb_generate_id(connection); |
| 1715 | |
| 1716 | value_mask = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK; |
| 1717 | value_list[0] = screen->black_pixel; |
| 1718 | value_list[1] = XCB_EVENT_MASK_KEY_RELEASE | XCB_EVENT_MASK_EXPOSURE | |
| 1719 | XCB_EVENT_MASK_STRUCTURE_NOTIFY; |
| 1720 | |
| 1721 | xcb_create_window(connection, XCB_COPY_FROM_PARENT, xcb_window, |
| 1722 | screen->root, 0, 0, width, height, 0, |
| 1723 | XCB_WINDOW_CLASS_INPUT_OUTPUT, screen->root_visual, |
| 1724 | value_mask, value_list); |
| 1725 | |
| 1726 | /* Magic code that will send notification when window is destroyed */ |
| 1727 | xcb_intern_atom_cookie_t cookie = |
| 1728 | xcb_intern_atom(connection, 1, 12, "WM_PROTOCOLS"); |
| 1729 | xcb_intern_atom_reply_t *reply = |
| 1730 | xcb_intern_atom_reply(connection, cookie, 0); |
| 1731 | |
| 1732 | xcb_intern_atom_cookie_t cookie2 = |
| 1733 | xcb_intern_atom(connection, 0, 16, "WM_DELETE_WINDOW"); |
| 1734 | atom_wm_delete_window = |
| 1735 | xcb_intern_atom_reply(connection, cookie2, 0); |
| 1736 | xcb_change_property(connection, XCB_PROP_MODE_REPLACE, xcb_window, |
| 1737 | (*reply).atom, 4, 32, 1, |
| 1738 | &(*atom_wm_delete_window).atom); |
| 1739 | free(reply); |
| 1740 | |
| 1741 | xcb_map_window(connection, xcb_window); |
| 1742 | |
| 1743 | // Force the x/y coordinates to 100,100 results are identical in consecutive |
| 1744 | // runs |
| 1745 | const uint32_t coords[] = {100, 100}; |
| 1746 | xcb_configure_window(connection, xcb_window, |
| 1747 | XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, coords); |
| 1748 | |
| 1749 | |
| 1750 | |
| 1751 | // Finally, try to correctly create a surface: |
| 1752 | xcb_create_info.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR; |
| 1753 | xcb_create_info.pNext = NULL; |
| 1754 | xcb_create_info.flags = 0; |
| 1755 | xcb_create_info.connection = connection; |
| 1756 | xcb_create_info.window = xcb_window; |
| 1757 | err = vkCreateXcbSurfaceKHR(instance(), &xcb_create_info, NULL, &surface); |
| 1758 | pass = (err == VK_SUCCESS); |
| 1759 | ASSERT_TRUE(pass); |
| 1760 | |
| 1761 | |
| 1762 | |
| 1763 | // Check if surface supports presentation: |
| 1764 | |
| 1765 | // 1st, do so without having queried the queue families: |
| 1766 | VkBool32 supported = false; |
| 1767 | // TODO: Get the following error to come out: |
| 1768 | m_errorMonitor->SetDesiredFailureMsg( |
| 1769 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1770 | "called before calling the vkGetPhysicalDeviceQueueFamilyProperties " |
| 1771 | "function"); |
| 1772 | err = vkGetPhysicalDeviceSurfaceSupportKHR(gpu(), 0, surface, &supported); |
| 1773 | pass = (err != VK_SUCCESS); |
| 1774 | // ASSERT_TRUE(pass); |
| 1775 | // m_errorMonitor->VerifyFound(); |
| 1776 | |
| 1777 | // Next, query a queue family index that's too large: |
| 1778 | m_errorMonitor->SetDesiredFailureMsg( |
| 1779 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1780 | "called with a queueFamilyIndex that is too large"); |
| 1781 | err = vkGetPhysicalDeviceSurfaceSupportKHR(gpu(), 100000, surface, &supported); |
| 1782 | pass = (err != VK_SUCCESS); |
| 1783 | ASSERT_TRUE(pass); |
| 1784 | m_errorMonitor->VerifyFound(); |
| 1785 | |
| 1786 | // Finally, do so correctly: |
| 1787 | // FIXME: THIS ISN'T CORRECT--MUST QUERY UNTIL WE FIND A QUEUE FAMILY THAT'S SUPPORTED |
| 1788 | err = vkGetPhysicalDeviceSurfaceSupportKHR(gpu(), 0, surface, &supported); |
| 1789 | pass = (err == VK_SUCCESS); |
| 1790 | ASSERT_TRUE(pass); |
| 1791 | |
| 1792 | |
| 1793 | |
| 1794 | // Before proceeding, try to create a swapchain without having called |
| 1795 | // vkGetPhysicalDeviceSurfaceCapabilitiesKHR(): |
| 1796 | swapchain_create_info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR; |
| 1797 | swapchain_create_info.pNext = NULL; |
| 1798 | swapchain_create_info.flags = 0; |
| 1799 | m_errorMonitor->SetDesiredFailureMsg( |
| 1800 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1801 | "called before calling vkGetPhysicalDeviceSurfaceCapabilitiesKHR()."); |
| 1802 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, |
| 1803 | NULL, &swapchain); |
| 1804 | pass = (err != VK_SUCCESS); |
| 1805 | ASSERT_TRUE(pass); |
| 1806 | m_errorMonitor->VerifyFound(); |
| 1807 | |
| 1808 | |
| 1809 | |
| 1810 | // Get the surface capabilities: |
| 1811 | VkSurfaceCapabilitiesKHR surface_capabilities; |
| 1812 | |
| 1813 | // Do so correctly (only error logged by this entrypoint is if the |
| 1814 | // extension isn't enabled): |
| 1815 | err = vkGetPhysicalDeviceSurfaceCapabilitiesKHR(gpu(), surface, |
| 1816 | &surface_capabilities); |
| 1817 | pass = (err == VK_SUCCESS); |
| 1818 | ASSERT_TRUE(pass); |
| 1819 | |
| 1820 | |
| 1821 | |
| 1822 | // Get the surface formats: |
| 1823 | uint32_t surface_format_count; |
| 1824 | |
| 1825 | // First, try without a pointer to surface_format_count: |
| 1826 | m_errorMonitor->SetDesiredFailureMsg( |
| 1827 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1828 | "called with NULL pointer"); |
| 1829 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, NULL, NULL); |
| 1830 | pass = (err == VK_SUCCESS); |
| 1831 | ASSERT_TRUE(pass); |
| 1832 | m_errorMonitor->VerifyFound(); |
| 1833 | |
| 1834 | // Next, call with a non-NULL pSurfaceFormats, even though we haven't |
| 1835 | // correctly done a 1st try (to get the count): |
| 1836 | m_errorMonitor->SetDesiredFailureMsg( |
| 1837 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1838 | "but no prior positive value has been seen for"); |
| 1839 | surface_format_count = 0; |
| 1840 | vkGetPhysicalDeviceSurfaceFormatsKHR( |
| 1841 | gpu(), |
| 1842 | surface, |
| 1843 | &surface_format_count, |
| 1844 | (VkSurfaceFormatKHR *) &surface_format_count); |
| 1845 | pass = (err == VK_SUCCESS); |
| 1846 | ASSERT_TRUE(pass); |
| 1847 | m_errorMonitor->VerifyFound(); |
| 1848 | |
| 1849 | // Next, correctly do a 1st try (with a NULL pointer to surface_formats): |
| 1850 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, |
| 1851 | &surface_format_count, NULL); |
| 1852 | pass = (err == VK_SUCCESS); |
| 1853 | ASSERT_TRUE(pass); |
| 1854 | |
| 1855 | // Allocate memory for the correct number of VkSurfaceFormatKHR's: |
| 1856 | VkSurfaceFormatKHR *surface_formats = |
| 1857 | (VkSurfaceFormatKHR *)malloc(surface_format_count * |
| 1858 | sizeof(VkSurfaceFormatKHR)); |
| 1859 | |
| 1860 | // Next, do a 2nd try with surface_format_count being set too high: |
| 1861 | surface_format_count += 5; |
| 1862 | m_errorMonitor->SetDesiredFailureMsg( |
| 1863 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1864 | "that is greater than the value"); |
| 1865 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, |
| 1866 | &surface_format_count, |
| 1867 | surface_formats); |
| 1868 | pass = (err == VK_SUCCESS); |
| 1869 | ASSERT_TRUE(pass); |
| 1870 | m_errorMonitor->VerifyFound(); |
| 1871 | |
| 1872 | // Finally, do a correct 1st and 2nd try: |
| 1873 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, |
| 1874 | &surface_format_count, NULL); |
| 1875 | pass = (err == VK_SUCCESS); |
| 1876 | ASSERT_TRUE(pass); |
| 1877 | vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, |
| 1878 | &surface_format_count, |
| 1879 | surface_formats); |
| 1880 | pass = (err == VK_SUCCESS); |
| 1881 | ASSERT_TRUE(pass); |
| 1882 | |
| 1883 | |
| 1884 | |
| 1885 | // Get the surface present modes: |
| 1886 | uint32_t surface_present_mode_count; |
| 1887 | |
| 1888 | // First, try without a pointer to surface_format_count: |
| 1889 | m_errorMonitor->SetDesiredFailureMsg( |
| 1890 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1891 | "called with NULL pointer"); |
| 1892 | vkGetPhysicalDeviceSurfacePresentModesKHR(gpu(), surface, NULL, NULL); |
| 1893 | pass = (err == VK_SUCCESS); |
| 1894 | ASSERT_TRUE(pass); |
| 1895 | m_errorMonitor->VerifyFound(); |
| 1896 | |
| 1897 | // Next, call with a non-NULL VkPresentModeKHR, even though we haven't |
| 1898 | // correctly done a 1st try (to get the count): |
| 1899 | m_errorMonitor->SetDesiredFailureMsg( |
| 1900 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1901 | "but no prior positive value has been seen for"); |
| 1902 | surface_present_mode_count = 0; |
| 1903 | vkGetPhysicalDeviceSurfacePresentModesKHR( |
| 1904 | gpu(), |
| 1905 | surface, |
| 1906 | &surface_present_mode_count, |
| 1907 | (VkPresentModeKHR *) &surface_present_mode_count); |
| 1908 | pass = (err == VK_SUCCESS); |
| 1909 | ASSERT_TRUE(pass); |
| 1910 | m_errorMonitor->VerifyFound(); |
| 1911 | |
| 1912 | // Next, correctly do a 1st try (with a NULL pointer to surface_formats): |
| 1913 | vkGetPhysicalDeviceSurfacePresentModesKHR(gpu(), surface, |
| 1914 | &surface_present_mode_count, |
| 1915 | NULL); |
| 1916 | pass = (err == VK_SUCCESS); |
| 1917 | ASSERT_TRUE(pass); |
| 1918 | |
| 1919 | // Allocate memory for the correct number of VkSurfaceFormatKHR's: |
| 1920 | VkPresentModeKHR *surface_present_modes = |
| 1921 | (VkPresentModeKHR *)malloc(surface_present_mode_count * |
| 1922 | sizeof(VkPresentModeKHR)); |
| 1923 | |
| 1924 | // Next, do a 2nd try with surface_format_count being set too high: |
| 1925 | surface_present_mode_count += 5; |
| 1926 | m_errorMonitor->SetDesiredFailureMsg( |
| 1927 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1928 | "that is greater than the value"); |
| 1929 | vkGetPhysicalDeviceSurfacePresentModesKHR(gpu(), surface, |
| 1930 | &surface_present_mode_count, |
| 1931 | surface_present_modes); |
| 1932 | pass = (err == VK_SUCCESS); |
| 1933 | ASSERT_TRUE(pass); |
| 1934 | m_errorMonitor->VerifyFound(); |
| 1935 | |
| 1936 | // Finally, do a correct 1st and 2nd try: |
| 1937 | vkGetPhysicalDeviceSurfacePresentModesKHR(gpu(), surface, |
| 1938 | &surface_present_mode_count, |
| 1939 | NULL); |
| 1940 | pass = (err == VK_SUCCESS); |
| 1941 | ASSERT_TRUE(pass); |
| 1942 | vkGetPhysicalDeviceSurfacePresentModesKHR(gpu(), surface, |
| 1943 | &surface_present_mode_count, |
| 1944 | surface_present_modes); |
| 1945 | pass = (err == VK_SUCCESS); |
| 1946 | ASSERT_TRUE(pass); |
| 1947 | |
| 1948 | |
| 1949 | |
| 1950 | // Create a swapchain: |
| 1951 | |
| 1952 | // First, try without a pointer to swapchain_create_info: |
| 1953 | m_errorMonitor->SetDesiredFailureMsg( |
| 1954 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1955 | "called with NULL pointer"); |
| 1956 | err = vkCreateSwapchainKHR(m_device->device(), NULL, NULL, &swapchain); |
| 1957 | pass = (err != VK_SUCCESS); |
| 1958 | ASSERT_TRUE(pass); |
| 1959 | m_errorMonitor->VerifyFound(); |
| 1960 | |
| 1961 | // Next, call with a non-NULL swapchain_create_info, that has the wrong |
| 1962 | // sType: |
| 1963 | swapchain_create_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; |
| 1964 | m_errorMonitor->SetDesiredFailureMsg( |
| 1965 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1966 | "called with the wrong value for"); |
| 1967 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, |
| 1968 | NULL, &swapchain); |
| 1969 | pass = (err != VK_SUCCESS); |
| 1970 | ASSERT_TRUE(pass); |
| 1971 | m_errorMonitor->VerifyFound(); |
| 1972 | |
| 1973 | // Next, call with a NULL swapchain pointer: |
| 1974 | swapchain_create_info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR; |
| 1975 | swapchain_create_info.pNext = NULL; |
| 1976 | swapchain_create_info.flags = 0; |
| 1977 | m_errorMonitor->SetDesiredFailureMsg( |
| 1978 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1979 | "called with NULL pointer"); |
| 1980 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, |
| 1981 | NULL, NULL); |
| 1982 | pass = (err != VK_SUCCESS); |
| 1983 | ASSERT_TRUE(pass); |
| 1984 | m_errorMonitor->VerifyFound(); |
| 1985 | |
| 1986 | // TODO: Enhance swapchain layer so that |
| 1987 | // swapchain_create_info.queueFamilyIndexCount is checked against something? |
| 1988 | |
| 1989 | // Next, call with a queue family index that's too large: |
| 1990 | uint32_t queueFamilyIndex[2] = {100000, 0}; |
| 1991 | swapchain_create_info.imageSharingMode = VK_SHARING_MODE_CONCURRENT; |
| 1992 | swapchain_create_info.queueFamilyIndexCount = 2; |
| 1993 | swapchain_create_info.pQueueFamilyIndices = queueFamilyIndex; |
| 1994 | m_errorMonitor->SetDesiredFailureMsg( |
| 1995 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1996 | "called with a queueFamilyIndex that is too large"); |
| 1997 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, |
| 1998 | NULL, &swapchain); |
| 1999 | pass = (err != VK_SUCCESS); |
| 2000 | ASSERT_TRUE(pass); |
| 2001 | m_errorMonitor->VerifyFound(); |
| 2002 | |
| 2003 | // Next, call a queueFamilyIndexCount that's too small for CONCURRENT: |
| 2004 | swapchain_create_info.imageSharingMode = VK_SHARING_MODE_CONCURRENT; |
| 2005 | swapchain_create_info.queueFamilyIndexCount = 1; |
| 2006 | m_errorMonitor->SetDesiredFailureMsg( |
| 2007 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2008 | "but with a bad value(s) for pCreateInfo->queueFamilyIndexCount or " |
| 2009 | "pCreateInfo->pQueueFamilyIndices)."); |
| 2010 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, |
| 2011 | NULL, &swapchain); |
| 2012 | pass = (err != VK_SUCCESS); |
| 2013 | ASSERT_TRUE(pass); |
| 2014 | m_errorMonitor->VerifyFound(); |
| 2015 | |
| 2016 | // Next, call with an invalid imageSharingMode: |
| 2017 | swapchain_create_info.imageSharingMode = VK_SHARING_MODE_MAX_ENUM; |
| 2018 | swapchain_create_info.queueFamilyIndexCount = 1; |
| 2019 | m_errorMonitor->SetDesiredFailureMsg( |
| 2020 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2021 | "called with a non-supported pCreateInfo->imageSharingMode (i.e."); |
| 2022 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, |
| 2023 | NULL, &swapchain); |
| 2024 | pass = (err != VK_SUCCESS); |
| 2025 | ASSERT_TRUE(pass); |
| 2026 | m_errorMonitor->VerifyFound(); |
| 2027 | // Fix for the future: |
| 2028 | // FIXME: THIS ISN'T CORRECT--MUST QUERY UNTIL WE FIND A QUEUE FAMILY THAT'S SUPPORTED |
| 2029 | swapchain_create_info.queueFamilyIndexCount = 0; |
| 2030 | queueFamilyIndex[0] = 0; |
| 2031 | swapchain_create_info.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 2032 | |
| 2033 | // TODO: CONTINUE TESTING VALIDATION OF vkCreateSwapchainKHR() ... |
| 2034 | |
| 2035 | |
| 2036 | |
| 2037 | // Get the images from a swapchain: |
| 2038 | |
| 2039 | |
| 2040 | |
| 2041 | // Acquire an image from a swapchain: |
| 2042 | |
| 2043 | |
| 2044 | |
| 2045 | // Present an image to a swapchain: |
| 2046 | |
| 2047 | |
| 2048 | |
| 2049 | // Destroy the swapchain: |
| 2050 | |
| 2051 | |
| 2052 | |
| 2053 | // TODOs: |
| 2054 | // |
| 2055 | // - Try destroying the device without first destroying the swapchain |
| 2056 | // |
| 2057 | // - Try destroying the device without first destroying the surface |
| 2058 | // |
| 2059 | // - Try destroying the surface without first destroying the swapchain |
| 2060 | |
| 2061 | |
| 2062 | // Destroy the surface: |
| 2063 | vkDestroySurfaceKHR(instance(), surface, NULL); |
| 2064 | |
| 2065 | |
| 2066 | // Tear down the window: |
| 2067 | xcb_destroy_window(connection, xcb_window); |
| 2068 | xcb_disconnect(connection); |
| 2069 | |
| 2070 | #else // VK_USE_PLATFORM_XCB_KHR |
| 2071 | err = (surface == VK_NULL_HANDLE) ? VK_SUCCESS : VK_SUCCESS; |
| 2072 | pass = (err != VK_SUCCESS); |
| 2073 | ASSERT_TRUE(pass); |
| 2074 | #endif // VK_USE_PLATFORM_XCB_KHR |
| 2075 | } |
| 2076 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2077 | TEST_F(VkLayerTest, MapMemWithoutHostVisibleBit) { |
| 2078 | VkResult err; |
| 2079 | bool pass; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2080 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2081 | m_errorMonitor->SetDesiredFailureMsg( |
| 2082 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2083 | "Mapping Memory without VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT"); |
| 2084 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2085 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2086 | |
| 2087 | // 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] | 2088 | VkImage image; |
| 2089 | VkDeviceMemory mem; |
| 2090 | VkMemoryRequirements mem_reqs; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2091 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2092 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2093 | const int32_t tex_width = 32; |
| 2094 | const int32_t tex_height = 32; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2095 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2096 | VkImageCreateInfo image_create_info = {}; |
| 2097 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2098 | image_create_info.pNext = NULL; |
| 2099 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2100 | image_create_info.format = tex_format; |
| 2101 | image_create_info.extent.width = tex_width; |
| 2102 | image_create_info.extent.height = tex_height; |
| 2103 | image_create_info.extent.depth = 1; |
| 2104 | image_create_info.mipLevels = 1; |
| 2105 | image_create_info.arrayLayers = 1; |
| 2106 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 2107 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 2108 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 2109 | image_create_info.flags = 0; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2110 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2111 | VkMemoryAllocateInfo mem_alloc = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2112 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2113 | mem_alloc.pNext = NULL; |
| 2114 | mem_alloc.allocationSize = 0; |
| 2115 | // Introduce failure, do NOT set memProps to |
| 2116 | // VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
| 2117 | mem_alloc.memoryTypeIndex = 1; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2118 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2119 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2120 | ASSERT_VK_SUCCESS(err); |
| 2121 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2122 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2123 | |
Mark Lobodzinski | 2306535 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 2124 | mem_alloc.allocationSize = mem_reqs.size; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2125 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2126 | pass = |
| 2127 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0, |
| 2128 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 2129 | if (!pass) { // If we can't find any unmappable memory this test doesn't |
| 2130 | // make sense |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2131 | vkDestroyImage(m_device->device(), image, NULL); |
Tony Barbour | 02fdc7d | 2015-08-04 16:13:01 -0600 | [diff] [blame] | 2132 | return; |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2133 | } |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 2134 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2135 | // allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2136 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2137 | ASSERT_VK_SUCCESS(err); |
| 2138 | |
| 2139 | // Try to bind free memory that has been freed |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 2140 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2141 | ASSERT_VK_SUCCESS(err); |
| 2142 | |
| 2143 | // Map memory as if to initialize the image |
| 2144 | void *mappedAddress = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2145 | err = vkMapMemory(m_device->device(), mem, 0, VK_WHOLE_SIZE, 0, |
| 2146 | &mappedAddress); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2147 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2148 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2149 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2150 | vkDestroyImage(m_device->device(), image, NULL); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2151 | } |
| 2152 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2153 | TEST_F(VkLayerTest, RebindMemory) { |
| 2154 | VkResult err; |
| 2155 | bool pass; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2156 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2157 | m_errorMonitor->SetDesiredFailureMsg( |
| 2158 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2159 | "which has already been bound to mem object"); |
| 2160 | |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2161 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2162 | |
| 2163 | // 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] | 2164 | VkImage image; |
| 2165 | VkDeviceMemory mem1; |
| 2166 | VkDeviceMemory mem2; |
| 2167 | VkMemoryRequirements mem_reqs; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2168 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2169 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2170 | const int32_t tex_width = 32; |
| 2171 | const int32_t tex_height = 32; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2172 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2173 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2174 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 2175 | image_create_info.pNext = NULL; |
| 2176 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2177 | image_create_info.format = tex_format; |
| 2178 | image_create_info.extent.width = tex_width; |
| 2179 | image_create_info.extent.height = tex_height; |
| 2180 | image_create_info.extent.depth = 1; |
| 2181 | image_create_info.mipLevels = 1; |
| 2182 | image_create_info.arrayLayers = 1; |
| 2183 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 2184 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 2185 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 2186 | image_create_info.flags = 0; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2187 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2188 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2189 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 2190 | mem_alloc.pNext = NULL; |
| 2191 | mem_alloc.allocationSize = 0; |
| 2192 | mem_alloc.memoryTypeIndex = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2193 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2194 | // Introduce failure, do NOT set memProps to |
| 2195 | // VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2196 | mem_alloc.memoryTypeIndex = 1; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2197 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2198 | ASSERT_VK_SUCCESS(err); |
| 2199 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2200 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2201 | |
| 2202 | mem_alloc.allocationSize = mem_reqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2203 | pass = |
| 2204 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 2205 | ASSERT_TRUE(pass); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2206 | |
| 2207 | // allocate 2 memory objects |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2208 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem1); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2209 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2210 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem2); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2211 | ASSERT_VK_SUCCESS(err); |
| 2212 | |
| 2213 | // Bind first memory object to Image object |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 2214 | err = vkBindImageMemory(m_device->device(), image, mem1, 0); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2215 | ASSERT_VK_SUCCESS(err); |
| 2216 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2217 | // Introduce validation failure, try to bind a different memory object to |
| 2218 | // the same image object |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 2219 | err = vkBindImageMemory(m_device->device(), image, mem2, 0); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2220 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2221 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2222 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2223 | vkDestroyImage(m_device->device(), image, NULL); |
| 2224 | vkFreeMemory(m_device->device(), mem1, NULL); |
| 2225 | vkFreeMemory(m_device->device(), mem2, NULL); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 2226 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 2227 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2228 | TEST_F(VkLayerTest, SubmitSignaledFence) { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2229 | vk_testing::Fence testFence; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2230 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2231 | m_errorMonitor->SetDesiredFailureMsg( |
| 2232 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "submitted in SIGNALED state. Fences " |
| 2233 | "must be reset before being submitted"); |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2234 | |
| 2235 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2236 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2237 | fenceInfo.pNext = NULL; |
| 2238 | fenceInfo.flags = VK_FENCE_CREATE_SIGNALED_BIT; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2239 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2240 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2241 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 2242 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2243 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 2244 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2245 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 2246 | m_stencil_clear_color, NULL); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 2247 | EndCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2248 | |
| 2249 | testFence.init(*m_device, fenceInfo); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2250 | |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2251 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 2252 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2253 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2254 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2255 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 2256 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2257 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2258 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2259 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2260 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 2261 | |
| 2262 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2263 | vkQueueWaitIdle(m_device->m_queue); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 2264 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2265 | m_errorMonitor->VerifyFound(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2266 | } |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 2267 | // This is a positive test. We used to expect error in this case but spec now |
| 2268 | // allows it |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2269 | TEST_F(VkLayerTest, ResetUnsignaledFence) { |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 2270 | m_errorMonitor->ExpectSuccess(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2271 | vk_testing::Fence testFence; |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 2272 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2273 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2274 | fenceInfo.pNext = NULL; |
| 2275 | |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 2276 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2277 | testFence.init(*m_device, fenceInfo); |
Chia-I Wu | d9e8e82 | 2015-07-03 11:45:55 +0800 | [diff] [blame] | 2278 | VkFence fences[1] = {testFence.handle()}; |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 2279 | VkResult result = vkResetFences(m_device->device(), 1, fences); |
| 2280 | ASSERT_VK_SUCCESS(result); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2281 | |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 2282 | m_errorMonitor->VerifyNotFound(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 2283 | } |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2284 | |
| 2285 | TEST_F(VkLayerTest, InvalidUsageBits) |
| 2286 | { |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2287 | TEST_DESCRIPTION( |
Karl Schultz | b5bc11e | 2016-05-04 08:36:08 -0600 | [diff] [blame] | 2288 | "Specify wrong usage for image then create conflicting view of image " |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2289 | "Initialize buffer with wrong usage then perform copy expecting errors " |
| 2290 | "from both the image and the buffer (2 calls)"); |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2291 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2292 | "Invalid usage flag for image "); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2293 | |
| 2294 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2295 | VkImageObj image(m_device); |
| 2296 | // Initialize image with USAGE_INPUT_ATTACHMENT |
| 2297 | image.init(128, 128, VK_FORMAT_D32_SFLOAT_S8_UINT, |
Karl Schultz | b5bc11e | 2016-05-04 08:36:08 -0600 | [diff] [blame] | 2298 | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
| 2299 | ASSERT_TRUE(image.initialized()); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2300 | |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2301 | VkImageView dsv; |
| 2302 | VkImageViewCreateInfo dsvci = {}; |
| 2303 | dsvci.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 2304 | dsvci.image = image.handle(); |
| 2305 | dsvci.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 2306 | dsvci.format = VK_FORMAT_D32_SFLOAT_S8_UINT; |
| 2307 | dsvci.subresourceRange.layerCount = 1; |
| 2308 | dsvci.subresourceRange.baseMipLevel = 0; |
| 2309 | dsvci.subresourceRange.levelCount = 1; |
| 2310 | dsvci.subresourceRange.aspectMask = |
| 2311 | VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2312 | |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2313 | // Create a view with depth / stencil aspect for image with different usage |
| 2314 | vkCreateImageView(m_device->device(), &dsvci, NULL, &dsv); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2315 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2316 | m_errorMonitor->VerifyFound(); |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 2317 | |
| 2318 | // Initialize buffer with TRANSFER_DST usage |
| 2319 | vk_testing::Buffer buffer; |
| 2320 | VkMemoryPropertyFlags reqs = 0; |
| 2321 | buffer.init_as_dst(*m_device, 128 * 128, reqs); |
| 2322 | VkBufferImageCopy region = {}; |
| 2323 | region.bufferRowLength = 128; |
| 2324 | region.bufferImageHeight = 128; |
| 2325 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 2326 | region.imageSubresource.layerCount = 1; |
| 2327 | region.imageExtent.height = 16; |
| 2328 | region.imageExtent.width = 16; |
| 2329 | region.imageExtent.depth = 1; |
| 2330 | |
| 2331 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2332 | "Invalid usage flag for buffer "); |
| 2333 | // Buffer usage not set to TRANSFER_SRC and image usage not set to |
| 2334 | // TRANSFER_DST |
| 2335 | BeginCommandBuffer(); |
| 2336 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 2337 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 2338 | 1, ®ion); |
| 2339 | m_errorMonitor->VerifyFound(); |
| 2340 | |
| 2341 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2342 | "Invalid usage flag for image "); |
| 2343 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 2344 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 2345 | 1, ®ion); |
| 2346 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 2347 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 2348 | #endif // MEM_TRACKER_TESTS |
| 2349 | |
Tobin Ehlis | 4bf96d1 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 2350 | #if OBJ_TRACKER_TESTS |
Mark Lobodzinski | fc5cc66 | 2016-05-02 17:17:41 -0600 | [diff] [blame] | 2351 | |
| 2352 | TEST_F(VkLayerTest, LeakAnObject) { |
| 2353 | VkResult err; |
| 2354 | |
| 2355 | TEST_DESCRIPTION( |
| 2356 | "Create a fence and destroy its device without first destroying the fence."); |
| 2357 | |
| 2358 | // Note that we have to create a new device since destroying the |
| 2359 | // framework's device causes Teardown() to fail and just calling Teardown |
| 2360 | // will destroy the errorMonitor. |
| 2361 | |
| 2362 | m_errorMonitor->SetDesiredFailureMsg( |
| 2363 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2364 | "OBJ ERROR : VK_DEBUG_REPORT_OBJECT_TYPE_FENCE_EXT object"); |
| 2365 | |
| 2366 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2367 | |
| 2368 | const std::vector<VkQueueFamilyProperties> queue_props = |
| 2369 | m_device->queue_props; |
| 2370 | std::vector<VkDeviceQueueCreateInfo> queue_info; |
| 2371 | queue_info.reserve(queue_props.size()); |
| 2372 | std::vector<std::vector<float>> queue_priorities; |
| 2373 | for (uint32_t i = 0; i < (uint32_t)queue_props.size(); i++) { |
| 2374 | VkDeviceQueueCreateInfo qi = {}; |
| 2375 | qi.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO; |
| 2376 | qi.pNext = NULL; |
| 2377 | qi.queueFamilyIndex = i; |
| 2378 | qi.queueCount = queue_props[i].queueCount; |
| 2379 | queue_priorities.emplace_back(qi.queueCount, 0.0f); |
| 2380 | qi.pQueuePriorities = queue_priorities[i].data(); |
| 2381 | queue_info.push_back(qi); |
| 2382 | } |
| 2383 | |
| 2384 | std::vector<const char *> device_layer_names; |
| 2385 | std::vector<const char *> device_extension_names; |
| 2386 | device_layer_names.push_back("VK_LAYER_GOOGLE_threading"); |
| 2387 | device_layer_names.push_back("VK_LAYER_LUNARG_parameter_validation"); |
| 2388 | device_layer_names.push_back("VK_LAYER_LUNARG_object_tracker"); |
| 2389 | device_layer_names.push_back("VK_LAYER_LUNARG_core_validation"); |
| 2390 | device_layer_names.push_back("VK_LAYER_LUNARG_device_limits"); |
| 2391 | device_layer_names.push_back("VK_LAYER_LUNARG_image"); |
| 2392 | device_layer_names.push_back("VK_LAYER_GOOGLE_unique_objects"); |
| 2393 | |
| 2394 | // The sacrificial device object |
| 2395 | VkDevice testDevice; |
| 2396 | VkDeviceCreateInfo device_create_info = {}; |
| 2397 | auto features = m_device->phy().features(); |
| 2398 | device_create_info.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO; |
| 2399 | device_create_info.pNext = NULL; |
| 2400 | device_create_info.queueCreateInfoCount = queue_info.size(); |
| 2401 | device_create_info.pQueueCreateInfos = queue_info.data(); |
| 2402 | device_create_info.enabledLayerCount = device_layer_names.size(); |
| 2403 | device_create_info.ppEnabledLayerNames = device_layer_names.data(); |
| 2404 | device_create_info.pEnabledFeatures = &features; |
| 2405 | err = vkCreateDevice(gpu(), &device_create_info, NULL, &testDevice); |
| 2406 | ASSERT_VK_SUCCESS(err); |
| 2407 | |
| 2408 | VkFence fence; |
| 2409 | VkFenceCreateInfo fence_create_info = {}; |
| 2410 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2411 | fence_create_info.pNext = NULL; |
| 2412 | fence_create_info.flags = 0; |
| 2413 | err = vkCreateFence(testDevice, &fence_create_info, NULL, &fence); |
| 2414 | ASSERT_VK_SUCCESS(err); |
| 2415 | |
| 2416 | // Induce failure by not calling vkDestroyFence |
| 2417 | vkDestroyDevice(testDevice, NULL); |
| 2418 | m_errorMonitor->VerifyFound(); |
| 2419 | } |
| 2420 | |
| 2421 | TEST_F(VkLayerTest, InvalidCommandPoolConsistency) { |
| 2422 | |
| 2423 | TEST_DESCRIPTION("Allocate command buffers from one command pool and " |
| 2424 | "attempt to delete them from another."); |
| 2425 | |
| 2426 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2427 | "FreeCommandBuffers is attempting to free Command Buffer"); |
| 2428 | |
| 2429 | VkCommandPool command_pool_one; |
| 2430 | VkCommandPool command_pool_two; |
| 2431 | |
| 2432 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2433 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2434 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2435 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2436 | |
| 2437 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2438 | &command_pool_one); |
| 2439 | |
| 2440 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2441 | &command_pool_two); |
| 2442 | |
| 2443 | VkCommandBuffer command_buffer[9]; |
| 2444 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2445 | command_buffer_allocate_info.sType = |
| 2446 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2447 | command_buffer_allocate_info.commandPool = command_pool_one; |
| 2448 | command_buffer_allocate_info.commandBufferCount = 9; |
| 2449 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2450 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2451 | command_buffer); |
| 2452 | |
| 2453 | vkFreeCommandBuffers(m_device->device(), command_pool_two, 4, |
| 2454 | &command_buffer[3]); |
| 2455 | |
| 2456 | m_errorMonitor->VerifyFound(); |
| 2457 | |
| 2458 | vkDestroyCommandPool(m_device->device(), command_pool_one, NULL); |
| 2459 | vkDestroyCommandPool(m_device->device(), command_pool_two, NULL); |
| 2460 | } |
| 2461 | |
| 2462 | TEST_F(VkLayerTest, InvalidDescriptorPoolConsistency) { |
| 2463 | VkResult err; |
| 2464 | |
| 2465 | TEST_DESCRIPTION("Allocate descriptor sets from one DS pool and " |
| 2466 | "attempt to delete them from another."); |
| 2467 | |
| 2468 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2469 | "FreeDescriptorSets is attempting to free descriptorSet"); |
| 2470 | |
| 2471 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2472 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2473 | |
| 2474 | VkDescriptorPoolSize ds_type_count = {}; |
| 2475 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 2476 | ds_type_count.descriptorCount = 1; |
| 2477 | |
| 2478 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2479 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2480 | ds_pool_ci.pNext = NULL; |
| 2481 | ds_pool_ci.flags = 0; |
| 2482 | ds_pool_ci.maxSets = 1; |
| 2483 | ds_pool_ci.poolSizeCount = 1; |
| 2484 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 2485 | |
| 2486 | VkDescriptorPool ds_pool_one; |
| 2487 | err = |
| 2488 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool_one); |
| 2489 | ASSERT_VK_SUCCESS(err); |
| 2490 | |
| 2491 | // Create a second descriptor pool |
| 2492 | VkDescriptorPool ds_pool_two; |
| 2493 | err = |
| 2494 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool_two); |
| 2495 | ASSERT_VK_SUCCESS(err); |
| 2496 | |
| 2497 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 2498 | dsl_binding.binding = 0; |
| 2499 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 2500 | dsl_binding.descriptorCount = 1; |
| 2501 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2502 | dsl_binding.pImmutableSamplers = NULL; |
| 2503 | |
| 2504 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2505 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2506 | ds_layout_ci.pNext = NULL; |
| 2507 | ds_layout_ci.bindingCount = 1; |
| 2508 | ds_layout_ci.pBindings = &dsl_binding; |
| 2509 | |
| 2510 | VkDescriptorSetLayout ds_layout; |
| 2511 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2512 | &ds_layout); |
| 2513 | ASSERT_VK_SUCCESS(err); |
| 2514 | |
| 2515 | VkDescriptorSet descriptorSet; |
| 2516 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 2517 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 2518 | alloc_info.descriptorSetCount = 1; |
| 2519 | alloc_info.descriptorPool = ds_pool_one; |
| 2520 | alloc_info.pSetLayouts = &ds_layout; |
| 2521 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 2522 | &descriptorSet); |
| 2523 | ASSERT_VK_SUCCESS(err); |
| 2524 | |
| 2525 | err = vkFreeDescriptorSets(m_device->device(), ds_pool_two, 1, &descriptorSet); |
| 2526 | |
| 2527 | m_errorMonitor->VerifyFound(); |
| 2528 | |
| 2529 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2530 | vkDestroyDescriptorPool(m_device->device(), ds_pool_one, NULL); |
| 2531 | vkDestroyDescriptorPool(m_device->device(), ds_pool_two, NULL); |
| 2532 | } |
| 2533 | |
| 2534 | TEST_F(VkLayerTest, CreateUnknownObject) { |
| 2535 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2536 | "Invalid VkImage Object "); |
| 2537 | |
| 2538 | TEST_DESCRIPTION( |
| 2539 | "Pass an invalid image object handle into a Vulkan API call."); |
| 2540 | |
| 2541 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2542 | |
| 2543 | // Pass bogus handle into GetImageMemoryRequirements |
| 2544 | VkMemoryRequirements mem_reqs; |
| 2545 | uint64_t fakeImageHandle = 0xCADECADE; |
| 2546 | VkImage fauxImage = reinterpret_cast<VkImage &>(fakeImageHandle); |
| 2547 | |
| 2548 | vkGetImageMemoryRequirements(m_device->device(), fauxImage, &mem_reqs); |
| 2549 | |
| 2550 | m_errorMonitor->VerifyFound(); |
| 2551 | } |
| 2552 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2553 | TEST_F(VkLayerTest, PipelineNotBound) { |
| 2554 | VkResult err; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2555 | |
Mark Lobodzinski | fc5cc66 | 2016-05-02 17:17:41 -0600 | [diff] [blame] | 2556 | TEST_DESCRIPTION( |
| 2557 | "Pass in an invalid pipeline object handle into a Vulkan API call."); |
| 2558 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2559 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2560 | "Invalid VkPipeline Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2561 | |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2562 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2563 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2564 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2565 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2566 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2567 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2568 | |
| 2569 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2570 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2571 | ds_pool_ci.pNext = NULL; |
| 2572 | ds_pool_ci.maxSets = 1; |
| 2573 | ds_pool_ci.poolSizeCount = 1; |
| 2574 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2575 | |
| 2576 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2577 | err = |
| 2578 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2579 | ASSERT_VK_SUCCESS(err); |
| 2580 | |
| 2581 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2582 | dsl_binding.binding = 0; |
| 2583 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2584 | dsl_binding.descriptorCount = 1; |
| 2585 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2586 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2587 | |
| 2588 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2589 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2590 | ds_layout_ci.pNext = NULL; |
| 2591 | ds_layout_ci.bindingCount = 1; |
| 2592 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2593 | |
| 2594 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2595 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 2596 | &ds_layout); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2597 | ASSERT_VK_SUCCESS(err); |
| 2598 | |
| 2599 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2600 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2601 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 2602 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2603 | alloc_info.descriptorPool = ds_pool; |
| 2604 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2605 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 2606 | &descriptorSet); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2607 | ASSERT_VK_SUCCESS(err); |
| 2608 | |
| 2609 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2610 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 2611 | pipeline_layout_ci.pNext = NULL; |
| 2612 | pipeline_layout_ci.setLayoutCount = 1; |
| 2613 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2614 | |
| 2615 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2616 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 2617 | &pipeline_layout); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2618 | ASSERT_VK_SUCCESS(err); |
| 2619 | |
Mark Young | ad77905 | 2016-01-06 14:26:04 -0700 | [diff] [blame] | 2620 | VkPipeline badPipeline = (VkPipeline)((size_t)0xbaadb1be); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2621 | |
| 2622 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2623 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 2624 | VK_PIPELINE_BIND_POINT_GRAPHICS, badPipeline); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2625 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2626 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2627 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2628 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2629 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2630 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2631 | } |
| 2632 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2633 | TEST_F(VkLayerTest, BindInvalidMemory) { |
| 2634 | VkResult err; |
| 2635 | bool pass; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2636 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2637 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2638 | "Invalid VkDeviceMemory Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2639 | |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2640 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2641 | |
| 2642 | // 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] | 2643 | VkImage image; |
| 2644 | VkDeviceMemory mem; |
| 2645 | VkMemoryRequirements mem_reqs; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2646 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2647 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2648 | const int32_t tex_width = 32; |
| 2649 | const int32_t tex_height = 32; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2650 | |
| 2651 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2652 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 2653 | image_create_info.pNext = NULL; |
| 2654 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2655 | image_create_info.format = tex_format; |
| 2656 | image_create_info.extent.width = tex_width; |
| 2657 | image_create_info.extent.height = tex_height; |
| 2658 | image_create_info.extent.depth = 1; |
| 2659 | image_create_info.mipLevels = 1; |
| 2660 | image_create_info.arrayLayers = 1; |
| 2661 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 2662 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 2663 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 2664 | image_create_info.flags = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2665 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2666 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2667 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 2668 | mem_alloc.pNext = NULL; |
| 2669 | mem_alloc.allocationSize = 0; |
| 2670 | mem_alloc.memoryTypeIndex = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2671 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2672 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2673 | ASSERT_VK_SUCCESS(err); |
| 2674 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2675 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2676 | |
| 2677 | mem_alloc.allocationSize = mem_reqs.size; |
| 2678 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2679 | pass = |
| 2680 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 2681 | ASSERT_TRUE(pass); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2682 | |
| 2683 | // allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2684 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2685 | ASSERT_VK_SUCCESS(err); |
| 2686 | |
| 2687 | // Introduce validation failure, free memory before binding |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2688 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2689 | |
| 2690 | // Try to bind free memory that has been freed |
| 2691 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 2692 | // This may very well return an error. |
| 2693 | (void)err; |
| 2694 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2695 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2696 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2697 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2698 | } |
| 2699 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2700 | TEST_F(VkLayerTest, BindMemoryToDestroyedObject) { |
| 2701 | VkResult err; |
| 2702 | bool pass; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2703 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2704 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2705 | "Invalid VkImage Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2706 | |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2707 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2708 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2709 | // Create an image object, allocate memory, destroy the object and then try |
| 2710 | // to bind it |
| 2711 | VkImage image; |
| 2712 | VkDeviceMemory mem; |
| 2713 | VkMemoryRequirements mem_reqs; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2714 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2715 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2716 | const int32_t tex_width = 32; |
| 2717 | const int32_t tex_height = 32; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2718 | |
| 2719 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2720 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 2721 | image_create_info.pNext = NULL; |
| 2722 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2723 | image_create_info.format = tex_format; |
| 2724 | image_create_info.extent.width = tex_width; |
| 2725 | image_create_info.extent.height = tex_height; |
| 2726 | image_create_info.extent.depth = 1; |
| 2727 | image_create_info.mipLevels = 1; |
| 2728 | image_create_info.arrayLayers = 1; |
| 2729 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 2730 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 2731 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 2732 | image_create_info.flags = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2733 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2734 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2735 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 2736 | mem_alloc.pNext = NULL; |
| 2737 | mem_alloc.allocationSize = 0; |
| 2738 | mem_alloc.memoryTypeIndex = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2739 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2740 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2741 | ASSERT_VK_SUCCESS(err); |
| 2742 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2743 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2744 | |
| 2745 | mem_alloc.allocationSize = mem_reqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2746 | pass = |
| 2747 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 2748 | ASSERT_TRUE(pass); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2749 | |
| 2750 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2751 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2752 | ASSERT_VK_SUCCESS(err); |
| 2753 | |
| 2754 | // Introduce validation failure, destroy Image object before binding |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2755 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2756 | ASSERT_VK_SUCCESS(err); |
| 2757 | |
| 2758 | // Now Try to bind memory to this destroyed object |
| 2759 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 2760 | // This may very well return an error. |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2761 | (void)err; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 2762 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2763 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2764 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2765 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2766 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 2767 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 2768 | #endif // OBJ_TRACKER_TESTS |
| 2769 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 2770 | #if DRAW_STATE_TESTS |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 2771 | |
| 2772 | // This is a positive test. No errors should be generated. |
| 2773 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceQWI) { |
| 2774 | |
| 2775 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 2776 | "submitted on separate queues followed by a QueueWaitIdle."); |
| 2777 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 2778 | if ((m_device->queue_props.empty()) || |
| 2779 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 2780 | return; |
| 2781 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 2782 | m_errorMonitor->ExpectSuccess(); |
| 2783 | |
| 2784 | VkSemaphore semaphore; |
| 2785 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 2786 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 2787 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 2788 | &semaphore); |
| 2789 | |
| 2790 | VkCommandPool command_pool; |
| 2791 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2792 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2793 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2794 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2795 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2796 | &command_pool); |
| 2797 | |
| 2798 | VkCommandBuffer command_buffer[2]; |
| 2799 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2800 | command_buffer_allocate_info.sType = |
| 2801 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2802 | command_buffer_allocate_info.commandPool = command_pool; |
| 2803 | command_buffer_allocate_info.commandBufferCount = 2; |
| 2804 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2805 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2806 | command_buffer); |
| 2807 | |
| 2808 | VkQueue queue = VK_NULL_HANDLE; |
| 2809 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 2810 | 1, &queue); |
| 2811 | |
| 2812 | { |
| 2813 | VkCommandBufferBeginInfo begin_info{}; |
| 2814 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2815 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2816 | |
| 2817 | vkCmdPipelineBarrier(command_buffer[0], |
| 2818 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2819 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 2820 | 0, nullptr, 0, nullptr); |
| 2821 | |
| 2822 | VkViewport viewport{}; |
| 2823 | viewport.maxDepth = 1.0f; |
| 2824 | viewport.minDepth = 0.0f; |
| 2825 | viewport.width = 512; |
| 2826 | viewport.height = 512; |
| 2827 | viewport.x = 0; |
| 2828 | viewport.y = 0; |
| 2829 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 2830 | vkEndCommandBuffer(command_buffer[0]); |
| 2831 | } |
| 2832 | { |
| 2833 | VkCommandBufferBeginInfo begin_info{}; |
| 2834 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2835 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 2836 | |
| 2837 | VkViewport viewport{}; |
| 2838 | viewport.maxDepth = 1.0f; |
| 2839 | viewport.minDepth = 0.0f; |
| 2840 | viewport.width = 512; |
| 2841 | viewport.height = 512; |
| 2842 | viewport.x = 0; |
| 2843 | viewport.y = 0; |
| 2844 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 2845 | vkEndCommandBuffer(command_buffer[1]); |
| 2846 | } |
| 2847 | { |
| 2848 | VkSubmitInfo submit_info{}; |
| 2849 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2850 | submit_info.commandBufferCount = 1; |
| 2851 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 2852 | submit_info.signalSemaphoreCount = 1; |
| 2853 | submit_info.pSignalSemaphores = &semaphore; |
| 2854 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2855 | } |
| 2856 | { |
| 2857 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 2858 | VkSubmitInfo submit_info{}; |
| 2859 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2860 | submit_info.commandBufferCount = 1; |
| 2861 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 2862 | submit_info.waitSemaphoreCount = 1; |
| 2863 | submit_info.pWaitSemaphores = &semaphore; |
| 2864 | submit_info.pWaitDstStageMask = flags; |
| 2865 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2866 | } |
| 2867 | |
| 2868 | vkQueueWaitIdle(m_device->m_queue); |
| 2869 | |
| 2870 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 2871 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 2872 | &command_buffer[0]); |
| 2873 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2874 | |
| 2875 | m_errorMonitor->VerifyNotFound(); |
| 2876 | } |
| 2877 | |
| 2878 | // This is a positive test. No errors should be generated. |
| 2879 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceQWIFence) { |
| 2880 | |
| 2881 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 2882 | "submitted on separate queues, the second having a fence" |
| 2883 | "followed by a QueueWaitIdle."); |
| 2884 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 2885 | if ((m_device->queue_props.empty()) || |
| 2886 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 2887 | return; |
| 2888 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 2889 | m_errorMonitor->ExpectSuccess(); |
| 2890 | |
| 2891 | VkFence fence; |
| 2892 | VkFenceCreateInfo fence_create_info{}; |
| 2893 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2894 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 2895 | |
| 2896 | VkSemaphore semaphore; |
| 2897 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 2898 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 2899 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 2900 | &semaphore); |
| 2901 | |
| 2902 | VkCommandPool command_pool; |
| 2903 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2904 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2905 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2906 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2907 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2908 | &command_pool); |
| 2909 | |
| 2910 | VkCommandBuffer command_buffer[2]; |
| 2911 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2912 | command_buffer_allocate_info.sType = |
| 2913 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2914 | command_buffer_allocate_info.commandPool = command_pool; |
| 2915 | command_buffer_allocate_info.commandBufferCount = 2; |
| 2916 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2917 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2918 | command_buffer); |
| 2919 | |
| 2920 | VkQueue queue = VK_NULL_HANDLE; |
| 2921 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 2922 | 1, &queue); |
| 2923 | |
| 2924 | { |
| 2925 | VkCommandBufferBeginInfo begin_info{}; |
| 2926 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2927 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2928 | |
| 2929 | vkCmdPipelineBarrier(command_buffer[0], |
| 2930 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2931 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 2932 | 0, nullptr, 0, nullptr); |
| 2933 | |
| 2934 | VkViewport viewport{}; |
| 2935 | viewport.maxDepth = 1.0f; |
| 2936 | viewport.minDepth = 0.0f; |
| 2937 | viewport.width = 512; |
| 2938 | viewport.height = 512; |
| 2939 | viewport.x = 0; |
| 2940 | viewport.y = 0; |
| 2941 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 2942 | vkEndCommandBuffer(command_buffer[0]); |
| 2943 | } |
| 2944 | { |
| 2945 | VkCommandBufferBeginInfo begin_info{}; |
| 2946 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2947 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 2948 | |
| 2949 | VkViewport viewport{}; |
| 2950 | viewport.maxDepth = 1.0f; |
| 2951 | viewport.minDepth = 0.0f; |
| 2952 | viewport.width = 512; |
| 2953 | viewport.height = 512; |
| 2954 | viewport.x = 0; |
| 2955 | viewport.y = 0; |
| 2956 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 2957 | vkEndCommandBuffer(command_buffer[1]); |
| 2958 | } |
| 2959 | { |
| 2960 | VkSubmitInfo submit_info{}; |
| 2961 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2962 | submit_info.commandBufferCount = 1; |
| 2963 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 2964 | submit_info.signalSemaphoreCount = 1; |
| 2965 | submit_info.pSignalSemaphores = &semaphore; |
| 2966 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2967 | } |
| 2968 | { |
| 2969 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 2970 | VkSubmitInfo submit_info{}; |
| 2971 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2972 | submit_info.commandBufferCount = 1; |
| 2973 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 2974 | submit_info.waitSemaphoreCount = 1; |
| 2975 | submit_info.pWaitSemaphores = &semaphore; |
| 2976 | submit_info.pWaitDstStageMask = flags; |
| 2977 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 2978 | } |
| 2979 | |
| 2980 | vkQueueWaitIdle(m_device->m_queue); |
| 2981 | |
| 2982 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 2983 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 2984 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 2985 | &command_buffer[0]); |
| 2986 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2987 | |
| 2988 | m_errorMonitor->VerifyNotFound(); |
| 2989 | } |
| 2990 | |
| 2991 | // This is a positive test. No errors should be generated. |
| 2992 | TEST_F(VkLayerTest, |
| 2993 | TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceTwoWFF) { |
| 2994 | |
| 2995 | TEST_DESCRIPTION( |
| 2996 | "Two command buffers, each in a separate QueueSubmit call " |
| 2997 | "submitted on separate queues, the second having a fence" |
| 2998 | "followed by two consecutive WaitForFences calls on the same fence."); |
| 2999 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 3000 | if ((m_device->queue_props.empty()) || |
| 3001 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 3002 | return; |
| 3003 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3004 | m_errorMonitor->ExpectSuccess(); |
| 3005 | |
| 3006 | VkFence fence; |
| 3007 | VkFenceCreateInfo fence_create_info{}; |
| 3008 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3009 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3010 | |
| 3011 | VkSemaphore semaphore; |
| 3012 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 3013 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 3014 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 3015 | &semaphore); |
| 3016 | |
| 3017 | VkCommandPool command_pool; |
| 3018 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3019 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3020 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3021 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3022 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3023 | &command_pool); |
| 3024 | |
| 3025 | VkCommandBuffer command_buffer[2]; |
| 3026 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3027 | command_buffer_allocate_info.sType = |
| 3028 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3029 | command_buffer_allocate_info.commandPool = command_pool; |
| 3030 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3031 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3032 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3033 | command_buffer); |
| 3034 | |
| 3035 | VkQueue queue = VK_NULL_HANDLE; |
| 3036 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 3037 | 1, &queue); |
| 3038 | |
| 3039 | { |
| 3040 | VkCommandBufferBeginInfo begin_info{}; |
| 3041 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3042 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3043 | |
| 3044 | vkCmdPipelineBarrier(command_buffer[0], |
| 3045 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3046 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3047 | 0, nullptr, 0, nullptr); |
| 3048 | |
| 3049 | VkViewport viewport{}; |
| 3050 | viewport.maxDepth = 1.0f; |
| 3051 | viewport.minDepth = 0.0f; |
| 3052 | viewport.width = 512; |
| 3053 | viewport.height = 512; |
| 3054 | viewport.x = 0; |
| 3055 | viewport.y = 0; |
| 3056 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3057 | vkEndCommandBuffer(command_buffer[0]); |
| 3058 | } |
| 3059 | { |
| 3060 | VkCommandBufferBeginInfo begin_info{}; |
| 3061 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3062 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3063 | |
| 3064 | VkViewport viewport{}; |
| 3065 | viewport.maxDepth = 1.0f; |
| 3066 | viewport.minDepth = 0.0f; |
| 3067 | viewport.width = 512; |
| 3068 | viewport.height = 512; |
| 3069 | viewport.x = 0; |
| 3070 | viewport.y = 0; |
| 3071 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3072 | vkEndCommandBuffer(command_buffer[1]); |
| 3073 | } |
| 3074 | { |
| 3075 | VkSubmitInfo submit_info{}; |
| 3076 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3077 | submit_info.commandBufferCount = 1; |
| 3078 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3079 | submit_info.signalSemaphoreCount = 1; |
| 3080 | submit_info.pSignalSemaphores = &semaphore; |
| 3081 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3082 | } |
| 3083 | { |
| 3084 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3085 | VkSubmitInfo submit_info{}; |
| 3086 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3087 | submit_info.commandBufferCount = 1; |
| 3088 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3089 | submit_info.waitSemaphoreCount = 1; |
| 3090 | submit_info.pWaitSemaphores = &semaphore; |
| 3091 | submit_info.pWaitDstStageMask = flags; |
| 3092 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 3093 | } |
| 3094 | |
| 3095 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3096 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3097 | |
| 3098 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3099 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 3100 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3101 | &command_buffer[0]); |
| 3102 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3103 | |
| 3104 | m_errorMonitor->VerifyNotFound(); |
| 3105 | } |
| 3106 | |
| 3107 | // This is a positive test. No errors should be generated. |
| 3108 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFence) { |
| 3109 | |
| 3110 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 3111 | "submitted on separate queues, the second having a fence, " |
| 3112 | "followed by a WaitForFences call."); |
| 3113 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 3114 | if ((m_device->queue_props.empty()) || |
| 3115 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 3116 | return; |
| 3117 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 3118 | m_errorMonitor->ExpectSuccess(); |
| 3119 | |
| 3120 | VkFence fence; |
| 3121 | VkFenceCreateInfo fence_create_info{}; |
| 3122 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3123 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3124 | |
| 3125 | VkSemaphore semaphore; |
| 3126 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 3127 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 3128 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 3129 | &semaphore); |
| 3130 | |
| 3131 | VkCommandPool command_pool; |
| 3132 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3133 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3134 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3135 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3136 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3137 | &command_pool); |
| 3138 | |
| 3139 | VkCommandBuffer command_buffer[2]; |
| 3140 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3141 | command_buffer_allocate_info.sType = |
| 3142 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3143 | command_buffer_allocate_info.commandPool = command_pool; |
| 3144 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3145 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3146 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3147 | command_buffer); |
| 3148 | |
| 3149 | VkQueue queue = VK_NULL_HANDLE; |
| 3150 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 3151 | 1, &queue); |
| 3152 | |
| 3153 | |
| 3154 | { |
| 3155 | VkCommandBufferBeginInfo begin_info{}; |
| 3156 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3157 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3158 | |
| 3159 | vkCmdPipelineBarrier(command_buffer[0], |
| 3160 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3161 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3162 | 0, nullptr, 0, nullptr); |
| 3163 | |
| 3164 | VkViewport viewport{}; |
| 3165 | viewport.maxDepth = 1.0f; |
| 3166 | viewport.minDepth = 0.0f; |
| 3167 | viewport.width = 512; |
| 3168 | viewport.height = 512; |
| 3169 | viewport.x = 0; |
| 3170 | viewport.y = 0; |
| 3171 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3172 | vkEndCommandBuffer(command_buffer[0]); |
| 3173 | } |
| 3174 | { |
| 3175 | VkCommandBufferBeginInfo begin_info{}; |
| 3176 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3177 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3178 | |
| 3179 | VkViewport viewport{}; |
| 3180 | viewport.maxDepth = 1.0f; |
| 3181 | viewport.minDepth = 0.0f; |
| 3182 | viewport.width = 512; |
| 3183 | viewport.height = 512; |
| 3184 | viewport.x = 0; |
| 3185 | viewport.y = 0; |
| 3186 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3187 | vkEndCommandBuffer(command_buffer[1]); |
| 3188 | } |
| 3189 | { |
| 3190 | VkSubmitInfo submit_info{}; |
| 3191 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3192 | submit_info.commandBufferCount = 1; |
| 3193 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3194 | submit_info.signalSemaphoreCount = 1; |
| 3195 | submit_info.pSignalSemaphores = &semaphore; |
| 3196 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3197 | } |
| 3198 | { |
| 3199 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3200 | VkSubmitInfo submit_info{}; |
| 3201 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3202 | submit_info.commandBufferCount = 1; |
| 3203 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3204 | submit_info.waitSemaphoreCount = 1; |
| 3205 | submit_info.pWaitSemaphores = &semaphore; |
| 3206 | submit_info.pWaitDstStageMask = flags; |
| 3207 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 3208 | } |
| 3209 | |
| 3210 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3211 | |
| 3212 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3213 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 3214 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3215 | &command_buffer[0]); |
| 3216 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3217 | |
| 3218 | m_errorMonitor->VerifyNotFound(); |
| 3219 | } |
| 3220 | |
| 3221 | // This is a positive test. No errors should be generated. |
| 3222 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueWithSemaphoreAndOneFence) { |
| 3223 | |
| 3224 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 3225 | "on the same queue, sharing a signal/wait semaphore, the " |
| 3226 | "second having a fence, " |
| 3227 | "followed by a WaitForFences call."); |
| 3228 | |
| 3229 | m_errorMonitor->ExpectSuccess(); |
| 3230 | |
| 3231 | VkFence fence; |
| 3232 | VkFenceCreateInfo fence_create_info{}; |
| 3233 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3234 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3235 | |
| 3236 | VkSemaphore semaphore; |
| 3237 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 3238 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 3239 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 3240 | &semaphore); |
| 3241 | |
| 3242 | VkCommandPool command_pool; |
| 3243 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3244 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3245 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3246 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3247 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3248 | &command_pool); |
| 3249 | |
| 3250 | VkCommandBuffer command_buffer[2]; |
| 3251 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3252 | command_buffer_allocate_info.sType = |
| 3253 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3254 | command_buffer_allocate_info.commandPool = command_pool; |
| 3255 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3256 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3257 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3258 | command_buffer); |
| 3259 | |
| 3260 | { |
| 3261 | VkCommandBufferBeginInfo begin_info{}; |
| 3262 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3263 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3264 | |
| 3265 | vkCmdPipelineBarrier(command_buffer[0], |
| 3266 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3267 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3268 | 0, nullptr, 0, nullptr); |
| 3269 | |
| 3270 | VkViewport viewport{}; |
| 3271 | viewport.maxDepth = 1.0f; |
| 3272 | viewport.minDepth = 0.0f; |
| 3273 | viewport.width = 512; |
| 3274 | viewport.height = 512; |
| 3275 | viewport.x = 0; |
| 3276 | viewport.y = 0; |
| 3277 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3278 | vkEndCommandBuffer(command_buffer[0]); |
| 3279 | } |
| 3280 | { |
| 3281 | VkCommandBufferBeginInfo begin_info{}; |
| 3282 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3283 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3284 | |
| 3285 | VkViewport viewport{}; |
| 3286 | viewport.maxDepth = 1.0f; |
| 3287 | viewport.minDepth = 0.0f; |
| 3288 | viewport.width = 512; |
| 3289 | viewport.height = 512; |
| 3290 | viewport.x = 0; |
| 3291 | viewport.y = 0; |
| 3292 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3293 | vkEndCommandBuffer(command_buffer[1]); |
| 3294 | } |
| 3295 | { |
| 3296 | VkSubmitInfo submit_info{}; |
| 3297 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3298 | submit_info.commandBufferCount = 1; |
| 3299 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3300 | submit_info.signalSemaphoreCount = 1; |
| 3301 | submit_info.pSignalSemaphores = &semaphore; |
| 3302 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3303 | } |
| 3304 | { |
| 3305 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3306 | VkSubmitInfo submit_info{}; |
| 3307 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3308 | submit_info.commandBufferCount = 1; |
| 3309 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3310 | submit_info.waitSemaphoreCount = 1; |
| 3311 | submit_info.pWaitSemaphores = &semaphore; |
| 3312 | submit_info.pWaitDstStageMask = flags; |
| 3313 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 3314 | } |
| 3315 | |
| 3316 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3317 | |
| 3318 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3319 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 3320 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3321 | &command_buffer[0]); |
| 3322 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3323 | |
| 3324 | m_errorMonitor->VerifyNotFound(); |
| 3325 | } |
| 3326 | |
| 3327 | // This is a positive test. No errors should be generated. |
| 3328 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueNullQueueSubmitWithFence) { |
| 3329 | |
| 3330 | TEST_DESCRIPTION( |
| 3331 | "Two command buffers, each in a separate QueueSubmit call " |
| 3332 | "on the same queue, no fences, followed by a third QueueSubmit with NO " |
| 3333 | "SubmitInfos but with a fence, followed by a WaitForFences call."); |
| 3334 | |
| 3335 | m_errorMonitor->ExpectSuccess(); |
| 3336 | |
| 3337 | VkFence fence; |
| 3338 | VkFenceCreateInfo fence_create_info{}; |
| 3339 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3340 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3341 | |
| 3342 | VkCommandPool command_pool; |
| 3343 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3344 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3345 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3346 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3347 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3348 | &command_pool); |
| 3349 | |
| 3350 | VkCommandBuffer command_buffer[2]; |
| 3351 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3352 | command_buffer_allocate_info.sType = |
| 3353 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3354 | command_buffer_allocate_info.commandPool = command_pool; |
| 3355 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3356 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3357 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3358 | command_buffer); |
| 3359 | |
| 3360 | { |
| 3361 | VkCommandBufferBeginInfo begin_info{}; |
| 3362 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3363 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3364 | |
| 3365 | vkCmdPipelineBarrier(command_buffer[0], |
| 3366 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3367 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3368 | 0, nullptr, 0, nullptr); |
| 3369 | |
| 3370 | VkViewport viewport{}; |
| 3371 | viewport.maxDepth = 1.0f; |
| 3372 | viewport.minDepth = 0.0f; |
| 3373 | viewport.width = 512; |
| 3374 | viewport.height = 512; |
| 3375 | viewport.x = 0; |
| 3376 | viewport.y = 0; |
| 3377 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3378 | vkEndCommandBuffer(command_buffer[0]); |
| 3379 | } |
| 3380 | { |
| 3381 | VkCommandBufferBeginInfo begin_info{}; |
| 3382 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3383 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3384 | |
| 3385 | VkViewport viewport{}; |
| 3386 | viewport.maxDepth = 1.0f; |
| 3387 | viewport.minDepth = 0.0f; |
| 3388 | viewport.width = 512; |
| 3389 | viewport.height = 512; |
| 3390 | viewport.x = 0; |
| 3391 | viewport.y = 0; |
| 3392 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3393 | vkEndCommandBuffer(command_buffer[1]); |
| 3394 | } |
| 3395 | { |
| 3396 | VkSubmitInfo submit_info{}; |
| 3397 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3398 | submit_info.commandBufferCount = 1; |
| 3399 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3400 | submit_info.signalSemaphoreCount = 0; |
| 3401 | submit_info.pSignalSemaphores = VK_NULL_HANDLE; |
| 3402 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3403 | } |
| 3404 | { |
| 3405 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3406 | VkSubmitInfo submit_info{}; |
| 3407 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3408 | submit_info.commandBufferCount = 1; |
| 3409 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3410 | submit_info.waitSemaphoreCount = 0; |
| 3411 | submit_info.pWaitSemaphores = VK_NULL_HANDLE; |
| 3412 | submit_info.pWaitDstStageMask = flags; |
| 3413 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3414 | } |
| 3415 | |
| 3416 | vkQueueSubmit(m_device->m_queue, 0, NULL, fence); |
| 3417 | |
| 3418 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3419 | |
| 3420 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3421 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3422 | &command_buffer[0]); |
| 3423 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3424 | |
| 3425 | m_errorMonitor->VerifyNotFound(); |
| 3426 | } |
| 3427 | |
| 3428 | // This is a positive test. No errors should be generated. |
| 3429 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueOneFence) { |
| 3430 | |
| 3431 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 3432 | "on the same queue, the second having a fence, followed " |
| 3433 | "by a WaitForFences call."); |
| 3434 | |
| 3435 | m_errorMonitor->ExpectSuccess(); |
| 3436 | |
| 3437 | VkFence fence; |
| 3438 | VkFenceCreateInfo fence_create_info{}; |
| 3439 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3440 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3441 | |
| 3442 | VkCommandPool command_pool; |
| 3443 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3444 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3445 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3446 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3447 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3448 | &command_pool); |
| 3449 | |
| 3450 | VkCommandBuffer command_buffer[2]; |
| 3451 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3452 | command_buffer_allocate_info.sType = |
| 3453 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3454 | command_buffer_allocate_info.commandPool = command_pool; |
| 3455 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3456 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3457 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3458 | command_buffer); |
| 3459 | |
| 3460 | { |
| 3461 | VkCommandBufferBeginInfo begin_info{}; |
| 3462 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3463 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3464 | |
| 3465 | vkCmdPipelineBarrier(command_buffer[0], |
| 3466 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3467 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3468 | 0, nullptr, 0, nullptr); |
| 3469 | |
| 3470 | VkViewport viewport{}; |
| 3471 | viewport.maxDepth = 1.0f; |
| 3472 | viewport.minDepth = 0.0f; |
| 3473 | viewport.width = 512; |
| 3474 | viewport.height = 512; |
| 3475 | viewport.x = 0; |
| 3476 | viewport.y = 0; |
| 3477 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3478 | vkEndCommandBuffer(command_buffer[0]); |
| 3479 | } |
| 3480 | { |
| 3481 | VkCommandBufferBeginInfo begin_info{}; |
| 3482 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3483 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3484 | |
| 3485 | VkViewport viewport{}; |
| 3486 | viewport.maxDepth = 1.0f; |
| 3487 | viewport.minDepth = 0.0f; |
| 3488 | viewport.width = 512; |
| 3489 | viewport.height = 512; |
| 3490 | viewport.x = 0; |
| 3491 | viewport.y = 0; |
| 3492 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3493 | vkEndCommandBuffer(command_buffer[1]); |
| 3494 | } |
| 3495 | { |
| 3496 | VkSubmitInfo submit_info{}; |
| 3497 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3498 | submit_info.commandBufferCount = 1; |
| 3499 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 3500 | submit_info.signalSemaphoreCount = 0; |
| 3501 | submit_info.pSignalSemaphores = VK_NULL_HANDLE; |
| 3502 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 3503 | } |
| 3504 | { |
| 3505 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3506 | VkSubmitInfo submit_info{}; |
| 3507 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3508 | submit_info.commandBufferCount = 1; |
| 3509 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 3510 | submit_info.waitSemaphoreCount = 0; |
| 3511 | submit_info.pWaitSemaphores = VK_NULL_HANDLE; |
| 3512 | submit_info.pWaitDstStageMask = flags; |
| 3513 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 3514 | } |
| 3515 | |
| 3516 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3517 | |
| 3518 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3519 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3520 | &command_buffer[0]); |
| 3521 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3522 | |
| 3523 | m_errorMonitor->VerifyNotFound(); |
| 3524 | } |
| 3525 | |
| 3526 | // This is a positive test. No errors should be generated. |
| 3527 | TEST_F(VkLayerTest, TwoSubmitInfosWithSemaphoreOneQueueSubmitsOneFence) { |
| 3528 | |
| 3529 | TEST_DESCRIPTION( |
| 3530 | "Two command buffers each in a separate SubmitInfo sent in a single " |
| 3531 | "QueueSubmit call followed by a WaitForFences call."); |
| 3532 | |
| 3533 | m_errorMonitor->ExpectSuccess(); |
| 3534 | |
| 3535 | VkFence fence; |
| 3536 | VkFenceCreateInfo fence_create_info{}; |
| 3537 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3538 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 3539 | |
| 3540 | VkSemaphore semaphore; |
| 3541 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 3542 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 3543 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 3544 | &semaphore); |
| 3545 | |
| 3546 | VkCommandPool command_pool; |
| 3547 | VkCommandPoolCreateInfo pool_create_info{}; |
| 3548 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 3549 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 3550 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 3551 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 3552 | &command_pool); |
| 3553 | |
| 3554 | VkCommandBuffer command_buffer[2]; |
| 3555 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 3556 | command_buffer_allocate_info.sType = |
| 3557 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 3558 | command_buffer_allocate_info.commandPool = command_pool; |
| 3559 | command_buffer_allocate_info.commandBufferCount = 2; |
| 3560 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 3561 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 3562 | command_buffer); |
| 3563 | |
| 3564 | { |
| 3565 | VkCommandBufferBeginInfo begin_info{}; |
| 3566 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3567 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 3568 | |
| 3569 | vkCmdPipelineBarrier(command_buffer[0], |
| 3570 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 3571 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 3572 | 0, nullptr, 0, nullptr); |
| 3573 | |
| 3574 | VkViewport viewport{}; |
| 3575 | viewport.maxDepth = 1.0f; |
| 3576 | viewport.minDepth = 0.0f; |
| 3577 | viewport.width = 512; |
| 3578 | viewport.height = 512; |
| 3579 | viewport.x = 0; |
| 3580 | viewport.y = 0; |
| 3581 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 3582 | vkEndCommandBuffer(command_buffer[0]); |
| 3583 | } |
| 3584 | { |
| 3585 | VkCommandBufferBeginInfo begin_info{}; |
| 3586 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 3587 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 3588 | |
| 3589 | VkViewport viewport{}; |
| 3590 | viewport.maxDepth = 1.0f; |
| 3591 | viewport.minDepth = 0.0f; |
| 3592 | viewport.width = 512; |
| 3593 | viewport.height = 512; |
| 3594 | viewport.x = 0; |
| 3595 | viewport.y = 0; |
| 3596 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 3597 | vkEndCommandBuffer(command_buffer[1]); |
| 3598 | } |
| 3599 | { |
| 3600 | VkSubmitInfo submit_info[2]; |
| 3601 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 3602 | |
| 3603 | submit_info[0].sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3604 | submit_info[0].pNext = NULL; |
| 3605 | submit_info[0].commandBufferCount = 1; |
| 3606 | submit_info[0].pCommandBuffers = &command_buffer[0]; |
| 3607 | submit_info[0].signalSemaphoreCount = 1; |
| 3608 | submit_info[0].pSignalSemaphores = &semaphore; |
| 3609 | submit_info[0].waitSemaphoreCount = 0; |
| 3610 | submit_info[0].pWaitSemaphores = NULL; |
| 3611 | submit_info[0].pWaitDstStageMask = 0; |
| 3612 | |
| 3613 | submit_info[1].sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3614 | submit_info[1].pNext = NULL; |
| 3615 | submit_info[1].commandBufferCount = 1; |
| 3616 | submit_info[1].pCommandBuffers = &command_buffer[1]; |
| 3617 | submit_info[1].waitSemaphoreCount = 1; |
| 3618 | submit_info[1].pWaitSemaphores = &semaphore; |
| 3619 | submit_info[1].pWaitDstStageMask = flags; |
| 3620 | submit_info[1].signalSemaphoreCount = 0; |
| 3621 | submit_info[1].pSignalSemaphores = NULL; |
| 3622 | vkQueueSubmit(m_device->m_queue, 2, &submit_info[0], fence); |
| 3623 | } |
| 3624 | |
| 3625 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 3626 | |
| 3627 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 3628 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 3629 | &command_buffer[0]); |
| 3630 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 3631 | |
| 3632 | m_errorMonitor->VerifyNotFound(); |
| 3633 | } |
| 3634 | |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 3635 | TEST_F(VkLayerTest, DynamicStatesNotBound) { |
| 3636 | TEST_DESCRIPTION( |
| 3637 | "Run a series of simple draw calls to validate all the different " |
| 3638 | "failure cases that can occur when dynamic state is required but not " |
| 3639 | "correctly bound." |
| 3640 | "Here are the different dynamic state cases verified by this test:\n" |
| 3641 | "-Line Width\n-Depth Bias\n-Viewport State\n-Scissor State\n-Blend " |
| 3642 | "State\n-Depth Bounds\n-Stencil Read Mask\n-Stencil Write " |
| 3643 | "Mask\n-Stencil Reference"); |
| 3644 | |
| 3645 | // Dynamic line width |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3646 | m_errorMonitor->SetDesiredFailureMsg( |
| 3647 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3648 | "Dynamic line width state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3649 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 3650 | BsoFailLineWidth); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3651 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 3652 | // Dynamic depth bias |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3653 | m_errorMonitor->SetDesiredFailureMsg( |
| 3654 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3655 | "Dynamic depth bias state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3656 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 3657 | BsoFailDepthBias); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3658 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 3659 | // Dynamic viewport state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3660 | m_errorMonitor->SetDesiredFailureMsg( |
| 3661 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3662 | "Dynamic viewport state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3663 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 3664 | BsoFailViewport); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3665 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 3666 | // Dynamic scissor state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3667 | m_errorMonitor->SetDesiredFailureMsg( |
| 3668 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3669 | "Dynamic scissor state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3670 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 3671 | BsoFailScissor); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3672 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 3673 | // Dynamic blend state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3674 | m_errorMonitor->SetDesiredFailureMsg( |
| 3675 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3676 | "Dynamic depth bounds state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3677 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 3678 | BsoFailDepthBounds); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3679 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 3680 | // Dynamic stencil read mask |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3681 | m_errorMonitor->SetDesiredFailureMsg( |
| 3682 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3683 | "Dynamic stencil read mask state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3684 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 3685 | BsoFailStencilReadMask); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3686 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 3687 | // Dynamic stencil write mask |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3688 | m_errorMonitor->SetDesiredFailureMsg( |
| 3689 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3690 | "Dynamic stencil write mask state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3691 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 3692 | BsoFailStencilWriteMask); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3693 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 3694 | // Dynamic stencil reference |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3695 | m_errorMonitor->SetDesiredFailureMsg( |
| 3696 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3697 | "Dynamic stencil reference state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3698 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 3699 | BsoFailStencilReference); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3700 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 3701 | } |
| 3702 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3703 | TEST_F(VkLayerTest, CommandBufferTwoSubmits) { |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 3704 | vk_testing::Fence testFence; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3705 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3706 | m_errorMonitor->SetDesiredFailureMsg( |
| 3707 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3708 | "was begun w/ VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set, but has " |
| 3709 | "been submitted"); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 3710 | |
| 3711 | VkFenceCreateInfo fenceInfo = {}; |
| 3712 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 3713 | fenceInfo.pNext = NULL; |
| 3714 | fenceInfo.flags = 0; |
| 3715 | |
| 3716 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3717 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 3718 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3719 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3720 | // We luck out b/c by default the framework creates CB w/ the |
| 3721 | // VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 3722 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3723 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 3724 | m_stencil_clear_color, NULL); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 3725 | EndCommandBuffer(); |
| 3726 | |
| 3727 | testFence.init(*m_device, fenceInfo); |
| 3728 | |
| 3729 | // Bypass framework since it does the waits automatically |
| 3730 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 3731 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 3732 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 3733 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3734 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 3735 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 3736 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3737 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3738 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3739 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 3740 | submit_info.pSignalSemaphores = NULL; |
| 3741 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3742 | err = vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
| 3743 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 3744 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3745 | // Cause validation error by re-submitting cmd buffer that should only be |
| 3746 | // submitted once |
| 3747 | err = vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 3748 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3749 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 3750 | } |
| 3751 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3752 | TEST_F(VkLayerTest, AllocDescriptorFromEmptyPool) { |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 3753 | // Initiate Draw w/o a PSO bound |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3754 | VkResult err; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 3755 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3756 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3757 | "Unable to allocate 1 descriptors of " |
| 3758 | "type " |
| 3759 | "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3760 | |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 3761 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3762 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 3763 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3764 | // Create Pool w/ 1 Sampler descriptor, but try to alloc Uniform Buffer |
| 3765 | // descriptor from it |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3766 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3767 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 3768 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 3769 | |
| 3770 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3771 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3772 | ds_pool_ci.pNext = NULL; |
| 3773 | ds_pool_ci.flags = 0; |
| 3774 | ds_pool_ci.maxSets = 1; |
| 3775 | ds_pool_ci.poolSizeCount = 1; |
| 3776 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 3777 | |
| 3778 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3779 | err = |
| 3780 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 3781 | ASSERT_VK_SUCCESS(err); |
| 3782 | |
| 3783 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3784 | dsl_binding.binding = 0; |
| 3785 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3786 | dsl_binding.descriptorCount = 1; |
| 3787 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3788 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 3789 | |
| 3790 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3791 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3792 | ds_layout_ci.pNext = NULL; |
| 3793 | ds_layout_ci.bindingCount = 1; |
| 3794 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 3795 | |
| 3796 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3797 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3798 | &ds_layout); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 3799 | ASSERT_VK_SUCCESS(err); |
| 3800 | |
| 3801 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3802 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3803 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3804 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3805 | alloc_info.descriptorPool = ds_pool; |
| 3806 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3807 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3808 | &descriptorSet); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 3809 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3810 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 3811 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3812 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3813 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 3814 | } |
| 3815 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3816 | TEST_F(VkLayerTest, FreeDescriptorFromOneShotPool) { |
| 3817 | VkResult err; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3818 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3819 | m_errorMonitor->SetDesiredFailureMsg( |
| 3820 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3821 | "It is invalid to call vkFreeDescriptorSets() with a pool created " |
| 3822 | "without setting VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3823 | |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3824 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3825 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3826 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3827 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3828 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3829 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3830 | |
| 3831 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3832 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3833 | ds_pool_ci.pNext = NULL; |
| 3834 | ds_pool_ci.maxSets = 1; |
| 3835 | ds_pool_ci.poolSizeCount = 1; |
| 3836 | ds_pool_ci.flags = 0; |
| 3837 | // Not specifying VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT means |
| 3838 | // app can only call vkResetDescriptorPool on this pool.; |
| 3839 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3840 | |
| 3841 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3842 | err = |
| 3843 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3844 | ASSERT_VK_SUCCESS(err); |
| 3845 | |
| 3846 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3847 | dsl_binding.binding = 0; |
| 3848 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3849 | dsl_binding.descriptorCount = 1; |
| 3850 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3851 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3852 | |
| 3853 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3854 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3855 | ds_layout_ci.pNext = NULL; |
| 3856 | ds_layout_ci.bindingCount = 1; |
| 3857 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3858 | |
| 3859 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3860 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3861 | &ds_layout); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3862 | ASSERT_VK_SUCCESS(err); |
| 3863 | |
| 3864 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3865 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3866 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3867 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3868 | alloc_info.descriptorPool = ds_pool; |
| 3869 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3870 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3871 | &descriptorSet); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3872 | ASSERT_VK_SUCCESS(err); |
| 3873 | |
| 3874 | err = vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptorSet); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3875 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3876 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3877 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3878 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3879 | } |
| 3880 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3881 | TEST_F(VkLayerTest, InvalidDescriptorPool) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3882 | // Attempt to clear Descriptor Pool with bad object. |
| 3883 | // ObjectTracker should catch this. |
| 3884 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3885 | "Invalid VkDescriptorPool Object 0xbaad6001"); |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 3886 | uint64_t fake_pool_handle = 0xbaad6001; |
| 3887 | VkDescriptorPool bad_pool = reinterpret_cast<VkDescriptorPool &>(fake_pool_handle); |
| 3888 | vkResetDescriptorPool(device(), bad_pool, 0); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3889 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3890 | } |
| 3891 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3892 | TEST_F(VkLayerTest, InvalidDescriptorSet) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3893 | // Attempt to bind an invalid Descriptor Set to a valid Command Buffer |
| 3894 | // ObjectTracker should catch this. |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3895 | // Create a valid cmd buffer |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3896 | // call vkCmdBindDescriptorSets w/ false Descriptor Set |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 3897 | |
| 3898 | uint64_t fake_set_handle = 0xbaad6001; |
| 3899 | VkDescriptorSet bad_set = reinterpret_cast<VkDescriptorSet &>(fake_set_handle); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3900 | VkResult err; |
| 3901 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3902 | "Invalid VkDescriptorSet Object 0xbaad6001"); |
| 3903 | |
| 3904 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3905 | |
| 3906 | VkDescriptorSetLayoutBinding layout_bindings[1] = {}; |
| 3907 | layout_bindings[0].binding = 0; |
| 3908 | layout_bindings[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3909 | layout_bindings[0].descriptorCount = 1; |
| 3910 | layout_bindings[0].stageFlags = VK_SHADER_STAGE_VERTEX_BIT; |
| 3911 | layout_bindings[0].pImmutableSamplers = NULL; |
| 3912 | |
| 3913 | VkDescriptorSetLayout descriptor_set_layout; |
| 3914 | VkDescriptorSetLayoutCreateInfo dslci = {}; |
| 3915 | dslci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3916 | dslci.pNext = NULL; |
| 3917 | dslci.bindingCount = 1; |
| 3918 | dslci.pBindings = layout_bindings; |
| 3919 | err = vkCreateDescriptorSetLayout(device(), &dslci, NULL, &descriptor_set_layout); |
Karl Schultz | 5cb2111 | 2016-04-21 17:17:40 -0600 | [diff] [blame] | 3920 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3921 | |
| 3922 | VkPipelineLayout pipeline_layout; |
| 3923 | VkPipelineLayoutCreateInfo plci = {}; |
| 3924 | plci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3925 | plci.pNext = NULL; |
| 3926 | plci.setLayoutCount = 1; |
| 3927 | plci.pSetLayouts = &descriptor_set_layout; |
| 3928 | err = vkCreatePipelineLayout(device(), &plci, NULL, &pipeline_layout); |
Karl Schultz | 5cb2111 | 2016-04-21 17:17:40 -0600 | [diff] [blame] | 3929 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3930 | |
| 3931 | BeginCommandBuffer(); |
| 3932 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 3933 | pipeline_layout, 0, 1, &bad_set, 0, NULL); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3934 | m_errorMonitor->VerifyFound(); |
| 3935 | EndCommandBuffer(); |
| 3936 | vkDestroyPipelineLayout(device(), pipeline_layout, NULL); |
| 3937 | vkDestroyDescriptorSetLayout(device(), descriptor_set_layout, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3938 | } |
| 3939 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3940 | TEST_F(VkLayerTest, InvalidDescriptorSetLayout) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3941 | // Attempt to create a Pipeline Layout with an invalid Descriptor Set Layout. |
| 3942 | // ObjectTracker should catch this. |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 3943 | uint64_t fake_layout_handle = 0xbaad6001; |
| 3944 | VkDescriptorSetLayout bad_layout = reinterpret_cast<VkDescriptorSetLayout &>(fake_layout_handle); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3945 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3946 | "Invalid VkDescriptorSetLayout Object 0xbaad6001"); |
| 3947 | |
| 3948 | VkPipelineLayout pipeline_layout; |
| 3949 | VkPipelineLayoutCreateInfo plci = {}; |
| 3950 | plci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3951 | plci.pNext = NULL; |
| 3952 | plci.setLayoutCount = 1; |
| 3953 | plci.pSetLayouts = &bad_layout; |
| 3954 | vkCreatePipelineLayout(device(), &plci, NULL, &pipeline_layout); |
| 3955 | |
| 3956 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3957 | } |
| 3958 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3959 | TEST_F(VkLayerTest, InvalidPipeline) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3960 | // Attempt to bind an invalid Pipeline to a valid Command Buffer |
| 3961 | // ObjectTracker should catch this. |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3962 | // Create a valid cmd buffer |
| 3963 | // call vkCmdBindPipeline w/ false Pipeline |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 3964 | uint64_t fake_pipeline_handle = 0xbaad6001; |
| 3965 | VkPipeline bad_pipeline = reinterpret_cast<VkPipeline &>(fake_pipeline_handle); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3966 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3967 | "Invalid VkPipeline Object 0xbaad6001"); |
| 3968 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3969 | BeginCommandBuffer(); |
| 3970 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 3971 | VK_PIPELINE_BIND_POINT_GRAPHICS, bad_pipeline); |
| 3972 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b8b6b27 | 2016-05-02 13:26:06 -0600 | [diff] [blame] | 3973 | |
| 3974 | // Now issue a draw call with no pipeline bound |
| 3975 | m_errorMonitor->SetDesiredFailureMsg( |
| 3976 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3977 | "At Draw/Dispatch time no valid VkPipeline is bound!"); |
| 3978 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3979 | BeginCommandBuffer(); |
| 3980 | Draw(1, 0, 0, 0); |
| 3981 | m_errorMonitor->VerifyFound(); |
| 3982 | // Finally same check once more but with Dispatch/Compute |
| 3983 | m_errorMonitor->SetDesiredFailureMsg( |
| 3984 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3985 | "At Draw/Dispatch time no valid VkPipeline is bound!"); |
| 3986 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3987 | BeginCommandBuffer(); |
| 3988 | vkCmdDispatch(m_commandBuffer->GetBufferHandle(), 0, 0, 0); |
| 3989 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3990 | } |
| 3991 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3992 | TEST_F(VkLayerTest, DescriptorSetNotUpdated) { |
| 3993 | // Create and update CommandBuffer then call QueueSubmit w/o calling End on |
| 3994 | // CommandBuffer |
| 3995 | VkResult err; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3996 | |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 3997 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3998 | " bound but it was never updated. "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3999 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4000 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 4001 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 4002 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4003 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4004 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4005 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4006 | |
| 4007 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4008 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4009 | ds_pool_ci.pNext = NULL; |
| 4010 | ds_pool_ci.maxSets = 1; |
| 4011 | ds_pool_ci.poolSizeCount = 1; |
| 4012 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 4013 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4014 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4015 | err = |
| 4016 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4017 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4018 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4019 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4020 | dsl_binding.binding = 0; |
| 4021 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4022 | dsl_binding.descriptorCount = 1; |
| 4023 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4024 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4025 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4026 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4027 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4028 | ds_layout_ci.pNext = NULL; |
| 4029 | ds_layout_ci.bindingCount = 1; |
| 4030 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4031 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4032 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4033 | &ds_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4034 | ASSERT_VK_SUCCESS(err); |
| 4035 | |
| 4036 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4037 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4038 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4039 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4040 | alloc_info.descriptorPool = ds_pool; |
| 4041 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4042 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4043 | &descriptorSet); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4044 | ASSERT_VK_SUCCESS(err); |
| 4045 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4046 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4047 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4048 | pipeline_layout_ci.pNext = NULL; |
| 4049 | pipeline_layout_ci.setLayoutCount = 1; |
| 4050 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4051 | |
| 4052 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4053 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4054 | &pipeline_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4055 | ASSERT_VK_SUCCESS(err); |
| 4056 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4057 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4058 | VK_SHADER_STAGE_VERTEX_BIT, this); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4059 | // 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] | 4060 | // on more devices |
| 4061 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4062 | VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4063 | |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 4064 | VkPipelineObj pipe(m_device); |
| 4065 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 4066 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 4067 | pipe.AddColorAttachment(); |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 4068 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4069 | |
| 4070 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4071 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4072 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 4073 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 4074 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 4075 | 1, &descriptorSet, 0, NULL); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4076 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4077 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 4078 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4079 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4080 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4081 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4082 | } |
| 4083 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4084 | TEST_F(VkLayerTest, InvalidBufferViewObject) { |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4085 | // Create a single TEXEL_BUFFER descriptor and send it an invalid bufferView |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4086 | VkResult err; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4087 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4088 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4089 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Attempted write update to texel buffer " |
| 4090 | "descriptor with invalid buffer view"); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4091 | |
| 4092 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4093 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4094 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 4095 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4096 | |
| 4097 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4098 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4099 | ds_pool_ci.pNext = NULL; |
| 4100 | ds_pool_ci.maxSets = 1; |
| 4101 | ds_pool_ci.poolSizeCount = 1; |
| 4102 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4103 | |
| 4104 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4105 | err = |
| 4106 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4107 | ASSERT_VK_SUCCESS(err); |
| 4108 | |
| 4109 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4110 | dsl_binding.binding = 0; |
| 4111 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 4112 | dsl_binding.descriptorCount = 1; |
| 4113 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4114 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4115 | |
| 4116 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4117 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4118 | ds_layout_ci.pNext = NULL; |
| 4119 | ds_layout_ci.bindingCount = 1; |
| 4120 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4121 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4122 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4123 | &ds_layout); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4124 | ASSERT_VK_SUCCESS(err); |
| 4125 | |
| 4126 | VkDescriptorSet descriptorSet; |
| 4127 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4128 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4129 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4130 | alloc_info.descriptorPool = ds_pool; |
| 4131 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4132 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4133 | &descriptorSet); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4134 | ASSERT_VK_SUCCESS(err); |
| 4135 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4136 | VkBufferView view = |
| 4137 | (VkBufferView)((size_t)0xbaadbeef); // invalid bufferView object |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4138 | VkWriteDescriptorSet descriptor_write; |
| 4139 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 4140 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 4141 | descriptor_write.dstSet = descriptorSet; |
| 4142 | descriptor_write.dstBinding = 0; |
| 4143 | descriptor_write.descriptorCount = 1; |
| 4144 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 4145 | descriptor_write.pTexelBufferView = &view; |
| 4146 | |
| 4147 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 4148 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4149 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 4150 | |
| 4151 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4152 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 4153 | } |
| 4154 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4155 | TEST_F(VkLayerTest, InvalidDynamicOffsetCases) { |
| 4156 | // Create a descriptorSet w/ dynamic descriptor and then hit 3 offset error |
| 4157 | // cases: |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4158 | // 1. No dynamicOffset supplied |
| 4159 | // 2. Too many dynamicOffsets supplied |
| 4160 | // 3. Dynamic offset oversteps buffer being updated |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4161 | VkResult err; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4162 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4163 | " requires 1 dynamicOffsets, but only " |
| 4164 | "0 dynamicOffsets are left in " |
| 4165 | "pDynamicOffsets "); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4166 | |
| 4167 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4168 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 4169 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4170 | |
| 4171 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4172 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 4173 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4174 | |
| 4175 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4176 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4177 | ds_pool_ci.pNext = NULL; |
| 4178 | ds_pool_ci.maxSets = 1; |
| 4179 | ds_pool_ci.poolSizeCount = 1; |
| 4180 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4181 | |
| 4182 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4183 | err = |
| 4184 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4185 | ASSERT_VK_SUCCESS(err); |
| 4186 | |
| 4187 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4188 | dsl_binding.binding = 0; |
| 4189 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 4190 | dsl_binding.descriptorCount = 1; |
| 4191 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4192 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4193 | |
| 4194 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4195 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4196 | ds_layout_ci.pNext = NULL; |
| 4197 | ds_layout_ci.bindingCount = 1; |
| 4198 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4199 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4200 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4201 | &ds_layout); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4202 | ASSERT_VK_SUCCESS(err); |
| 4203 | |
| 4204 | VkDescriptorSet descriptorSet; |
| 4205 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4206 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4207 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4208 | alloc_info.descriptorPool = ds_pool; |
| 4209 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4210 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4211 | &descriptorSet); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4212 | ASSERT_VK_SUCCESS(err); |
| 4213 | |
| 4214 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4215 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4216 | pipeline_layout_ci.pNext = NULL; |
| 4217 | pipeline_layout_ci.setLayoutCount = 1; |
| 4218 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4219 | |
| 4220 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4221 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4222 | &pipeline_layout); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4223 | ASSERT_VK_SUCCESS(err); |
| 4224 | |
| 4225 | // Create a buffer to update the descriptor with |
| 4226 | uint32_t qfi = 0; |
| 4227 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4228 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 4229 | buffCI.size = 1024; |
| 4230 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 4231 | buffCI.queueFamilyIndexCount = 1; |
| 4232 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4233 | |
| 4234 | VkBuffer dyub; |
| 4235 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 4236 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4237 | // Allocate memory and bind to buffer so we can make it to the appropriate |
| 4238 | // error |
| 4239 | VkMemoryAllocateInfo mem_alloc = {}; |
| 4240 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 4241 | mem_alloc.pNext = NULL; |
| 4242 | mem_alloc.allocationSize = 1024; |
Chris Forbes | b6116cc | 2016-05-08 11:39:59 +1200 | [diff] [blame] | 4243 | mem_alloc.memoryTypeIndex = 0; |
| 4244 | |
| 4245 | VkMemoryRequirements memReqs; |
| 4246 | vkGetBufferMemoryRequirements(m_device->device(), dyub, &memReqs); |
| 4247 | bool pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &mem_alloc, |
| 4248 | 0); |
| 4249 | if (!pass) { |
| 4250 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
| 4251 | return; |
| 4252 | } |
| 4253 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4254 | VkDeviceMemory mem; |
| 4255 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
| 4256 | ASSERT_VK_SUCCESS(err); |
| 4257 | err = vkBindBufferMemory(m_device->device(), dyub, mem, 0); |
| 4258 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4259 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 4260 | VkDescriptorBufferInfo buffInfo = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4261 | buffInfo.buffer = dyub; |
| 4262 | buffInfo.offset = 0; |
| 4263 | buffInfo.range = 1024; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4264 | |
| 4265 | VkWriteDescriptorSet descriptor_write; |
| 4266 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 4267 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 4268 | descriptor_write.dstSet = descriptorSet; |
| 4269 | descriptor_write.dstBinding = 0; |
| 4270 | descriptor_write.descriptorCount = 1; |
| 4271 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 4272 | descriptor_write.pBufferInfo = &buffInfo; |
| 4273 | |
| 4274 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 4275 | |
| 4276 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4277 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 4278 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 4279 | 1, &descriptorSet, 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4280 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4281 | uint32_t pDynOff[2] = {512, 756}; |
| 4282 | // 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] | 4283 | m_errorMonitor->SetDesiredFailureMsg( |
| 4284 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4285 | "Attempting to bind 1 descriptorSets with 1 dynamic descriptors, but "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4286 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 4287 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 4288 | 1, &descriptorSet, 2, pDynOff); |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 4289 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4290 | // Finally cause error due to dynamicOffset being too big |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4291 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4292 | " dynamic offset 512 combined with " |
| 4293 | "offset 0 and range 1024 that " |
| 4294 | "oversteps the buffer size of 1024"); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4295 | // Create PSO to be used for draw-time errors below |
| 4296 | char const *vsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 4297 | "#version 450\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4298 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 4299 | "out gl_PerVertex { \n" |
| 4300 | " vec4 gl_Position;\n" |
| 4301 | "};\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4302 | "void main(){\n" |
| 4303 | " gl_Position = vec4(1);\n" |
| 4304 | "}\n"; |
| 4305 | char const *fsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 4306 | "#version 450\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4307 | "\n" |
| 4308 | "layout(location=0) out vec4 x;\n" |
| 4309 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 4310 | "void main(){\n" |
| 4311 | " x = vec4(bar.y);\n" |
| 4312 | "}\n"; |
| 4313 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4314 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 4315 | VkPipelineObj pipe(m_device); |
| 4316 | pipe.AddShader(&vs); |
| 4317 | pipe.AddShader(&fs); |
| 4318 | pipe.AddColorAttachment(); |
| 4319 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 4320 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4321 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4322 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 4323 | // This update should succeed, but offset size of 512 will overstep buffer |
| 4324 | // /w range 1024 & size 1024 |
| 4325 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 4326 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 4327 | 1, &descriptorSet, 1, pDynOff); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 4328 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4329 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4330 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4331 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
Tobin Ehlis | 512098e | 2016-05-05 09:06:12 -0600 | [diff] [blame] | 4332 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 4333 | |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 4334 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4335 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 4336 | } |
| 4337 | |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4338 | TEST_F(VkLayerTest, InvalidPushConstants) { |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4339 | VkResult err; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4340 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4341 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 4342 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4343 | |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4344 | VkPipelineLayout pipeline_layout; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4345 | VkPushConstantRange pc_range = {}; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4346 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 4347 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4348 | pipeline_layout_ci.pushConstantRangeCount = 1; |
| 4349 | pipeline_layout_ci.pPushConstantRanges = &pc_range; |
| 4350 | |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4351 | // |
| 4352 | // Check for invalid push constant ranges in pipeline layouts. |
| 4353 | // |
| 4354 | struct PipelineLayoutTestCase { |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4355 | VkPushConstantRange const range; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4356 | char const *msg; |
| 4357 | }; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4358 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4359 | const uint32_t too_big = m_device->props.limits.maxPushConstantsSize + 0x4; |
| 4360 | const std::array<PipelineLayoutTestCase, 10> range_tests = {{ |
| 4361 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 0}, |
| 4362 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 4363 | "size 0."}, |
| 4364 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 1}, |
| 4365 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 4366 | "size 1."}, |
| 4367 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 1}, |
| 4368 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 4369 | "size 1."}, |
| 4370 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 0}, |
| 4371 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 4372 | "size 0."}, |
| 4373 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 4}, |
| 4374 | "vkCreatePipelineLayout() call has push constants index 0 with " |
| 4375 | "offset 1. Offset must"}, |
| 4376 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, too_big}, |
| 4377 | "vkCreatePipelineLayout() call has push constants index 0 " |
| 4378 | "with offset "}, |
| 4379 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, too_big}, |
| 4380 | "vkCreatePipelineLayout() call has push constants " |
| 4381 | "index 0 with offset "}, |
| 4382 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, 0}, |
| 4383 | "vkCreatePipelineLayout() call has push constants index 0 " |
| 4384 | "with offset "}, |
| 4385 | {{VK_SHADER_STAGE_VERTEX_BIT, 0xFFFFFFF0, 0x00000020}, |
| 4386 | "vkCreatePipelineLayout() call has push " |
| 4387 | "constants index 0 with offset "}, |
| 4388 | {{VK_SHADER_STAGE_VERTEX_BIT, 0x00000020, 0xFFFFFFF0}, |
| 4389 | "vkCreatePipelineLayout() call has push " |
| 4390 | "constants index 0 with offset "}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4391 | }}; |
| 4392 | |
| 4393 | // Check for invalid offset and size |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4394 | for (const auto &iter : range_tests) { |
| 4395 | pc_range = iter.range; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4396 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4397 | iter.msg); |
| 4398 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, |
| 4399 | NULL, &pipeline_layout); |
| 4400 | m_errorMonitor->VerifyFound(); |
| 4401 | if (VK_SUCCESS == err) { |
| 4402 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4403 | } |
| 4404 | } |
| 4405 | |
| 4406 | // Check for invalid stage flag |
| 4407 | pc_range.offset = 0; |
| 4408 | pc_range.size = 16; |
| 4409 | pc_range.stageFlags = 0; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4410 | m_errorMonitor->SetDesiredFailureMsg( |
| 4411 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4412 | "vkCreatePipelineLayout() call has no stageFlags set."); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4413 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4414 | &pipeline_layout); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4415 | m_errorMonitor->VerifyFound(); |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4416 | if (VK_SUCCESS == err) { |
| 4417 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4418 | } |
| 4419 | |
| 4420 | // Check for overlapping ranges |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4421 | const uint32_t ranges_per_test = 5; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4422 | struct OverlappingRangeTestCase { |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4423 | VkPushConstantRange const ranges[ranges_per_test]; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4424 | char const *msg; |
| 4425 | }; |
| 4426 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4427 | const std::array<OverlappingRangeTestCase, 5> overlapping_range_tests = { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4428 | {{{{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4429 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4430 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4431 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4432 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, |
| 4433 | "vkCreatePipelineLayout() call has push constants with overlapping " |
| 4434 | "ranges: 0:[0, 4), 1:[0, 4)"}, |
| 4435 | { |
| 4436 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4437 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, |
| 4438 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, |
| 4439 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 8}, |
| 4440 | {VK_SHADER_STAGE_VERTEX_BIT, 16, 4}}, |
| 4441 | "vkCreatePipelineLayout() call has push constants with " |
| 4442 | "overlapping " |
| 4443 | "ranges: 3:[12, 20), 4:[16, 20)", |
| 4444 | }, |
| 4445 | { |
| 4446 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, |
| 4447 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 8}, |
| 4448 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, |
| 4449 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, |
| 4450 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, |
| 4451 | "vkCreatePipelineLayout() call has push constants with " |
| 4452 | "overlapping " |
| 4453 | "ranges: 0:[16, 20), 1:[12, 20)", |
| 4454 | }, |
| 4455 | { |
| 4456 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, |
| 4457 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, |
| 4458 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, |
| 4459 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 8}, |
| 4460 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, |
| 4461 | "vkCreatePipelineLayout() call has push constants with " |
| 4462 | "overlapping " |
| 4463 | "ranges: 0:[16, 20), 3:[12, 20)", |
| 4464 | }, |
| 4465 | { |
| 4466 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, |
| 4467 | {VK_SHADER_STAGE_VERTEX_BIT, 32, 4}, |
| 4468 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 96}, |
| 4469 | {VK_SHADER_STAGE_VERTEX_BIT, 40, 8}, |
| 4470 | {VK_SHADER_STAGE_VERTEX_BIT, 52, 4}}, |
| 4471 | "vkCreatePipelineLayout() call has push constants with " |
| 4472 | "overlapping " |
| 4473 | "ranges: 0:[16, 20), 2:[4, 100)", |
| 4474 | }}}; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4475 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4476 | for (const auto &iter : overlapping_range_tests) { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4477 | pipeline_layout_ci.pPushConstantRanges = iter.ranges; |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4478 | pipeline_layout_ci.pushConstantRangeCount = ranges_per_test; |
| 4479 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4480 | iter.msg); |
| 4481 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, |
| 4482 | NULL, &pipeline_layout); |
| 4483 | m_errorMonitor->VerifyFound(); |
| 4484 | if (VK_SUCCESS == err) { |
| 4485 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4486 | } |
| 4487 | } |
| 4488 | |
| 4489 | // 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] | 4490 | const std::array<OverlappingRangeTestCase, 2> overlapping_range_tests_pos = |
| 4491 | {{{{{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4492 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 4}, |
| 4493 | {VK_SHADER_STAGE_VERTEX_BIT, 8, 4}, |
| 4494 | {VK_SHADER_STAGE_VERTEX_BIT, 12, 4}, |
| 4495 | {VK_SHADER_STAGE_VERTEX_BIT, 16, 4}}, |
| 4496 | ""}, |
| 4497 | {{{VK_SHADER_STAGE_VERTEX_BIT, 92, 24}, |
| 4498 | {VK_SHADER_STAGE_VERTEX_BIT, 80, 4}, |
| 4499 | {VK_SHADER_STAGE_VERTEX_BIT, 64, 8}, |
| 4500 | {VK_SHADER_STAGE_VERTEX_BIT, 4, 16}, |
| 4501 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}}, |
| 4502 | ""}}}; |
| 4503 | for (const auto &iter : overlapping_range_tests_pos) { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4504 | pipeline_layout_ci.pPushConstantRanges = iter.ranges; |
| 4505 | m_errorMonitor->ExpectSuccess(); |
| 4506 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, |
| 4507 | NULL, &pipeline_layout); |
| 4508 | m_errorMonitor->VerifyNotFound(); |
| 4509 | if (VK_SUCCESS == err) { |
| 4510 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4511 | } |
| 4512 | } |
| 4513 | |
| 4514 | // |
| 4515 | // CmdPushConstants tests |
| 4516 | // |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4517 | const uint8_t dummy_values[100] = {}; |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4518 | |
| 4519 | // 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] | 4520 | const std::array<PipelineLayoutTestCase, 16> cmd_range_tests = {{ |
| 4521 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 0}, |
| 4522 | "vkCmdPushConstants() call has push constants with size 0. Size " |
| 4523 | "must be greater than zero and a multiple of 4."}, |
| 4524 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 1}, |
| 4525 | "vkCmdPushConstants() call has push constants with size 1. Size " |
| 4526 | "must be greater than zero and a multiple of 4."}, |
| 4527 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 1}, |
| 4528 | "vkCmdPushConstants() call has push constants with size 1. Size " |
| 4529 | "must be greater than zero and a multiple of 4."}, |
| 4530 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 0}, |
| 4531 | "vkCmdPushConstants() call has push constants with offset 1. " |
| 4532 | "Offset must be a multiple of 4."}, |
| 4533 | {{VK_SHADER_STAGE_VERTEX_BIT, 1, 4}, |
| 4534 | "vkCmdPushConstants() call has push constants with offset 1. " |
| 4535 | "Offset must be a multiple of 4."}, |
| 4536 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 20}, |
| 4537 | "vkCmdPushConstants() Push constant range [0, 20) with stageFlags = " |
| 4538 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4539 | {{VK_SHADER_STAGE_VERTEX_BIT, 60, 8}, |
| 4540 | "vkCmdPushConstants() Push constant range [60, 68) with stageFlags = " |
| 4541 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4542 | {{VK_SHADER_STAGE_VERTEX_BIT, 76, 8}, |
| 4543 | "vkCmdPushConstants() Push constant range [76, 84) with stageFlags = " |
| 4544 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4545 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 80}, |
| 4546 | "vkCmdPushConstants() Push constant range [0, 80) with stageFlags = " |
| 4547 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4548 | {{VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, 0, 4}, |
| 4549 | "vkCmdPushConstants() stageFlags = 0x2 do not match the stageFlags in " |
| 4550 | "any of the ranges in pipeline layout"}, |
| 4551 | {{VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, |
| 4552 | 0, 16}, |
| 4553 | "vkCmdPushConstants() stageFlags = 0x3 do not match the stageFlags in " |
| 4554 | "any of the ranges in pipeline layout"}, |
| 4555 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, too_big}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4556 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4557 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, too_big}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4558 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4559 | {{VK_SHADER_STAGE_VERTEX_BIT, too_big, 0}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4560 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4561 | {{VK_SHADER_STAGE_VERTEX_BIT, 0xFFFFFFF0, 0x00000020}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4562 | "vkCmdPushConstants() call has push constants with offset "}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4563 | {{VK_SHADER_STAGE_VERTEX_BIT, 0x00000020, 0xFFFFFFF0}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4564 | "vkCmdPushConstants() call has push constants with offset "}, |
| 4565 | }}; |
| 4566 | |
| 4567 | // Two ranges for testing robustness |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4568 | const VkPushConstantRange pc_range2[] = { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4569 | {VK_SHADER_STAGE_VERTEX_BIT, 64, 16}, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4570 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4571 | }; |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4572 | pipeline_layout_ci.pushConstantRangeCount = |
| 4573 | sizeof(pc_range2) / sizeof(VkPushConstantRange); |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4574 | pipeline_layout_ci.pPushConstantRanges = pc_range2; |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4575 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4576 | &pipeline_layout); |
| 4577 | ASSERT_VK_SUCCESS(err); |
| 4578 | BeginCommandBuffer(); |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4579 | for (const auto &iter : cmd_range_tests) { |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4580 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4581 | iter.msg); |
| 4582 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4583 | iter.range.stageFlags, iter.range.offset, |
| 4584 | iter.range.size, dummy_values); |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4585 | m_errorMonitor->VerifyFound(); |
| 4586 | } |
| 4587 | |
| 4588 | // Check for invalid stage flag |
| 4589 | m_errorMonitor->SetDesiredFailureMsg( |
| 4590 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4591 | "vkCmdPushConstants() call has no stageFlags set."); |
| 4592 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, 0, |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4593 | 0, 16, dummy_values); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4594 | m_errorMonitor->VerifyFound(); |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4595 | EndCommandBuffer(); |
| 4596 | vkResetCommandBuffer(m_commandBuffer->GetBufferHandle(), 0); |
| 4597 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
Karl Schultz | fc8eaf1 | 2016-05-06 13:56:42 -0600 | [diff] [blame] | 4598 | |
Karl Schultz | c81037d | 2016-05-12 08:11:23 -0600 | [diff] [blame] | 4599 | // overlapping range tests with cmd |
| 4600 | const std::array<PipelineLayoutTestCase, 3> cmd_overlap_tests = {{ |
| 4601 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 20}, |
| 4602 | "vkCmdPushConstants() Push constant range [0, 20) with stageFlags = " |
| 4603 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4604 | {{VK_SHADER_STAGE_VERTEX_BIT, 16, 4}, |
| 4605 | "vkCmdPushConstants() Push constant range [16, 20) with stageFlags = " |
| 4606 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4607 | {{VK_SHADER_STAGE_VERTEX_BIT, 40, 16}, |
| 4608 | "vkCmdPushConstants() Push constant range [40, 56) with stageFlags = " |
| 4609 | "0x1 not within flag-matching ranges in pipeline layout"}, |
| 4610 | }}; |
| 4611 | const VkPushConstantRange pc_range3[] = { |
| 4612 | {VK_SHADER_STAGE_VERTEX_BIT, 20, 16}, |
| 4613 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, |
| 4614 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4615 | {VK_SHADER_STAGE_VERTEX_BIT, 44, 8}, |
| 4616 | {VK_SHADER_STAGE_VERTEX_BIT, 80, 12}, |
| 4617 | {VK_SHADER_STAGE_VERTEX_BIT, 36, 8}, |
| 4618 | {VK_SHADER_STAGE_VERTEX_BIT, 56, 28}, |
| 4619 | }; |
| 4620 | pipeline_layout_ci.pushConstantRangeCount = |
| 4621 | sizeof(pc_range3) / sizeof(VkPushConstantRange); |
| 4622 | pipeline_layout_ci.pPushConstantRanges = pc_range3; |
| 4623 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4624 | &pipeline_layout); |
| 4625 | ASSERT_VK_SUCCESS(err); |
| 4626 | BeginCommandBuffer(); |
| 4627 | for (const auto &iter : cmd_overlap_tests) { |
| 4628 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4629 | iter.msg); |
| 4630 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, |
| 4631 | iter.range.stageFlags, iter.range.offset, |
| 4632 | iter.range.size, dummy_values); |
| 4633 | m_errorMonitor->VerifyFound(); |
| 4634 | } |
| 4635 | EndCommandBuffer(); |
| 4636 | vkResetCommandBuffer(m_commandBuffer->GetBufferHandle(), 0); |
| 4637 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4638 | |
| 4639 | // positive overlapping range tests with cmd |
| 4640 | const std::array<PipelineLayoutTestCase, 4> cmd_overlap_tests_pos = {{ |
| 4641 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, ""}, |
| 4642 | {{VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, ""}, |
| 4643 | {{VK_SHADER_STAGE_VERTEX_BIT, 20, 12}, ""}, |
| 4644 | {{VK_SHADER_STAGE_VERTEX_BIT, 56, 36}, ""}, |
| 4645 | }}; |
| 4646 | const VkPushConstantRange pc_range4[] = { |
| 4647 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 64}, |
| 4648 | {VK_SHADER_STAGE_VERTEX_BIT, 20, 16}, |
| 4649 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 16}, |
| 4650 | {VK_SHADER_STAGE_VERTEX_BIT, 0, 4}, |
| 4651 | {VK_SHADER_STAGE_VERTEX_BIT, 44, 8}, |
| 4652 | {VK_SHADER_STAGE_VERTEX_BIT, 80, 12}, |
| 4653 | {VK_SHADER_STAGE_VERTEX_BIT, 36, 8}, |
| 4654 | {VK_SHADER_STAGE_VERTEX_BIT, 56, 28}, |
| 4655 | }; |
| 4656 | pipeline_layout_ci.pushConstantRangeCount = |
| 4657 | sizeof(pc_range4) / sizeof(VkPushConstantRange); |
| 4658 | pipeline_layout_ci.pPushConstantRanges = pc_range4; |
| 4659 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4660 | &pipeline_layout); |
| 4661 | ASSERT_VK_SUCCESS(err); |
| 4662 | BeginCommandBuffer(); |
| 4663 | for (const auto &iter : cmd_overlap_tests_pos) { |
| 4664 | m_errorMonitor->ExpectSuccess(); |
| 4665 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, |
| 4666 | iter.range.stageFlags, iter.range.offset, |
| 4667 | iter.range.size, dummy_values); |
| 4668 | m_errorMonitor->VerifyNotFound(); |
| 4669 | } |
| 4670 | EndCommandBuffer(); |
| 4671 | vkResetCommandBuffer(m_commandBuffer->GetBufferHandle(), 0); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 4672 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4673 | } |
| 4674 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4675 | TEST_F(VkLayerTest, DescriptorSetCompatibility) { |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4676 | // Test various desriptorSet errors with bad binding combinations |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4677 | VkResult err; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4678 | |
| 4679 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4680 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 4681 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4682 | |
| 4683 | static const uint32_t NUM_DESCRIPTOR_TYPES = 5; |
| 4684 | VkDescriptorPoolSize ds_type_count[NUM_DESCRIPTOR_TYPES] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4685 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4686 | ds_type_count[0].descriptorCount = 10; |
| 4687 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 4688 | ds_type_count[1].descriptorCount = 2; |
| 4689 | ds_type_count[2].type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 4690 | ds_type_count[2].descriptorCount = 2; |
| 4691 | ds_type_count[3].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 4692 | ds_type_count[3].descriptorCount = 5; |
| 4693 | // TODO : LunarG ILO driver currently asserts in desc.c w/ INPUT_ATTACHMENT |
| 4694 | // type |
| 4695 | // ds_type_count[4].type = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; |
| 4696 | ds_type_count[4].type = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
| 4697 | ds_type_count[4].descriptorCount = 2; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4698 | |
| 4699 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4700 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4701 | ds_pool_ci.pNext = NULL; |
| 4702 | ds_pool_ci.maxSets = 5; |
| 4703 | ds_pool_ci.poolSizeCount = NUM_DESCRIPTOR_TYPES; |
| 4704 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4705 | |
| 4706 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4707 | err = |
| 4708 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4709 | ASSERT_VK_SUCCESS(err); |
| 4710 | |
| 4711 | static const uint32_t MAX_DS_TYPES_IN_LAYOUT = 2; |
| 4712 | VkDescriptorSetLayoutBinding dsl_binding[MAX_DS_TYPES_IN_LAYOUT] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4713 | dsl_binding[0].binding = 0; |
| 4714 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4715 | dsl_binding[0].descriptorCount = 5; |
| 4716 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 4717 | dsl_binding[0].pImmutableSamplers = NULL; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4718 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4719 | // Create layout identical to set0 layout but w/ different stageFlags |
| 4720 | VkDescriptorSetLayoutBinding dsl_fs_stage_only = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4721 | dsl_fs_stage_only.binding = 0; |
| 4722 | dsl_fs_stage_only.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4723 | dsl_fs_stage_only.descriptorCount = 5; |
| 4724 | dsl_fs_stage_only.stageFlags = |
| 4725 | VK_SHADER_STAGE_FRAGMENT_BIT; // Different stageFlags to cause error at |
| 4726 | // bind time |
| 4727 | dsl_fs_stage_only.pImmutableSamplers = NULL; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4728 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4729 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4730 | ds_layout_ci.pNext = NULL; |
| 4731 | ds_layout_ci.bindingCount = 1; |
| 4732 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4733 | static const uint32_t NUM_LAYOUTS = 4; |
| 4734 | VkDescriptorSetLayout ds_layout[NUM_LAYOUTS] = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4735 | VkDescriptorSetLayout ds_layout_fs_only = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4736 | // Create 4 unique layouts for full pipelineLayout, and 1 special fs-only |
| 4737 | // layout for error case |
| 4738 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4739 | &ds_layout[0]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4740 | ASSERT_VK_SUCCESS(err); |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 4741 | ds_layout_ci.pBindings = &dsl_fs_stage_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4742 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4743 | &ds_layout_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4744 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4745 | dsl_binding[0].binding = 0; |
| 4746 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4747 | dsl_binding[0].descriptorCount = 2; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 4748 | dsl_binding[1].binding = 1; |
| 4749 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 4750 | dsl_binding[1].descriptorCount = 2; |
| 4751 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 4752 | dsl_binding[1].pImmutableSamplers = NULL; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 4753 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4754 | ds_layout_ci.bindingCount = 2; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4755 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4756 | &ds_layout[1]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4757 | ASSERT_VK_SUCCESS(err); |
| 4758 | dsl_binding[0].binding = 0; |
| 4759 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4760 | dsl_binding[0].descriptorCount = 5; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4761 | ds_layout_ci.bindingCount = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4762 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4763 | &ds_layout[2]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4764 | ASSERT_VK_SUCCESS(err); |
| 4765 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4766 | dsl_binding[0].descriptorCount = 2; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4767 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4768 | &ds_layout[3]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4769 | ASSERT_VK_SUCCESS(err); |
| 4770 | |
| 4771 | static const uint32_t NUM_SETS = 4; |
| 4772 | VkDescriptorSet descriptorSet[NUM_SETS] = {}; |
| 4773 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4774 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4775 | alloc_info.descriptorSetCount = NUM_LAYOUTS; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4776 | alloc_info.descriptorPool = ds_pool; |
| 4777 | alloc_info.pSetLayouts = ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4778 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4779 | descriptorSet); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4780 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4781 | VkDescriptorSet ds0_fs_only = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4782 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4783 | alloc_info.pSetLayouts = &ds_layout_fs_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4784 | err = |
| 4785 | vkAllocateDescriptorSets(m_device->device(), &alloc_info, &ds0_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4786 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4787 | |
| 4788 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4789 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4790 | pipeline_layout_ci.pNext = NULL; |
| 4791 | pipeline_layout_ci.setLayoutCount = NUM_LAYOUTS; |
| 4792 | pipeline_layout_ci.pSetLayouts = ds_layout; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4793 | |
| 4794 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4795 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4796 | &pipeline_layout); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4797 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4798 | // Create pipelineLayout with only one setLayout |
| 4799 | pipeline_layout_ci.setLayoutCount = 1; |
| 4800 | VkPipelineLayout single_pipe_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4801 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4802 | &single_pipe_layout); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4803 | ASSERT_VK_SUCCESS(err); |
| 4804 | // Create pipelineLayout with 2 descriptor setLayout at index 0 |
| 4805 | pipeline_layout_ci.pSetLayouts = &ds_layout[3]; |
| 4806 | VkPipelineLayout pipe_layout_one_desc; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4807 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4808 | &pipe_layout_one_desc); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4809 | ASSERT_VK_SUCCESS(err); |
| 4810 | // Create pipelineLayout with 5 SAMPLER descriptor setLayout at index 0 |
| 4811 | pipeline_layout_ci.pSetLayouts = &ds_layout[2]; |
| 4812 | VkPipelineLayout pipe_layout_five_samp; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4813 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4814 | &pipe_layout_five_samp); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4815 | ASSERT_VK_SUCCESS(err); |
| 4816 | // Create pipelineLayout with UB type, but stageFlags for FS only |
| 4817 | pipeline_layout_ci.pSetLayouts = &ds_layout_fs_only; |
| 4818 | VkPipelineLayout pipe_layout_fs_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4819 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4820 | &pipe_layout_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4821 | ASSERT_VK_SUCCESS(err); |
| 4822 | // Create pipelineLayout w/ incompatible set0 layout, but set1 is fine |
| 4823 | VkDescriptorSetLayout pl_bad_s0[2] = {}; |
| 4824 | pl_bad_s0[0] = ds_layout_fs_only; |
| 4825 | pl_bad_s0[1] = ds_layout[1]; |
| 4826 | pipeline_layout_ci.setLayoutCount = 2; |
| 4827 | pipeline_layout_ci.pSetLayouts = pl_bad_s0; |
| 4828 | VkPipelineLayout pipe_layout_bad_set0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4829 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4830 | &pipe_layout_bad_set0); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4831 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4832 | |
| 4833 | // Create a buffer to update the descriptor with |
| 4834 | uint32_t qfi = 0; |
| 4835 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4836 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 4837 | buffCI.size = 1024; |
| 4838 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 4839 | buffCI.queueFamilyIndexCount = 1; |
| 4840 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4841 | |
| 4842 | VkBuffer dyub; |
| 4843 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 4844 | ASSERT_VK_SUCCESS(err); |
| 4845 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 4846 | static const uint32_t NUM_BUFFS = 5; |
| 4847 | VkDescriptorBufferInfo buffInfo[NUM_BUFFS] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4848 | for (uint32_t i = 0; i < NUM_BUFFS; ++i) { |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4849 | buffInfo[i].buffer = dyub; |
| 4850 | buffInfo[i].offset = 0; |
| 4851 | buffInfo[i].range = 1024; |
| 4852 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4853 | VkImage image; |
| 4854 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 4855 | const int32_t tex_width = 32; |
| 4856 | const int32_t tex_height = 32; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4857 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4858 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4859 | image_create_info.pNext = NULL; |
| 4860 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4861 | image_create_info.format = tex_format; |
| 4862 | image_create_info.extent.width = tex_width; |
| 4863 | image_create_info.extent.height = tex_height; |
| 4864 | image_create_info.extent.depth = 1; |
| 4865 | image_create_info.mipLevels = 1; |
| 4866 | image_create_info.arrayLayers = 1; |
| 4867 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 4868 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 4869 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 4870 | image_create_info.flags = 0; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4871 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 4872 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4873 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4874 | VkMemoryRequirements memReqs; |
| 4875 | VkDeviceMemory imageMem; |
| 4876 | bool pass; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 4877 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4878 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 4879 | memAlloc.pNext = NULL; |
| 4880 | memAlloc.allocationSize = 0; |
| 4881 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 4882 | vkGetImageMemoryRequirements(m_device->device(), image, &memReqs); |
| 4883 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4884 | pass = |
| 4885 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 4886 | ASSERT_TRUE(pass); |
| 4887 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &imageMem); |
| 4888 | ASSERT_VK_SUCCESS(err); |
| 4889 | err = vkBindImageMemory(m_device->device(), image, imageMem, 0); |
| 4890 | ASSERT_VK_SUCCESS(err); |
| 4891 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4892 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4893 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 4894 | image_view_create_info.image = image; |
| 4895 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 4896 | image_view_create_info.format = tex_format; |
| 4897 | image_view_create_info.subresourceRange.layerCount = 1; |
| 4898 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 4899 | image_view_create_info.subresourceRange.levelCount = 1; |
| 4900 | image_view_create_info.subresourceRange.aspectMask = |
| 4901 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4902 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4903 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4904 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 4905 | &view); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4906 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 4907 | VkDescriptorImageInfo imageInfo[4] = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4908 | imageInfo[0].imageView = view; |
| 4909 | imageInfo[0].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 4910 | imageInfo[1].imageView = view; |
| 4911 | imageInfo[1].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 4912 | imageInfo[2].imageView = view; |
| 4913 | imageInfo[2].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 4914 | imageInfo[3].imageView = view; |
| 4915 | imageInfo[3].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4916 | |
| 4917 | static const uint32_t NUM_SET_UPDATES = 3; |
| 4918 | VkWriteDescriptorSet descriptor_write[NUM_SET_UPDATES] = {}; |
| 4919 | descriptor_write[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 4920 | descriptor_write[0].dstSet = descriptorSet[0]; |
| 4921 | descriptor_write[0].dstBinding = 0; |
| 4922 | descriptor_write[0].descriptorCount = 5; |
| 4923 | descriptor_write[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4924 | descriptor_write[0].pBufferInfo = buffInfo; |
| 4925 | descriptor_write[1].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 4926 | descriptor_write[1].dstSet = descriptorSet[1]; |
| 4927 | descriptor_write[1].dstBinding = 0; |
| 4928 | descriptor_write[1].descriptorCount = 2; |
| 4929 | descriptor_write[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 4930 | descriptor_write[1].pImageInfo = imageInfo; |
| 4931 | descriptor_write[2].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 4932 | descriptor_write[2].dstSet = descriptorSet[1]; |
| 4933 | descriptor_write[2].dstBinding = 1; |
| 4934 | descriptor_write[2].descriptorCount = 2; |
| 4935 | descriptor_write[2].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 4936 | descriptor_write[2].pImageInfo = &imageInfo[2]; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4937 | |
| 4938 | vkUpdateDescriptorSets(m_device->device(), 3, descriptor_write, 0, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4939 | |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 4940 | // Create PSO to be used for draw-time errors below |
| 4941 | char const *vsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 4942 | "#version 450\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 4943 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 4944 | "out gl_PerVertex {\n" |
| 4945 | " vec4 gl_Position;\n" |
| 4946 | "};\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 4947 | "void main(){\n" |
| 4948 | " gl_Position = vec4(1);\n" |
| 4949 | "}\n"; |
| 4950 | char const *fsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 4951 | "#version 450\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 4952 | "\n" |
| 4953 | "layout(location=0) out vec4 x;\n" |
| 4954 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 4955 | "void main(){\n" |
| 4956 | " x = vec4(bar.y);\n" |
| 4957 | "}\n"; |
| 4958 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4959 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4960 | VkPipelineObj pipe(m_device); |
| 4961 | pipe.AddShader(&vs); |
| 4962 | pipe.AddShader(&fs); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 4963 | pipe.AddColorAttachment(); |
| 4964 | pipe.CreateVKPipeline(pipe_layout_fs_only, renderPass()); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4965 | |
| 4966 | BeginCommandBuffer(); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 4967 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4968 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4969 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 4970 | // NOTE : I believe LunarG ilo driver has bug (LX#189) that requires binding |
| 4971 | // of PSO |
| 4972 | // here before binding DSs. Otherwise we assert in cmd_copy_dset_data() of |
| 4973 | // cmd_pipeline.c |
| 4974 | // due to the fact that cmd_alloc_dset_data() has not been called in |
| 4975 | // cmd_bind_graphics_pipeline() |
| 4976 | // TODO : Want to cause various binding incompatibility issues here to test |
| 4977 | // DrawState |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4978 | // First cause various verify_layout_compatibility() fails |
| 4979 | // Second disturb early and late sets and verify INFO msgs |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4980 | // verify_set_layout_compatibility fail cases: |
| 4981 | // 1. invalid VkPipelineLayout (layout) passed into vkCmdBindDescriptorSets |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4982 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4983 | " due to: invalid VkPipelineLayout "); |
| 4984 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 4985 | VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 4986 | (VkPipelineLayout)((size_t)0xbaadb1be), 0, 1, |
| 4987 | &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4988 | m_errorMonitor->VerifyFound(); |
| 4989 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4990 | // 2. layoutIndex exceeds # of layouts in layout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4991 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4992 | " attempting to bind set to index 1"); |
| 4993 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 4994 | VK_PIPELINE_BIND_POINT_GRAPHICS, single_pipe_layout, |
| 4995 | 0, 2, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4996 | m_errorMonitor->VerifyFound(); |
| 4997 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4998 | vkDestroyPipelineLayout(m_device->device(), single_pipe_layout, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4999 | // 3. Pipeline setLayout[0] has 2 descriptors, but set being bound has 5 |
| 5000 | // descriptors |
| 5001 | m_errorMonitor->SetDesiredFailureMsg( |
| 5002 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 5003 | " has 2 descriptors, but DescriptorSetLayout "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5004 | vkCmdBindDescriptorSets( |
| 5005 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5006 | pipe_layout_one_desc, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5007 | m_errorMonitor->VerifyFound(); |
| 5008 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5009 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_one_desc, NULL); |
| 5010 | // 4. same # of descriptors but mismatch in type |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5011 | m_errorMonitor->SetDesiredFailureMsg( |
| 5012 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 5013 | " is type 'VK_DESCRIPTOR_TYPE_SAMPLER' but binding "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5014 | vkCmdBindDescriptorSets( |
| 5015 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5016 | pipe_layout_five_samp, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5017 | m_errorMonitor->VerifyFound(); |
| 5018 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5019 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_five_samp, NULL); |
| 5020 | // 5. same # of descriptors but mismatch in stageFlags |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5021 | m_errorMonitor->SetDesiredFailureMsg( |
| 5022 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 5023 | " has stageFlags 16 but binding 0 for DescriptorSetLayout "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5024 | vkCmdBindDescriptorSets( |
| 5025 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5026 | pipe_layout_fs_only, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5027 | m_errorMonitor->VerifyFound(); |
| 5028 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5029 | // Cause INFO messages due to disturbing previously bound Sets |
| 5030 | // First bind sets 0 & 1 |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5031 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5032 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 5033 | 2, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5034 | // 1. Disturb bound set0 by re-binding set1 w/ updated pipelineLayout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5035 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 5036 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5037 | " previously bound as set #0 was disturbed "); |
| 5038 | vkCmdBindDescriptorSets( |
| 5039 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5040 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5041 | m_errorMonitor->VerifyFound(); |
| 5042 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5043 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5044 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 5045 | 2, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5046 | // 2. Disturb set after last bound set |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 5047 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5048 | " newly bound as set #0 so set #1 and " |
| 5049 | "any subsequent sets were disturbed "); |
| 5050 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5051 | VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5052 | pipe_layout_fs_only, 0, 1, &ds0_fs_only, 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5053 | m_errorMonitor->VerifyFound(); |
| 5054 | |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5055 | // Cause draw-time errors due to PSO incompatibilities |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5056 | // 1. Error due to not binding required set (we actually use same code as |
| 5057 | // above to disturb set0) |
| 5058 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5059 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 5060 | 2, &descriptorSet[0], 0, NULL); |
| 5061 | vkCmdBindDescriptorSets( |
| 5062 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 5063 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
| 5064 | m_errorMonitor->SetDesiredFailureMsg( |
| 5065 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5066 | " uses set #0 but that set is not bound."); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5067 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5068 | m_errorMonitor->VerifyFound(); |
| 5069 | |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 5070 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_bad_set0, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5071 | // 2. Error due to bound set not being compatible with PSO's |
| 5072 | // VkPipelineLayout (diff stageFlags in this case) |
| 5073 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 5074 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 5075 | 2, &descriptorSet[0], 0, NULL); |
| 5076 | m_errorMonitor->SetDesiredFailureMsg( |
| 5077 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5078 | " bound as set #0 is not compatible with "); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 5079 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5080 | m_errorMonitor->VerifyFound(); |
| 5081 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5082 | // Remaining clean-up |
| 5083 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_fs_only, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5084 | for (uint32_t i = 0; i < NUM_LAYOUTS; ++i) { |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5085 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout[i], NULL); |
| 5086 | } |
| 5087 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout_fs_only, NULL); |
Tobin Ehlis | 9bfd449 | 2016-05-05 15:09:11 -0600 | [diff] [blame] | 5088 | vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &ds0_fs_only); |
| 5089 | vkFreeDescriptorSets(m_device->device(), ds_pool, NUM_SETS, descriptorSet); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 5090 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5091 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5092 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 5093 | } |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 5094 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5095 | TEST_F(VkLayerTest, NoBeginCommandBuffer) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5096 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5097 | m_errorMonitor->SetDesiredFailureMsg( |
| 5098 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5099 | "You must call vkBeginCommandBuffer() before this call to "); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5100 | |
| 5101 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5102 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5103 | // Call EndCommandBuffer() w/o calling BeginCommandBuffer() |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5104 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5105 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5106 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5107 | } |
| 5108 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5109 | TEST_F(VkLayerTest, SecondaryCommandBufferNullRenderpass) { |
| 5110 | VkResult err; |
| 5111 | VkCommandBuffer draw_cmd; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5112 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5113 | m_errorMonitor->SetDesiredFailureMsg( |
| 5114 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 61b36f3 | 2015-12-16 08:19:42 -0700 | [diff] [blame] | 5115 | " must specify a valid renderpass parameter."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5116 | |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 5117 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 5118 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5119 | VkCommandBufferAllocateInfo cmd = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5120 | cmd.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 5121 | cmd.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5122 | cmd.commandPool = m_commandPool; |
| 5123 | cmd.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5124 | cmd.commandBufferCount = 1; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 5125 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5126 | err = vkAllocateCommandBuffers(m_device->device(), &cmd, &draw_cmd); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5127 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 5128 | |
| 5129 | // Force the failure by not setting the Renderpass and Framebuffer fields |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5130 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5131 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5132 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 5133 | cmd_buf_info.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5134 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT | |
| 5135 | VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5136 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 5137 | |
| 5138 | // The error should be caught by validation of the BeginCommandBuffer call |
| 5139 | vkBeginCommandBuffer(draw_cmd, &cmd_buf_info); |
| 5140 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5141 | m_errorMonitor->VerifyFound(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5142 | vkFreeCommandBuffers(m_device->device(), m_commandPool, 1, &draw_cmd); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 5143 | } |
| 5144 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5145 | TEST_F(VkLayerTest, CommandBufferResetErrors) { |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5146 | // Cause error due to Begin while recording CB |
| 5147 | // Then cause 2 errors for attempting to reset CB w/o having |
| 5148 | // VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT set for the pool from |
| 5149 | // which CBs were allocated. Note that this bit is off by default. |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5150 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5151 | "Cannot call Begin on CB"); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5152 | |
| 5153 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5154 | |
| 5155 | // Calls AllocateCommandBuffers |
| 5156 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
| 5157 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5158 | // Force the failure by setting the Renderpass and Framebuffer fields with |
| 5159 | // (fake) data |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5160 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5161 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5162 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 5163 | cmd_buf_info.pNext = NULL; |
| 5164 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5165 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5166 | |
| 5167 | // Begin CB to transition to recording state |
| 5168 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
| 5169 | // Can't re-begin. This should trigger error |
| 5170 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5171 | m_errorMonitor->VerifyFound(); |
| 5172 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5173 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5174 | "Attempt to reset command buffer "); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5175 | VkCommandBufferResetFlags flags = 0; // Don't care about flags for this test |
| 5176 | // Reset attempt will trigger error due to incorrect CommandPool state |
| 5177 | vkResetCommandBuffer(commandBuffer.GetBufferHandle(), flags); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5178 | m_errorMonitor->VerifyFound(); |
| 5179 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5180 | m_errorMonitor->SetDesiredFailureMsg( |
| 5181 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5182 | " attempts to implicitly reset cmdBuffer created from "); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5183 | // Transition CB to RECORDED state |
| 5184 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
| 5185 | // Now attempting to Begin will implicitly reset, which triggers error |
| 5186 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5187 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 5188 | } |
| 5189 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5190 | TEST_F(VkLayerTest, InvalidPipelineCreateState) { |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5191 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5192 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5193 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5194 | m_errorMonitor->SetDesiredFailureMsg( |
| 5195 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5196 | "Invalid Pipeline CreateInfo State: Vtx Shader required"); |
| 5197 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5198 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 5199 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 5200 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5201 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5202 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5203 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5204 | |
| 5205 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5206 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5207 | ds_pool_ci.pNext = NULL; |
| 5208 | ds_pool_ci.maxSets = 1; |
| 5209 | ds_pool_ci.poolSizeCount = 1; |
| 5210 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 5211 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5212 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5213 | err = |
| 5214 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5215 | ASSERT_VK_SUCCESS(err); |
| 5216 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5217 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5218 | dsl_binding.binding = 0; |
| 5219 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5220 | dsl_binding.descriptorCount = 1; |
| 5221 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5222 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5223 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5224 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5225 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5226 | ds_layout_ci.pNext = NULL; |
| 5227 | ds_layout_ci.bindingCount = 1; |
| 5228 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5229 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5230 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5231 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5232 | &ds_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5233 | ASSERT_VK_SUCCESS(err); |
| 5234 | |
| 5235 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5236 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5237 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5238 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5239 | alloc_info.descriptorPool = ds_pool; |
| 5240 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5241 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5242 | &descriptorSet); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5243 | ASSERT_VK_SUCCESS(err); |
| 5244 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5245 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5246 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5247 | pipeline_layout_ci.setLayoutCount = 1; |
| 5248 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5249 | |
| 5250 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5251 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5252 | &pipeline_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5253 | ASSERT_VK_SUCCESS(err); |
| 5254 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5255 | VkViewport vp = {}; // Just need dummy vp to point to |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5256 | VkRect2D sc = {}; // dummy scissor to point to |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5257 | |
| 5258 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5259 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 5260 | vp_state_ci.scissorCount = 1; |
| 5261 | vp_state_ci.pScissors = ≻ |
| 5262 | vp_state_ci.viewportCount = 1; |
| 5263 | vp_state_ci.pViewports = &vp; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5264 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 5265 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 5266 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 5267 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 5268 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 5269 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 5270 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 5271 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 5272 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 5273 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5274 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5275 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 5276 | gp_ci.pViewportState = &vp_state_ci; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 5277 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5278 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 5279 | gp_ci.layout = pipeline_layout; |
| 5280 | gp_ci.renderPass = renderPass(); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5281 | |
| 5282 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5283 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 5284 | pc_ci.initialDataSize = 0; |
| 5285 | pc_ci.pInitialData = 0; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5286 | |
| 5287 | VkPipeline pipeline; |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 5288 | VkPipelineCache pipelineCache; |
| 5289 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5290 | err = |
| 5291 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 5292 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5293 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 5294 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 5295 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5296 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5297 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5298 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 5299 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5300 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5301 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5302 | } |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5303 | /*// TODO : This test should be good, but needs Tess support in compiler to run |
| 5304 | TEST_F(VkLayerTest, InvalidPatchControlPoints) |
| 5305 | { |
| 5306 | // Attempt to Create Gfx Pipeline w/o a VS |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5307 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5308 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5309 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5310 | "Invalid Pipeline CreateInfo State: VK_PRIMITIVE_TOPOLOGY_PATCH |
| 5311 | primitive "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5312 | |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5313 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5314 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5315 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5316 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5317 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5318 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5319 | |
| 5320 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 5321 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5322 | ds_pool_ci.pNext = NULL; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5323 | ds_pool_ci.poolSizeCount = 1; |
| 5324 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5325 | |
| 5326 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5327 | err = vkCreateDescriptorPool(m_device->device(), |
| 5328 | 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] | 5329 | ASSERT_VK_SUCCESS(err); |
| 5330 | |
| 5331 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5332 | dsl_binding.binding = 0; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5333 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 5334 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5335 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5336 | dsl_binding.pImmutableSamplers = NULL; |
| 5337 | |
| 5338 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5339 | ds_layout_ci.sType = |
| 5340 | VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5341 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5342 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 5343 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5344 | |
| 5345 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5346 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5347 | &ds_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5348 | ASSERT_VK_SUCCESS(err); |
| 5349 | |
| 5350 | VkDescriptorSet descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5351 | err = vkAllocateDescriptorSets(m_device->device(), ds_pool, |
| 5352 | VK_DESCRIPTOR_SET_USAGE_NON_FREE, 1, &ds_layout, &descriptorSet); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5353 | ASSERT_VK_SUCCESS(err); |
| 5354 | |
| 5355 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5356 | pipeline_layout_ci.sType = |
| 5357 | VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5358 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5359 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5360 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 5361 | |
| 5362 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5363 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5364 | &pipeline_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5365 | ASSERT_VK_SUCCESS(err); |
| 5366 | |
| 5367 | VkPipelineShaderStageCreateInfo shaderStages[3]; |
| 5368 | memset(&shaderStages, 0, 3 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 5369 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5370 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, |
| 5371 | this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5372 | // 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] | 5373 | VkShaderObj |
| 5374 | tc(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, |
| 5375 | this); |
| 5376 | VkShaderObj |
| 5377 | te(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, |
| 5378 | this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5379 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5380 | shaderStages[0].sType = |
| 5381 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5382 | shaderStages[0].stage = VK_SHADER_STAGE_VERTEX_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5383 | shaderStages[0].shader = vs.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5384 | shaderStages[1].sType = |
| 5385 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5386 | shaderStages[1].stage = VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5387 | shaderStages[1].shader = tc.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5388 | shaderStages[2].sType = |
| 5389 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5390 | shaderStages[2].stage = VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5391 | shaderStages[2].shader = te.handle(); |
| 5392 | |
| 5393 | VkPipelineInputAssemblyStateCreateInfo iaCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5394 | iaCI.sType = |
| 5395 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
Chia-I Wu | 515eb8f | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5396 | iaCI.topology = VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5397 | |
| 5398 | VkPipelineTessellationStateCreateInfo tsCI = {}; |
| 5399 | tsCI.sType = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO; |
| 5400 | tsCI.patchControlPoints = 0; // This will cause an error |
| 5401 | |
| 5402 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 5403 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 5404 | gp_ci.pNext = NULL; |
| 5405 | gp_ci.stageCount = 3; |
| 5406 | gp_ci.pStages = shaderStages; |
| 5407 | gp_ci.pVertexInputState = NULL; |
| 5408 | gp_ci.pInputAssemblyState = &iaCI; |
| 5409 | gp_ci.pTessellationState = &tsCI; |
| 5410 | gp_ci.pViewportState = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5411 | gp_ci.pRasterizationState = NULL; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5412 | gp_ci.pMultisampleState = NULL; |
| 5413 | gp_ci.pDepthStencilState = NULL; |
| 5414 | gp_ci.pColorBlendState = NULL; |
| 5415 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 5416 | gp_ci.layout = pipeline_layout; |
| 5417 | gp_ci.renderPass = renderPass(); |
| 5418 | |
| 5419 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 5420 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 5421 | pc_ci.pNext = NULL; |
| 5422 | pc_ci.initialSize = 0; |
| 5423 | pc_ci.initialData = 0; |
| 5424 | pc_ci.maxSize = 0; |
| 5425 | |
| 5426 | VkPipeline pipeline; |
| 5427 | VkPipelineCache pipelineCache; |
| 5428 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5429 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, |
| 5430 | &pipelineCache); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5431 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5432 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 5433 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5434 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5435 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5436 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5437 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 5438 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5439 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5440 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 5441 | } |
| 5442 | */ |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5443 | // Set scissor and viewport counts to different numbers |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5444 | TEST_F(VkLayerTest, PSOViewportScissorCountMismatch) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5445 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5446 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5447 | m_errorMonitor->SetDesiredFailureMsg( |
| 5448 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5449 | "Gfx Pipeline viewport count (1) must match scissor count (0)."); |
| 5450 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5451 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5452 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5453 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5454 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5455 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5456 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5457 | |
| 5458 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5459 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5460 | ds_pool_ci.maxSets = 1; |
| 5461 | ds_pool_ci.poolSizeCount = 1; |
| 5462 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5463 | |
| 5464 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5465 | err = |
| 5466 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5467 | ASSERT_VK_SUCCESS(err); |
| 5468 | |
| 5469 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5470 | dsl_binding.binding = 0; |
| 5471 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5472 | dsl_binding.descriptorCount = 1; |
| 5473 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5474 | |
| 5475 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5476 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5477 | ds_layout_ci.bindingCount = 1; |
| 5478 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5479 | |
| 5480 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5481 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5482 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5483 | ASSERT_VK_SUCCESS(err); |
| 5484 | |
| 5485 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5486 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5487 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5488 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5489 | alloc_info.descriptorPool = ds_pool; |
| 5490 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5491 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5492 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5493 | ASSERT_VK_SUCCESS(err); |
| 5494 | |
| 5495 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5496 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5497 | pipeline_layout_ci.setLayoutCount = 1; |
| 5498 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5499 | |
| 5500 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5501 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5502 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5503 | ASSERT_VK_SUCCESS(err); |
| 5504 | |
| 5505 | VkViewport vp = {}; // Just need dummy vp to point to |
| 5506 | |
| 5507 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5508 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 5509 | vp_state_ci.scissorCount = 0; |
| 5510 | vp_state_ci.viewportCount = 1; // Count mismatch should cause error |
| 5511 | vp_state_ci.pViewports = &vp; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5512 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 5513 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 5514 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 5515 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 5516 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 5517 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 5518 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 5519 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 5520 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 5521 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 5522 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5523 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5524 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5525 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 5526 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5527 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 5528 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 5529 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5530 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5531 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 5532 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5533 | |
| 5534 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5535 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 5536 | gp_ci.stageCount = 2; |
| 5537 | gp_ci.pStages = shaderStages; |
| 5538 | gp_ci.pViewportState = &vp_state_ci; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 5539 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5540 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 5541 | gp_ci.layout = pipeline_layout; |
| 5542 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5543 | |
| 5544 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5545 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5546 | |
| 5547 | VkPipeline pipeline; |
| 5548 | VkPipelineCache pipelineCache; |
| 5549 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5550 | err = |
| 5551 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5552 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5553 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 5554 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5555 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5556 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5557 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5558 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 5559 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5560 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5561 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5562 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5563 | // Don't set viewport state in PSO. This is an error b/c we always need this |
| 5564 | // state |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 5565 | // 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] | 5566 | TEST_F(VkLayerTest, PSOViewportStateNotSet) { |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5567 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5568 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5569 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5570 | m_errorMonitor->SetDesiredFailureMsg( |
| 5571 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5572 | "Gfx Pipeline pViewportState is null. Even if "); |
| 5573 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5574 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5575 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5576 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5577 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5578 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5579 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5580 | |
| 5581 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5582 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5583 | ds_pool_ci.maxSets = 1; |
| 5584 | ds_pool_ci.poolSizeCount = 1; |
| 5585 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5586 | |
| 5587 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5588 | err = |
| 5589 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5590 | ASSERT_VK_SUCCESS(err); |
| 5591 | |
| 5592 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5593 | dsl_binding.binding = 0; |
| 5594 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5595 | dsl_binding.descriptorCount = 1; |
| 5596 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5597 | |
| 5598 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5599 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5600 | ds_layout_ci.bindingCount = 1; |
| 5601 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5602 | |
| 5603 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5604 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5605 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5606 | ASSERT_VK_SUCCESS(err); |
| 5607 | |
| 5608 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5609 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5610 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5611 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5612 | alloc_info.descriptorPool = ds_pool; |
| 5613 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5614 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5615 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5616 | ASSERT_VK_SUCCESS(err); |
| 5617 | |
| 5618 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5619 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5620 | pipeline_layout_ci.setLayoutCount = 1; |
| 5621 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5622 | |
| 5623 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5624 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5625 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5626 | ASSERT_VK_SUCCESS(err); |
| 5627 | |
| 5628 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 5629 | // Set scissor as dynamic to avoid second error |
| 5630 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5631 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 5632 | dyn_state_ci.dynamicStateCount = 1; |
| 5633 | dyn_state_ci.pDynamicStates = &sc_state; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5634 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 5635 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5636 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5637 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5638 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 5639 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5640 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 5641 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 5642 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5643 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5644 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 5645 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5646 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 5647 | |
| 5648 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 5649 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 5650 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 5651 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 5652 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 5653 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 5654 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 5655 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 5656 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5657 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5658 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 5659 | gp_ci.stageCount = 2; |
| 5660 | gp_ci.pStages = shaderStages; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 5661 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5662 | gp_ci.pViewportState = NULL; // Not setting VP state w/o dynamic vp state |
| 5663 | // should cause validation error |
| 5664 | gp_ci.pDynamicState = &dyn_state_ci; |
| 5665 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 5666 | gp_ci.layout = pipeline_layout; |
| 5667 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5668 | |
| 5669 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5670 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5671 | |
| 5672 | VkPipeline pipeline; |
| 5673 | VkPipelineCache pipelineCache; |
| 5674 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5675 | err = |
| 5676 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5677 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5678 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 5679 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5680 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5681 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5682 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5683 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 5684 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5685 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5686 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5687 | } |
| 5688 | // Create PSO w/o non-zero viewportCount but no viewport data |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5689 | // Then run second test where dynamic scissor count doesn't match PSO scissor |
| 5690 | // count |
| 5691 | TEST_F(VkLayerTest, PSOViewportCountWithoutDataAndDynScissorMismatch) { |
| 5692 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5693 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5694 | m_errorMonitor->SetDesiredFailureMsg( |
| 5695 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5696 | "Gfx Pipeline viewportCount is 1, but pViewports is NULL. "); |
| 5697 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5698 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5699 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5700 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5701 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5702 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5703 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5704 | |
| 5705 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5706 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5707 | ds_pool_ci.maxSets = 1; |
| 5708 | ds_pool_ci.poolSizeCount = 1; |
| 5709 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5710 | |
| 5711 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5712 | err = |
| 5713 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5714 | ASSERT_VK_SUCCESS(err); |
| 5715 | |
| 5716 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5717 | dsl_binding.binding = 0; |
| 5718 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5719 | dsl_binding.descriptorCount = 1; |
| 5720 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5721 | |
| 5722 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5723 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5724 | ds_layout_ci.bindingCount = 1; |
| 5725 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5726 | |
| 5727 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5728 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5729 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5730 | ASSERT_VK_SUCCESS(err); |
| 5731 | |
| 5732 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5733 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5734 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5735 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5736 | alloc_info.descriptorPool = ds_pool; |
| 5737 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5738 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5739 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5740 | ASSERT_VK_SUCCESS(err); |
| 5741 | |
| 5742 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5743 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5744 | pipeline_layout_ci.setLayoutCount = 1; |
| 5745 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5746 | |
| 5747 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5748 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5749 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5750 | ASSERT_VK_SUCCESS(err); |
| 5751 | |
| 5752 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5753 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 5754 | vp_state_ci.viewportCount = 1; |
| 5755 | vp_state_ci.pViewports = NULL; // Null vp w/ count of 1 should cause error |
| 5756 | vp_state_ci.scissorCount = 1; |
| 5757 | vp_state_ci.pScissors = |
| 5758 | NULL; // Scissor is dynamic (below) so this won't cause error |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5759 | |
| 5760 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 5761 | // Set scissor as dynamic to avoid that error |
| 5762 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5763 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 5764 | dyn_state_ci.dynamicStateCount = 1; |
| 5765 | dyn_state_ci.pDynamicStates = &sc_state; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5766 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 5767 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5768 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5769 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5770 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 5771 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5772 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 5773 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 5774 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5775 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5776 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 5777 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5778 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 5779 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 5780 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 5781 | vi_ci.pNext = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5782 | vi_ci.vertexBindingDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 5783 | vi_ci.pVertexBindingDescriptions = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5784 | vi_ci.vertexAttributeDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 5785 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 5786 | |
| 5787 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 5788 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 5789 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 5790 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5791 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5792 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 5793 | rs_ci.pNext = nullptr; |
| 5794 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 5795 | VkPipelineColorBlendAttachmentState att = {}; |
| 5796 | att.blendEnable = VK_FALSE; |
| 5797 | att.colorWriteMask = 0xf; |
| 5798 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 5799 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 5800 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 5801 | cb_ci.pNext = nullptr; |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 5802 | cb_ci.attachmentCount = 1; |
| 5803 | cb_ci.pAttachments = &att; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 5804 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5805 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5806 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 5807 | gp_ci.stageCount = 2; |
| 5808 | gp_ci.pStages = shaderStages; |
| 5809 | gp_ci.pVertexInputState = &vi_ci; |
| 5810 | gp_ci.pInputAssemblyState = &ia_ci; |
| 5811 | gp_ci.pViewportState = &vp_state_ci; |
| 5812 | gp_ci.pRasterizationState = &rs_ci; |
| 5813 | gp_ci.pColorBlendState = &cb_ci; |
| 5814 | gp_ci.pDynamicState = &dyn_state_ci; |
| 5815 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 5816 | gp_ci.layout = pipeline_layout; |
| 5817 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5818 | |
| 5819 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5820 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5821 | |
| 5822 | VkPipeline pipeline; |
| 5823 | VkPipelineCache pipelineCache; |
| 5824 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5825 | err = |
| 5826 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5827 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5828 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 5829 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 5830 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5831 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5832 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 5833 | // 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] | 5834 | // First need to successfully create the PSO from above by setting |
| 5835 | // pViewports |
| 5836 | m_errorMonitor->SetDesiredFailureMsg( |
| 5837 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5838 | "Dynamic scissorCount from vkCmdSetScissor() is 2, but PSO " |
| 5839 | "scissorCount is 1. These counts must match."); |
| 5840 | |
| 5841 | VkViewport vp = {}; // Just need dummy vp to point to |
| 5842 | vp_state_ci.pViewports = &vp; |
| 5843 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 5844 | &gp_ci, NULL, &pipeline); |
| 5845 | ASSERT_VK_SUCCESS(err); |
| 5846 | BeginCommandBuffer(); |
| 5847 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 5848 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
| 5849 | VkRect2D scissors[2] = {}; // don't care about data |
| 5850 | // Count of 2 doesn't match PSO count of 1 |
| 5851 | vkCmdSetScissor(m_commandBuffer->GetBufferHandle(), 0, 2, scissors); |
| 5852 | Draw(1, 0, 0, 0); |
| 5853 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5854 | m_errorMonitor->VerifyFound(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5855 | |
| 5856 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 5857 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5858 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5859 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 5860 | } |
| 5861 | // Create PSO w/o non-zero scissorCount but no scissor data |
| 5862 | // Then run second test where dynamic viewportCount doesn't match PSO |
| 5863 | // viewportCount |
| 5864 | TEST_F(VkLayerTest, PSOScissorCountWithoutDataAndDynViewportMismatch) { |
| 5865 | VkResult err; |
| 5866 | |
| 5867 | m_errorMonitor->SetDesiredFailureMsg( |
| 5868 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5869 | "Gfx Pipeline scissorCount is 1, but pScissors is NULL. "); |
| 5870 | |
| 5871 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5872 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5873 | |
| 5874 | VkDescriptorPoolSize ds_type_count = {}; |
| 5875 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5876 | ds_type_count.descriptorCount = 1; |
| 5877 | |
| 5878 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 5879 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5880 | ds_pool_ci.maxSets = 1; |
| 5881 | ds_pool_ci.poolSizeCount = 1; |
| 5882 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 5883 | |
| 5884 | VkDescriptorPool ds_pool; |
| 5885 | err = |
| 5886 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 5887 | ASSERT_VK_SUCCESS(err); |
| 5888 | |
| 5889 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 5890 | dsl_binding.binding = 0; |
| 5891 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5892 | dsl_binding.descriptorCount = 1; |
| 5893 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5894 | |
| 5895 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 5896 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5897 | ds_layout_ci.bindingCount = 1; |
| 5898 | ds_layout_ci.pBindings = &dsl_binding; |
| 5899 | |
| 5900 | VkDescriptorSetLayout ds_layout; |
| 5901 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5902 | &ds_layout); |
| 5903 | ASSERT_VK_SUCCESS(err); |
| 5904 | |
| 5905 | VkDescriptorSet descriptorSet; |
| 5906 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 5907 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 5908 | alloc_info.descriptorSetCount = 1; |
| 5909 | alloc_info.descriptorPool = ds_pool; |
| 5910 | alloc_info.pSetLayouts = &ds_layout; |
| 5911 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5912 | &descriptorSet); |
| 5913 | ASSERT_VK_SUCCESS(err); |
| 5914 | |
| 5915 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 5916 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5917 | pipeline_layout_ci.setLayoutCount = 1; |
| 5918 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 5919 | |
| 5920 | VkPipelineLayout pipeline_layout; |
| 5921 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5922 | &pipeline_layout); |
| 5923 | ASSERT_VK_SUCCESS(err); |
| 5924 | |
| 5925 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 5926 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 5927 | vp_state_ci.scissorCount = 1; |
| 5928 | vp_state_ci.pScissors = |
| 5929 | NULL; // Null scissor w/ count of 1 should cause error |
| 5930 | vp_state_ci.viewportCount = 1; |
| 5931 | vp_state_ci.pViewports = |
| 5932 | NULL; // vp is dynamic (below) so this won't cause error |
| 5933 | |
| 5934 | VkDynamicState vp_state = VK_DYNAMIC_STATE_VIEWPORT; |
| 5935 | // Set scissor as dynamic to avoid that error |
| 5936 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 5937 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 5938 | dyn_state_ci.dynamicStateCount = 1; |
| 5939 | dyn_state_ci.pDynamicStates = &vp_state; |
| 5940 | |
| 5941 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 5942 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 5943 | |
| 5944 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 5945 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5946 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 5947 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 5948 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5949 | // but add it to be able to run on more devices |
| 5950 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 5951 | shaderStages[1] = fs.GetStageCreateInfo(); |
| 5952 | |
| 5953 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 5954 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 5955 | vi_ci.pNext = nullptr; |
| 5956 | vi_ci.vertexBindingDescriptionCount = 0; |
| 5957 | vi_ci.pVertexBindingDescriptions = nullptr; |
| 5958 | vi_ci.vertexAttributeDescriptionCount = 0; |
| 5959 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 5960 | |
| 5961 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 5962 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 5963 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 5964 | |
| 5965 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
| 5966 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 5967 | rs_ci.pNext = nullptr; |
| 5968 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 5969 | VkPipelineColorBlendAttachmentState att = {}; |
| 5970 | att.blendEnable = VK_FALSE; |
| 5971 | att.colorWriteMask = 0xf; |
| 5972 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5973 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 5974 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 5975 | cb_ci.pNext = nullptr; |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 5976 | cb_ci.attachmentCount = 1; |
| 5977 | cb_ci.pAttachments = &att; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5978 | |
| 5979 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 5980 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 5981 | gp_ci.stageCount = 2; |
| 5982 | gp_ci.pStages = shaderStages; |
| 5983 | gp_ci.pVertexInputState = &vi_ci; |
| 5984 | gp_ci.pInputAssemblyState = &ia_ci; |
| 5985 | gp_ci.pViewportState = &vp_state_ci; |
| 5986 | gp_ci.pRasterizationState = &rs_ci; |
| 5987 | gp_ci.pColorBlendState = &cb_ci; |
| 5988 | gp_ci.pDynamicState = &dyn_state_ci; |
| 5989 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 5990 | gp_ci.layout = pipeline_layout; |
| 5991 | gp_ci.renderPass = renderPass(); |
| 5992 | |
| 5993 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 5994 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 5995 | |
| 5996 | VkPipeline pipeline; |
| 5997 | VkPipelineCache pipelineCache; |
| 5998 | |
| 5999 | err = |
| 6000 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 6001 | ASSERT_VK_SUCCESS(err); |
| 6002 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6003 | &gp_ci, NULL, &pipeline); |
| 6004 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6005 | m_errorMonitor->VerifyFound(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6006 | |
| 6007 | // Now hit second fail case where we set scissor w/ different count than PSO |
| 6008 | // First need to successfully create the PSO from above by setting |
| 6009 | // pViewports |
| 6010 | m_errorMonitor->SetDesiredFailureMsg( |
| 6011 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6012 | "Dynamic viewportCount from vkCmdSetViewport() is 2, but PSO " |
| 6013 | "viewportCount is 1. These counts must match."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6014 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6015 | VkRect2D sc = {}; // Just need dummy vp to point to |
| 6016 | vp_state_ci.pScissors = ≻ |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6017 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6018 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6019 | ASSERT_VK_SUCCESS(err); |
| 6020 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6021 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 6022 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6023 | VkViewport viewports[2] = {}; // don't care about data |
| 6024 | // Count of 2 doesn't match PSO count of 1 |
Jon Ashburn | 19d3bf1 | 2015-12-30 14:06:55 -0700 | [diff] [blame] | 6025 | vkCmdSetViewport(m_commandBuffer->GetBufferHandle(), 0, 2, viewports); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6026 | Draw(1, 0, 0, 0); |
| 6027 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6028 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6029 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6030 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 6031 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6032 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6033 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 6034 | } |
| 6035 | |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6036 | TEST_F(VkLayerTest, PSOLineWidthInvalid) { |
| 6037 | VkResult err; |
| 6038 | |
| 6039 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 6040 | "Attempt to set lineWidth to -1"); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6041 | |
| 6042 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6043 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6044 | |
| 6045 | VkDescriptorPoolSize ds_type_count = {}; |
| 6046 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6047 | ds_type_count.descriptorCount = 1; |
| 6048 | |
| 6049 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 6050 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6051 | ds_pool_ci.maxSets = 1; |
| 6052 | ds_pool_ci.poolSizeCount = 1; |
| 6053 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 6054 | |
| 6055 | VkDescriptorPool ds_pool; |
| 6056 | err = |
| 6057 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 6058 | ASSERT_VK_SUCCESS(err); |
| 6059 | |
| 6060 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 6061 | dsl_binding.binding = 0; |
| 6062 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6063 | dsl_binding.descriptorCount = 1; |
| 6064 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6065 | |
| 6066 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 6067 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6068 | ds_layout_ci.bindingCount = 1; |
| 6069 | ds_layout_ci.pBindings = &dsl_binding; |
| 6070 | |
| 6071 | VkDescriptorSetLayout ds_layout; |
| 6072 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6073 | &ds_layout); |
| 6074 | ASSERT_VK_SUCCESS(err); |
| 6075 | |
| 6076 | VkDescriptorSet descriptorSet; |
| 6077 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 6078 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 6079 | alloc_info.descriptorSetCount = 1; |
| 6080 | alloc_info.descriptorPool = ds_pool; |
| 6081 | alloc_info.pSetLayouts = &ds_layout; |
| 6082 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6083 | &descriptorSet); |
| 6084 | ASSERT_VK_SUCCESS(err); |
| 6085 | |
| 6086 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 6087 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6088 | pipeline_layout_ci.setLayoutCount = 1; |
| 6089 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 6090 | |
| 6091 | VkPipelineLayout pipeline_layout; |
| 6092 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6093 | &pipeline_layout); |
| 6094 | ASSERT_VK_SUCCESS(err); |
| 6095 | |
| 6096 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 6097 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 6098 | vp_state_ci.scissorCount = 1; |
| 6099 | vp_state_ci.pScissors = NULL; |
| 6100 | vp_state_ci.viewportCount = 1; |
| 6101 | vp_state_ci.pViewports = NULL; |
| 6102 | |
| 6103 | VkDynamicState dynamic_states[3] = {VK_DYNAMIC_STATE_VIEWPORT, |
| 6104 | VK_DYNAMIC_STATE_SCISSOR, |
| 6105 | VK_DYNAMIC_STATE_LINE_WIDTH}; |
| 6106 | // Set scissor as dynamic to avoid that error |
| 6107 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 6108 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 6109 | dyn_state_ci.dynamicStateCount = 2; |
| 6110 | dyn_state_ci.pDynamicStates = dynamic_states; |
| 6111 | |
| 6112 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 6113 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 6114 | |
| 6115 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6116 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6117 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6118 | VK_SHADER_STAGE_FRAGMENT_BIT, |
| 6119 | this); // TODO - We shouldn't need a fragment shader |
| 6120 | // but add it to be able to run on more devices |
| 6121 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 6122 | shaderStages[1] = fs.GetStageCreateInfo(); |
| 6123 | |
| 6124 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 6125 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 6126 | vi_ci.pNext = nullptr; |
| 6127 | vi_ci.vertexBindingDescriptionCount = 0; |
| 6128 | vi_ci.pVertexBindingDescriptions = nullptr; |
| 6129 | vi_ci.vertexAttributeDescriptionCount = 0; |
| 6130 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 6131 | |
| 6132 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 6133 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 6134 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 6135 | |
| 6136 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
| 6137 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 6138 | rs_ci.pNext = nullptr; |
| 6139 | |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 6140 | // Check too low (line width of -1.0f). |
| 6141 | rs_ci.lineWidth = -1.0f; |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6142 | |
| 6143 | VkPipelineColorBlendAttachmentState att = {}; |
| 6144 | att.blendEnable = VK_FALSE; |
| 6145 | att.colorWriteMask = 0xf; |
| 6146 | |
| 6147 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 6148 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 6149 | cb_ci.pNext = nullptr; |
| 6150 | cb_ci.attachmentCount = 1; |
| 6151 | cb_ci.pAttachments = &att; |
| 6152 | |
| 6153 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 6154 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 6155 | gp_ci.stageCount = 2; |
| 6156 | gp_ci.pStages = shaderStages; |
| 6157 | gp_ci.pVertexInputState = &vi_ci; |
| 6158 | gp_ci.pInputAssemblyState = &ia_ci; |
| 6159 | gp_ci.pViewportState = &vp_state_ci; |
| 6160 | gp_ci.pRasterizationState = &rs_ci; |
| 6161 | gp_ci.pColorBlendState = &cb_ci; |
| 6162 | gp_ci.pDynamicState = &dyn_state_ci; |
| 6163 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 6164 | gp_ci.layout = pipeline_layout; |
| 6165 | gp_ci.renderPass = renderPass(); |
| 6166 | |
| 6167 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 6168 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 6169 | |
| 6170 | VkPipeline pipeline; |
| 6171 | VkPipelineCache pipelineCache; |
| 6172 | |
| 6173 | err = |
| 6174 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 6175 | ASSERT_VK_SUCCESS(err); |
| 6176 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6177 | &gp_ci, NULL, &pipeline); |
| 6178 | |
| 6179 | m_errorMonitor->VerifyFound(); |
| 6180 | |
| 6181 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6182 | "Attempt to set lineWidth to 65536"); |
| 6183 | |
| 6184 | // Check too high (line width of 65536.0f). |
| 6185 | rs_ci.lineWidth = 65536.0f; |
| 6186 | |
| 6187 | err = |
| 6188 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 6189 | ASSERT_VK_SUCCESS(err); |
| 6190 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6191 | &gp_ci, NULL, &pipeline); |
| 6192 | |
| 6193 | m_errorMonitor->VerifyFound(); |
| 6194 | |
| 6195 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 6196 | "Attempt to set lineWidth to -1"); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6197 | |
| 6198 | dyn_state_ci.dynamicStateCount = 3; |
| 6199 | |
| 6200 | rs_ci.lineWidth = 1.0f; |
| 6201 | |
| 6202 | err = |
| 6203 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 6204 | ASSERT_VK_SUCCESS(err); |
| 6205 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 6206 | &gp_ci, NULL, &pipeline); |
| 6207 | BeginCommandBuffer(); |
| 6208 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 6209 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
| 6210 | |
| 6211 | // Check too low with dynamic setting. |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 6212 | vkCmdSetLineWidth(m_commandBuffer->GetBufferHandle(), -1.0f); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 6213 | m_errorMonitor->VerifyFound(); |
| 6214 | |
| 6215 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6216 | "Attempt to set lineWidth to 65536"); |
| 6217 | |
| 6218 | // Check too high with dynamic setting. |
| 6219 | vkCmdSetLineWidth(m_commandBuffer->GetBufferHandle(), 65536.0f); |
| 6220 | m_errorMonitor->VerifyFound(); |
| 6221 | EndCommandBuffer(); |
| 6222 | |
| 6223 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 6224 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6225 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6226 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 6227 | } |
| 6228 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6229 | TEST_F(VkLayerTest, NullRenderPass) { |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 6230 | // Bind a NULL RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6231 | m_errorMonitor->SetDesiredFailureMsg( |
| 6232 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6233 | "You cannot use a NULL RenderPass object in vkCmdBeginRenderPass()"); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 6234 | |
| 6235 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6236 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 6237 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 6238 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6239 | // Don't care about RenderPass handle b/c error should be flagged before |
| 6240 | // that |
| 6241 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), NULL, |
| 6242 | VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 6243 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6244 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 6245 | } |
| 6246 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6247 | TEST_F(VkLayerTest, RenderPassWithinRenderPass) { |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6248 | // Bind a BeginRenderPass within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6249 | m_errorMonitor->SetDesiredFailureMsg( |
| 6250 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6251 | "It is invalid to issue this call inside an active render pass"); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6252 | |
| 6253 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6254 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6255 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 6256 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6257 | // Just create a dummy Renderpass that's non-NULL so we can get to the |
| 6258 | // proper error |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6259 | VkRenderPassBeginInfo rp_begin = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6260 | rp_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; |
| 6261 | rp_begin.pNext = NULL; |
| 6262 | rp_begin.renderPass = renderPass(); |
| 6263 | rp_begin.framebuffer = framebuffer(); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6264 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6265 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &rp_begin, |
| 6266 | VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 6267 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6268 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 6269 | } |
| 6270 | |
Cody Northrop | 3bb4d96 | 2016-05-09 16:15:57 -0600 | [diff] [blame] | 6271 | TEST_F(VkLayerTest, EndCommandBufferWithinRenderPass) { |
| 6272 | |
| 6273 | TEST_DESCRIPTION("End a command buffer with an active render pass"); |
| 6274 | |
| 6275 | m_errorMonitor->SetDesiredFailureMsg( |
| 6276 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6277 | "It is invalid to issue this call inside an active render pass"); |
| 6278 | |
| 6279 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6280 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6281 | |
| 6282 | // The framework's BeginCommandBuffer calls CreateRenderPass |
| 6283 | BeginCommandBuffer(); |
| 6284 | |
| 6285 | // Call directly into vkEndCommandBuffer instead of the |
| 6286 | // the framework's EndCommandBuffer, which inserts a |
| 6287 | // vkEndRenderPass |
| 6288 | vkEndCommandBuffer(m_commandBuffer->GetBufferHandle()); |
| 6289 | |
| 6290 | m_errorMonitor->VerifyFound(); |
| 6291 | |
| 6292 | // TODO: Add test for VK_COMMAND_BUFFER_LEVEL_SECONDARY |
| 6293 | // TODO: Add test for VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT |
| 6294 | } |
| 6295 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6296 | TEST_F(VkLayerTest, FillBufferWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6297 | // Call CmdFillBuffer within an active renderpass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6298 | m_errorMonitor->SetDesiredFailureMsg( |
| 6299 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6300 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6301 | |
| 6302 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6303 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6304 | |
| 6305 | // Renderpass is started here |
| 6306 | BeginCommandBuffer(); |
| 6307 | |
| 6308 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6309 | vk_testing::Buffer dstBuffer; |
| 6310 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6311 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6312 | m_commandBuffer->FillBuffer(dstBuffer.handle(), 0, 4, 0x11111111); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6313 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6314 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6315 | } |
| 6316 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6317 | TEST_F(VkLayerTest, UpdateBufferWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6318 | // Call CmdUpdateBuffer within an active renderpass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6319 | m_errorMonitor->SetDesiredFailureMsg( |
| 6320 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6321 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6322 | |
| 6323 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6324 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6325 | |
| 6326 | // Renderpass is started here |
| 6327 | BeginCommandBuffer(); |
| 6328 | |
| 6329 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6330 | vk_testing::Buffer dstBuffer; |
| 6331 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6332 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6333 | VkDeviceSize dstOffset = 0; |
| 6334 | VkDeviceSize dataSize = 1024; |
| 6335 | const uint32_t *pData = NULL; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6336 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6337 | vkCmdUpdateBuffer(m_commandBuffer->GetBufferHandle(), dstBuffer.handle(), |
| 6338 | dstOffset, dataSize, pData); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6339 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6340 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6341 | } |
| 6342 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6343 | TEST_F(VkLayerTest, ClearColorImageWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6344 | // Call CmdClearColorImage within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6345 | m_errorMonitor->SetDesiredFailureMsg( |
| 6346 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6347 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6348 | |
| 6349 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6350 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6351 | |
| 6352 | // Renderpass is started here |
| 6353 | BeginCommandBuffer(); |
| 6354 | |
Michael Lentine | 0a369f6 | 2016-02-03 16:51:46 -0600 | [diff] [blame] | 6355 | VkClearColorValue clear_color; |
| 6356 | memset(clear_color.uint32, 0, sizeof(uint32_t) * 4); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6357 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 6358 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6359 | const int32_t tex_width = 32; |
| 6360 | const int32_t tex_height = 32; |
| 6361 | VkImageCreateInfo image_create_info = {}; |
| 6362 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6363 | image_create_info.pNext = NULL; |
| 6364 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6365 | image_create_info.format = tex_format; |
| 6366 | image_create_info.extent.width = tex_width; |
| 6367 | image_create_info.extent.height = tex_height; |
| 6368 | image_create_info.extent.depth = 1; |
| 6369 | image_create_info.mipLevels = 1; |
| 6370 | image_create_info.arrayLayers = 1; |
| 6371 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 6372 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 6373 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6374 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6375 | vk_testing::Image dstImage; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6376 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 6377 | reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6378 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6379 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
| 6380 | image_create_info, VK_IMAGE_ASPECT_COLOR_BIT); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6381 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6382 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), dstImage.handle(), |
| 6383 | VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1, &range); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6384 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6385 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6386 | } |
| 6387 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6388 | TEST_F(VkLayerTest, ClearDepthStencilImageWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6389 | // Call CmdClearDepthStencilImage within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6390 | m_errorMonitor->SetDesiredFailureMsg( |
| 6391 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6392 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6393 | |
| 6394 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6395 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6396 | |
| 6397 | // Renderpass is started here |
| 6398 | BeginCommandBuffer(); |
| 6399 | |
| 6400 | VkClearDepthStencilValue clear_value = {0}; |
Dustin Graves | a2e5c94 | 2016-02-11 18:28:06 -0700 | [diff] [blame] | 6401 | VkMemoryPropertyFlags reqs = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6402 | VkImageCreateInfo image_create_info = vk_testing::Image::create_info(); |
| 6403 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6404 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 6405 | image_create_info.extent.width = 64; |
| 6406 | image_create_info.extent.height = 64; |
| 6407 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 6408 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6409 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6410 | vk_testing::Image dstImage; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6411 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 6412 | reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6413 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6414 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
| 6415 | image_create_info, VK_IMAGE_ASPECT_DEPTH_BIT); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6416 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6417 | vkCmdClearDepthStencilImage( |
| 6418 | m_commandBuffer->GetBufferHandle(), dstImage.handle(), |
| 6419 | VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, &clear_value, 1, |
| 6420 | &range); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6421 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6422 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6423 | } |
| 6424 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6425 | TEST_F(VkLayerTest, ClearColorAttachmentsOutsideRenderPass) { |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 6426 | // Call CmdClearAttachmentss outside of an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6427 | VkResult err; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6428 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6429 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6430 | "vkCmdClearAttachments: This call " |
| 6431 | "must be issued inside an active " |
| 6432 | "render pass"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6433 | |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6434 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6435 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6436 | |
| 6437 | // Start no RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6438 | err = m_commandBuffer->BeginCommandBuffer(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6439 | ASSERT_VK_SUCCESS(err); |
| 6440 | |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 6441 | VkClearAttachment color_attachment; |
| 6442 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 6443 | color_attachment.clearValue.color.float32[0] = 0; |
| 6444 | color_attachment.clearValue.color.float32[1] = 0; |
| 6445 | color_attachment.clearValue.color.float32[2] = 0; |
| 6446 | color_attachment.clearValue.color.float32[3] = 0; |
| 6447 | color_attachment.colorAttachment = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6448 | VkClearRect clear_rect = {{{0, 0}, {32, 32}}}; |
| 6449 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
| 6450 | &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6451 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6452 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 6453 | } |
| 6454 | |
Karl Schultz | 9e66a29 | 2016-04-21 15:57:51 -0600 | [diff] [blame] | 6455 | TEST_F(VkLayerTest, BufferMemoryBarrierNoBuffer) { |
| 6456 | // Try to add a buffer memory barrier with no buffer. |
| 6457 | m_errorMonitor->SetDesiredFailureMsg( |
| 6458 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6459 | "required parameter pBufferMemoryBarriers[i].buffer specified as VK_NULL_HANDLE"); |
| 6460 | |
| 6461 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6462 | BeginCommandBuffer(); |
| 6463 | |
| 6464 | VkBufferMemoryBarrier buf_barrier = {}; |
| 6465 | buf_barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; |
| 6466 | buf_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 6467 | buf_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 6468 | buf_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 6469 | buf_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 6470 | buf_barrier.buffer = VK_NULL_HANDLE; |
| 6471 | buf_barrier.offset = 0; |
| 6472 | buf_barrier.size = VK_WHOLE_SIZE; |
| 6473 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6474 | VK_PIPELINE_STAGE_HOST_BIT, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, |
| 6475 | 0, 0, nullptr, 1, &buf_barrier, 0, nullptr); |
| 6476 | |
| 6477 | m_errorMonitor->VerifyFound(); |
| 6478 | } |
| 6479 | |
Tony Barbour | 7fd5c0f | 2016-05-03 16:11:53 -0600 | [diff] [blame] | 6480 | TEST_F(VkLayerTest, InvalidBarriers) { |
| 6481 | TEST_DESCRIPTION("A variety of ways to get VK_INVALID_BARRIER "); |
| 6482 | |
| 6483 | m_errorMonitor->SetDesiredFailureMsg( |
| 6484 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Barriers cannot be set during subpass"); |
| 6485 | |
| 6486 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6487 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6488 | |
| 6489 | VkMemoryBarrier mem_barrier = {}; |
| 6490 | mem_barrier.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER; |
| 6491 | mem_barrier.pNext = NULL; |
| 6492 | mem_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 6493 | mem_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 6494 | BeginCommandBuffer(); |
| 6495 | // BeginCommandBuffer() starts a render pass |
| 6496 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6497 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6498 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 1, |
| 6499 | &mem_barrier, 0, nullptr, 0, nullptr); |
| 6500 | m_errorMonitor->VerifyFound(); |
| 6501 | |
| 6502 | m_errorMonitor->SetDesiredFailureMsg( |
| 6503 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6504 | "Image Layout cannot be transitioned to UNDEFINED"); |
| 6505 | VkImageObj image(m_device); |
| 6506 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 6507 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
| 6508 | ASSERT_TRUE(image.initialized()); |
| 6509 | VkImageMemoryBarrier img_barrier = {}; |
| 6510 | img_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; |
| 6511 | img_barrier.pNext = NULL; |
| 6512 | img_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 6513 | img_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 6514 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 6515 | // New layout can't be UNDEFINED |
| 6516 | img_barrier.newLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 6517 | img_barrier.image = image.handle(); |
| 6518 | img_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 6519 | img_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 6520 | img_barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 6521 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 6522 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 6523 | img_barrier.subresourceRange.layerCount = 1; |
| 6524 | img_barrier.subresourceRange.levelCount = 1; |
| 6525 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6526 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6527 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 6528 | nullptr, 1, &img_barrier); |
| 6529 | m_errorMonitor->VerifyFound(); |
| 6530 | img_barrier.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 6531 | |
| 6532 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6533 | "Subresource must have the sum of the " |
| 6534 | "baseArrayLayer"); |
| 6535 | // baseArrayLayer + layerCount must be <= image's arrayLayers |
| 6536 | img_barrier.subresourceRange.baseArrayLayer = 1; |
| 6537 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6538 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6539 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 6540 | nullptr, 1, &img_barrier); |
| 6541 | m_errorMonitor->VerifyFound(); |
| 6542 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 6543 | |
| 6544 | m_errorMonitor->SetDesiredFailureMsg( |
| 6545 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6546 | "Subresource must have the sum of the baseMipLevel"); |
| 6547 | // baseMipLevel + levelCount must be <= image's mipLevels |
| 6548 | img_barrier.subresourceRange.baseMipLevel = 1; |
| 6549 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6550 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6551 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 6552 | nullptr, 1, &img_barrier); |
| 6553 | m_errorMonitor->VerifyFound(); |
| 6554 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 6555 | |
| 6556 | m_errorMonitor->SetDesiredFailureMsg( |
| 6557 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6558 | "Buffer Barriers cannot be used during a render pass"); |
| 6559 | vk_testing::Buffer buffer; |
| 6560 | buffer.init(*m_device, 256); |
| 6561 | VkBufferMemoryBarrier buf_barrier = {}; |
| 6562 | buf_barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; |
| 6563 | buf_barrier.pNext = NULL; |
| 6564 | buf_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 6565 | buf_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 6566 | buf_barrier.buffer = buffer.handle(); |
| 6567 | buf_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 6568 | buf_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 6569 | buf_barrier.offset = 0; |
| 6570 | buf_barrier.size = VK_WHOLE_SIZE; |
| 6571 | // Can't send buffer barrier during a render pass |
| 6572 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6573 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6574 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 6575 | &buf_barrier, 0, nullptr); |
| 6576 | m_errorMonitor->VerifyFound(); |
| 6577 | vkCmdEndRenderPass(m_commandBuffer->GetBufferHandle()); |
| 6578 | |
| 6579 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6580 | "which is not less than total size"); |
| 6581 | buf_barrier.offset = 257; |
| 6582 | // Offset greater than total size |
| 6583 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6584 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6585 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 6586 | &buf_barrier, 0, nullptr); |
| 6587 | m_errorMonitor->VerifyFound(); |
| 6588 | buf_barrier.offset = 0; |
| 6589 | |
| 6590 | m_errorMonitor->SetDesiredFailureMsg( |
| 6591 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "whose sum is greater than total size"); |
| 6592 | buf_barrier.size = 257; |
| 6593 | // Size greater than total size |
| 6594 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6595 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6596 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 6597 | &buf_barrier, 0, nullptr); |
| 6598 | m_errorMonitor->VerifyFound(); |
| 6599 | buf_barrier.size = VK_WHOLE_SIZE; |
| 6600 | |
| 6601 | m_errorMonitor->SetDesiredFailureMsg( |
| 6602 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6603 | "Image is a depth and stencil format and thus must " |
| 6604 | "have both VK_IMAGE_ASPECT_DEPTH_BIT and " |
| 6605 | "VK_IMAGE_ASPECT_STENCIL_BIT set."); |
| 6606 | VkDepthStencilObj ds_image(m_device); |
| 6607 | ds_image.Init(m_device, 128, 128, VK_FORMAT_D24_UNORM_S8_UINT); |
| 6608 | ASSERT_TRUE(ds_image.initialized()); |
| 6609 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 6610 | img_barrier.newLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; |
| 6611 | img_barrier.image = ds_image.handle(); |
| 6612 | // Leave aspectMask at COLOR on purpose |
| 6613 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 6614 | VK_PIPELINE_STAGE_HOST_BIT, |
| 6615 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 6616 | nullptr, 1, &img_barrier); |
| 6617 | m_errorMonitor->VerifyFound(); |
| 6618 | } |
| 6619 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6620 | TEST_F(VkLayerTest, IdxBufferAlignmentError) { |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 6621 | // Bind a BeginRenderPass within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6622 | VkResult err; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 6623 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6624 | m_errorMonitor->SetDesiredFailureMsg( |
| 6625 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6626 | "vkCmdBindIndexBuffer() offset (0x7) does not fall on "); |
| 6627 | |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 6628 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6629 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 6630 | uint32_t qfi = 0; |
| 6631 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6632 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 6633 | buffCI.size = 1024; |
| 6634 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
| 6635 | buffCI.queueFamilyIndexCount = 1; |
| 6636 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 6637 | |
| 6638 | VkBuffer ib; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6639 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 6640 | ASSERT_VK_SUCCESS(err); |
| 6641 | |
| 6642 | BeginCommandBuffer(); |
| 6643 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6644 | // vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 6645 | // VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 6646 | // 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] | 6647 | vkCmdBindIndexBuffer(m_commandBuffer->GetBufferHandle(), ib, 7, |
| 6648 | VK_INDEX_TYPE_UINT16); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 6649 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6650 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 6651 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6652 | vkDestroyBuffer(m_device->device(), ib, NULL); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 6653 | } |
| 6654 | |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 6655 | TEST_F(VkLayerTest, InvalidQueueFamilyIndex) { |
| 6656 | // Create an out-of-range queueFamilyIndex |
| 6657 | m_errorMonitor->SetDesiredFailureMsg( |
| 6658 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Dustin Graves | de62853 | 2016-04-21 16:30:17 -0600 | [diff] [blame] | 6659 | "vkCreateBuffer: pCreateInfo->pQueueFamilyIndices[0] (777) must be one " |
| 6660 | "of the indices specified when the device was created, via the " |
| 6661 | "VkDeviceQueueCreateInfo structure."); |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 6662 | |
| 6663 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6664 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6665 | VkBufferCreateInfo buffCI = {}; |
| 6666 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 6667 | buffCI.size = 1024; |
| 6668 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
| 6669 | buffCI.queueFamilyIndexCount = 1; |
| 6670 | // Introduce failure by specifying invalid queue_family_index |
| 6671 | uint32_t qfi = 777; |
| 6672 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 6673 | buffCI.sharingMode = VK_SHARING_MODE_CONCURRENT; // qfi only matters in CONCURRENT mode |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 6674 | |
| 6675 | VkBuffer ib; |
| 6676 | vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
| 6677 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6678 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 6679 | } |
| 6680 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6681 | TEST_F(VkLayerTest, ExecuteCommandsPrimaryCB) { |
| 6682 | // Attempt vkCmdExecuteCommands w/ a primary cmd buffer (should only be |
| 6683 | // secondary) |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6684 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6685 | m_errorMonitor->SetDesiredFailureMsg( |
| 6686 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6687 | "vkCmdExecuteCommands() called w/ Primary Cmd Buffer "); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 6688 | |
| 6689 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6690 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 6691 | |
| 6692 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6693 | // ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6694 | VkCommandBuffer primCB = m_commandBuffer->GetBufferHandle(); |
| 6695 | vkCmdExecuteCommands(m_commandBuffer->GetBufferHandle(), 1, &primCB); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 6696 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6697 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 6698 | } |
| 6699 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6700 | TEST_F(VkLayerTest, DSTypeMismatch) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 6701 | // 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] | 6702 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6703 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6704 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 6705 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6706 | " binding #0 with type VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER but update " |
| 6707 | "type is VK_DESCRIPTOR_TYPE_SAMPLER"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6708 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6709 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6710 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6711 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6712 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6713 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6714 | |
| 6715 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6716 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6717 | ds_pool_ci.pNext = NULL; |
| 6718 | ds_pool_ci.maxSets = 1; |
| 6719 | ds_pool_ci.poolSizeCount = 1; |
| 6720 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6721 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6722 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6723 | err = |
| 6724 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6725 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6726 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6727 | dsl_binding.binding = 0; |
| 6728 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6729 | dsl_binding.descriptorCount = 1; |
| 6730 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6731 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6732 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6733 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6734 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6735 | ds_layout_ci.pNext = NULL; |
| 6736 | ds_layout_ci.bindingCount = 1; |
| 6737 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6738 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6739 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6740 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6741 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6742 | ASSERT_VK_SUCCESS(err); |
| 6743 | |
| 6744 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6745 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6746 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6747 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 6748 | alloc_info.descriptorPool = ds_pool; |
| 6749 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6750 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6751 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6752 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6753 | |
Tobin Ehlis | 30db8f8 | 2016-05-05 08:19:48 -0600 | [diff] [blame] | 6754 | VkSamplerCreateInfo sampler_ci = {}; |
| 6755 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 6756 | sampler_ci.pNext = NULL; |
| 6757 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 6758 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 6759 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 6760 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 6761 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 6762 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 6763 | sampler_ci.mipLodBias = 1.0; |
| 6764 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 6765 | sampler_ci.maxAnisotropy = 1; |
| 6766 | sampler_ci.compareEnable = VK_FALSE; |
| 6767 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 6768 | sampler_ci.minLod = 1.0; |
| 6769 | sampler_ci.maxLod = 1.0; |
| 6770 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 6771 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
| 6772 | VkSampler sampler; |
| 6773 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
| 6774 | ASSERT_VK_SUCCESS(err); |
| 6775 | |
| 6776 | VkDescriptorImageInfo info = {}; |
| 6777 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 6778 | |
| 6779 | VkWriteDescriptorSet descriptor_write; |
| 6780 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 6781 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6782 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6783 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6784 | // This is a mismatched type for the layout which expects BUFFER |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 6785 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 6786 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 6787 | |
| 6788 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 6789 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6790 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 6791 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6792 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 6793 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6794 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 6795 | } |
| 6796 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6797 | TEST_F(VkLayerTest, DSUpdateOutOfBounds) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 6798 | // For overlapping Update, have arrayIndex exceed that of layout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6799 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6800 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6801 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 6802 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6803 | " binding #0 with 1 total descriptors but update of 1 descriptors " |
| 6804 | "starting at binding offset of 0 combined with update array element " |
| 6805 | "offset of 1 oversteps the size of this descriptor set."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6806 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6807 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6808 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6809 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6810 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6811 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6812 | |
| 6813 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6814 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6815 | ds_pool_ci.pNext = NULL; |
| 6816 | ds_pool_ci.maxSets = 1; |
| 6817 | ds_pool_ci.poolSizeCount = 1; |
| 6818 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6819 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6820 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6821 | err = |
| 6822 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6823 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6824 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6825 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6826 | dsl_binding.binding = 0; |
| 6827 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6828 | dsl_binding.descriptorCount = 1; |
| 6829 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6830 | dsl_binding.pImmutableSamplers = NULL; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6831 | |
| 6832 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6833 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6834 | ds_layout_ci.pNext = NULL; |
| 6835 | ds_layout_ci.bindingCount = 1; |
| 6836 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6837 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6838 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6839 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6840 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6841 | ASSERT_VK_SUCCESS(err); |
| 6842 | |
| 6843 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6844 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6845 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6846 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 6847 | alloc_info.descriptorPool = ds_pool; |
| 6848 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6849 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6850 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6851 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6852 | |
Tobin Ehlis | 30db8f8 | 2016-05-05 08:19:48 -0600 | [diff] [blame] | 6853 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 6854 | VkDescriptorBufferInfo buff_info = {}; |
| 6855 | buff_info.buffer = |
| 6856 | VkBuffer(0); // Don't care about buffer handle for this test |
| 6857 | buff_info.offset = 0; |
| 6858 | buff_info.range = 1024; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 6859 | |
| 6860 | VkWriteDescriptorSet descriptor_write; |
| 6861 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 6862 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6863 | descriptor_write.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6864 | descriptor_write.dstArrayElement = |
| 6865 | 1; /* This index out of bounds for the update */ |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6866 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 6867 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6868 | descriptor_write.pBufferInfo = &buff_info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 6869 | |
| 6870 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 6871 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6872 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 6873 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6874 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6875 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 6876 | } |
| 6877 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6878 | TEST_F(VkLayerTest, InvalidDSUpdateIndex) { |
| 6879 | // Create layout w/ count of 1 and attempt update to that layout w/ binding |
| 6880 | // index 2 |
| 6881 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6882 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 6883 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6884 | " does not have binding 2."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6885 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6886 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6887 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6888 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6889 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6890 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6891 | |
| 6892 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6893 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6894 | ds_pool_ci.pNext = NULL; |
| 6895 | ds_pool_ci.maxSets = 1; |
| 6896 | ds_pool_ci.poolSizeCount = 1; |
| 6897 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 6898 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6899 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6900 | err = |
| 6901 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6902 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6903 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6904 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6905 | dsl_binding.binding = 0; |
| 6906 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6907 | dsl_binding.descriptorCount = 1; |
| 6908 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6909 | dsl_binding.pImmutableSamplers = NULL; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6910 | |
| 6911 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6912 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6913 | ds_layout_ci.pNext = NULL; |
| 6914 | ds_layout_ci.bindingCount = 1; |
| 6915 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6916 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6917 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6918 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6919 | ASSERT_VK_SUCCESS(err); |
| 6920 | |
| 6921 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6922 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6923 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6924 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 6925 | alloc_info.descriptorPool = ds_pool; |
| 6926 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6927 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6928 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6929 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6930 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6931 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6932 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 6933 | sampler_ci.pNext = NULL; |
| 6934 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 6935 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 6936 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 6937 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 6938 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 6939 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 6940 | sampler_ci.mipLodBias = 1.0; |
| 6941 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 6942 | sampler_ci.maxAnisotropy = 1; |
| 6943 | sampler_ci.compareEnable = VK_FALSE; |
| 6944 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 6945 | sampler_ci.minLod = 1.0; |
| 6946 | sampler_ci.maxLod = 1.0; |
| 6947 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 6948 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6949 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6950 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6951 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6952 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 6953 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 6954 | VkDescriptorImageInfo info = {}; |
| 6955 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 6956 | |
| 6957 | VkWriteDescriptorSet descriptor_write; |
| 6958 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 6959 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6960 | descriptor_write.dstSet = descriptorSet; |
| 6961 | descriptor_write.dstBinding = 2; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6962 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6963 | // 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] | 6964 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 6965 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 6966 | |
| 6967 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 6968 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6969 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 6970 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6971 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 6972 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6973 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 6974 | } |
| 6975 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6976 | TEST_F(VkLayerTest, InvalidDSUpdateStruct) { |
| 6977 | // Call UpdateDS w/ struct type other than valid VK_STRUCTUR_TYPE_UPDATE_* |
| 6978 | // types |
| 6979 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6980 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6981 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6982 | "Unexpected UPDATE struct of type "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6983 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6984 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6985 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6986 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6987 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6988 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6989 | |
| 6990 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6991 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6992 | ds_pool_ci.pNext = NULL; |
| 6993 | ds_pool_ci.maxSets = 1; |
| 6994 | ds_pool_ci.poolSizeCount = 1; |
| 6995 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 6996 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6997 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6998 | err = |
| 6999 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7000 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7001 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7002 | dsl_binding.binding = 0; |
| 7003 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7004 | dsl_binding.descriptorCount = 1; |
| 7005 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7006 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7007 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7008 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7009 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7010 | ds_layout_ci.pNext = NULL; |
| 7011 | ds_layout_ci.bindingCount = 1; |
| 7012 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7013 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7014 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7015 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7016 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7017 | ASSERT_VK_SUCCESS(err); |
| 7018 | |
| 7019 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7020 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7021 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7022 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 7023 | alloc_info.descriptorPool = ds_pool; |
| 7024 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7025 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7026 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7027 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7028 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7029 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7030 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 7031 | sampler_ci.pNext = NULL; |
| 7032 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 7033 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 7034 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 7035 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7036 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7037 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7038 | sampler_ci.mipLodBias = 1.0; |
| 7039 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 7040 | sampler_ci.maxAnisotropy = 1; |
| 7041 | sampler_ci.compareEnable = VK_FALSE; |
| 7042 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 7043 | sampler_ci.minLod = 1.0; |
| 7044 | sampler_ci.maxLod = 1.0; |
| 7045 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 7046 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7047 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7048 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7049 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7050 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 7051 | VkDescriptorImageInfo info = {}; |
| 7052 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7053 | |
| 7054 | VkWriteDescriptorSet descriptor_write; |
| 7055 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7056 | descriptor_write.sType = |
| 7057 | (VkStructureType)0x99999999; /* Intentionally broken struct type */ |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7058 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7059 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7060 | // 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] | 7061 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 7062 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 7063 | |
| 7064 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 7065 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7066 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7067 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7068 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 7069 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7070 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 7071 | } |
| 7072 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7073 | TEST_F(VkLayerTest, SampleDescriptorUpdateError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7074 | // Create a single Sampler descriptor and send it an invalid Sampler |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7075 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7076 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7077 | m_errorMonitor->SetDesiredFailureMsg( |
| 7078 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7079 | "Attempted write update to sampler descriptor with invalid sampler"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7080 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7081 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7082 | // TODO : Farm Descriptor setup code to helper function(s) to reduce copied |
| 7083 | // code |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7084 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7085 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 7086 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7087 | |
| 7088 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7089 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7090 | ds_pool_ci.pNext = NULL; |
| 7091 | ds_pool_ci.maxSets = 1; |
| 7092 | ds_pool_ci.poolSizeCount = 1; |
| 7093 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7094 | |
| 7095 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7096 | err = |
| 7097 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7098 | ASSERT_VK_SUCCESS(err); |
| 7099 | |
| 7100 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7101 | dsl_binding.binding = 0; |
| 7102 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 7103 | dsl_binding.descriptorCount = 1; |
| 7104 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7105 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7106 | |
| 7107 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7108 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7109 | ds_layout_ci.pNext = NULL; |
| 7110 | ds_layout_ci.bindingCount = 1; |
| 7111 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7112 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7113 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7114 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7115 | ASSERT_VK_SUCCESS(err); |
| 7116 | |
| 7117 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7118 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7119 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7120 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7121 | alloc_info.descriptorPool = ds_pool; |
| 7122 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7123 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7124 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7125 | ASSERT_VK_SUCCESS(err); |
| 7126 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7127 | VkSampler sampler = |
| 7128 | (VkSampler)((size_t)0xbaadbeef); // Sampler with invalid handle |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7129 | |
| 7130 | VkDescriptorImageInfo descriptor_info; |
| 7131 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 7132 | descriptor_info.sampler = sampler; |
| 7133 | |
| 7134 | VkWriteDescriptorSet descriptor_write; |
| 7135 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 7136 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7137 | descriptor_write.dstSet = descriptorSet; |
| 7138 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7139 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7140 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 7141 | descriptor_write.pImageInfo = &descriptor_info; |
| 7142 | |
| 7143 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 7144 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7145 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7146 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7147 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7148 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7149 | } |
| 7150 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7151 | TEST_F(VkLayerTest, ImageViewDescriptorUpdateError) { |
| 7152 | // Create a single combined Image/Sampler descriptor and send it an invalid |
| 7153 | // imageView |
| 7154 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7155 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7156 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7157 | "Attempted write update to combined " |
| 7158 | "image sampler descriptor failed due " |
Tobin Ehlis | 63c4b8a | 2016-05-09 10:29:34 -0600 | [diff] [blame] | 7159 | "to: Invalid VkImageView:"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7160 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7161 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7162 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7163 | ds_type_count.type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 7164 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7165 | |
| 7166 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7167 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7168 | ds_pool_ci.pNext = NULL; |
| 7169 | ds_pool_ci.maxSets = 1; |
| 7170 | ds_pool_ci.poolSizeCount = 1; |
| 7171 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7172 | |
| 7173 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7174 | err = |
| 7175 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7176 | ASSERT_VK_SUCCESS(err); |
| 7177 | |
| 7178 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7179 | dsl_binding.binding = 0; |
| 7180 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 7181 | dsl_binding.descriptorCount = 1; |
| 7182 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7183 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7184 | |
| 7185 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7186 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7187 | ds_layout_ci.pNext = NULL; |
| 7188 | ds_layout_ci.bindingCount = 1; |
| 7189 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7190 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7191 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7192 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7193 | ASSERT_VK_SUCCESS(err); |
| 7194 | |
| 7195 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7196 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7197 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7198 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7199 | alloc_info.descriptorPool = ds_pool; |
| 7200 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7201 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7202 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7203 | ASSERT_VK_SUCCESS(err); |
| 7204 | |
| 7205 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7206 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 7207 | sampler_ci.pNext = NULL; |
| 7208 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 7209 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 7210 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 7211 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7212 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7213 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7214 | sampler_ci.mipLodBias = 1.0; |
| 7215 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 7216 | sampler_ci.maxAnisotropy = 1; |
| 7217 | sampler_ci.compareEnable = VK_FALSE; |
| 7218 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 7219 | sampler_ci.minLod = 1.0; |
| 7220 | sampler_ci.maxLod = 1.0; |
| 7221 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 7222 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7223 | |
| 7224 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7225 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7226 | ASSERT_VK_SUCCESS(err); |
| 7227 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7228 | VkImageView view = |
| 7229 | (VkImageView)((size_t)0xbaadbeef); // invalid imageView object |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7230 | |
| 7231 | VkDescriptorImageInfo descriptor_info; |
| 7232 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 7233 | descriptor_info.sampler = sampler; |
| 7234 | descriptor_info.imageView = view; |
| 7235 | |
| 7236 | VkWriteDescriptorSet descriptor_write; |
| 7237 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 7238 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7239 | descriptor_write.dstSet = descriptorSet; |
| 7240 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7241 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7242 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 7243 | descriptor_write.pImageInfo = &descriptor_info; |
| 7244 | |
| 7245 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 7246 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7247 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7248 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7249 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 7250 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7251 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 7252 | } |
| 7253 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7254 | TEST_F(VkLayerTest, CopyDescriptorUpdateErrors) { |
| 7255 | // Create DS w/ layout of 2 types, write update 1 and attempt to copy-update |
| 7256 | // into the other |
| 7257 | VkResult err; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7258 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7259 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7260 | " binding #1 with type " |
| 7261 | "VK_DESCRIPTOR_TYPE_SAMPLER. Types do " |
| 7262 | "not match."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7263 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7264 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7265 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7266 | VkDescriptorPoolSize ds_type_count[2] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7267 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7268 | ds_type_count[0].descriptorCount = 1; |
| 7269 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 7270 | ds_type_count[1].descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7271 | |
| 7272 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7273 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7274 | ds_pool_ci.pNext = NULL; |
| 7275 | ds_pool_ci.maxSets = 1; |
| 7276 | ds_pool_ci.poolSizeCount = 2; |
| 7277 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7278 | |
| 7279 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7280 | err = |
| 7281 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7282 | ASSERT_VK_SUCCESS(err); |
| 7283 | VkDescriptorSetLayoutBinding dsl_binding[2] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7284 | dsl_binding[0].binding = 0; |
| 7285 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7286 | dsl_binding[0].descriptorCount = 1; |
| 7287 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 7288 | dsl_binding[0].pImmutableSamplers = NULL; |
| 7289 | dsl_binding[1].binding = 1; |
| 7290 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 7291 | dsl_binding[1].descriptorCount = 1; |
| 7292 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 7293 | dsl_binding[1].pImmutableSamplers = NULL; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7294 | |
| 7295 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7296 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7297 | ds_layout_ci.pNext = NULL; |
| 7298 | ds_layout_ci.bindingCount = 2; |
| 7299 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7300 | |
| 7301 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7302 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7303 | &ds_layout); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7304 | ASSERT_VK_SUCCESS(err); |
| 7305 | |
| 7306 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7307 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7308 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7309 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7310 | alloc_info.descriptorPool = ds_pool; |
| 7311 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7312 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7313 | &descriptorSet); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7314 | ASSERT_VK_SUCCESS(err); |
| 7315 | |
| 7316 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7317 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 7318 | sampler_ci.pNext = NULL; |
| 7319 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 7320 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 7321 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 7322 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7323 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7324 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 7325 | sampler_ci.mipLodBias = 1.0; |
| 7326 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 7327 | sampler_ci.maxAnisotropy = 1; |
| 7328 | sampler_ci.compareEnable = VK_FALSE; |
| 7329 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 7330 | sampler_ci.minLod = 1.0; |
| 7331 | sampler_ci.maxLod = 1.0; |
| 7332 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 7333 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7334 | |
| 7335 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7336 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7337 | ASSERT_VK_SUCCESS(err); |
| 7338 | |
| 7339 | VkDescriptorImageInfo info = {}; |
| 7340 | info.sampler = sampler; |
| 7341 | |
| 7342 | VkWriteDescriptorSet descriptor_write; |
| 7343 | memset(&descriptor_write, 0, sizeof(VkWriteDescriptorSet)); |
| 7344 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7345 | descriptor_write.dstSet = descriptorSet; |
| 7346 | descriptor_write.dstBinding = 1; // SAMPLER binding from layout above |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7347 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7348 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 7349 | descriptor_write.pImageInfo = &info; |
| 7350 | // This write update should succeed |
| 7351 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 7352 | // Now perform a copy update that fails due to type mismatch |
| 7353 | VkCopyDescriptorSet copy_ds_update; |
| 7354 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 7355 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 7356 | copy_ds_update.srcSet = descriptorSet; |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 7357 | copy_ds_update.srcBinding = 1; // Copy from SAMPLER binding |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7358 | copy_ds_update.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7359 | copy_ds_update.dstBinding = 0; // ERROR : copy to UNIFORM binding |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7360 | copy_ds_update.descriptorCount = 1; // copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7361 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 7362 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7363 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7364 | // 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] | 7365 | m_errorMonitor->SetDesiredFailureMsg( |
| 7366 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7367 | " does not have copy update src binding of 3."); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7368 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 7369 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 7370 | copy_ds_update.srcSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7371 | copy_ds_update.srcBinding = |
| 7372 | 3; // ERROR : Invalid binding for matching layout |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7373 | copy_ds_update.dstSet = descriptorSet; |
| 7374 | copy_ds_update.dstBinding = 0; |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 7375 | copy_ds_update.descriptorCount = 1; // Copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7376 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 7377 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7378 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7379 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7380 | // 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] | 7381 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 7382 | VK_DEBUG_REPORT_ERROR_BIT_EXT, " binding#1 with offset index of 1 plus " |
| 7383 | "update array offset of 0 and update of " |
| 7384 | "5 descriptors oversteps total number " |
| 7385 | "of descriptors in set: 2."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7386 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7387 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 7388 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 7389 | copy_ds_update.srcSet = descriptorSet; |
| 7390 | copy_ds_update.srcBinding = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7391 | copy_ds_update.dstSet = descriptorSet; |
| 7392 | copy_ds_update.dstBinding = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7393 | copy_ds_update.descriptorCount = |
| 7394 | 5; // ERROR copy 5 descriptors (out of bounds for layout) |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7395 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 7396 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7397 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7398 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7399 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 7400 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7401 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 7402 | } |
| 7403 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7404 | TEST_F(VkLayerTest, NumSamplesMismatch) { |
| 7405 | // Create CommandBuffer where MSAA samples doesn't match RenderPass |
| 7406 | // sampleCount |
| 7407 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7408 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7409 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7410 | "Num samples mismatch! "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7411 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7412 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7413 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7414 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7415 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7416 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7417 | |
| 7418 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7419 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7420 | ds_pool_ci.pNext = NULL; |
| 7421 | ds_pool_ci.maxSets = 1; |
| 7422 | ds_pool_ci.poolSizeCount = 1; |
| 7423 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 7424 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7425 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7426 | err = |
| 7427 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7428 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7429 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7430 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 7431 | dsl_binding.binding = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7432 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 7433 | dsl_binding.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7434 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7435 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7436 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7437 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 7438 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7439 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 7440 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 7441 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7442 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7443 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7444 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7445 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7446 | ASSERT_VK_SUCCESS(err); |
| 7447 | |
| 7448 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7449 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7450 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7451 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 7452 | alloc_info.descriptorPool = ds_pool; |
| 7453 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7454 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7455 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7456 | ASSERT_VK_SUCCESS(err); |
| 7457 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7458 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7459 | pipe_ms_state_ci.sType = |
| 7460 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 7461 | pipe_ms_state_ci.pNext = NULL; |
| 7462 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
| 7463 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 7464 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 7465 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7466 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7467 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7468 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 7469 | pipeline_layout_ci.pNext = NULL; |
| 7470 | pipeline_layout_ci.setLayoutCount = 1; |
| 7471 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7472 | |
| 7473 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7474 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 7475 | &pipeline_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7476 | ASSERT_VK_SUCCESS(err); |
| 7477 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7478 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 7479 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7480 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 7481 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 7482 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7483 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 7484 | VkPipelineObj pipe(m_device); |
| 7485 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 7486 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 7487 | pipe.AddColorAttachment(); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 7488 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 7489 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7490 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 7491 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7492 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 7493 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 7494 | |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 7495 | // Render triangle (the error should trigger on the attempt to draw). |
| 7496 | Draw(3, 1, 0, 0); |
| 7497 | |
| 7498 | // Finalize recording of the command buffer |
| 7499 | EndCommandBuffer(); |
| 7500 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7501 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7502 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7503 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 7504 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7505 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 7506 | } |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 7507 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 7508 | TEST_F(VkLayerTest, NumBlendAttachMismatch) { |
| 7509 | // Create Pipeline where the number of blend attachments doesn't match the |
| 7510 | // number of color attachments. In this case, we don't add any color |
| 7511 | // blend attachments even though we have a color attachment. |
| 7512 | VkResult err; |
| 7513 | |
| 7514 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 7515 | "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] | 7516 | |
| 7517 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7518 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7519 | VkDescriptorPoolSize ds_type_count = {}; |
| 7520 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7521 | ds_type_count.descriptorCount = 1; |
| 7522 | |
| 7523 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 7524 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7525 | ds_pool_ci.pNext = NULL; |
| 7526 | ds_pool_ci.maxSets = 1; |
| 7527 | ds_pool_ci.poolSizeCount = 1; |
| 7528 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 7529 | |
| 7530 | VkDescriptorPool ds_pool; |
| 7531 | err = |
| 7532 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 7533 | ASSERT_VK_SUCCESS(err); |
| 7534 | |
| 7535 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 7536 | dsl_binding.binding = 0; |
| 7537 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7538 | dsl_binding.descriptorCount = 1; |
| 7539 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7540 | dsl_binding.pImmutableSamplers = NULL; |
| 7541 | |
| 7542 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 7543 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7544 | ds_layout_ci.pNext = NULL; |
| 7545 | ds_layout_ci.bindingCount = 1; |
| 7546 | ds_layout_ci.pBindings = &dsl_binding; |
| 7547 | |
| 7548 | VkDescriptorSetLayout ds_layout; |
| 7549 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7550 | &ds_layout); |
| 7551 | ASSERT_VK_SUCCESS(err); |
| 7552 | |
| 7553 | VkDescriptorSet descriptorSet; |
| 7554 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 7555 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 7556 | alloc_info.descriptorSetCount = 1; |
| 7557 | alloc_info.descriptorPool = ds_pool; |
| 7558 | alloc_info.pSetLayouts = &ds_layout; |
| 7559 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7560 | &descriptorSet); |
| 7561 | ASSERT_VK_SUCCESS(err); |
| 7562 | |
| 7563 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 7564 | pipe_ms_state_ci.sType = |
| 7565 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 7566 | pipe_ms_state_ci.pNext = NULL; |
| 7567 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 7568 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 7569 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 7570 | pipe_ms_state_ci.pSampleMask = NULL; |
| 7571 | |
| 7572 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 7573 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 7574 | pipeline_layout_ci.pNext = NULL; |
| 7575 | pipeline_layout_ci.setLayoutCount = 1; |
| 7576 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 7577 | |
| 7578 | VkPipelineLayout pipeline_layout; |
| 7579 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 7580 | &pipeline_layout); |
| 7581 | ASSERT_VK_SUCCESS(err); |
| 7582 | |
| 7583 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 7584 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7585 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 7586 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 7587 | this); // We shouldn't need a fragment shader |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 7588 | // but add it to be able to run on more devices |
| 7589 | VkPipelineObj pipe(m_device); |
| 7590 | pipe.AddShader(&vs); |
| 7591 | pipe.AddShader(&fs); |
| 7592 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 7593 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 7594 | |
| 7595 | BeginCommandBuffer(); |
| 7596 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 7597 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 7598 | |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 7599 | // Render triangle (the error should trigger on the attempt to draw). |
| 7600 | Draw(3, 1, 0, 0); |
| 7601 | |
| 7602 | // Finalize recording of the command buffer |
| 7603 | EndCommandBuffer(); |
| 7604 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7605 | m_errorMonitor->VerifyFound(); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 7606 | |
| 7607 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 7608 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7609 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 7610 | } |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 7611 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7612 | TEST_F(VkLayerTest, ClearCmdNoDraw) { |
| 7613 | // Create CommandBuffer where we add ClearCmd for FB Color attachment prior |
| 7614 | // to issuing a Draw |
| 7615 | VkResult err; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7616 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7617 | m_errorMonitor->SetDesiredFailureMsg( |
Tony Barbour | 7e56d30 | 2016-03-02 15:12:01 -0700 | [diff] [blame] | 7618 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7619 | "vkCmdClearAttachments() issued on CB object "); |
| 7620 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7621 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7622 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7623 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7624 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7625 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7626 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7627 | |
| 7628 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7629 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7630 | ds_pool_ci.pNext = NULL; |
| 7631 | ds_pool_ci.maxSets = 1; |
| 7632 | ds_pool_ci.poolSizeCount = 1; |
| 7633 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7634 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7635 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7636 | err = |
| 7637 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7638 | ASSERT_VK_SUCCESS(err); |
| 7639 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7640 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7641 | dsl_binding.binding = 0; |
| 7642 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7643 | dsl_binding.descriptorCount = 1; |
| 7644 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7645 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7646 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7647 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7648 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7649 | ds_layout_ci.pNext = NULL; |
| 7650 | ds_layout_ci.bindingCount = 1; |
| 7651 | ds_layout_ci.pBindings = &dsl_binding; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 7652 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7653 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7654 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7655 | &ds_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7656 | ASSERT_VK_SUCCESS(err); |
| 7657 | |
| 7658 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7659 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7660 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7661 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 7662 | alloc_info.descriptorPool = ds_pool; |
| 7663 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7664 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7665 | &descriptorSet); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7666 | ASSERT_VK_SUCCESS(err); |
| 7667 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7668 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7669 | pipe_ms_state_ci.sType = |
| 7670 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 7671 | pipe_ms_state_ci.pNext = NULL; |
| 7672 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
| 7673 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 7674 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 7675 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7676 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7677 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7678 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 7679 | pipeline_layout_ci.pNext = NULL; |
| 7680 | pipeline_layout_ci.setLayoutCount = 1; |
| 7681 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7682 | |
| 7683 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7684 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 7685 | &pipeline_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7686 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 7687 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7688 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 7689 | VK_SHADER_STAGE_VERTEX_BIT, this); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 7690 | // 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] | 7691 | // on more devices |
| 7692 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 7693 | VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7694 | |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 7695 | VkPipelineObj pipe(m_device); |
| 7696 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 7697 | pipe.AddShader(&fs); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 7698 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 7699 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 7700 | |
| 7701 | BeginCommandBuffer(); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7702 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7703 | // Main thing we care about for this test is that the VkImage obj we're |
| 7704 | // clearing matches Color Attachment of FB |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7705 | // Also pass down other dummy params to keep driver and paramchecker happy |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 7706 | VkClearAttachment color_attachment; |
| 7707 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 7708 | color_attachment.clearValue.color.float32[0] = 1.0; |
| 7709 | color_attachment.clearValue.color.float32[1] = 1.0; |
| 7710 | color_attachment.clearValue.color.float32[2] = 1.0; |
| 7711 | color_attachment.clearValue.color.float32[3] = 1.0; |
| 7712 | color_attachment.colorAttachment = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7713 | VkClearRect clear_rect = { |
| 7714 | {{0, 0}, {(uint32_t)m_width, (uint32_t)m_height}}}; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7715 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7716 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
| 7717 | &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7718 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7719 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7720 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7721 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 7722 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7723 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 7724 | } |
| 7725 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7726 | TEST_F(VkLayerTest, VtxBufferBadIndex) { |
| 7727 | VkResult err; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 7728 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7729 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 7730 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | dfcd9b6 | 2015-12-14 15:14:10 -0700 | [diff] [blame] | 7731 | "but no vertex buffers are attached to this Pipeline State Object"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7732 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 7733 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 7734 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 7735 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7736 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 7737 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7738 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7739 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7740 | |
| 7741 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7742 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 7743 | ds_pool_ci.pNext = NULL; |
| 7744 | ds_pool_ci.maxSets = 1; |
| 7745 | ds_pool_ci.poolSizeCount = 1; |
| 7746 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7747 | |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 7748 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7749 | err = |
| 7750 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 7751 | ASSERT_VK_SUCCESS(err); |
| 7752 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7753 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7754 | dsl_binding.binding = 0; |
| 7755 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 7756 | dsl_binding.descriptorCount = 1; |
| 7757 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 7758 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 7759 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7760 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7761 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 7762 | ds_layout_ci.pNext = NULL; |
| 7763 | ds_layout_ci.bindingCount = 1; |
| 7764 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7765 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 7766 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7767 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 7768 | &ds_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 7769 | ASSERT_VK_SUCCESS(err); |
| 7770 | |
| 7771 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7772 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 7773 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 7774 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 7775 | alloc_info.descriptorPool = ds_pool; |
| 7776 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7777 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 7778 | &descriptorSet); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 7779 | ASSERT_VK_SUCCESS(err); |
| 7780 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7781 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7782 | pipe_ms_state_ci.sType = |
| 7783 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 7784 | pipe_ms_state_ci.pNext = NULL; |
| 7785 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 7786 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 7787 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 7788 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 7789 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 7790 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7791 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 7792 | pipeline_layout_ci.pNext = NULL; |
| 7793 | pipeline_layout_ci.setLayoutCount = 1; |
| 7794 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 7795 | VkPipelineLayout pipeline_layout; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 7796 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7797 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 7798 | &pipeline_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 7799 | ASSERT_VK_SUCCESS(err); |
| 7800 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7801 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 7802 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7803 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 7804 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 7805 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7806 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 7807 | VkPipelineObj pipe(m_device); |
| 7808 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 7809 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 7810 | pipe.AddColorAttachment(); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 7811 | pipe.SetMSAA(&pipe_ms_state_ci); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 7812 | pipe.SetViewport(m_viewports); |
| 7813 | pipe.SetScissor(m_scissors); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 7814 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 7815 | |
| 7816 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7817 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 7818 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 7819 | // Don't care about actual data, just need to get to draw to flag error |
| 7820 | static const float vbo_data[3] = {1.f, 0.f, 1.f}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7821 | VkConstantBufferObj vbo(m_device, sizeof(vbo_data), sizeof(float), |
| 7822 | (const void *)&vbo_data); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 7823 | 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] | 7824 | Draw(1, 0, 0, 0); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 7825 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7826 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 7827 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7828 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 7829 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 7830 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 7831 | } |
Tobin Ehlis | c555a3c | 2016-05-04 14:08:34 -0600 | [diff] [blame] | 7832 | // INVALID_IMAGE_LAYOUT tests (one other case is hit by MapMemWithoutHostVisibleBit and not here) |
| 7833 | TEST_F(VkLayerTest, InvalidImageLayout) { |
| 7834 | TEST_DESCRIPTION("Hit all possible validation checks associated with the " |
| 7835 | "DRAWSTATE_INVALID_IMAGE_LAYOUT enum. Generally these involve having" |
| 7836 | "images in the wrong layout when they're copied or transitioned."); |
| 7837 | // 3 in ValidateCmdBufImageLayouts |
| 7838 | // * -1 Attempt to submit cmd buf w/ deleted image |
| 7839 | // * -2 Cmd buf submit of image w/ layout not matching first use w/ subresource |
| 7840 | // * -3 Cmd buf submit of image w/ layout not matching first use w/o subresource |
| 7841 | m_errorMonitor->SetDesiredFailureMsg( |
| 7842 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 7843 | "Layout for input image should be TRANSFER_SRC_OPTIMAL instead of GENERAL."); |
| 7844 | |
| 7845 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7846 | // Create src & dst images to use for copy operations |
| 7847 | VkImage src_image; |
| 7848 | VkImage dst_image; |
| 7849 | |
| 7850 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 7851 | const int32_t tex_width = 32; |
| 7852 | const int32_t tex_height = 32; |
| 7853 | |
| 7854 | VkImageCreateInfo image_create_info = {}; |
| 7855 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 7856 | image_create_info.pNext = NULL; |
| 7857 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 7858 | image_create_info.format = tex_format; |
| 7859 | image_create_info.extent.width = tex_width; |
| 7860 | image_create_info.extent.height = tex_height; |
| 7861 | image_create_info.extent.depth = 1; |
| 7862 | image_create_info.mipLevels = 1; |
| 7863 | image_create_info.arrayLayers = 4; |
| 7864 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 7865 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 7866 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 7867 | image_create_info.flags = 0; |
| 7868 | |
| 7869 | VkResult err = vkCreateImage(m_device->device(), &image_create_info, NULL, &src_image); |
| 7870 | ASSERT_VK_SUCCESS(err); |
| 7871 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dst_image); |
| 7872 | ASSERT_VK_SUCCESS(err); |
| 7873 | |
| 7874 | BeginCommandBuffer(); |
| 7875 | VkImageCopy copyRegion; |
| 7876 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 7877 | copyRegion.srcSubresource.mipLevel = 0; |
| 7878 | copyRegion.srcSubresource.baseArrayLayer = 0; |
| 7879 | copyRegion.srcSubresource.layerCount = 1; |
| 7880 | copyRegion.srcOffset.x = 0; |
| 7881 | copyRegion.srcOffset.y = 0; |
| 7882 | copyRegion.srcOffset.z = 0; |
| 7883 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 7884 | copyRegion.dstSubresource.mipLevel = 0; |
| 7885 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 7886 | copyRegion.dstSubresource.layerCount = 1; |
| 7887 | copyRegion.dstOffset.x = 0; |
| 7888 | copyRegion.dstOffset.y = 0; |
| 7889 | copyRegion.dstOffset.z = 0; |
| 7890 | copyRegion.extent.width = 1; |
| 7891 | copyRegion.extent.height = 1; |
| 7892 | copyRegion.extent.depth = 1; |
| 7893 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 7894 | m_errorMonitor->VerifyFound(); |
| 7895 | // Now cause error due to src image layout changing |
| 7896 | m_errorMonitor->SetDesiredFailureMsg( |
| 7897 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7898 | "Cannot copy from an image whose source layout is VK_IMAGE_LAYOUT_UNDEFINED and doesn't match the current layout VK_IMAGE_LAYOUT_GENERAL."); |
| 7899 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_UNDEFINED, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 7900 | m_errorMonitor->VerifyFound(); |
| 7901 | // Final src error is due to bad layout type |
| 7902 | m_errorMonitor->SetDesiredFailureMsg( |
| 7903 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7904 | "Layout for input image is VK_IMAGE_LAYOUT_UNDEFINED but can only be TRANSFER_SRC_OPTIMAL or GENERAL."); |
| 7905 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_UNDEFINED, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 7906 | m_errorMonitor->VerifyFound(); |
| 7907 | // Now verify same checks for dst |
| 7908 | m_errorMonitor->SetDesiredFailureMsg( |
| 7909 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 7910 | "Layout for output image should be TRANSFER_DST_OPTIMAL instead of GENERAL."); |
| 7911 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 7912 | m_errorMonitor->VerifyFound(); |
| 7913 | // Now cause error due to src image layout changing |
| 7914 | m_errorMonitor->SetDesiredFailureMsg( |
| 7915 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7916 | "Cannot copy from an image whose dest layout is VK_IMAGE_LAYOUT_UNDEFINED and doesn't match the current layout VK_IMAGE_LAYOUT_GENERAL."); |
| 7917 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_UNDEFINED, 1, ©Region); |
| 7918 | m_errorMonitor->VerifyFound(); |
| 7919 | m_errorMonitor->SetDesiredFailureMsg( |
| 7920 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7921 | "Layout for output image is VK_IMAGE_LAYOUT_UNDEFINED but can only be TRANSFER_DST_OPTIMAL or GENERAL."); |
| 7922 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_UNDEFINED, 1, ©Region); |
| 7923 | m_errorMonitor->VerifyFound(); |
| 7924 | // Now cause error due to bad image layout transition in PipelineBarrier |
| 7925 | VkImageMemoryBarrier image_barrier[1] = {}; |
| 7926 | image_barrier[0].oldLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; |
| 7927 | image_barrier[0].image = src_image; |
| 7928 | image_barrier[0].subresourceRange.layerCount = 2; |
| 7929 | image_barrier[0].subresourceRange.levelCount = 2; |
| 7930 | image_barrier[0].subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 7931 | m_errorMonitor->SetDesiredFailureMsg( |
| 7932 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7933 | "You cannot transition the layout from VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL when current layout is VK_IMAGE_LAYOUT_GENERAL."); |
| 7934 | vkCmdPipelineBarrier(m_commandBuffer->handle(), VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, NULL, 0, NULL, 1, image_barrier); |
| 7935 | m_errorMonitor->VerifyFound(); |
| 7936 | |
| 7937 | // Finally some layout errors at RenderPass create time |
| 7938 | // Just hacking in specific state to get to the errors we want so don't copy this unless you know what you're doing. |
| 7939 | VkAttachmentReference attach = {}; |
| 7940 | // perf warning for GENERAL layout w/ non-DS input attachment |
| 7941 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 7942 | VkSubpassDescription subpass = {}; |
| 7943 | subpass.inputAttachmentCount = 1; |
| 7944 | subpass.pInputAttachments = &attach; |
| 7945 | VkRenderPassCreateInfo rpci = {}; |
| 7946 | rpci.subpassCount = 1; |
| 7947 | rpci.pSubpasses = &subpass; |
| 7948 | rpci.attachmentCount = 1; |
| 7949 | VkAttachmentDescription attach_desc = {}; |
| 7950 | attach_desc.format = VK_FORMAT_UNDEFINED; |
| 7951 | rpci.pAttachments = &attach_desc; |
Tobin Ehlis | 1efce02 | 2016-05-11 10:40:34 -0600 | [diff] [blame] | 7952 | rpci.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; |
Tobin Ehlis | c555a3c | 2016-05-04 14:08:34 -0600 | [diff] [blame] | 7953 | VkRenderPass rp; |
| 7954 | m_errorMonitor->SetDesiredFailureMsg( |
| 7955 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 7956 | "Layout for input attachment is GENERAL but should be READ_ONLY_OPTIMAL."); |
| 7957 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 7958 | m_errorMonitor->VerifyFound(); |
| 7959 | // error w/ non-general layout |
| 7960 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; |
| 7961 | |
| 7962 | m_errorMonitor->SetDesiredFailureMsg( |
| 7963 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7964 | "Layout for input attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be READ_ONLY_OPTIMAL or GENERAL."); |
| 7965 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 7966 | m_errorMonitor->VerifyFound(); |
| 7967 | subpass.inputAttachmentCount = 0; |
| 7968 | subpass.colorAttachmentCount = 1; |
| 7969 | subpass.pColorAttachments = &attach; |
| 7970 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 7971 | // perf warning for GENERAL layout on color attachment |
| 7972 | m_errorMonitor->SetDesiredFailureMsg( |
| 7973 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 7974 | "Layout for color attachment is GENERAL but should be COLOR_ATTACHMENT_OPTIMAL."); |
| 7975 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 7976 | m_errorMonitor->VerifyFound(); |
| 7977 | // error w/ non-color opt or GENERAL layout for color attachment |
| 7978 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; |
| 7979 | m_errorMonitor->SetDesiredFailureMsg( |
| 7980 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7981 | "Layout for color attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be COLOR_ATTACHMENT_OPTIMAL or GENERAL."); |
| 7982 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 7983 | m_errorMonitor->VerifyFound(); |
| 7984 | subpass.colorAttachmentCount = 0; |
| 7985 | subpass.pDepthStencilAttachment = &attach; |
| 7986 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 7987 | // perf warning for GENERAL layout on DS attachment |
| 7988 | m_errorMonitor->SetDesiredFailureMsg( |
| 7989 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 7990 | "Layout for depth attachment is GENERAL but should be DEPTH_STENCIL_ATTACHMENT_OPTIMAL."); |
| 7991 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 7992 | m_errorMonitor->VerifyFound(); |
| 7993 | // error w/ non-ds opt or GENERAL layout for color attachment |
| 7994 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; |
| 7995 | m_errorMonitor->SetDesiredFailureMsg( |
| 7996 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7997 | "Layout for depth attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be DEPTH_STENCIL_ATTACHMENT_OPTIMAL or GENERAL."); |
| 7998 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 7999 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 1efce02 | 2016-05-11 10:40:34 -0600 | [diff] [blame] | 8000 | // For this error we need a valid renderpass so create default one |
| 8001 | attach.layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; |
| 8002 | attach.attachment = 0; |
| 8003 | attach_desc.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 8004 | attach_desc.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8005 | attach_desc.storeOp = VK_ATTACHMENT_STORE_OP_STORE; |
| 8006 | attach_desc.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; |
| 8007 | attach_desc.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; |
| 8008 | // Can't do a CLEAR load on READ_ONLY initialLayout |
| 8009 | attach_desc.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; |
| 8010 | attach_desc.initialLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; |
| 8011 | attach_desc.finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 8012 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8013 | " with invalid first layout " |
| 8014 | "VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_" |
| 8015 | "ONLY_OPTIMAL"); |
| 8016 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 8017 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | c555a3c | 2016-05-04 14:08:34 -0600 | [diff] [blame] | 8018 | |
| 8019 | vkDestroyImage(m_device->device(), src_image, NULL); |
| 8020 | vkDestroyImage(m_device->device(), dst_image, NULL); |
| 8021 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 8022 | #endif // DRAW_STATE_TESTS |
| 8023 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 8024 | #if THREADING_TESTS |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8025 | #if GTEST_IS_THREADSAFE |
| 8026 | struct thread_data_struct { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8027 | VkCommandBuffer commandBuffer; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8028 | VkEvent event; |
| 8029 | bool bailout; |
| 8030 | }; |
| 8031 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8032 | extern "C" void *AddToCommandBuffer(void *arg) { |
| 8033 | struct thread_data_struct *data = (struct thread_data_struct *)arg; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8034 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8035 | for (int i = 0; i < 10000; i++) { |
| 8036 | vkCmdSetEvent(data->commandBuffer, data->event, |
| 8037 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8038 | if (data->bailout) { |
| 8039 | break; |
| 8040 | } |
| 8041 | } |
| 8042 | return NULL; |
| 8043 | } |
| 8044 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8045 | TEST_F(VkLayerTest, ThreadCommandBufferCollision) { |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 8046 | test_platform_thread thread; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8047 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8048 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8049 | "THREADING ERROR"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8050 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8051 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8052 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 8053 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8054 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8055 | // Calls AllocateCommandBuffers |
| 8056 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 8057 | |
| 8058 | // Avoid creating RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8059 | commandBuffer.BeginCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8060 | |
| 8061 | VkEventCreateInfo event_info; |
| 8062 | VkEvent event; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8063 | VkResult err; |
| 8064 | |
| 8065 | memset(&event_info, 0, sizeof(event_info)); |
| 8066 | event_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 8067 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8068 | err = vkCreateEvent(device(), &event_info, NULL, &event); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8069 | ASSERT_VK_SUCCESS(err); |
| 8070 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8071 | err = vkResetEvent(device(), event); |
| 8072 | ASSERT_VK_SUCCESS(err); |
| 8073 | |
| 8074 | struct thread_data_struct data; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8075 | data.commandBuffer = commandBuffer.GetBufferHandle(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8076 | data.event = event; |
| 8077 | data.bailout = false; |
| 8078 | m_errorMonitor->SetBailout(&data.bailout); |
| 8079 | // Add many entries to command buffer from another thread. |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 8080 | test_platform_thread_create(&thread, AddToCommandBuffer, (void *)&data); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8081 | // Add many entries to command buffer from this thread at the same time. |
| 8082 | AddToCommandBuffer(&data); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 8083 | |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 8084 | test_platform_thread_join(thread, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8085 | commandBuffer.EndCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8086 | |
Mike Stroyan | 10b8cb7 | 2016-01-22 15:22:03 -0700 | [diff] [blame] | 8087 | m_errorMonitor->SetBailout(NULL); |
| 8088 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8089 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8090 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8091 | vkDestroyEvent(device(), event, NULL); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 8092 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 8093 | #endif // GTEST_IS_THREADSAFE |
| 8094 | #endif // THREADING_TESTS |
| 8095 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8096 | #if SHADER_CHECKER_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8097 | TEST_F(VkLayerTest, InvalidSPIRVCodeSize) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8098 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 8099 | "Invalid SPIR-V header"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8100 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8101 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8102 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8103 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8104 | VkShaderModule module; |
| 8105 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 8106 | struct icd_spv_header spv; |
| 8107 | |
| 8108 | spv.magic = ICD_SPV_MAGIC; |
| 8109 | spv.version = ICD_SPV_VERSION; |
| 8110 | spv.gen_magic = 0; |
| 8111 | |
| 8112 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 8113 | moduleCreateInfo.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8114 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8115 | moduleCreateInfo.codeSize = 4; |
| 8116 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8117 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8118 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8119 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8120 | } |
| 8121 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8122 | TEST_F(VkLayerTest, InvalidSPIRVMagic) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8123 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 8124 | "Invalid SPIR-V magic number"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8125 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8126 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8127 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8128 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8129 | VkShaderModule module; |
| 8130 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 8131 | struct icd_spv_header spv; |
| 8132 | |
| 8133 | spv.magic = ~ICD_SPV_MAGIC; |
| 8134 | spv.version = ICD_SPV_VERSION; |
| 8135 | spv.gen_magic = 0; |
| 8136 | |
| 8137 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 8138 | moduleCreateInfo.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8139 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8140 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 8141 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8142 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8143 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8144 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8145 | } |
| 8146 | |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 8147 | #if 0 |
| 8148 | // Not currently covered by SPIRV-Tools validator |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8149 | TEST_F(VkLayerTest, InvalidSPIRVVersion) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8150 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 8151 | "Invalid SPIR-V header"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8152 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8153 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8154 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8155 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8156 | VkShaderModule module; |
| 8157 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 8158 | struct icd_spv_header spv; |
| 8159 | |
| 8160 | spv.magic = ICD_SPV_MAGIC; |
| 8161 | spv.version = ~ICD_SPV_VERSION; |
| 8162 | spv.gen_magic = 0; |
| 8163 | |
| 8164 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 8165 | moduleCreateInfo.pNext = NULL; |
| 8166 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8167 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8168 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 8169 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8170 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8171 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8172 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8173 | } |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 8174 | #endif |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 8175 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8176 | TEST_F(VkLayerTest, CreatePipelineVertexOutputNotConsumed) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 8177 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8178 | "not consumed by fragment shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8179 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8180 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 8181 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8182 | |
| 8183 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8184 | "#version 450\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8185 | "\n" |
| 8186 | "layout(location=0) out float x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8187 | "out gl_PerVertex {\n" |
| 8188 | " vec4 gl_Position;\n" |
| 8189 | "};\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8190 | "void main(){\n" |
| 8191 | " gl_Position = vec4(1);\n" |
| 8192 | " x = 0;\n" |
| 8193 | "}\n"; |
| 8194 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8195 | "#version 450\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8196 | "\n" |
| 8197 | "layout(location=0) out vec4 color;\n" |
| 8198 | "void main(){\n" |
| 8199 | " color = vec4(1);\n" |
| 8200 | "}\n"; |
| 8201 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8202 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8203 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8204 | |
| 8205 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 8206 | pipe.AddColorAttachment(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8207 | pipe.AddShader(&vs); |
| 8208 | pipe.AddShader(&fs); |
| 8209 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8210 | VkDescriptorSetObj descriptorSet(m_device); |
| 8211 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8212 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8213 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 8214 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8215 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8216 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8217 | } |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 8218 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8219 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvided) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8220 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8221 | "not written by vertex shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8222 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8223 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 8224 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8225 | |
| 8226 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8227 | "#version 450\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8228 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8229 | "out gl_PerVertex {\n" |
| 8230 | " vec4 gl_Position;\n" |
| 8231 | "};\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8232 | "void main(){\n" |
| 8233 | " gl_Position = vec4(1);\n" |
| 8234 | "}\n"; |
| 8235 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8236 | "#version 450\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8237 | "\n" |
| 8238 | "layout(location=0) in float x;\n" |
| 8239 | "layout(location=0) out vec4 color;\n" |
| 8240 | "void main(){\n" |
| 8241 | " color = vec4(x);\n" |
| 8242 | "}\n"; |
| 8243 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8244 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8245 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8246 | |
| 8247 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 8248 | pipe.AddColorAttachment(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8249 | pipe.AddShader(&vs); |
| 8250 | pipe.AddShader(&fs); |
| 8251 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8252 | VkDescriptorSetObj descriptorSet(m_device); |
| 8253 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8254 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8255 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 8256 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8257 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8258 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 8259 | } |
| 8260 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8261 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvidedInBlock) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8262 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8263 | "not written by vertex shader"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8264 | |
| 8265 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8266 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8267 | |
| 8268 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8269 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8270 | "\n" |
| 8271 | "out gl_PerVertex {\n" |
| 8272 | " vec4 gl_Position;\n" |
| 8273 | "};\n" |
| 8274 | "void main(){\n" |
| 8275 | " gl_Position = vec4(1);\n" |
| 8276 | "}\n"; |
| 8277 | char const *fsSource = |
| 8278 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8279 | "\n" |
| 8280 | "in block { layout(location=0) float x; } ins;\n" |
| 8281 | "layout(location=0) out vec4 color;\n" |
| 8282 | "void main(){\n" |
| 8283 | " color = vec4(ins.x);\n" |
| 8284 | "}\n"; |
| 8285 | |
| 8286 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8287 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8288 | |
| 8289 | VkPipelineObj pipe(m_device); |
| 8290 | pipe.AddColorAttachment(); |
| 8291 | pipe.AddShader(&vs); |
| 8292 | pipe.AddShader(&fs); |
| 8293 | |
| 8294 | VkDescriptorSetObj descriptorSet(m_device); |
| 8295 | descriptorSet.AppendDummy(); |
| 8296 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8297 | |
| 8298 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8299 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8300 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8301 | } |
| 8302 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8303 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchArraySize) { |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 8304 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 8305 | "Type mismatch on location 0.0: 'ptr to " |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8306 | "output arr[2] of float32' vs 'ptr to " |
| 8307 | "input arr[3] of float32'"); |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 8308 | |
| 8309 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8310 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8311 | |
| 8312 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8313 | "#version 450\n" |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 8314 | "\n" |
| 8315 | "layout(location=0) out float x[2];\n" |
| 8316 | "out gl_PerVertex {\n" |
| 8317 | " vec4 gl_Position;\n" |
| 8318 | "};\n" |
| 8319 | "void main(){\n" |
| 8320 | " x[0] = 0; x[1] = 0;\n" |
| 8321 | " gl_Position = vec4(1);\n" |
| 8322 | "}\n"; |
| 8323 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8324 | "#version 450\n" |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 8325 | "\n" |
| 8326 | "layout(location=0) in float x[3];\n" |
| 8327 | "layout(location=0) out vec4 color;\n" |
| 8328 | "void main(){\n" |
| 8329 | " color = vec4(x[0] + x[1] + x[2]);\n" |
| 8330 | "}\n"; |
| 8331 | |
| 8332 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8333 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8334 | |
| 8335 | VkPipelineObj pipe(m_device); |
| 8336 | pipe.AddColorAttachment(); |
| 8337 | pipe.AddShader(&vs); |
| 8338 | pipe.AddShader(&fs); |
| 8339 | |
| 8340 | VkDescriptorSetObj descriptorSet(m_device); |
| 8341 | descriptorSet.AppendDummy(); |
| 8342 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8343 | |
| 8344 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8345 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8346 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 8347 | } |
| 8348 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8349 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatch) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8350 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8351 | "Type mismatch on location 0"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8352 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8353 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 8354 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8355 | |
| 8356 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8357 | "#version 450\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8358 | "\n" |
| 8359 | "layout(location=0) out int x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8360 | "out gl_PerVertex {\n" |
| 8361 | " vec4 gl_Position;\n" |
| 8362 | "};\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8363 | "void main(){\n" |
| 8364 | " x = 0;\n" |
| 8365 | " gl_Position = vec4(1);\n" |
| 8366 | "}\n"; |
| 8367 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8368 | "#version 450\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8369 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8370 | "layout(location=0) in float x;\n" /* VS writes int */ |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8371 | "layout(location=0) out vec4 color;\n" |
| 8372 | "void main(){\n" |
| 8373 | " color = vec4(x);\n" |
| 8374 | "}\n"; |
| 8375 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8376 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8377 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8378 | |
| 8379 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 8380 | pipe.AddColorAttachment(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8381 | pipe.AddShader(&vs); |
| 8382 | pipe.AddShader(&fs); |
| 8383 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8384 | VkDescriptorSetObj descriptorSet(m_device); |
| 8385 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8386 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8387 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 8388 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8389 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8390 | m_errorMonitor->VerifyFound(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 8391 | } |
| 8392 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8393 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchInBlock) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8394 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8395 | "Type mismatch on location 0"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8396 | |
| 8397 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8398 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8399 | |
| 8400 | char const *vsSource = |
| 8401 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8402 | "\n" |
| 8403 | "out block { layout(location=0) int x; } outs;\n" |
| 8404 | "out gl_PerVertex {\n" |
| 8405 | " vec4 gl_Position;\n" |
| 8406 | "};\n" |
| 8407 | "void main(){\n" |
| 8408 | " outs.x = 0;\n" |
| 8409 | " gl_Position = vec4(1);\n" |
| 8410 | "}\n"; |
| 8411 | char const *fsSource = |
| 8412 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8413 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8414 | "in block { layout(location=0) float x; } ins;\n" /* VS writes int */ |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8415 | "layout(location=0) out vec4 color;\n" |
| 8416 | "void main(){\n" |
| 8417 | " color = vec4(ins.x);\n" |
| 8418 | "}\n"; |
| 8419 | |
| 8420 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8421 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8422 | |
| 8423 | VkPipelineObj pipe(m_device); |
| 8424 | pipe.AddColorAttachment(); |
| 8425 | pipe.AddShader(&vs); |
| 8426 | pipe.AddShader(&fs); |
| 8427 | |
| 8428 | VkDescriptorSetObj descriptorSet(m_device); |
| 8429 | descriptorSet.AppendDummy(); |
| 8430 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8431 | |
| 8432 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8433 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8434 | m_errorMonitor->VerifyFound(); |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 8435 | } |
| 8436 | |
| 8437 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByLocation) { |
| 8438 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8439 | "location 0.0 which is not written by vertex shader"); |
| 8440 | |
| 8441 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8442 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8443 | |
| 8444 | char const *vsSource = |
| 8445 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 8446 | "\n" |
| 8447 | "out block { layout(location=1) float x; } outs;\n" |
| 8448 | "out gl_PerVertex {\n" |
| 8449 | " vec4 gl_Position;\n" |
| 8450 | "};\n" |
| 8451 | "void main(){\n" |
| 8452 | " outs.x = 0;\n" |
| 8453 | " gl_Position = vec4(1);\n" |
| 8454 | "}\n"; |
| 8455 | char const *fsSource = |
| 8456 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 8457 | "\n" |
| 8458 | "in block { layout(location=0) float x; } ins;\n" |
| 8459 | "layout(location=0) out vec4 color;\n" |
| 8460 | "void main(){\n" |
| 8461 | " color = vec4(ins.x);\n" |
| 8462 | "}\n"; |
| 8463 | |
| 8464 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8465 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8466 | |
| 8467 | VkPipelineObj pipe(m_device); |
| 8468 | pipe.AddColorAttachment(); |
| 8469 | pipe.AddShader(&vs); |
| 8470 | pipe.AddShader(&fs); |
| 8471 | |
| 8472 | VkDescriptorSetObj descriptorSet(m_device); |
| 8473 | descriptorSet.AppendDummy(); |
| 8474 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8475 | |
| 8476 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8477 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8478 | m_errorMonitor->VerifyFound(); |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 8479 | } |
| 8480 | |
| 8481 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByComponent) { |
| 8482 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8483 | "location 0.1 which is not written by vertex shader"); |
| 8484 | |
| 8485 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8486 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8487 | |
| 8488 | char const *vsSource = |
| 8489 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 8490 | "\n" |
| 8491 | "out block { layout(location=0, component=0) float x; } outs;\n" |
| 8492 | "out gl_PerVertex {\n" |
| 8493 | " vec4 gl_Position;\n" |
| 8494 | "};\n" |
| 8495 | "void main(){\n" |
| 8496 | " outs.x = 0;\n" |
| 8497 | " gl_Position = vec4(1);\n" |
| 8498 | "}\n"; |
| 8499 | char const *fsSource = |
| 8500 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 8501 | "\n" |
| 8502 | "in block { layout(location=0, component=1) float x; } ins;\n" |
| 8503 | "layout(location=0) out vec4 color;\n" |
| 8504 | "void main(){\n" |
| 8505 | " color = vec4(ins.x);\n" |
| 8506 | "}\n"; |
| 8507 | |
| 8508 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8509 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8510 | |
| 8511 | VkPipelineObj pipe(m_device); |
| 8512 | pipe.AddColorAttachment(); |
| 8513 | pipe.AddShader(&vs); |
| 8514 | pipe.AddShader(&fs); |
| 8515 | |
| 8516 | VkDescriptorSetObj descriptorSet(m_device); |
| 8517 | descriptorSet.AppendDummy(); |
| 8518 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8519 | |
| 8520 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8521 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8522 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 8523 | } |
| 8524 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8525 | TEST_F(VkLayerTest, CreatePipelineAttribNotConsumed) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 8526 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8527 | "location 0 not consumed by VS"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8528 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8529 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 8530 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8531 | |
| 8532 | VkVertexInputBindingDescription input_binding; |
| 8533 | memset(&input_binding, 0, sizeof(input_binding)); |
| 8534 | |
| 8535 | VkVertexInputAttributeDescription input_attrib; |
| 8536 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 8537 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 8538 | |
| 8539 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8540 | "#version 450\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8541 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8542 | "out gl_PerVertex {\n" |
| 8543 | " vec4 gl_Position;\n" |
| 8544 | "};\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8545 | "void main(){\n" |
| 8546 | " gl_Position = vec4(1);\n" |
| 8547 | "}\n"; |
| 8548 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8549 | "#version 450\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8550 | "\n" |
| 8551 | "layout(location=0) out vec4 color;\n" |
| 8552 | "void main(){\n" |
| 8553 | " color = vec4(1);\n" |
| 8554 | "}\n"; |
| 8555 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8556 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8557 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8558 | |
| 8559 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 8560 | pipe.AddColorAttachment(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8561 | pipe.AddShader(&vs); |
| 8562 | pipe.AddShader(&fs); |
| 8563 | |
| 8564 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 8565 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 8566 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8567 | VkDescriptorSetObj descriptorSet(m_device); |
| 8568 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8569 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8570 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 8571 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8572 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8573 | m_errorMonitor->VerifyFound(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 8574 | } |
| 8575 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8576 | TEST_F(VkLayerTest, CreatePipelineAttribLocationMismatch) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 8577 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8578 | "location 0 not consumed by VS"); |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 8579 | |
| 8580 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8581 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8582 | |
| 8583 | VkVertexInputBindingDescription input_binding; |
| 8584 | memset(&input_binding, 0, sizeof(input_binding)); |
| 8585 | |
| 8586 | VkVertexInputAttributeDescription input_attrib; |
| 8587 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 8588 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 8589 | |
| 8590 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8591 | "#version 450\n" |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 8592 | "\n" |
| 8593 | "layout(location=1) in float x;\n" |
| 8594 | "out gl_PerVertex {\n" |
| 8595 | " vec4 gl_Position;\n" |
| 8596 | "};\n" |
| 8597 | "void main(){\n" |
| 8598 | " gl_Position = vec4(x);\n" |
| 8599 | "}\n"; |
| 8600 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8601 | "#version 450\n" |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 8602 | "\n" |
| 8603 | "layout(location=0) out vec4 color;\n" |
| 8604 | "void main(){\n" |
| 8605 | " color = vec4(1);\n" |
| 8606 | "}\n"; |
| 8607 | |
| 8608 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8609 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8610 | |
| 8611 | VkPipelineObj pipe(m_device); |
| 8612 | pipe.AddColorAttachment(); |
| 8613 | pipe.AddShader(&vs); |
| 8614 | pipe.AddShader(&fs); |
| 8615 | |
| 8616 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 8617 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 8618 | |
| 8619 | VkDescriptorSetObj descriptorSet(m_device); |
| 8620 | descriptorSet.AppendDummy(); |
| 8621 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8622 | |
| 8623 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8624 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8625 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 8626 | } |
| 8627 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8628 | TEST_F(VkLayerTest, CreatePipelineAttribNotProvided) { |
| 8629 | m_errorMonitor->SetDesiredFailureMsg( |
| 8630 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8631 | "VS consumes input at location 0 but not provided"); |
| 8632 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8633 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 8634 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8635 | |
| 8636 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8637 | "#version 450\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8638 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8639 | "layout(location=0) in vec4 x;\n" /* not provided */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8640 | "out gl_PerVertex {\n" |
| 8641 | " vec4 gl_Position;\n" |
| 8642 | "};\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8643 | "void main(){\n" |
| 8644 | " gl_Position = x;\n" |
| 8645 | "}\n"; |
| 8646 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8647 | "#version 450\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8648 | "\n" |
| 8649 | "layout(location=0) out vec4 color;\n" |
| 8650 | "void main(){\n" |
| 8651 | " color = vec4(1);\n" |
| 8652 | "}\n"; |
| 8653 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8654 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8655 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8656 | |
| 8657 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 8658 | pipe.AddColorAttachment(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8659 | pipe.AddShader(&vs); |
| 8660 | pipe.AddShader(&fs); |
| 8661 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8662 | VkDescriptorSetObj descriptorSet(m_device); |
| 8663 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8664 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8665 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 8666 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8667 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8668 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 8669 | } |
| 8670 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8671 | TEST_F(VkLayerTest, CreatePipelineAttribTypeMismatch) { |
| 8672 | m_errorMonitor->SetDesiredFailureMsg( |
| 8673 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8674 | "location 0 does not match VS input type"); |
| 8675 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 8676 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 8677 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 8678 | |
| 8679 | VkVertexInputBindingDescription input_binding; |
| 8680 | memset(&input_binding, 0, sizeof(input_binding)); |
| 8681 | |
| 8682 | VkVertexInputAttributeDescription input_attrib; |
| 8683 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 8684 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 8685 | |
| 8686 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8687 | "#version 450\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 8688 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8689 | "layout(location=0) in int x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8690 | "out gl_PerVertex {\n" |
| 8691 | " vec4 gl_Position;\n" |
| 8692 | "};\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 8693 | "void main(){\n" |
| 8694 | " gl_Position = vec4(x);\n" |
| 8695 | "}\n"; |
| 8696 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8697 | "#version 450\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 8698 | "\n" |
| 8699 | "layout(location=0) out vec4 color;\n" |
| 8700 | "void main(){\n" |
| 8701 | " color = vec4(1);\n" |
| 8702 | "}\n"; |
| 8703 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8704 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8705 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 8706 | |
| 8707 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 8708 | pipe.AddColorAttachment(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 8709 | pipe.AddShader(&vs); |
| 8710 | pipe.AddShader(&fs); |
| 8711 | |
| 8712 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 8713 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 8714 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 8715 | VkDescriptorSetObj descriptorSet(m_device); |
| 8716 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8717 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 8718 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 8719 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 8720 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8721 | m_errorMonitor->VerifyFound(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 8722 | } |
| 8723 | |
Chris Forbes | c68b43c | 2016-04-06 11:18:47 +1200 | [diff] [blame] | 8724 | TEST_F(VkLayerTest, CreatePipelineDuplicateStage) { |
| 8725 | m_errorMonitor->SetDesiredFailureMsg( |
| 8726 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8727 | "Multiple shaders provided for stage VK_SHADER_STAGE_VERTEX_BIT"); |
| 8728 | |
| 8729 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8730 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8731 | |
| 8732 | char const *vsSource = |
| 8733 | "#version 450\n" |
| 8734 | "\n" |
| 8735 | "out gl_PerVertex {\n" |
| 8736 | " vec4 gl_Position;\n" |
| 8737 | "};\n" |
| 8738 | "void main(){\n" |
| 8739 | " gl_Position = vec4(1);\n" |
| 8740 | "}\n"; |
| 8741 | char const *fsSource = |
| 8742 | "#version 450\n" |
| 8743 | "\n" |
| 8744 | "layout(location=0) out vec4 color;\n" |
| 8745 | "void main(){\n" |
| 8746 | " color = vec4(1);\n" |
| 8747 | "}\n"; |
| 8748 | |
| 8749 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8750 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8751 | |
| 8752 | VkPipelineObj pipe(m_device); |
| 8753 | pipe.AddColorAttachment(); |
| 8754 | pipe.AddShader(&vs); |
| 8755 | pipe.AddShader(&vs); |
| 8756 | pipe.AddShader(&fs); |
| 8757 | |
| 8758 | VkDescriptorSetObj descriptorSet(m_device); |
| 8759 | descriptorSet.AppendDummy(); |
| 8760 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8761 | |
| 8762 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8763 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8764 | m_errorMonitor->VerifyFound(); |
Chris Forbes | c68b43c | 2016-04-06 11:18:47 +1200 | [diff] [blame] | 8765 | } |
| 8766 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8767 | TEST_F(VkLayerTest, CreatePipelineAttribMatrixType) { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8768 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 8769 | |
| 8770 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8771 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8772 | |
| 8773 | VkVertexInputBindingDescription input_binding; |
| 8774 | memset(&input_binding, 0, sizeof(input_binding)); |
| 8775 | |
| 8776 | VkVertexInputAttributeDescription input_attribs[2]; |
| 8777 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 8778 | |
| 8779 | for (int i = 0; i < 2; i++) { |
| 8780 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 8781 | input_attribs[i].location = i; |
| 8782 | } |
| 8783 | |
| 8784 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8785 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 8786 | "\n" |
| 8787 | "layout(location=0) in mat2x4 x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8788 | "out gl_PerVertex {\n" |
| 8789 | " vec4 gl_Position;\n" |
| 8790 | "};\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 8791 | "void main(){\n" |
| 8792 | " gl_Position = x[0] + x[1];\n" |
| 8793 | "}\n"; |
| 8794 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8795 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 8796 | "\n" |
| 8797 | "layout(location=0) out vec4 color;\n" |
| 8798 | "void main(){\n" |
| 8799 | " color = vec4(1);\n" |
| 8800 | "}\n"; |
| 8801 | |
| 8802 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8803 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8804 | |
| 8805 | VkPipelineObj pipe(m_device); |
| 8806 | pipe.AddColorAttachment(); |
| 8807 | pipe.AddShader(&vs); |
| 8808 | pipe.AddShader(&fs); |
| 8809 | |
| 8810 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 8811 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 8812 | |
| 8813 | VkDescriptorSetObj descriptorSet(m_device); |
| 8814 | descriptorSet.AppendDummy(); |
| 8815 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8816 | |
| 8817 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8818 | |
| 8819 | /* expect success */ |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8820 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 8821 | } |
| 8822 | |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 8823 | TEST_F(VkLayerTest, CreatePipelineAttribArrayType) |
| 8824 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8825 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 8826 | |
| 8827 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8828 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8829 | |
| 8830 | VkVertexInputBindingDescription input_binding; |
| 8831 | memset(&input_binding, 0, sizeof(input_binding)); |
| 8832 | |
| 8833 | VkVertexInputAttributeDescription input_attribs[2]; |
| 8834 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 8835 | |
| 8836 | for (int i = 0; i < 2; i++) { |
| 8837 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 8838 | input_attribs[i].location = i; |
| 8839 | } |
| 8840 | |
| 8841 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8842 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 8843 | "\n" |
| 8844 | "layout(location=0) in vec4 x[2];\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8845 | "out gl_PerVertex {\n" |
| 8846 | " vec4 gl_Position;\n" |
| 8847 | "};\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 8848 | "void main(){\n" |
| 8849 | " gl_Position = x[0] + x[1];\n" |
| 8850 | "}\n"; |
| 8851 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8852 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 8853 | "\n" |
| 8854 | "layout(location=0) out vec4 color;\n" |
| 8855 | "void main(){\n" |
| 8856 | " color = vec4(1);\n" |
| 8857 | "}\n"; |
| 8858 | |
| 8859 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8860 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8861 | |
| 8862 | VkPipelineObj pipe(m_device); |
| 8863 | pipe.AddColorAttachment(); |
| 8864 | pipe.AddShader(&vs); |
| 8865 | pipe.AddShader(&fs); |
| 8866 | |
| 8867 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 8868 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 8869 | |
| 8870 | VkDescriptorSetObj descriptorSet(m_device); |
| 8871 | descriptorSet.AppendDummy(); |
| 8872 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8873 | |
| 8874 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8875 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8876 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 8877 | } |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 8878 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 8879 | TEST_F(VkLayerTest, CreatePipelineSimplePositive) |
| 8880 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8881 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 8882 | |
| 8883 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8884 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8885 | |
| 8886 | char const *vsSource = |
| 8887 | "#version 450\n" |
| 8888 | "out gl_PerVertex {\n" |
| 8889 | " vec4 gl_Position;\n" |
| 8890 | "};\n" |
| 8891 | "void main(){\n" |
| 8892 | " gl_Position = vec4(0);\n" |
| 8893 | "}\n"; |
| 8894 | char const *fsSource = |
| 8895 | "#version 450\n" |
| 8896 | "\n" |
| 8897 | "layout(location=0) out vec4 color;\n" |
| 8898 | "void main(){\n" |
| 8899 | " color = vec4(1);\n" |
| 8900 | "}\n"; |
| 8901 | |
| 8902 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8903 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8904 | |
| 8905 | VkPipelineObj pipe(m_device); |
| 8906 | pipe.AddColorAttachment(); |
| 8907 | pipe.AddShader(&vs); |
| 8908 | pipe.AddShader(&fs); |
| 8909 | |
| 8910 | VkDescriptorSetObj descriptorSet(m_device); |
| 8911 | descriptorSet.AppendDummy(); |
| 8912 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8913 | |
| 8914 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8915 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8916 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 8917 | } |
| 8918 | |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 8919 | TEST_F(VkLayerTest, CreatePipelineRelaxedTypeMatch) |
| 8920 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8921 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 8922 | |
| 8923 | // VK 1.0.8 Specification, 14.1.3 "Additionally,..." block |
| 8924 | |
| 8925 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8926 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8927 | |
| 8928 | char const *vsSource = |
| 8929 | "#version 450\n" |
| 8930 | "out gl_PerVertex {\n" |
| 8931 | " vec4 gl_Position;\n" |
| 8932 | "};\n" |
| 8933 | "layout(location=0) out vec3 x;\n" |
| 8934 | "layout(location=1) out ivec3 y;\n" |
| 8935 | "layout(location=2) out vec3 z;\n" |
| 8936 | "void main(){\n" |
| 8937 | " gl_Position = vec4(0);\n" |
| 8938 | " x = vec3(0); y = ivec3(0); z = vec3(0);\n" |
| 8939 | "}\n"; |
| 8940 | char const *fsSource = |
| 8941 | "#version 450\n" |
| 8942 | "\n" |
| 8943 | "layout(location=0) out vec4 color;\n" |
| 8944 | "layout(location=0) in float x;\n" |
| 8945 | "layout(location=1) flat in int y;\n" |
| 8946 | "layout(location=2) in vec2 z;\n" |
| 8947 | "void main(){\n" |
| 8948 | " color = vec4(1 + x + y + z.x);\n" |
| 8949 | "}\n"; |
| 8950 | |
| 8951 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8952 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8953 | |
| 8954 | VkPipelineObj pipe(m_device); |
| 8955 | pipe.AddColorAttachment(); |
| 8956 | pipe.AddShader(&vs); |
| 8957 | pipe.AddShader(&fs); |
| 8958 | |
| 8959 | VkDescriptorSetObj descriptorSet(m_device); |
| 8960 | descriptorSet.AppendDummy(); |
| 8961 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8962 | |
| 8963 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8964 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8965 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 8966 | } |
| 8967 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 8968 | TEST_F(VkLayerTest, CreatePipelineTessPerVertex) |
| 8969 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8970 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 8971 | |
| 8972 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8973 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8974 | |
Chris Forbes | c1e852d | 2016-04-04 19:26:42 +1200 | [diff] [blame] | 8975 | if (!m_device->phy().features().tessellationShader) { |
| 8976 | printf("Device does not support tessellation shaders; skipped.\n"); |
| 8977 | return; |
| 8978 | } |
| 8979 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 8980 | char const *vsSource = |
| 8981 | "#version 450\n" |
| 8982 | "void main(){}\n"; |
| 8983 | char const *tcsSource = |
| 8984 | "#version 450\n" |
| 8985 | "layout(location=0) out int x[];\n" |
| 8986 | "layout(vertices=3) out;\n" |
| 8987 | "void main(){\n" |
| 8988 | " gl_TessLevelOuter[0] = gl_TessLevelOuter[1] = gl_TessLevelOuter[2] = 1;\n" |
| 8989 | " gl_TessLevelInner[0] = 1;\n" |
| 8990 | " x[gl_InvocationID] = gl_InvocationID;\n" |
| 8991 | "}\n"; |
| 8992 | char const *tesSource = |
| 8993 | "#version 450\n" |
| 8994 | "layout(triangles, equal_spacing, cw) in;\n" |
| 8995 | "layout(location=0) in int x[];\n" |
| 8996 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 8997 | "void main(){\n" |
| 8998 | " gl_Position.xyz = gl_TessCoord;\n" |
| 8999 | " gl_Position.w = x[0] + x[1] + x[2];\n" |
| 9000 | "}\n"; |
| 9001 | char const *fsSource = |
| 9002 | "#version 450\n" |
| 9003 | "layout(location=0) out vec4 color;\n" |
| 9004 | "void main(){\n" |
| 9005 | " color = vec4(1);\n" |
| 9006 | "}\n"; |
| 9007 | |
| 9008 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9009 | VkShaderObj tcs(m_device, tcsSource, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 9010 | VkShaderObj tes(m_device, tesSource, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
| 9011 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9012 | |
| 9013 | VkPipelineInputAssemblyStateCreateInfo iasci{ |
| 9014 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, |
| 9015 | nullptr, |
| 9016 | 0, |
| 9017 | VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, |
| 9018 | VK_FALSE}; |
| 9019 | |
Chris Forbes | b4cacb6 | 2016-04-04 19:15:00 +1200 | [diff] [blame] | 9020 | VkPipelineTessellationStateCreateInfo tsci{ |
| 9021 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, |
| 9022 | nullptr, |
| 9023 | 0, |
| 9024 | 3}; |
| 9025 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9026 | VkPipelineObj pipe(m_device); |
| 9027 | pipe.SetInputAssembly(&iasci); |
Chris Forbes | b4cacb6 | 2016-04-04 19:15:00 +1200 | [diff] [blame] | 9028 | pipe.SetTessellation(&tsci); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9029 | pipe.AddColorAttachment(); |
| 9030 | pipe.AddShader(&vs); |
| 9031 | pipe.AddShader(&tcs); |
| 9032 | pipe.AddShader(&tes); |
| 9033 | pipe.AddShader(&fs); |
| 9034 | |
| 9035 | VkDescriptorSetObj descriptorSet(m_device); |
| 9036 | descriptorSet.AppendDummy(); |
| 9037 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9038 | |
| 9039 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9040 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9041 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 9042 | } |
| 9043 | |
Chris Forbes | a0ab815 | 2016-04-20 13:34:27 +1200 | [diff] [blame] | 9044 | TEST_F(VkLayerTest, CreatePipelineGeometryInputBlockPositive) |
| 9045 | { |
| 9046 | m_errorMonitor->ExpectSuccess(); |
| 9047 | |
| 9048 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9049 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9050 | |
| 9051 | if (!m_device->phy().features().geometryShader) { |
| 9052 | printf("Device does not support geometry shaders; skipped.\n"); |
| 9053 | return; |
| 9054 | } |
| 9055 | |
| 9056 | char const *vsSource = |
| 9057 | "#version 450\n" |
| 9058 | "layout(location=0) out VertexData { vec4 x; } vs_out;\n" |
| 9059 | "void main(){\n" |
| 9060 | " vs_out.x = vec4(1);\n" |
| 9061 | "}\n"; |
| 9062 | char const *gsSource = |
| 9063 | "#version 450\n" |
| 9064 | "layout(triangles) in;\n" |
| 9065 | "layout(triangle_strip, max_vertices=3) out;\n" |
| 9066 | "layout(location=0) in VertexData { vec4 x; } gs_in[];\n" |
| 9067 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 9068 | "void main() {\n" |
| 9069 | " gl_Position = gs_in[0].x;\n" |
| 9070 | " EmitVertex();\n" |
| 9071 | "}\n"; |
| 9072 | char const *fsSource = |
| 9073 | "#version 450\n" |
| 9074 | "layout(location=0) out vec4 color;\n" |
| 9075 | "void main(){\n" |
| 9076 | " color = vec4(1);\n" |
| 9077 | "}\n"; |
| 9078 | |
| 9079 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9080 | VkShaderObj gs(m_device, gsSource, VK_SHADER_STAGE_GEOMETRY_BIT, this); |
| 9081 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9082 | |
| 9083 | VkPipelineObj pipe(m_device); |
| 9084 | pipe.AddColorAttachment(); |
| 9085 | pipe.AddShader(&vs); |
| 9086 | pipe.AddShader(&gs); |
| 9087 | pipe.AddShader(&fs); |
| 9088 | |
| 9089 | VkDescriptorSetObj descriptorSet(m_device); |
| 9090 | descriptorSet.AppendDummy(); |
| 9091 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9092 | |
| 9093 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9094 | |
| 9095 | m_errorMonitor->VerifyNotFound(); |
| 9096 | } |
| 9097 | |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 9098 | TEST_F(VkLayerTest, CreatePipelineTessPatchDecorationMismatch) |
| 9099 | { |
| 9100 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9101 | "is per-vertex in tessellation control shader stage " |
| 9102 | "but per-patch in tessellation evaluation shader stage"); |
| 9103 | |
| 9104 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9105 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9106 | |
Chris Forbes | c1e852d | 2016-04-04 19:26:42 +1200 | [diff] [blame] | 9107 | if (!m_device->phy().features().tessellationShader) { |
| 9108 | printf("Device does not support tessellation shaders; skipped.\n"); |
| 9109 | return; |
| 9110 | } |
| 9111 | |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 9112 | char const *vsSource = |
| 9113 | "#version 450\n" |
| 9114 | "void main(){}\n"; |
| 9115 | char const *tcsSource = |
| 9116 | "#version 450\n" |
| 9117 | "layout(location=0) out int x[];\n" |
| 9118 | "layout(vertices=3) out;\n" |
| 9119 | "void main(){\n" |
| 9120 | " gl_TessLevelOuter[0] = gl_TessLevelOuter[1] = gl_TessLevelOuter[2] = 1;\n" |
| 9121 | " gl_TessLevelInner[0] = 1;\n" |
| 9122 | " x[gl_InvocationID] = gl_InvocationID;\n" |
| 9123 | "}\n"; |
| 9124 | char const *tesSource = |
| 9125 | "#version 450\n" |
| 9126 | "layout(triangles, equal_spacing, cw) in;\n" |
| 9127 | "layout(location=0) patch in int x;\n" |
| 9128 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 9129 | "void main(){\n" |
| 9130 | " gl_Position.xyz = gl_TessCoord;\n" |
| 9131 | " gl_Position.w = x;\n" |
| 9132 | "}\n"; |
| 9133 | char const *fsSource = |
| 9134 | "#version 450\n" |
| 9135 | "layout(location=0) out vec4 color;\n" |
| 9136 | "void main(){\n" |
| 9137 | " color = vec4(1);\n" |
| 9138 | "}\n"; |
| 9139 | |
| 9140 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9141 | VkShaderObj tcs(m_device, tcsSource, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 9142 | VkShaderObj tes(m_device, tesSource, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
| 9143 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9144 | |
| 9145 | VkPipelineInputAssemblyStateCreateInfo iasci{ |
| 9146 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, |
| 9147 | nullptr, |
| 9148 | 0, |
| 9149 | VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, |
| 9150 | VK_FALSE}; |
| 9151 | |
| 9152 | VkPipelineTessellationStateCreateInfo tsci{ |
| 9153 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, |
| 9154 | nullptr, |
| 9155 | 0, |
| 9156 | 3}; |
| 9157 | |
| 9158 | VkPipelineObj pipe(m_device); |
| 9159 | pipe.SetInputAssembly(&iasci); |
| 9160 | pipe.SetTessellation(&tsci); |
| 9161 | pipe.AddColorAttachment(); |
| 9162 | pipe.AddShader(&vs); |
| 9163 | pipe.AddShader(&tcs); |
| 9164 | pipe.AddShader(&tes); |
| 9165 | pipe.AddShader(&fs); |
| 9166 | |
| 9167 | VkDescriptorSetObj descriptorSet(m_device); |
| 9168 | descriptorSet.AppendDummy(); |
| 9169 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9170 | |
| 9171 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9172 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9173 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 9174 | } |
| 9175 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9176 | TEST_F(VkLayerTest, CreatePipelineAttribBindingConflict) { |
| 9177 | m_errorMonitor->SetDesiredFailureMsg( |
| 9178 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9179 | "Duplicate vertex input binding descriptions for binding 0"); |
| 9180 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9181 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 9182 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9183 | |
| 9184 | /* Two binding descriptions for binding 0 */ |
| 9185 | VkVertexInputBindingDescription input_bindings[2]; |
| 9186 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 9187 | |
| 9188 | VkVertexInputAttributeDescription input_attrib; |
| 9189 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 9190 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 9191 | |
| 9192 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9193 | "#version 450\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9194 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9195 | "layout(location=0) in float x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9196 | "out gl_PerVertex {\n" |
| 9197 | " vec4 gl_Position;\n" |
| 9198 | "};\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9199 | "void main(){\n" |
| 9200 | " gl_Position = vec4(x);\n" |
| 9201 | "}\n"; |
| 9202 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9203 | "#version 450\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9204 | "\n" |
| 9205 | "layout(location=0) out vec4 color;\n" |
| 9206 | "void main(){\n" |
| 9207 | " color = vec4(1);\n" |
| 9208 | "}\n"; |
| 9209 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9210 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9211 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9212 | |
| 9213 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9214 | pipe.AddColorAttachment(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9215 | pipe.AddShader(&vs); |
| 9216 | pipe.AddShader(&fs); |
| 9217 | |
| 9218 | pipe.AddVertexInputBindings(input_bindings, 2); |
| 9219 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 9220 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9221 | VkDescriptorSetObj descriptorSet(m_device); |
| 9222 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9223 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9224 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9225 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9226 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9227 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 9228 | } |
Chris Forbes | 8f68b56 | 2015-05-25 11:13:32 +1200 | [diff] [blame] | 9229 | |
Chris Forbes | 35efec7 | 2016-04-21 14:32:08 +1200 | [diff] [blame] | 9230 | TEST_F(VkLayerTest, CreatePipeline64BitAttributesPositive) { |
| 9231 | m_errorMonitor->ExpectSuccess(); |
| 9232 | |
| 9233 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9234 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9235 | |
| 9236 | if (!m_device->phy().features().tessellationShader) { |
| 9237 | printf("Device does not support 64bit vertex attributes; skipped.\n"); |
| 9238 | return; |
| 9239 | } |
| 9240 | |
| 9241 | VkVertexInputBindingDescription input_bindings[1]; |
| 9242 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 9243 | |
| 9244 | VkVertexInputAttributeDescription input_attribs[4]; |
| 9245 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 9246 | input_attribs[0].location = 0; |
| 9247 | input_attribs[0].offset = 0; |
| 9248 | input_attribs[0].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 9249 | input_attribs[1].location = 2; |
| 9250 | input_attribs[1].offset = 32; |
| 9251 | input_attribs[1].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 9252 | input_attribs[2].location = 4; |
| 9253 | input_attribs[2].offset = 64; |
| 9254 | input_attribs[2].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 9255 | input_attribs[3].location = 6; |
| 9256 | input_attribs[3].offset = 96; |
| 9257 | input_attribs[3].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 9258 | |
| 9259 | char const *vsSource = |
| 9260 | "#version 450\n" |
| 9261 | "\n" |
| 9262 | "layout(location=0) in dmat4 x;\n" |
| 9263 | "out gl_PerVertex {\n" |
| 9264 | " vec4 gl_Position;\n" |
| 9265 | "};\n" |
| 9266 | "void main(){\n" |
| 9267 | " gl_Position = vec4(x[0][0]);\n" |
| 9268 | "}\n"; |
| 9269 | char const *fsSource = |
| 9270 | "#version 450\n" |
| 9271 | "\n" |
| 9272 | "layout(location=0) out vec4 color;\n" |
| 9273 | "void main(){\n" |
| 9274 | " color = vec4(1);\n" |
| 9275 | "}\n"; |
| 9276 | |
| 9277 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9278 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9279 | |
| 9280 | VkPipelineObj pipe(m_device); |
| 9281 | pipe.AddColorAttachment(); |
| 9282 | pipe.AddShader(&vs); |
| 9283 | pipe.AddShader(&fs); |
| 9284 | |
| 9285 | pipe.AddVertexInputBindings(input_bindings, 1); |
| 9286 | pipe.AddVertexInputAttribs(input_attribs, 4); |
| 9287 | |
| 9288 | VkDescriptorSetObj descriptorSet(m_device); |
| 9289 | descriptorSet.AppendDummy(); |
| 9290 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9291 | |
| 9292 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9293 | |
| 9294 | m_errorMonitor->VerifyNotFound(); |
| 9295 | } |
| 9296 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9297 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotWritten) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9298 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9299 | "Attachment 0 not written by FS"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9300 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9301 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9302 | |
| 9303 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9304 | "#version 450\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9305 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9306 | "out gl_PerVertex {\n" |
| 9307 | " vec4 gl_Position;\n" |
| 9308 | "};\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9309 | "void main(){\n" |
| 9310 | " gl_Position = vec4(1);\n" |
| 9311 | "}\n"; |
| 9312 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9313 | "#version 450\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9314 | "\n" |
| 9315 | "void main(){\n" |
| 9316 | "}\n"; |
| 9317 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9318 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9319 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9320 | |
| 9321 | VkPipelineObj pipe(m_device); |
| 9322 | pipe.AddShader(&vs); |
| 9323 | pipe.AddShader(&fs); |
| 9324 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9325 | /* set up CB 0, not written */ |
| 9326 | pipe.AddColorAttachment(); |
| 9327 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9328 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9329 | VkDescriptorSetObj descriptorSet(m_device); |
| 9330 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9331 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9332 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9333 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9334 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9335 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 9336 | } |
| 9337 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9338 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotConsumed) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9339 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 9340 | VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9341 | "FS writes to output location 1 with no matching attachment"); |
| 9342 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9343 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9344 | |
| 9345 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9346 | "#version 450\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9347 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9348 | "out gl_PerVertex {\n" |
| 9349 | " vec4 gl_Position;\n" |
| 9350 | "};\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9351 | "void main(){\n" |
| 9352 | " gl_Position = vec4(1);\n" |
| 9353 | "}\n"; |
| 9354 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9355 | "#version 450\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9356 | "\n" |
| 9357 | "layout(location=0) out vec4 x;\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9358 | "layout(location=1) out vec4 y;\n" /* no matching attachment for this */ |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9359 | "void main(){\n" |
| 9360 | " x = vec4(1);\n" |
| 9361 | " y = vec4(1);\n" |
| 9362 | "}\n"; |
| 9363 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9364 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9365 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9366 | |
| 9367 | VkPipelineObj pipe(m_device); |
| 9368 | pipe.AddShader(&vs); |
| 9369 | pipe.AddShader(&fs); |
| 9370 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9371 | /* set up CB 0, not written */ |
| 9372 | pipe.AddColorAttachment(); |
| 9373 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9374 | /* FS writes CB 1, but we don't configure it */ |
| 9375 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9376 | VkDescriptorSetObj descriptorSet(m_device); |
| 9377 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9378 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9379 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9380 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9381 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9382 | m_errorMonitor->VerifyFound(); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 9383 | } |
| 9384 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9385 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputTypeMismatch) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9386 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9387 | "does not match FS output type"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9388 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9389 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9390 | |
| 9391 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9392 | "#version 450\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9393 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9394 | "out gl_PerVertex {\n" |
| 9395 | " vec4 gl_Position;\n" |
| 9396 | "};\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9397 | "void main(){\n" |
| 9398 | " gl_Position = vec4(1);\n" |
| 9399 | "}\n"; |
| 9400 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9401 | "#version 450\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9402 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9403 | "layout(location=0) out ivec4 x;\n" /* not UNORM */ |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9404 | "void main(){\n" |
| 9405 | " x = ivec4(1);\n" |
| 9406 | "}\n"; |
| 9407 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9408 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9409 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9410 | |
| 9411 | VkPipelineObj pipe(m_device); |
| 9412 | pipe.AddShader(&vs); |
| 9413 | pipe.AddShader(&fs); |
| 9414 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 9415 | /* set up CB 0; type is UNORM by default */ |
| 9416 | pipe.AddColorAttachment(); |
| 9417 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9418 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9419 | VkDescriptorSetObj descriptorSet(m_device); |
| 9420 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9421 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9422 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 9423 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9424 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9425 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9426 | } |
Chris Forbes | 7b1b893 | 2015-06-05 14:43:36 +1200 | [diff] [blame] | 9427 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9428 | TEST_F(VkLayerTest, CreatePipelineUniformBlockNotProvided) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9429 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9430 | "not declared in pipeline layout"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9431 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 9432 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 9433 | |
| 9434 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9435 | "#version 450\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 9436 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 9437 | "out gl_PerVertex {\n" |
| 9438 | " vec4 gl_Position;\n" |
| 9439 | "};\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 9440 | "void main(){\n" |
| 9441 | " gl_Position = vec4(1);\n" |
| 9442 | "}\n"; |
| 9443 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 9444 | "#version 450\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 9445 | "\n" |
| 9446 | "layout(location=0) out vec4 x;\n" |
| 9447 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 9448 | "void main(){\n" |
| 9449 | " x = vec4(bar.y);\n" |
| 9450 | "}\n"; |
| 9451 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 9452 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9453 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 9454 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 9455 | VkPipelineObj pipe(m_device); |
| 9456 | pipe.AddShader(&vs); |
| 9457 | pipe.AddShader(&fs); |
| 9458 | |
| 9459 | /* set up CB 0; type is UNORM by default */ |
| 9460 | pipe.AddColorAttachment(); |
| 9461 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9462 | |
| 9463 | VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9464 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 9465 | |
| 9466 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9467 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9468 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 9469 | } |
| 9470 | |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 9471 | TEST_F(VkLayerTest, CreatePipelinePushConstantsNotInLayout) { |
| 9472 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9473 | "not declared in layout"); |
| 9474 | |
| 9475 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9476 | |
| 9477 | char const *vsSource = |
| 9478 | "#version 450\n" |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 9479 | "\n" |
| 9480 | "layout(push_constant, std430) uniform foo { float x; } consts;\n" |
| 9481 | "out gl_PerVertex {\n" |
| 9482 | " vec4 gl_Position;\n" |
| 9483 | "};\n" |
| 9484 | "void main(){\n" |
| 9485 | " gl_Position = vec4(consts.x);\n" |
| 9486 | "}\n"; |
| 9487 | char const *fsSource = |
| 9488 | "#version 450\n" |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 9489 | "\n" |
| 9490 | "layout(location=0) out vec4 x;\n" |
| 9491 | "void main(){\n" |
| 9492 | " x = vec4(1);\n" |
| 9493 | "}\n"; |
| 9494 | |
| 9495 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 9496 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 9497 | |
| 9498 | VkPipelineObj pipe(m_device); |
| 9499 | pipe.AddShader(&vs); |
| 9500 | pipe.AddShader(&fs); |
| 9501 | |
| 9502 | /* set up CB 0; type is UNORM by default */ |
| 9503 | pipe.AddColorAttachment(); |
| 9504 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9505 | |
| 9506 | VkDescriptorSetObj descriptorSet(m_device); |
| 9507 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 9508 | |
| 9509 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 9510 | |
| 9511 | /* should have generated an error -- no push constant ranges provided! */ |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9512 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 9513 | } |
| 9514 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 9515 | #endif // SHADER_CHECKER_TESTS |
| 9516 | |
| 9517 | #if DEVICE_LIMITS_TESTS |
Mark Young | c48c4c1 | 2016-04-11 14:26:49 -0600 | [diff] [blame] | 9518 | TEST_F(VkLayerTest, CreateImageLimitsViolationMaxWidth) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9519 | m_errorMonitor->SetDesiredFailureMsg( |
| 9520 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9521 | "CreateImage extents exceed allowable limits for format"); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 9522 | |
| 9523 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 9524 | |
| 9525 | // Create an image |
| 9526 | VkImage image; |
| 9527 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9528 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 9529 | const int32_t tex_width = 32; |
| 9530 | const int32_t tex_height = 32; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 9531 | |
| 9532 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9533 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9534 | image_create_info.pNext = NULL; |
| 9535 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 9536 | image_create_info.format = tex_format; |
| 9537 | image_create_info.extent.width = tex_width; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 9538 | image_create_info.extent.height = tex_height; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9539 | image_create_info.extent.depth = 1; |
| 9540 | image_create_info.mipLevels = 1; |
| 9541 | image_create_info.arrayLayers = 1; |
| 9542 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 9543 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 9544 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 9545 | image_create_info.flags = 0; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 9546 | |
| 9547 | // Introduce error by sending down a bogus width extent |
| 9548 | image_create_info.extent.width = 65536; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9549 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 9550 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9551 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 9552 | } |
| 9553 | |
Mark Young | c48c4c1 | 2016-04-11 14:26:49 -0600 | [diff] [blame] | 9554 | TEST_F(VkLayerTest, CreateImageLimitsViolationMinWidth) { |
| 9555 | m_errorMonitor->SetDesiredFailureMsg( |
| 9556 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9557 | "CreateImage extents is 0 for at least one required dimension"); |
| 9558 | |
| 9559 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9560 | |
| 9561 | // Create an image |
| 9562 | VkImage image; |
| 9563 | |
| 9564 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 9565 | const int32_t tex_width = 32; |
| 9566 | const int32_t tex_height = 32; |
| 9567 | |
| 9568 | VkImageCreateInfo image_create_info = {}; |
| 9569 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9570 | image_create_info.pNext = NULL; |
| 9571 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 9572 | image_create_info.format = tex_format; |
| 9573 | image_create_info.extent.width = tex_width; |
| 9574 | image_create_info.extent.height = tex_height; |
| 9575 | image_create_info.extent.depth = 1; |
| 9576 | image_create_info.mipLevels = 1; |
| 9577 | image_create_info.arrayLayers = 1; |
| 9578 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 9579 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 9580 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 9581 | image_create_info.flags = 0; |
| 9582 | |
| 9583 | // Introduce error by sending down a bogus width extent |
| 9584 | image_create_info.extent.width = 0; |
| 9585 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 9586 | |
| 9587 | m_errorMonitor->VerifyFound(); |
| 9588 | } |
| 9589 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9590 | TEST_F(VkLayerTest, UpdateBufferAlignment) { |
| 9591 | uint32_t updateData[] = {1, 2, 3, 4, 5, 6, 7, 8}; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9592 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9593 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9594 | "dstOffset, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9595 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9596 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9597 | |
| 9598 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 9599 | vk_testing::Buffer buffer; |
| 9600 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 9601 | |
| 9602 | BeginCommandBuffer(); |
| 9603 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9604 | m_commandBuffer->UpdateBuffer(buffer.handle(), 1, 4, updateData); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9605 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9606 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9607 | // Introduce failure by using size that is not multiple of 4 |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9608 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9609 | "dataSize, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9610 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9611 | m_commandBuffer->UpdateBuffer(buffer.handle(), 0, 6, updateData); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9612 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9613 | EndCommandBuffer(); |
| 9614 | } |
| 9615 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9616 | TEST_F(VkLayerTest, FillBufferAlignment) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9617 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9618 | "dstOffset, is not a multiple of 4"); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9619 | |
| 9620 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9621 | |
| 9622 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 9623 | vk_testing::Buffer buffer; |
| 9624 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 9625 | |
| 9626 | BeginCommandBuffer(); |
| 9627 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9628 | m_commandBuffer->FillBuffer(buffer.handle(), 1, 4, 0x11111111); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9629 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9630 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9631 | // Introduce failure by using size that is not multiple of 4 |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9632 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9633 | "size, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9634 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9635 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 6, 0x11111111); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9636 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9637 | m_errorMonitor->VerifyFound(); |
| 9638 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9639 | EndCommandBuffer(); |
| 9640 | } |
| 9641 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 9642 | #endif // DEVICE_LIMITS_TESTS |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 9643 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 9644 | #if IMAGE_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9645 | TEST_F(VkLayerTest, InvalidImageView) { |
| 9646 | VkResult err; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 9647 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9648 | m_errorMonitor->SetDesiredFailureMsg( |
| 9649 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9650 | "vkCreateImageView called with baseMipLevel 10 "); |
| 9651 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 9652 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 9653 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9654 | // Create an image and try to create a view with bad baseMipLevel |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9655 | VkImage image; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 9656 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9657 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 9658 | const int32_t tex_width = 32; |
| 9659 | const int32_t tex_height = 32; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 9660 | |
| 9661 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9662 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9663 | image_create_info.pNext = NULL; |
| 9664 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 9665 | image_create_info.format = tex_format; |
| 9666 | image_create_info.extent.width = tex_width; |
| 9667 | image_create_info.extent.height = tex_height; |
| 9668 | image_create_info.extent.depth = 1; |
| 9669 | image_create_info.mipLevels = 1; |
| 9670 | image_create_info.arrayLayers = 1; |
| 9671 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 9672 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 9673 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 9674 | image_create_info.flags = 0; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 9675 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9676 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 9677 | ASSERT_VK_SUCCESS(err); |
| 9678 | |
| 9679 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9680 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9681 | image_view_create_info.image = image; |
| 9682 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 9683 | image_view_create_info.format = tex_format; |
| 9684 | image_view_create_info.subresourceRange.layerCount = 1; |
| 9685 | image_view_create_info.subresourceRange.baseMipLevel = 10; // cause an error |
| 9686 | image_view_create_info.subresourceRange.levelCount = 1; |
| 9687 | image_view_create_info.subresourceRange.aspectMask = |
| 9688 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 9689 | |
| 9690 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9691 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 9692 | &view); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 9693 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9694 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 9695 | } |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9696 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9697 | TEST_F(VkLayerTest, InvalidImageViewAspect) { |
| 9698 | VkResult err; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 9699 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 9700 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9701 | "vkCreateImageView: Color image " |
| 9702 | "formats must have ONLY the " |
| 9703 | "VK_IMAGE_ASPECT_COLOR_BIT set"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9704 | |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 9705 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 9706 | |
| 9707 | // 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] | 9708 | VkImage image; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 9709 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9710 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 9711 | const int32_t tex_width = 32; |
| 9712 | const int32_t tex_height = 32; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 9713 | |
| 9714 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9715 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9716 | image_create_info.pNext = NULL; |
| 9717 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 9718 | image_create_info.format = tex_format; |
| 9719 | image_create_info.extent.width = tex_width; |
| 9720 | image_create_info.extent.height = tex_height; |
| 9721 | image_create_info.extent.depth = 1; |
| 9722 | image_create_info.mipLevels = 1; |
| 9723 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 9724 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 9725 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 9726 | image_create_info.flags = 0; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 9727 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9728 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 9729 | ASSERT_VK_SUCCESS(err); |
| 9730 | |
| 9731 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9732 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9733 | image_view_create_info.image = image; |
| 9734 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 9735 | image_view_create_info.format = tex_format; |
| 9736 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 9737 | image_view_create_info.subresourceRange.levelCount = 1; |
| 9738 | // Cause an error by setting an invalid image aspect |
| 9739 | image_view_create_info.subresourceRange.aspectMask = |
| 9740 | VK_IMAGE_ASPECT_METADATA_BIT; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 9741 | |
| 9742 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9743 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 9744 | &view); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 9745 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9746 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 9747 | } |
| 9748 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 9749 | TEST_F(VkLayerTest, CopyImageLayerCountMismatch) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9750 | VkResult err; |
| 9751 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9752 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9753 | m_errorMonitor->SetDesiredFailureMsg( |
| 9754 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 9755 | "vkCmdCopyImage: number of layers in source and destination subresources for pRegions"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9756 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9757 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9758 | |
| 9759 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9760 | VkImage srcImage; |
| 9761 | VkImage dstImage; |
| 9762 | VkDeviceMemory srcMem; |
| 9763 | VkDeviceMemory destMem; |
| 9764 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9765 | |
| 9766 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9767 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9768 | image_create_info.pNext = NULL; |
| 9769 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 9770 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 9771 | image_create_info.extent.width = 32; |
| 9772 | image_create_info.extent.height = 32; |
| 9773 | image_create_info.extent.depth = 1; |
| 9774 | image_create_info.mipLevels = 1; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 9775 | image_create_info.arrayLayers = 4; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9776 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 9777 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 9778 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 9779 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9780 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9781 | err = |
| 9782 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9783 | ASSERT_VK_SUCCESS(err); |
| 9784 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9785 | err = |
| 9786 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9787 | ASSERT_VK_SUCCESS(err); |
| 9788 | |
| 9789 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9790 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9791 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 9792 | memAlloc.pNext = NULL; |
| 9793 | memAlloc.allocationSize = 0; |
| 9794 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9795 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 9796 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9797 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9798 | pass = |
| 9799 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 9800 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9801 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9802 | ASSERT_VK_SUCCESS(err); |
| 9803 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9804 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9805 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9806 | pass = |
| 9807 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9808 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9809 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9810 | ASSERT_VK_SUCCESS(err); |
| 9811 | |
| 9812 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 9813 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9814 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9815 | ASSERT_VK_SUCCESS(err); |
| 9816 | |
| 9817 | BeginCommandBuffer(); |
| 9818 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 9819 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9820 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 9821 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 9822 | copyRegion.srcSubresource.layerCount = 1; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9823 | copyRegion.srcOffset.x = 0; |
| 9824 | copyRegion.srcOffset.y = 0; |
| 9825 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 9826 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9827 | copyRegion.dstSubresource.mipLevel = 0; |
| 9828 | copyRegion.dstSubresource.baseArrayLayer = 0; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 9829 | // Introduce failure by forcing the dst layerCount to differ from src |
| 9830 | copyRegion.dstSubresource.layerCount = 3; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9831 | copyRegion.dstOffset.x = 0; |
| 9832 | copyRegion.dstOffset.y = 0; |
| 9833 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9834 | copyRegion.extent.width = 1; |
| 9835 | copyRegion.extent.height = 1; |
| 9836 | copyRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9837 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 9838 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9839 | EndCommandBuffer(); |
| 9840 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9841 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9842 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9843 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9844 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9845 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 9846 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9847 | } |
| 9848 | |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 9849 | TEST_F(VkLayerTest, ImageLayerUnsupportedFormat) { |
| 9850 | |
| 9851 | TEST_DESCRIPTION("Creating images with unsuported formats "); |
| 9852 | |
| 9853 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9854 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 9855 | VkImageObj image(m_device); |
| 9856 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 9857 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 9858 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 9859 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 9860 | ASSERT_TRUE(image.initialized()); |
| 9861 | |
| 9862 | VkFormat unsupported = VK_FORMAT_UNDEFINED; |
| 9863 | for (int f = VK_FORMAT_BEGIN_RANGE; f <= VK_FORMAT_END_RANGE; f++) { |
| 9864 | VkFormat format = static_cast<VkFormat>(f); |
| 9865 | VkFormatProperties fProps = m_device->format_properties(format); |
| 9866 | if (format != VK_FORMAT_UNDEFINED && fProps.linearTilingFeatures == 0 && |
| 9867 | fProps.optimalTilingFeatures == 0) { |
| 9868 | unsupported = format; |
| 9869 | break; |
| 9870 | } |
| 9871 | } |
| 9872 | if (unsupported != VK_FORMAT_UNDEFINED) { |
| 9873 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9874 | "vkCreateImage parameter, " |
| 9875 | "VkFormat pCreateInfo->format, " |
| 9876 | "contains unsupported format"); |
| 9877 | // Create image with unsupported format - Expect FORMAT_UNSUPPORTED |
| 9878 | VkImageCreateInfo image_create_info; |
| 9879 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9880 | image_create_info.pNext = NULL; |
| 9881 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 9882 | image_create_info.format = unsupported; |
| 9883 | image_create_info.extent.width = 32; |
| 9884 | image_create_info.extent.height = 32; |
| 9885 | image_create_info.extent.depth = 1; |
| 9886 | image_create_info.mipLevels = 1; |
| 9887 | image_create_info.arrayLayers = 1; |
| 9888 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 9889 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 9890 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 9891 | image_create_info.flags = 0; |
| 9892 | |
| 9893 | VkImage localImage; |
| 9894 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &localImage); |
| 9895 | m_errorMonitor->VerifyFound(); |
| 9896 | |
| 9897 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9898 | "vkCreateRenderPass parameter, " |
| 9899 | "VkFormat in " |
| 9900 | "pCreateInfo->pAttachments"); |
| 9901 | // Create renderpass with unsupported format - Expect FORMAT_UNSUPPORTED |
| 9902 | VkAttachmentDescription att; |
| 9903 | att.format = unsupported; |
| 9904 | att.samples = VK_SAMPLE_COUNT_1_BIT; |
| 9905 | att.loadOp = VK_ATTACHMENT_LOAD_OP_LOAD; |
| 9906 | att.storeOp = VK_ATTACHMENT_STORE_OP_STORE; |
| 9907 | att.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; |
| 9908 | att.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; |
| 9909 | att.initialLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 9910 | att.finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 9911 | |
| 9912 | VkRenderPassCreateInfo rp_info = {}; |
| 9913 | VkRenderPass rp; |
| 9914 | rp_info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; |
| 9915 | rp_info.attachmentCount = 1; |
| 9916 | rp_info.pAttachments = &att; |
| 9917 | rp_info.subpassCount = 0; |
| 9918 | rp_info.pSubpasses = NULL; |
| 9919 | vkCreateRenderPass(m_device->handle(), &rp_info, NULL, &rp); |
| 9920 | m_errorMonitor->VerifyFound(); |
| 9921 | } |
| 9922 | } |
| 9923 | |
| 9924 | TEST_F(VkLayerTest, ImageLayerViewTests) { |
| 9925 | VkResult ret; |
| 9926 | TEST_DESCRIPTION("Passing bad parameters to CreateImageView"); |
| 9927 | |
| 9928 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9929 | |
| 9930 | VkImageObj image(m_device); |
| 9931 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 9932 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 9933 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 9934 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 9935 | ASSERT_TRUE(image.initialized()); |
| 9936 | |
| 9937 | VkImageView imgView; |
| 9938 | VkImageViewCreateInfo imgViewInfo = {}; |
| 9939 | imgViewInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 9940 | imgViewInfo.image = image.handle(); |
| 9941 | imgViewInfo.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 9942 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 9943 | imgViewInfo.subresourceRange.layerCount = 1; |
| 9944 | imgViewInfo.subresourceRange.baseMipLevel = 0; |
| 9945 | imgViewInfo.subresourceRange.levelCount = 1; |
| 9946 | imgViewInfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 9947 | |
| 9948 | m_errorMonitor->SetDesiredFailureMsg( |
| 9949 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9950 | "vkCreateImageView called with baseMipLevel"); |
| 9951 | // View can't have baseMipLevel >= image's mipLevels - Expect |
| 9952 | // VIEW_CREATE_ERROR |
| 9953 | imgViewInfo.subresourceRange.baseMipLevel = 1; |
| 9954 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 9955 | m_errorMonitor->VerifyFound(); |
| 9956 | imgViewInfo.subresourceRange.baseMipLevel = 0; |
| 9957 | |
| 9958 | m_errorMonitor->SetDesiredFailureMsg( |
| 9959 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9960 | "vkCreateImageView called with baseArrayLayer"); |
| 9961 | // View can't have baseArrayLayer >= image's arraySize - Expect |
| 9962 | // VIEW_CREATE_ERROR |
| 9963 | imgViewInfo.subresourceRange.baseArrayLayer = 1; |
| 9964 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 9965 | m_errorMonitor->VerifyFound(); |
| 9966 | imgViewInfo.subresourceRange.baseArrayLayer = 0; |
| 9967 | |
| 9968 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9969 | "vkCreateImageView called with 0 in " |
| 9970 | "pCreateInfo->subresourceRange." |
| 9971 | "levelCount"); |
| 9972 | // View's levelCount can't be 0 - Expect VIEW_CREATE_ERROR |
| 9973 | imgViewInfo.subresourceRange.levelCount = 0; |
| 9974 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 9975 | m_errorMonitor->VerifyFound(); |
| 9976 | imgViewInfo.subresourceRange.levelCount = 1; |
| 9977 | |
| 9978 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9979 | "vkCreateImageView called with 0 in " |
| 9980 | "pCreateInfo->subresourceRange." |
| 9981 | "layerCount"); |
| 9982 | // View's layerCount can't be 0 - Expect VIEW_CREATE_ERROR |
| 9983 | imgViewInfo.subresourceRange.layerCount = 0; |
| 9984 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 9985 | m_errorMonitor->VerifyFound(); |
| 9986 | imgViewInfo.subresourceRange.layerCount = 1; |
| 9987 | |
| 9988 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9989 | "but both must be color formats"); |
| 9990 | // Can't use depth format for view into color image - Expect INVALID_FORMAT |
| 9991 | imgViewInfo.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 9992 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 9993 | m_errorMonitor->VerifyFound(); |
| 9994 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 9995 | |
| 9996 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9997 | "Formats MUST be IDENTICAL unless " |
| 9998 | "VK_IMAGE_CREATE_MUTABLE_FORMAT BIT " |
| 9999 | "was set on image creation."); |
| 10000 | // Same compatibility class but no MUTABLE_FORMAT bit - Expect |
| 10001 | // VIEW_CREATE_ERROR |
| 10002 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UINT; |
| 10003 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 10004 | m_errorMonitor->VerifyFound(); |
| 10005 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10006 | |
| 10007 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10008 | "can support ImageViews with " |
| 10009 | "differing formats but they must be " |
| 10010 | "in the same compatibility class."); |
| 10011 | // Have MUTABLE_FORMAT bit but not in same compatibility class - Expect |
| 10012 | // VIEW_CREATE_ERROR |
| 10013 | VkImageCreateInfo mutImgInfo = image.create_info(); |
| 10014 | VkImage mutImage; |
| 10015 | mutImgInfo.format = VK_FORMAT_R8_UINT; |
| 10016 | assert( |
| 10017 | m_device->format_properties(VK_FORMAT_R8_UINT).optimalTilingFeatures & |
| 10018 | VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT); |
| 10019 | mutImgInfo.flags = VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT; |
| 10020 | mutImgInfo.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 10021 | ret = vkCreateImage(m_device->handle(), &mutImgInfo, NULL, &mutImage); |
| 10022 | ASSERT_VK_SUCCESS(ret); |
| 10023 | imgViewInfo.image = mutImage; |
| 10024 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 10025 | m_errorMonitor->VerifyFound(); |
| 10026 | imgViewInfo.image = image.handle(); |
| 10027 | vkDestroyImage(m_device->handle(), mutImage, NULL); |
| 10028 | } |
| 10029 | |
| 10030 | TEST_F(VkLayerTest, MiscImageLayerTests) { |
| 10031 | |
| 10032 | TEST_DESCRIPTION("Image layer tests that don't belong elsewhare"); |
| 10033 | |
| 10034 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10035 | |
| 10036 | VkImageObj image(m_device); |
| 10037 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 10038 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 10039 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 10040 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 10041 | ASSERT_TRUE(image.initialized()); |
| 10042 | |
| 10043 | m_errorMonitor->SetDesiredFailureMsg( |
| 10044 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10045 | "number of layers in image subresource is zero"); |
| 10046 | vk_testing::Buffer buffer; |
| 10047 | VkMemoryPropertyFlags reqs = 0; |
| 10048 | buffer.init_as_src(*m_device, 128 * 128 * 4, reqs); |
| 10049 | VkBufferImageCopy region = {}; |
| 10050 | region.bufferRowLength = 128; |
| 10051 | region.bufferImageHeight = 128; |
| 10052 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10053 | // layerCount can't be 0 - Expect MISMATCHED_IMAGE_ASPECT |
| 10054 | region.imageSubresource.layerCount = 0; |
| 10055 | region.imageExtent.height = 4; |
| 10056 | region.imageExtent.width = 4; |
| 10057 | region.imageExtent.depth = 1; |
| 10058 | m_commandBuffer->BeginCommandBuffer(); |
| 10059 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 10060 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 10061 | 1, ®ion); |
| 10062 | m_errorMonitor->VerifyFound(); |
| 10063 | region.imageSubresource.layerCount = 1; |
| 10064 | |
| 10065 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10066 | "aspectMasks for each region must " |
| 10067 | "specify only COLOR or DEPTH or " |
| 10068 | "STENCIL"); |
| 10069 | // Expect MISMATCHED_IMAGE_ASPECT |
| 10070 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_METADATA_BIT; |
| 10071 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 10072 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 10073 | 1, ®ion); |
| 10074 | m_errorMonitor->VerifyFound(); |
| 10075 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10076 | |
| 10077 | m_errorMonitor->SetDesiredFailureMsg( |
| 10078 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10079 | "If the format of srcImage is a depth, stencil, depth stencil or " |
| 10080 | "integer-based format then filter must be VK_FILTER_NEAREST"); |
| 10081 | // Expect INVALID_FILTER |
| 10082 | VkImageObj intImage1(m_device); |
| 10083 | intImage1.init(128, 128, VK_FORMAT_R8_UINT, |
| 10084 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, |
| 10085 | 0); |
| 10086 | VkImageObj intImage2(m_device); |
| 10087 | intImage2.init(128, 128, VK_FORMAT_R8_UINT, |
| 10088 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, |
| 10089 | 0); |
| 10090 | VkImageBlit blitRegion = {}; |
| 10091 | blitRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10092 | blitRegion.srcSubresource.baseArrayLayer = 0; |
| 10093 | blitRegion.srcSubresource.layerCount = 1; |
| 10094 | blitRegion.srcSubresource.mipLevel = 0; |
| 10095 | blitRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10096 | blitRegion.dstSubresource.baseArrayLayer = 0; |
| 10097 | blitRegion.dstSubresource.layerCount = 1; |
| 10098 | blitRegion.dstSubresource.mipLevel = 0; |
| 10099 | |
| 10100 | vkCmdBlitImage(m_commandBuffer->GetBufferHandle(), intImage1.handle(), |
| 10101 | intImage1.layout(), intImage2.handle(), intImage2.layout(), |
| 10102 | 16, &blitRegion, VK_FILTER_LINEAR); |
| 10103 | m_errorMonitor->VerifyFound(); |
| 10104 | |
| 10105 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10106 | "called with 0 in ppMemoryBarriers"); |
| 10107 | VkImageMemoryBarrier img_barrier; |
| 10108 | img_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; |
| 10109 | img_barrier.pNext = NULL; |
| 10110 | img_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 10111 | img_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 10112 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 10113 | img_barrier.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 10114 | img_barrier.image = image.handle(); |
| 10115 | img_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 10116 | img_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 10117 | img_barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10118 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 10119 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 10120 | // layerCount should not be 0 - Expect INVALID_IMAGE_RESOURCE |
| 10121 | img_barrier.subresourceRange.layerCount = 0; |
| 10122 | img_barrier.subresourceRange.levelCount = 1; |
| 10123 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 10124 | VK_PIPELINE_STAGE_HOST_BIT, |
| 10125 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 10126 | nullptr, 1, &img_barrier); |
| 10127 | m_errorMonitor->VerifyFound(); |
| 10128 | img_barrier.subresourceRange.layerCount = 1; |
| 10129 | } |
| 10130 | |
| 10131 | TEST_F(VkLayerTest, ImageFormatLimits) { |
| 10132 | |
| 10133 | TEST_DESCRIPTION("Exceed the limits of image format "); |
| 10134 | |
| 10135 | m_errorMonitor->SetDesiredFailureMsg( |
| 10136 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10137 | "CreateImage extents exceed allowable limits for format"); |
| 10138 | VkImageCreateInfo image_create_info = {}; |
| 10139 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10140 | image_create_info.pNext = NULL; |
| 10141 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10142 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10143 | image_create_info.extent.width = 32; |
| 10144 | image_create_info.extent.height = 32; |
| 10145 | image_create_info.extent.depth = 1; |
| 10146 | image_create_info.mipLevels = 1; |
| 10147 | image_create_info.arrayLayers = 1; |
| 10148 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10149 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 10150 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 10151 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 10152 | image_create_info.flags = 0; |
| 10153 | |
| 10154 | VkImage nullImg; |
| 10155 | VkImageFormatProperties imgFmtProps; |
| 10156 | vkGetPhysicalDeviceImageFormatProperties( |
| 10157 | gpu(), image_create_info.format, image_create_info.imageType, |
| 10158 | image_create_info.tiling, image_create_info.usage, |
| 10159 | image_create_info.flags, &imgFmtProps); |
| 10160 | image_create_info.extent.depth = imgFmtProps.maxExtent.depth + 1; |
| 10161 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 10162 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 10163 | m_errorMonitor->VerifyFound(); |
| 10164 | image_create_info.extent.depth = 1; |
| 10165 | |
| 10166 | m_errorMonitor->SetDesiredFailureMsg( |
| 10167 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10168 | "exceeds allowable maximum supported by format of"); |
| 10169 | image_create_info.mipLevels = imgFmtProps.maxMipLevels + 1; |
| 10170 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 10171 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 10172 | m_errorMonitor->VerifyFound(); |
| 10173 | image_create_info.mipLevels = 1; |
| 10174 | |
| 10175 | m_errorMonitor->SetDesiredFailureMsg( |
| 10176 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10177 | "exceeds allowable maximum supported by format of"); |
| 10178 | image_create_info.arrayLayers = imgFmtProps.maxArrayLayers + 1; |
| 10179 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 10180 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 10181 | m_errorMonitor->VerifyFound(); |
| 10182 | image_create_info.arrayLayers = 1; |
| 10183 | |
| 10184 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10185 | "is not supported by format"); |
| 10186 | int samples = imgFmtProps.sampleCounts >> 1; |
| 10187 | image_create_info.samples = (VkSampleCountFlagBits)samples; |
| 10188 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 10189 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 10190 | m_errorMonitor->VerifyFound(); |
| 10191 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10192 | |
| 10193 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10194 | "pCreateInfo->initialLayout, must be " |
| 10195 | "VK_IMAGE_LAYOUT_UNDEFINED or " |
| 10196 | "VK_IMAGE_LAYOUT_PREINITIALIZED"); |
| 10197 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 10198 | // Expect INVALID_LAYOUT |
| 10199 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 10200 | m_errorMonitor->VerifyFound(); |
| 10201 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 10202 | } |
| 10203 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10204 | TEST_F(VkLayerTest, CopyImageFormatSizeMismatch) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 10205 | VkResult err; |
| 10206 | bool pass; |
| 10207 | |
| 10208 | // Create color images with different format sizes and try to copy between them |
| 10209 | m_errorMonitor->SetDesiredFailureMsg( |
| 10210 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 10211 | "vkCmdCopyImage called with unmatched source and dest image format sizes"); |
| 10212 | |
| 10213 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 10214 | |
| 10215 | // Create two images of different types and try to copy between them |
| 10216 | VkImage srcImage; |
| 10217 | VkImage dstImage; |
| 10218 | VkDeviceMemory srcMem; |
| 10219 | VkDeviceMemory destMem; |
| 10220 | VkMemoryRequirements memReqs; |
| 10221 | |
| 10222 | VkImageCreateInfo image_create_info = {}; |
| 10223 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10224 | image_create_info.pNext = NULL; |
| 10225 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10226 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10227 | image_create_info.extent.width = 32; |
| 10228 | image_create_info.extent.height = 32; |
| 10229 | image_create_info.extent.depth = 1; |
| 10230 | image_create_info.mipLevels = 1; |
| 10231 | image_create_info.arrayLayers = 1; |
| 10232 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10233 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 10234 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 10235 | image_create_info.flags = 0; |
| 10236 | |
| 10237 | err = |
| 10238 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
| 10239 | ASSERT_VK_SUCCESS(err); |
| 10240 | |
| 10241 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 10242 | // Introduce failure by creating second image with a different-sized format. |
| 10243 | image_create_info.format = VK_FORMAT_R5G5B5A1_UNORM_PACK16; |
| 10244 | |
| 10245 | err = |
| 10246 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
| 10247 | ASSERT_VK_SUCCESS(err); |
| 10248 | |
| 10249 | // Allocate memory |
| 10250 | VkMemoryAllocateInfo memAlloc = {}; |
| 10251 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 10252 | memAlloc.pNext = NULL; |
| 10253 | memAlloc.allocationSize = 0; |
| 10254 | memAlloc.memoryTypeIndex = 0; |
| 10255 | |
| 10256 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
| 10257 | memAlloc.allocationSize = memReqs.size; |
| 10258 | pass = |
| 10259 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 10260 | ASSERT_TRUE(pass); |
| 10261 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
| 10262 | ASSERT_VK_SUCCESS(err); |
| 10263 | |
| 10264 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
| 10265 | memAlloc.allocationSize = memReqs.size; |
| 10266 | pass = |
| 10267 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 10268 | ASSERT_TRUE(pass); |
| 10269 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
| 10270 | ASSERT_VK_SUCCESS(err); |
| 10271 | |
| 10272 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 10273 | ASSERT_VK_SUCCESS(err); |
| 10274 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
| 10275 | ASSERT_VK_SUCCESS(err); |
| 10276 | |
| 10277 | BeginCommandBuffer(); |
| 10278 | VkImageCopy copyRegion; |
| 10279 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10280 | copyRegion.srcSubresource.mipLevel = 0; |
| 10281 | copyRegion.srcSubresource.baseArrayLayer = 0; |
| 10282 | copyRegion.srcSubresource.layerCount = 0; |
| 10283 | copyRegion.srcOffset.x = 0; |
| 10284 | copyRegion.srcOffset.y = 0; |
| 10285 | copyRegion.srcOffset.z = 0; |
| 10286 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 10287 | copyRegion.dstSubresource.mipLevel = 0; |
| 10288 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 10289 | copyRegion.dstSubresource.layerCount = 0; |
| 10290 | copyRegion.dstOffset.x = 0; |
| 10291 | copyRegion.dstOffset.y = 0; |
| 10292 | copyRegion.dstOffset.z = 0; |
| 10293 | copyRegion.extent.width = 1; |
| 10294 | copyRegion.extent.height = 1; |
| 10295 | copyRegion.extent.depth = 1; |
| 10296 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 10297 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 10298 | EndCommandBuffer(); |
| 10299 | |
| 10300 | m_errorMonitor->VerifyFound(); |
| 10301 | |
| 10302 | vkDestroyImage(m_device->device(), srcImage, NULL); |
| 10303 | vkDestroyImage(m_device->device(), dstImage, NULL); |
| 10304 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 10305 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10306 | } |
| 10307 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10308 | TEST_F(VkLayerTest, CopyImageDepthStencilFormatMismatch) { |
| 10309 | VkResult err; |
| 10310 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10311 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10312 | // 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] | 10313 | m_errorMonitor->SetDesiredFailureMsg( |
| 10314 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10315 | "vkCmdCopyImage called with unmatched source and dest image depth"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10316 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10317 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10318 | |
| 10319 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10320 | VkImage srcImage; |
| 10321 | VkImage dstImage; |
| 10322 | VkDeviceMemory srcMem; |
| 10323 | VkDeviceMemory destMem; |
| 10324 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10325 | |
| 10326 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10327 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10328 | image_create_info.pNext = NULL; |
| 10329 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10330 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10331 | image_create_info.extent.width = 32; |
| 10332 | image_create_info.extent.height = 32; |
| 10333 | image_create_info.extent.depth = 1; |
| 10334 | image_create_info.mipLevels = 1; |
| 10335 | image_create_info.arrayLayers = 1; |
| 10336 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10337 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 10338 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 10339 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10340 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10341 | err = |
| 10342 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10343 | ASSERT_VK_SUCCESS(err); |
| 10344 | |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 10345 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 10346 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10347 | // Introduce failure by creating second image with a depth/stencil format |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10348 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 10349 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 10350 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10351 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10352 | err = |
| 10353 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10354 | ASSERT_VK_SUCCESS(err); |
| 10355 | |
| 10356 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10357 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10358 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 10359 | memAlloc.pNext = NULL; |
| 10360 | memAlloc.allocationSize = 0; |
| 10361 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10362 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 10363 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10364 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10365 | pass = |
| 10366 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10367 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10368 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10369 | ASSERT_VK_SUCCESS(err); |
| 10370 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10371 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10372 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10373 | pass = |
| 10374 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10375 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10376 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10377 | ASSERT_VK_SUCCESS(err); |
| 10378 | |
| 10379 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 10380 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10381 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10382 | ASSERT_VK_SUCCESS(err); |
| 10383 | |
| 10384 | BeginCommandBuffer(); |
| 10385 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10386 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10387 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 10388 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10389 | copyRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10390 | copyRegion.srcOffset.x = 0; |
| 10391 | copyRegion.srcOffset.y = 0; |
| 10392 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10393 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10394 | copyRegion.dstSubresource.mipLevel = 0; |
| 10395 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 10396 | copyRegion.dstSubresource.layerCount = 0; |
| 10397 | copyRegion.dstOffset.x = 0; |
| 10398 | copyRegion.dstOffset.y = 0; |
| 10399 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10400 | copyRegion.extent.width = 1; |
| 10401 | copyRegion.extent.height = 1; |
| 10402 | copyRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10403 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 10404 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10405 | EndCommandBuffer(); |
| 10406 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10407 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10408 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10409 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10410 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10411 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 10412 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10413 | } |
| 10414 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10415 | TEST_F(VkLayerTest, ResolveImageLowSampleCount) { |
| 10416 | VkResult err; |
| 10417 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10418 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10419 | m_errorMonitor->SetDesiredFailureMsg( |
| 10420 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10421 | "vkCmdResolveImage called with source sample count less than 2."); |
| 10422 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10423 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10424 | |
| 10425 | // 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] | 10426 | VkImage srcImage; |
| 10427 | VkImage dstImage; |
| 10428 | VkDeviceMemory srcMem; |
| 10429 | VkDeviceMemory destMem; |
| 10430 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10431 | |
| 10432 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10433 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10434 | image_create_info.pNext = NULL; |
| 10435 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10436 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10437 | image_create_info.extent.width = 32; |
| 10438 | image_create_info.extent.height = 1; |
| 10439 | image_create_info.extent.depth = 1; |
| 10440 | image_create_info.mipLevels = 1; |
| 10441 | image_create_info.arrayLayers = 1; |
| 10442 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10443 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 10444 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 10445 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10446 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10447 | err = |
| 10448 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10449 | ASSERT_VK_SUCCESS(err); |
| 10450 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10451 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10452 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10453 | err = |
| 10454 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10455 | ASSERT_VK_SUCCESS(err); |
| 10456 | |
| 10457 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10458 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10459 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 10460 | memAlloc.pNext = NULL; |
| 10461 | memAlloc.allocationSize = 0; |
| 10462 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10463 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 10464 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10465 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10466 | pass = |
| 10467 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10468 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10469 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10470 | ASSERT_VK_SUCCESS(err); |
| 10471 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10472 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10473 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10474 | pass = |
| 10475 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10476 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10477 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10478 | ASSERT_VK_SUCCESS(err); |
| 10479 | |
| 10480 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 10481 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10482 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10483 | ASSERT_VK_SUCCESS(err); |
| 10484 | |
| 10485 | BeginCommandBuffer(); |
| 10486 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10487 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 10488 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10489 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10490 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10491 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 10492 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10493 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10494 | resolveRegion.srcOffset.x = 0; |
| 10495 | resolveRegion.srcOffset.y = 0; |
| 10496 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10497 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10498 | resolveRegion.dstSubresource.mipLevel = 0; |
| 10499 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 10500 | resolveRegion.dstSubresource.layerCount = 0; |
| 10501 | resolveRegion.dstOffset.x = 0; |
| 10502 | resolveRegion.dstOffset.y = 0; |
| 10503 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10504 | resolveRegion.extent.width = 1; |
| 10505 | resolveRegion.extent.height = 1; |
| 10506 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10507 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 10508 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10509 | EndCommandBuffer(); |
| 10510 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10511 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10512 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10513 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10514 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10515 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 10516 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10517 | } |
| 10518 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10519 | TEST_F(VkLayerTest, ResolveImageHighSampleCount) { |
| 10520 | VkResult err; |
| 10521 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10522 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10523 | m_errorMonitor->SetDesiredFailureMsg( |
| 10524 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10525 | "vkCmdResolveImage called with dest sample count greater than 1."); |
| 10526 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10527 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10528 | |
Chris Forbes | a753069 | 2016-05-08 12:35:39 +1200 | [diff] [blame] | 10529 | // 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] | 10530 | VkImage srcImage; |
| 10531 | VkImage dstImage; |
| 10532 | VkDeviceMemory srcMem; |
| 10533 | VkDeviceMemory destMem; |
| 10534 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10535 | |
| 10536 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10537 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10538 | image_create_info.pNext = NULL; |
| 10539 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10540 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10541 | image_create_info.extent.width = 32; |
| 10542 | image_create_info.extent.height = 1; |
| 10543 | image_create_info.extent.depth = 1; |
| 10544 | image_create_info.mipLevels = 1; |
| 10545 | image_create_info.arrayLayers = 1; |
Chris Forbes | a753069 | 2016-05-08 12:35:39 +1200 | [diff] [blame] | 10546 | image_create_info.samples = VK_SAMPLE_COUNT_4_BIT; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10547 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 10548 | // Note: Some implementations expect color attachment usage for any |
| 10549 | // multisample surface |
| 10550 | image_create_info.usage = |
| 10551 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 10552 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10553 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10554 | err = |
| 10555 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10556 | ASSERT_VK_SUCCESS(err); |
| 10557 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10558 | // Note: Some implementations expect color attachment usage for any |
| 10559 | // multisample surface |
| 10560 | image_create_info.usage = |
| 10561 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10562 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10563 | err = |
| 10564 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10565 | ASSERT_VK_SUCCESS(err); |
| 10566 | |
| 10567 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10568 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10569 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 10570 | memAlloc.pNext = NULL; |
| 10571 | memAlloc.allocationSize = 0; |
| 10572 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10573 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 10574 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10575 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10576 | pass = |
| 10577 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10578 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10579 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10580 | ASSERT_VK_SUCCESS(err); |
| 10581 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10582 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10583 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10584 | pass = |
| 10585 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10586 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10587 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10588 | ASSERT_VK_SUCCESS(err); |
| 10589 | |
| 10590 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 10591 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10592 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10593 | ASSERT_VK_SUCCESS(err); |
| 10594 | |
| 10595 | BeginCommandBuffer(); |
| 10596 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10597 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 10598 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10599 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10600 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10601 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 10602 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10603 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10604 | resolveRegion.srcOffset.x = 0; |
| 10605 | resolveRegion.srcOffset.y = 0; |
| 10606 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10607 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10608 | resolveRegion.dstSubresource.mipLevel = 0; |
| 10609 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 10610 | resolveRegion.dstSubresource.layerCount = 0; |
| 10611 | resolveRegion.dstOffset.x = 0; |
| 10612 | resolveRegion.dstOffset.y = 0; |
| 10613 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10614 | resolveRegion.extent.width = 1; |
| 10615 | resolveRegion.extent.height = 1; |
| 10616 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10617 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 10618 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10619 | EndCommandBuffer(); |
| 10620 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10621 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10622 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10623 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10624 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10625 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 10626 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10627 | } |
| 10628 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10629 | TEST_F(VkLayerTest, ResolveImageFormatMismatch) { |
| 10630 | VkResult err; |
| 10631 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10632 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10633 | m_errorMonitor->SetDesiredFailureMsg( |
| 10634 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10635 | "vkCmdResolveImage called with unmatched source and dest formats."); |
| 10636 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10637 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10638 | |
| 10639 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10640 | VkImage srcImage; |
| 10641 | VkImage dstImage; |
| 10642 | VkDeviceMemory srcMem; |
| 10643 | VkDeviceMemory destMem; |
| 10644 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10645 | |
| 10646 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10647 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10648 | image_create_info.pNext = NULL; |
| 10649 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10650 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10651 | image_create_info.extent.width = 32; |
| 10652 | image_create_info.extent.height = 1; |
| 10653 | image_create_info.extent.depth = 1; |
| 10654 | image_create_info.mipLevels = 1; |
| 10655 | image_create_info.arrayLayers = 1; |
| 10656 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 10657 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 10658 | // Note: Some implementations expect color attachment usage for any |
| 10659 | // multisample surface |
| 10660 | image_create_info.usage = |
| 10661 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 10662 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10663 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10664 | err = |
| 10665 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10666 | ASSERT_VK_SUCCESS(err); |
| 10667 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10668 | // Set format to something other than source image |
| 10669 | image_create_info.format = VK_FORMAT_R32_SFLOAT; |
| 10670 | // Note: Some implementations expect color attachment usage for any |
| 10671 | // multisample surface |
| 10672 | image_create_info.usage = |
| 10673 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 10674 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10675 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10676 | err = |
| 10677 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10678 | ASSERT_VK_SUCCESS(err); |
| 10679 | |
| 10680 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10681 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10682 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 10683 | memAlloc.pNext = NULL; |
| 10684 | memAlloc.allocationSize = 0; |
| 10685 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10686 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 10687 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10688 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10689 | pass = |
| 10690 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10691 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10692 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10693 | ASSERT_VK_SUCCESS(err); |
| 10694 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10695 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10696 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10697 | pass = |
| 10698 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10699 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10700 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10701 | ASSERT_VK_SUCCESS(err); |
| 10702 | |
| 10703 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 10704 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10705 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10706 | ASSERT_VK_SUCCESS(err); |
| 10707 | |
| 10708 | BeginCommandBuffer(); |
| 10709 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10710 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 10711 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10712 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10713 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10714 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 10715 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10716 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10717 | resolveRegion.srcOffset.x = 0; |
| 10718 | resolveRegion.srcOffset.y = 0; |
| 10719 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10720 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10721 | resolveRegion.dstSubresource.mipLevel = 0; |
| 10722 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 10723 | resolveRegion.dstSubresource.layerCount = 0; |
| 10724 | resolveRegion.dstOffset.x = 0; |
| 10725 | resolveRegion.dstOffset.y = 0; |
| 10726 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10727 | resolveRegion.extent.width = 1; |
| 10728 | resolveRegion.extent.height = 1; |
| 10729 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10730 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 10731 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10732 | EndCommandBuffer(); |
| 10733 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10734 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10735 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10736 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10737 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10738 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 10739 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10740 | } |
| 10741 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10742 | TEST_F(VkLayerTest, ResolveImageTypeMismatch) { |
| 10743 | VkResult err; |
| 10744 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10745 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10746 | m_errorMonitor->SetDesiredFailureMsg( |
| 10747 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10748 | "vkCmdResolveImage called with unmatched source and dest image types."); |
| 10749 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10750 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10751 | |
| 10752 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10753 | VkImage srcImage; |
| 10754 | VkImage dstImage; |
| 10755 | VkDeviceMemory srcMem; |
| 10756 | VkDeviceMemory destMem; |
| 10757 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10758 | |
| 10759 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10760 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10761 | image_create_info.pNext = NULL; |
| 10762 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10763 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 10764 | image_create_info.extent.width = 32; |
| 10765 | image_create_info.extent.height = 1; |
| 10766 | image_create_info.extent.depth = 1; |
| 10767 | image_create_info.mipLevels = 1; |
| 10768 | image_create_info.arrayLayers = 1; |
| 10769 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 10770 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 10771 | // Note: Some implementations expect color attachment usage for any |
| 10772 | // multisample surface |
| 10773 | image_create_info.usage = |
| 10774 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 10775 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10776 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10777 | err = |
| 10778 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10779 | ASSERT_VK_SUCCESS(err); |
| 10780 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10781 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 10782 | // Note: Some implementations expect color attachment usage for any |
| 10783 | // multisample surface |
| 10784 | image_create_info.usage = |
| 10785 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 10786 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10787 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10788 | err = |
| 10789 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10790 | ASSERT_VK_SUCCESS(err); |
| 10791 | |
| 10792 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10793 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10794 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 10795 | memAlloc.pNext = NULL; |
| 10796 | memAlloc.allocationSize = 0; |
| 10797 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10798 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 10799 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10800 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10801 | pass = |
| 10802 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10803 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10804 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10805 | ASSERT_VK_SUCCESS(err); |
| 10806 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10807 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10808 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10809 | pass = |
| 10810 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 10811 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10812 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10813 | ASSERT_VK_SUCCESS(err); |
| 10814 | |
| 10815 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 10816 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10817 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10818 | ASSERT_VK_SUCCESS(err); |
| 10819 | |
| 10820 | BeginCommandBuffer(); |
| 10821 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10822 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 10823 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10824 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10825 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10826 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 10827 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10828 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10829 | resolveRegion.srcOffset.x = 0; |
| 10830 | resolveRegion.srcOffset.y = 0; |
| 10831 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 10832 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10833 | resolveRegion.dstSubresource.mipLevel = 0; |
| 10834 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 10835 | resolveRegion.dstSubresource.layerCount = 0; |
| 10836 | resolveRegion.dstOffset.x = 0; |
| 10837 | resolveRegion.dstOffset.y = 0; |
| 10838 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10839 | resolveRegion.extent.width = 1; |
| 10840 | resolveRegion.extent.height = 1; |
| 10841 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10842 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 10843 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10844 | EndCommandBuffer(); |
| 10845 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10846 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10847 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10848 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10849 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10850 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 10851 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 10852 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10853 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10854 | TEST_F(VkLayerTest, DepthStencilImageViewWithColorAspectBitError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10855 | // 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] | 10856 | // to using a DS format, then cause it to hit error due to COLOR_BIT not |
| 10857 | // set in aspect |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10858 | // The image format check comes 2nd in validation so we trigger it first, |
| 10859 | // 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] | 10860 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10861 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10862 | m_errorMonitor->SetDesiredFailureMsg( |
| 10863 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10864 | "Combination depth/stencil image formats can have only the "); |
| 10865 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10866 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10867 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 10868 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10869 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 10870 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10871 | |
| 10872 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10873 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 10874 | ds_pool_ci.pNext = NULL; |
| 10875 | ds_pool_ci.maxSets = 1; |
| 10876 | ds_pool_ci.poolSizeCount = 1; |
| 10877 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10878 | |
| 10879 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10880 | err = |
| 10881 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10882 | ASSERT_VK_SUCCESS(err); |
| 10883 | |
| 10884 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10885 | dsl_binding.binding = 0; |
| 10886 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 10887 | dsl_binding.descriptorCount = 1; |
| 10888 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 10889 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10890 | |
| 10891 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10892 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 10893 | ds_layout_ci.pNext = NULL; |
| 10894 | ds_layout_ci.bindingCount = 1; |
| 10895 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10896 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10897 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 10898 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10899 | ASSERT_VK_SUCCESS(err); |
| 10900 | |
| 10901 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 10902 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 10903 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 10904 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10905 | alloc_info.descriptorPool = ds_pool; |
| 10906 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10907 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 10908 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10909 | ASSERT_VK_SUCCESS(err); |
| 10910 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10911 | VkImage image_bad; |
| 10912 | VkImage image_good; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10913 | // One bad format and one good format for Color attachment |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10914 | const VkFormat tex_format_bad = VK_FORMAT_D32_SFLOAT_S8_UINT; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10915 | const VkFormat tex_format_good = VK_FORMAT_B8G8R8A8_UNORM; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10916 | const int32_t tex_width = 32; |
| 10917 | const int32_t tex_height = 32; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10918 | |
| 10919 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10920 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10921 | image_create_info.pNext = NULL; |
| 10922 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 10923 | image_create_info.format = tex_format_bad; |
| 10924 | image_create_info.extent.width = tex_width; |
| 10925 | image_create_info.extent.height = tex_height; |
| 10926 | image_create_info.extent.depth = 1; |
| 10927 | image_create_info.mipLevels = 1; |
| 10928 | image_create_info.arrayLayers = 1; |
| 10929 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 10930 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 10931 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT | |
| 10932 | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 10933 | image_create_info.flags = 0; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10934 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10935 | err = |
| 10936 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image_bad); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10937 | ASSERT_VK_SUCCESS(err); |
| 10938 | image_create_info.format = tex_format_good; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10939 | image_create_info.usage = |
| 10940 | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 10941 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, |
| 10942 | &image_good); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10943 | ASSERT_VK_SUCCESS(err); |
| 10944 | |
| 10945 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10946 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 10947 | image_view_create_info.image = image_bad; |
| 10948 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 10949 | image_view_create_info.format = tex_format_bad; |
| 10950 | image_view_create_info.subresourceRange.baseArrayLayer = 0; |
| 10951 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 10952 | image_view_create_info.subresourceRange.layerCount = 1; |
| 10953 | image_view_create_info.subresourceRange.levelCount = 1; |
| 10954 | image_view_create_info.subresourceRange.aspectMask = |
| 10955 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10956 | |
| 10957 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 10958 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 10959 | &view); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 10960 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 10961 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10962 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10963 | vkDestroyImage(m_device->device(), image_bad, NULL); |
| 10964 | vkDestroyImage(m_device->device(), image_good, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 10965 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 10966 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 10967 | } |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 10968 | #endif // IMAGE_TESTS |
| 10969 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 10970 | int main(int argc, char **argv) { |
| 10971 | int result; |
| 10972 | |
Cody Northrop | 8e54a40 | 2016-03-08 22:25:52 -0700 | [diff] [blame] | 10973 | #ifdef ANDROID |
| 10974 | int vulkanSupport = InitVulkan(); |
| 10975 | if (vulkanSupport == 0) |
| 10976 | return 1; |
| 10977 | #endif |
| 10978 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 10979 | ::testing::InitGoogleTest(&argc, argv); |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 10980 | VkTestFramework::InitArgs(&argc, argv); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 10981 | |
| 10982 | ::testing::AddGlobalTestEnvironment(new TestEnvironment); |
| 10983 | |
| 10984 | result = RUN_ALL_TESTS(); |
| 10985 | |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 10986 | VkTestFramework::Finish(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 10987 | return result; |
| 10988 | } |