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; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 268 | |
| 269 | virtual void SetUp() { |
Courtney Goeltzenleuchter | cd69eee | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 270 | std::vector<const char *> instance_layer_names; |
| 271 | std::vector<const char *> device_layer_names; |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 272 | std::vector<const char *> instance_extension_names; |
| 273 | std::vector<const char *> device_extension_names; |
Tony Barbour | 3fdff9e | 2015-04-23 12:55:36 -0600 | [diff] [blame] | 274 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 275 | instance_extension_names.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME); |
Courtney Goeltzenleuchter | c2b06fe | 2015-06-16 15:59:11 -0600 | [diff] [blame] | 276 | /* |
| 277 | * Since CreateDbgMsgCallback is an instance level extension call |
| 278 | * any extension / layer that utilizes that feature also needs |
| 279 | * to be enabled at create instance time. |
| 280 | */ |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 281 | // Use Threading layer first to protect others from |
| 282 | // ThreadCommandBufferCollision test |
Courtney Goeltzenleuchter | 7688532 | 2016-02-06 17:11:22 -0700 | [diff] [blame] | 283 | instance_layer_names.push_back("VK_LAYER_GOOGLE_threading"); |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 284 | instance_layer_names.push_back("VK_LAYER_LUNARG_parameter_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 285 | instance_layer_names.push_back("VK_LAYER_LUNARG_object_tracker"); |
Tobin Ehlis | c96f806 | 2016-03-09 16:12:48 -0700 | [diff] [blame] | 286 | instance_layer_names.push_back("VK_LAYER_LUNARG_core_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 287 | instance_layer_names.push_back("VK_LAYER_LUNARG_device_limits"); |
| 288 | instance_layer_names.push_back("VK_LAYER_LUNARG_image"); |
Ian Elliott | e48a138 | 2016-04-28 14:22:58 -0600 | [diff] [blame] | 289 | instance_layer_names.push_back("VK_LAYER_LUNARG_swapchain"); |
Dustin Graves | eaa78cd | 2016-01-26 16:30:22 -0700 | [diff] [blame] | 290 | instance_layer_names.push_back("VK_LAYER_GOOGLE_unique_objects"); |
Courtney Goeltzenleuchter | d971b61 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 291 | |
Courtney Goeltzenleuchter | 7688532 | 2016-02-06 17:11:22 -0700 | [diff] [blame] | 292 | device_layer_names.push_back("VK_LAYER_GOOGLE_threading"); |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 293 | device_layer_names.push_back("VK_LAYER_LUNARG_parameter_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 294 | device_layer_names.push_back("VK_LAYER_LUNARG_object_tracker"); |
Tobin Ehlis | c96f806 | 2016-03-09 16:12:48 -0700 | [diff] [blame] | 295 | device_layer_names.push_back("VK_LAYER_LUNARG_core_validation"); |
Michael Lentine | 03107b4 | 2015-12-11 10:49:51 -0800 | [diff] [blame] | 296 | device_layer_names.push_back("VK_LAYER_LUNARG_device_limits"); |
| 297 | device_layer_names.push_back("VK_LAYER_LUNARG_image"); |
Ian Elliott | e48a138 | 2016-04-28 14:22:58 -0600 | [diff] [blame] | 298 | device_layer_names.push_back("VK_LAYER_LUNARG_swapchain"); |
Dustin Graves | eaa78cd | 2016-01-26 16:30:22 -0700 | [diff] [blame] | 299 | device_layer_names.push_back("VK_LAYER_GOOGLE_unique_objects"); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 300 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 301 | this->app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 302 | this->app_info.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 303 | this->app_info.pApplicationName = "layer_tests"; |
| 304 | this->app_info.applicationVersion = 1; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 305 | this->app_info.pEngineName = "unittest"; |
| 306 | this->app_info.engineVersion = 1; |
Jon Ashburn | c5012ff | 2016-03-22 13:57:46 -0600 | [diff] [blame] | 307 | this->app_info.apiVersion = VK_API_VERSION_1_0; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 308 | |
Tony Barbour | 15524c3 | 2015-04-29 17:34:29 -0600 | [diff] [blame] | 309 | m_errorMonitor = new ErrorMonitor; |
Courtney Goeltzenleuchter | cd69eee | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 310 | InitFramework(instance_layer_names, device_layer_names, |
| 311 | instance_extension_names, device_extension_names, |
| 312 | myDbgFunc, m_errorMonitor); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 313 | } |
| 314 | |
| 315 | virtual void TearDown() { |
| 316 | // Clean up resources before we reset |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 317 | ShutdownFramework(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 318 | delete m_errorMonitor; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 319 | } |
| 320 | }; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 321 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 322 | VkResult VkLayerTest::BeginCommandBuffer(VkCommandBufferObj &commandBuffer) { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 323 | VkResult result; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 324 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 325 | result = commandBuffer.BeginCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 326 | |
| 327 | /* |
| 328 | * For render test all drawing happens in a single render pass |
| 329 | * on a single command buffer. |
| 330 | */ |
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 331 | if (VK_SUCCESS == result && renderPass()) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 332 | commandBuffer.BeginRenderPass(renderPassBeginInfo()); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 333 | } |
| 334 | |
| 335 | return result; |
| 336 | } |
| 337 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 338 | VkResult VkLayerTest::EndCommandBuffer(VkCommandBufferObj &commandBuffer) { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 339 | VkResult result; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 340 | |
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 341 | if (renderPass()) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 342 | commandBuffer.EndRenderPass(); |
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 343 | } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 344 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 345 | result = commandBuffer.EndCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 346 | |
| 347 | return result; |
| 348 | } |
| 349 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 350 | void VkLayerTest::VKTriangleTest(const char *vertShaderText, |
| 351 | const char *fragShaderText, |
| 352 | BsoFailSelect failMask) { |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 353 | // Create identity matrix |
| 354 | int i; |
| 355 | struct vktriangle_vs_uniform data; |
| 356 | |
| 357 | glm::mat4 Projection = glm::mat4(1.0f); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 358 | glm::mat4 View = glm::mat4(1.0f); |
| 359 | glm::mat4 Model = glm::mat4(1.0f); |
| 360 | glm::mat4 MVP = Projection * View * Model; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 361 | const int matrixSize = sizeof(MVP); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 362 | const int bufSize = sizeof(vktriangle_vs_uniform) / sizeof(float); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 363 | |
| 364 | memcpy(&data.mvp, &MVP[0][0], matrixSize); |
| 365 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 366 | static const Vertex tri_data[] = { |
| 367 | {XYZ1(-1, -1, 0), XYZ1(1.f, 0.f, 0.f)}, |
| 368 | {XYZ1(1, -1, 0), XYZ1(0.f, 1.f, 0.f)}, |
| 369 | {XYZ1(0, 1, 0), XYZ1(0.f, 0.f, 1.f)}, |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 370 | }; |
| 371 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 372 | for (i = 0; i < 3; i++) { |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 373 | data.position[i][0] = tri_data[i].posX; |
| 374 | data.position[i][1] = tri_data[i].posY; |
| 375 | data.position[i][2] = tri_data[i].posZ; |
| 376 | data.position[i][3] = tri_data[i].posW; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 377 | data.color[i][0] = tri_data[i].r; |
| 378 | data.color[i][1] = tri_data[i].g; |
| 379 | data.color[i][2] = tri_data[i].b; |
| 380 | data.color[i][3] = tri_data[i].a; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 381 | } |
| 382 | |
| 383 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 384 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 385 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 386 | VkConstantBufferObj constantBuffer(m_device, bufSize * 2, sizeof(float), |
| 387 | (const void *)&data); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 388 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 389 | VkShaderObj vs(m_device, vertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 390 | VkShaderObj ps(m_device, fragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, |
| 391 | this); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 392 | |
| 393 | VkPipelineObj pipelineobj(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 394 | pipelineobj.AddColorAttachment(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 395 | pipelineobj.AddShader(&vs); |
| 396 | pipelineobj.AddShader(&ps); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 397 | if (failMask & BsoFailLineWidth) { |
| 398 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_LINE_WIDTH); |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 399 | VkPipelineInputAssemblyStateCreateInfo ia_state = {}; |
| 400 | ia_state.sType = |
| 401 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 402 | ia_state.topology = VK_PRIMITIVE_TOPOLOGY_LINE_LIST; |
| 403 | pipelineobj.SetInputAssembly(&ia_state); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 404 | } |
| 405 | if (failMask & BsoFailDepthBias) { |
| 406 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_DEPTH_BIAS); |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 407 | VkPipelineRasterizationStateCreateInfo rs_state = {}; |
| 408 | rs_state.sType = |
| 409 | VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 410 | rs_state.depthBiasEnable = VK_TRUE; |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 411 | rs_state.lineWidth = 1.0f; |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 412 | pipelineobj.SetRasterization(&rs_state); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 413 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 414 | // Viewport and scissors must stay in synch or other errors will occur than |
| 415 | // the ones we want |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 416 | if (failMask & BsoFailViewport) { |
| 417 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_VIEWPORT); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 418 | m_viewports.clear(); |
| 419 | m_scissors.clear(); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 420 | } |
| 421 | if (failMask & BsoFailScissor) { |
| 422 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_SCISSOR); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 423 | m_scissors.clear(); |
| 424 | m_viewports.clear(); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 425 | } |
| 426 | if (failMask & BsoFailBlend) { |
| 427 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_BLEND_CONSTANTS); |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 428 | VkPipelineColorBlendAttachmentState att_state = {}; |
| 429 | att_state.dstAlphaBlendFactor = VK_BLEND_FACTOR_CONSTANT_COLOR; |
| 430 | att_state.blendEnable = VK_TRUE; |
| 431 | pipelineobj.AddColorAttachment(0, &att_state); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 432 | } |
| 433 | if (failMask & BsoFailDepthBounds) { |
| 434 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_DEPTH_BOUNDS); |
| 435 | } |
| 436 | if (failMask & BsoFailStencilReadMask) { |
| 437 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK); |
| 438 | } |
| 439 | if (failMask & BsoFailStencilWriteMask) { |
| 440 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_WRITE_MASK); |
| 441 | } |
| 442 | if (failMask & BsoFailStencilReference) { |
| 443 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_REFERENCE); |
| 444 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 445 | |
| 446 | VkDescriptorSetObj descriptorSet(m_device); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 447 | descriptorSet.AppendBuffer(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, |
| 448 | constantBuffer); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 449 | |
| 450 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 451 | ASSERT_VK_SUCCESS(BeginCommandBuffer()); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 452 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 453 | GenericDrawPreparation(pipelineobj, descriptorSet, failMask); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 454 | |
| 455 | // render triangle |
Courtney Goeltzenleuchter | 08c2637 | 2015-09-23 12:31:50 -0600 | [diff] [blame] | 456 | Draw(3, 1, 0, 0); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 457 | |
| 458 | // finalize recording of the command buffer |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 459 | EndCommandBuffer(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 460 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 461 | QueueCommandBuffer(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 462 | } |
| 463 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 464 | void VkLayerTest::GenericDrawPreparation(VkCommandBufferObj *commandBuffer, |
| 465 | VkPipelineObj &pipelineobj, |
| 466 | VkDescriptorSetObj &descriptorSet, |
| 467 | BsoFailSelect failMask) { |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 468 | if (m_depthStencil->Initialized()) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 469 | commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 470 | m_stencil_clear_color, m_depthStencil); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 471 | } else { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 472 | commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 473 | m_stencil_clear_color, NULL); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 474 | } |
| 475 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 476 | commandBuffer->PrepareAttachments(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 477 | // Make sure depthWriteEnable is set so that Depth fail test will work |
| 478 | // correctly |
| 479 | // Make sure stencilTestEnable is set so that Stencil fail test will work |
| 480 | // correctly |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 481 | VkStencilOpState stencil = {}; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 482 | stencil.failOp = VK_STENCIL_OP_KEEP; |
| 483 | stencil.passOp = VK_STENCIL_OP_KEEP; |
| 484 | stencil.depthFailOp = VK_STENCIL_OP_KEEP; |
| 485 | stencil.compareOp = VK_COMPARE_OP_NEVER; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 486 | |
| 487 | VkPipelineDepthStencilStateCreateInfo ds_ci = {}; |
| 488 | ds_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO; |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 489 | ds_ci.pNext = NULL; |
| 490 | ds_ci.depthTestEnable = VK_FALSE; |
| 491 | ds_ci.depthWriteEnable = VK_TRUE; |
| 492 | ds_ci.depthCompareOp = VK_COMPARE_OP_NEVER; |
| 493 | ds_ci.depthBoundsTestEnable = VK_FALSE; |
Tobin Ehlis | 7a1d235 | 2016-03-28 11:18:19 -0600 | [diff] [blame] | 494 | if (failMask & BsoFailDepthBounds) { |
| 495 | ds_ci.depthBoundsTestEnable = VK_TRUE; |
| 496 | } |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 497 | ds_ci.stencilTestEnable = VK_TRUE; |
| 498 | ds_ci.front = stencil; |
| 499 | ds_ci.back = stencil; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 500 | |
Tobin Ehlis | 4bf96d1 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 501 | pipelineobj.SetDepthStencil(&ds_ci); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 502 | pipelineobj.SetViewport(m_viewports); |
| 503 | pipelineobj.SetScissor(m_scissors); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 504 | descriptorSet.CreateVKDescriptorSet(commandBuffer); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 505 | VkResult err = pipelineobj.CreateVKPipeline( |
| 506 | descriptorSet.GetPipelineLayout(), renderPass()); |
Cody Northrop | 29a08f2 | 2015-08-27 10:20:35 -0600 | [diff] [blame] | 507 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 508 | commandBuffer->BindPipeline(pipelineobj); |
| 509 | commandBuffer->BindDescriptorSet(descriptorSet); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 510 | } |
| 511 | |
| 512 | // ******************************************************************************************************************** |
| 513 | // ******************************************************************************************************************** |
| 514 | // ******************************************************************************************************************** |
| 515 | // ******************************************************************************************************************** |
Dustin Graves | ffa90fa | 2016-05-06 11:20:38 -0600 | [diff] [blame] | 516 | #if PARAMETER_VALIDATION_TESTS |
| 517 | TEST_F(VkLayerTest, RequiredParameter) { |
| 518 | TEST_DESCRIPTION("Specify VK_NULL_HANDLE, NULL, and 0 for required handle, " |
| 519 | "pointer, array, and array count parameters"); |
| 520 | |
| 521 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 522 | |
| 523 | m_errorMonitor->SetDesiredFailureMsg( |
| 524 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 525 | "required parameter pFeatures specified as NULL"); |
| 526 | // Specify NULL for a pointer to a handle |
| 527 | // Expected to trigger an error with |
| 528 | // parameter_validation::validate_required_pointer |
| 529 | vkGetPhysicalDeviceFeatures(gpu(), NULL); |
| 530 | m_errorMonitor->VerifyFound(); |
| 531 | |
| 532 | m_errorMonitor->SetDesiredFailureMsg( |
| 533 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 534 | "required parameter pPhysicalDeviceCount specified as NULL"); |
| 535 | // Specify NULL for pointer to array count |
| 536 | // Expected to trigger an error with parameter_validation::validate_array |
| 537 | vkEnumeratePhysicalDevices(instance(), NULL, NULL); |
| 538 | m_errorMonitor->VerifyFound(); |
| 539 | |
| 540 | m_errorMonitor->SetDesiredFailureMsg( |
| 541 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 542 | "parameter viewportCount must be greater than 0"); |
| 543 | // Specify 0 for a required array count |
| 544 | // Expected to trigger an error with parameter_validation::validate_array |
| 545 | VkViewport view_port = {}; |
| 546 | m_commandBuffer->SetViewport(0, 0, &view_port); |
| 547 | m_errorMonitor->VerifyFound(); |
| 548 | |
| 549 | m_errorMonitor->SetDesiredFailureMsg( |
| 550 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 551 | "required parameter pViewports specified as NULL"); |
| 552 | // Specify NULL for a required array |
| 553 | // Expected to trigger an error with parameter_validation::validate_array |
| 554 | m_commandBuffer->SetViewport(0, 1, NULL); |
| 555 | m_errorMonitor->VerifyFound(); |
| 556 | |
| 557 | m_errorMonitor->SetDesiredFailureMsg( |
| 558 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 559 | "required parameter memory specified as VK_NULL_HANDLE"); |
| 560 | // Specify VK_NULL_HANDLE for a required handle |
| 561 | // Expected to trigger an error with |
| 562 | // parameter_validation::validate_required_handle |
| 563 | vkUnmapMemory(device(), VK_NULL_HANDLE); |
| 564 | m_errorMonitor->VerifyFound(); |
| 565 | |
| 566 | m_errorMonitor->SetDesiredFailureMsg( |
| 567 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 568 | "required parameter pFences[0] specified as VK_NULL_HANDLE"); |
| 569 | // Specify VK_NULL_HANDLE for a required handle array entry |
| 570 | // Expected to trigger an error with |
| 571 | // parameter_validation::validate_required_handle_array |
| 572 | VkFence fence = VK_NULL_HANDLE; |
| 573 | vkResetFences(device(), 1, &fence); |
| 574 | m_errorMonitor->VerifyFound(); |
| 575 | |
| 576 | m_errorMonitor->SetDesiredFailureMsg( |
| 577 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 578 | "required parameter pAllocateInfo specified as NULL"); |
| 579 | // Specify NULL for a required struct pointer |
| 580 | // Expected to trigger an error with |
| 581 | // parameter_validation::validate_struct_type |
| 582 | VkDeviceMemory memory = VK_NULL_HANDLE; |
| 583 | vkAllocateMemory(device(), NULL, NULL, &memory); |
| 584 | m_errorMonitor->VerifyFound(); |
| 585 | |
| 586 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 587 | "value of faceMask must not be 0"); |
| 588 | // Specify 0 for a required VkFlags parameter |
| 589 | // Expected to trigger an error with parameter_validation::validate_flags |
| 590 | m_commandBuffer->SetStencilReference(0, 0); |
| 591 | m_errorMonitor->VerifyFound(); |
| 592 | |
| 593 | m_errorMonitor->SetDesiredFailureMsg( |
| 594 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 595 | "value of pSubmits[i].pWaitDstStageMask[0] must not be 0"); |
| 596 | // Specify 0 for a required VkFlags array entry |
| 597 | // Expected to trigger an error with |
| 598 | // parameter_validation::validate_flags_array |
| 599 | VkSemaphore semaphore = VK_NULL_HANDLE; |
| 600 | VkPipelineStageFlags stageFlags = 0; |
| 601 | VkSubmitInfo submitInfo = {}; |
| 602 | submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 603 | submitInfo.waitSemaphoreCount = 1; |
| 604 | submitInfo.pWaitSemaphores = &semaphore; |
| 605 | submitInfo.pWaitDstStageMask = &stageFlags; |
| 606 | vkQueueSubmit(m_device->m_queue, 1, &submitInfo, VK_NULL_HANDLE); |
| 607 | m_errorMonitor->VerifyFound(); |
| 608 | } |
Dustin Graves | c99cf5a | 2016-05-09 14:40:29 -0600 | [diff] [blame] | 609 | |
| 610 | TEST_F(VkLayerTest, InvalidStructSType) { |
| 611 | TEST_DESCRIPTION("Specify an invalid VkStructureType for a Vulkan " |
| 612 | "structure's sType field"); |
| 613 | |
| 614 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 615 | |
| 616 | m_errorMonitor->SetDesiredFailureMsg( |
| 617 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 618 | "parameter pAllocateInfo->sType must be"); |
| 619 | // Zero struct memory, effectively setting sType to |
| 620 | // VK_STRUCTURE_TYPE_APPLICATION_INFO |
| 621 | // Expected to trigger an error with |
| 622 | // parameter_validation::validate_struct_type |
| 623 | VkMemoryAllocateInfo alloc_info = {}; |
| 624 | VkDeviceMemory memory = VK_NULL_HANDLE; |
| 625 | vkAllocateMemory(device(), &alloc_info, NULL, &memory); |
| 626 | m_errorMonitor->VerifyFound(); |
| 627 | |
| 628 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 629 | "parameter pSubmits[0].sType must be"); |
| 630 | // Zero struct memory, effectively setting sType to |
| 631 | // VK_STRUCTURE_TYPE_APPLICATION_INFO |
| 632 | // Expected to trigger an error with |
| 633 | // parameter_validation::validate_struct_type_array |
| 634 | VkSubmitInfo submit_info = {}; |
| 635 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 636 | m_errorMonitor->VerifyFound(); |
| 637 | } |
| 638 | |
| 639 | TEST_F(VkLayerTest, InvalidStructPNext) { |
| 640 | TEST_DESCRIPTION( |
| 641 | "Specify an invalid value for a Vulkan structure's pNext field"); |
| 642 | |
| 643 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 644 | |
| 645 | m_errorMonitor->SetDesiredFailureMsg( |
| 646 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 647 | "value of pAllocateInfo->pNext must be NULL"); |
| 648 | // Set VkMemoryAllocateInfo::pNext to a non-NULL value, when pNext must be |
| 649 | // NULL |
| 650 | // Expected to trigger an error with |
| 651 | // parameter_validation::validate_struct_pnext |
| 652 | VkDeviceMemory memory = VK_NULL_HANDLE; |
| 653 | // Zero-initialization will provide the correct sType |
| 654 | VkApplicationInfo app_info = {}; |
| 655 | VkMemoryAllocateInfo alloc_info = {}; |
| 656 | alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 657 | alloc_info.pNext = &app_info; |
| 658 | vkAllocateMemory(device(), &alloc_info, NULL, &memory); |
| 659 | m_errorMonitor->VerifyFound(); |
| 660 | |
| 661 | // TODO: Add non-NULL pNext case |
| 662 | } |
Dustin Graves | 5d33d53 | 2016-05-09 16:21:12 -0600 | [diff] [blame^] | 663 | |
| 664 | TEST_F(VkLayerTest, UnrecognizedValue) { |
| 665 | TEST_DESCRIPTION( |
| 666 | "Specify unrecognized Vulkan enumeration, flags, and VkBool32 values"); |
| 667 | |
| 668 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 669 | |
| 670 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 671 | "does not fall within the begin..end " |
| 672 | "range of the core VkFormat " |
| 673 | "enumeration tokens"); |
| 674 | // Specify an invalid VkFormat value |
| 675 | // Expected to trigger an error with |
| 676 | // parameter_validation::validate_ranged_enum |
| 677 | VkFormatProperties format_properties; |
| 678 | vkGetPhysicalDeviceFormatProperties(gpu(), static_cast<VkFormat>(8000), |
| 679 | &format_properties); |
| 680 | m_errorMonitor->VerifyFound(); |
| 681 | |
| 682 | m_errorMonitor->SetDesiredFailureMsg( |
| 683 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 684 | "contains flag bits that are not recognized members of"); |
| 685 | // Specify an invalid VkFlags bitmask value |
| 686 | // Expected to trigger an error with parameter_validation::validate_flags |
| 687 | VkImageFormatProperties image_format_properties; |
| 688 | vkGetPhysicalDeviceImageFormatProperties( |
| 689 | gpu(), VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_TYPE_2D, |
| 690 | VK_IMAGE_TILING_OPTIMAL, static_cast<VkImageUsageFlags>(1 << 25), 0, |
| 691 | &image_format_properties); |
| 692 | m_errorMonitor->VerifyFound(); |
| 693 | |
| 694 | m_errorMonitor->SetDesiredFailureMsg( |
| 695 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 696 | "contains flag bits that are not recognized members of"); |
| 697 | // Specify an invalid VkFlags array entry |
| 698 | // Expected to trigger an error with |
| 699 | // parameter_validation::validate_flags_array |
| 700 | VkSemaphore semaphore = VK_NULL_HANDLE; |
| 701 | VkPipelineStageFlags stage_flags = |
| 702 | static_cast<VkPipelineStageFlags>(1 << 25); |
| 703 | VkSubmitInfo submit_info = {}; |
| 704 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 705 | submit_info.waitSemaphoreCount = 1; |
| 706 | submit_info.pWaitSemaphores = &semaphore; |
| 707 | submit_info.pWaitDstStageMask = &stage_flags; |
| 708 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 709 | m_errorMonitor->VerifyFound(); |
| 710 | |
| 711 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, |
| 712 | "is neither VK_TRUE nor VK_FALSE"); |
| 713 | // Specify an invalid VkBool32 value |
| 714 | // Expected to trigger a warning with |
| 715 | // parameter_validation::validate_bool32 |
| 716 | VkSampler sampler = VK_NULL_HANDLE; |
| 717 | VkSamplerCreateInfo sampler_info = {}; |
| 718 | sampler_info.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 719 | sampler_info.pNext = NULL; |
| 720 | sampler_info.magFilter = VK_FILTER_NEAREST; |
| 721 | sampler_info.minFilter = VK_FILTER_NEAREST; |
| 722 | sampler_info.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 723 | sampler_info.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 724 | sampler_info.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 725 | sampler_info.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 726 | sampler_info.mipLodBias = 1.0; |
| 727 | sampler_info.maxAnisotropy = 1; |
| 728 | sampler_info.compareEnable = VK_FALSE; |
| 729 | sampler_info.compareOp = VK_COMPARE_OP_NEVER; |
| 730 | sampler_info.minLod = 1.0; |
| 731 | sampler_info.maxLod = 1.0; |
| 732 | sampler_info.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 733 | sampler_info.unnormalizedCoordinates = VK_FALSE; |
| 734 | // Not VK_TRUE or VK_FALSE |
| 735 | sampler_info.anisotropyEnable = 3; |
| 736 | vkCreateSampler(m_device->device(), &sampler_info, NULL, &sampler); |
| 737 | m_errorMonitor->VerifyFound(); |
| 738 | } |
Dustin Graves | ffa90fa | 2016-05-06 11:20:38 -0600 | [diff] [blame] | 739 | #endif // PARAMETER_VALIDATION_TESTS |
| 740 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 741 | #if MEM_TRACKER_TESTS |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 742 | #if 0 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 743 | TEST_F(VkLayerTest, CallResetCommandBufferBeforeCompletion) |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 744 | { |
| 745 | vk_testing::Fence testFence; |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 746 | VkFenceCreateInfo fenceInfo = {}; |
| 747 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 748 | fenceInfo.pNext = NULL; |
| 749 | fenceInfo.flags = 0; |
| 750 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 751 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, "Resetting CB"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 752 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 753 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tony Barbour | c1eb1a5 | 2015-07-20 13:00:10 -0600 | [diff] [blame] | 754 | |
| 755 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 756 | vk_testing::Buffer buffer; |
| 757 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 758 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 759 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 760 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 4, 0x11111111); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 761 | EndCommandBuffer(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 762 | |
| 763 | testFence.init(*m_device, fenceInfo); |
| 764 | |
| 765 | // Bypass framework since it does the waits automatically |
| 766 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 767 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 768 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 769 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 770 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 771 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 772 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 773 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 774 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 775 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 776 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 777 | |
| 778 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 779 | ASSERT_VK_SUCCESS( err ); |
| 780 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 781 | // Introduce failure by calling begin again before checking fence |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 782 | vkResetCommandBuffer(m_commandBuffer->handle(), 0); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 783 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 784 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 785 | } |
| 786 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 787 | TEST_F(VkLayerTest, CallBeginCommandBufferBeforeCompletion) |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 788 | { |
| 789 | vk_testing::Fence testFence; |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 790 | VkFenceCreateInfo fenceInfo = {}; |
| 791 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 792 | fenceInfo.pNext = NULL; |
| 793 | fenceInfo.flags = 0; |
| 794 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 795 | 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] | 796 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 797 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 798 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 799 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 800 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 801 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 802 | 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] | 803 | EndCommandBuffer(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 804 | |
| 805 | testFence.init(*m_device, fenceInfo); |
| 806 | |
| 807 | // Bypass framework since it does the waits automatically |
| 808 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 809 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 810 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 811 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 812 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 813 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 814 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 815 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 816 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 817 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 818 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 819 | |
| 820 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 821 | ASSERT_VK_SUCCESS( err ); |
| 822 | |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 823 | VkCommandBufferInheritanceInfo hinfo = {}; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 824 | VkCommandBufferBeginInfo info = {}; |
| 825 | info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
| 826 | info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 827 | info.renderPass = VK_NULL_HANDLE; |
| 828 | info.subpass = 0; |
| 829 | info.framebuffer = VK_NULL_HANDLE; |
Chia-I Wu | b8d47ae | 2015-11-11 10:18:12 +0800 | [diff] [blame] | 830 | info.occlusionQueryEnable = VK_FALSE; |
| 831 | info.queryFlags = 0; |
| 832 | info.pipelineStatistics = 0; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 833 | |
| 834 | // Introduce failure by calling BCB again before checking fence |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 835 | vkBeginCommandBuffer(m_commandBuffer->handle(), &info); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 836 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 837 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 838 | } |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 839 | #endif |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 840 | |
Mark Lobodzinski | 152fe25 | 2016-05-03 16:49:15 -0600 | [diff] [blame] | 841 | // This is a positive test. No failures are expected. |
| 842 | TEST_F(VkLayerTest, TestAliasedMemoryTracking) { |
| 843 | VkResult err; |
| 844 | bool pass; |
| 845 | |
| 846 | TEST_DESCRIPTION("Create a buffer, allocate memory, bind memory, destroy " |
| 847 | "the buffer, create an image, and bind the same memory to " |
| 848 | "it"); |
| 849 | |
| 850 | m_errorMonitor->ExpectSuccess(); |
| 851 | |
| 852 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 853 | |
| 854 | VkBuffer buffer; |
| 855 | VkImage image; |
| 856 | VkDeviceMemory mem; |
| 857 | VkMemoryRequirements mem_reqs; |
| 858 | |
| 859 | VkBufferCreateInfo buf_info = {}; |
| 860 | buf_info.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 861 | buf_info.pNext = NULL; |
| 862 | buf_info.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 863 | buf_info.size = 256; |
| 864 | buf_info.queueFamilyIndexCount = 0; |
| 865 | buf_info.pQueueFamilyIndices = NULL; |
| 866 | buf_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 867 | buf_info.flags = 0; |
| 868 | err = vkCreateBuffer(m_device->device(), &buf_info, NULL, &buffer); |
| 869 | ASSERT_VK_SUCCESS(err); |
| 870 | |
| 871 | vkGetBufferMemoryRequirements(m_device->device(), buffer, &mem_reqs); |
| 872 | |
| 873 | VkMemoryAllocateInfo alloc_info = {}; |
| 874 | alloc_info.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 875 | alloc_info.pNext = NULL; |
| 876 | alloc_info.memoryTypeIndex = 0; |
| 877 | |
| 878 | // Ensure memory is big enough for both bindings |
| 879 | alloc_info.allocationSize = 0x10000; |
| 880 | |
| 881 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &alloc_info, |
| 882 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 883 | if (!pass) { |
| 884 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 885 | return; |
| 886 | } |
| 887 | |
| 888 | err = vkAllocateMemory(m_device->device(), &alloc_info, NULL, &mem); |
| 889 | ASSERT_VK_SUCCESS(err); |
| 890 | |
| 891 | uint8_t *pData; |
| 892 | err = vkMapMemory(m_device->device(), mem, 0, mem_reqs.size, 0, |
| 893 | (void **)&pData); |
| 894 | ASSERT_VK_SUCCESS(err); |
| 895 | |
Mark Lobodzinski | 2abefa9 | 2016-05-05 11:45:57 -0600 | [diff] [blame] | 896 | memset(pData, 0xCADECADE, static_cast<size_t>(mem_reqs.size)); |
Mark Lobodzinski | 152fe25 | 2016-05-03 16:49:15 -0600 | [diff] [blame] | 897 | |
| 898 | vkUnmapMemory(m_device->device(), mem); |
| 899 | |
| 900 | err = vkBindBufferMemory(m_device->device(), buffer, mem, 0); |
| 901 | ASSERT_VK_SUCCESS(err); |
| 902 | |
| 903 | // NOW, destroy the buffer. Obviously, the resource no longer occupies this |
| 904 | // memory. In fact, it was never used by the GPU. |
| 905 | // Just be be sure, wait for idle. |
| 906 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 907 | vkDeviceWaitIdle(m_device->device()); |
| 908 | |
| 909 | VkImageCreateInfo image_create_info = {}; |
| 910 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 911 | image_create_info.pNext = NULL; |
| 912 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 913 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; |
| 914 | image_create_info.extent.width = 64; |
| 915 | image_create_info.extent.height = 64; |
| 916 | image_create_info.extent.depth = 1; |
| 917 | image_create_info.mipLevels = 1; |
| 918 | image_create_info.arrayLayers = 1; |
| 919 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 920 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 921 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_PREINITIALIZED; |
| 922 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 923 | image_create_info.queueFamilyIndexCount = 0; |
| 924 | image_create_info.pQueueFamilyIndices = NULL; |
| 925 | image_create_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE; |
| 926 | image_create_info.flags = 0; |
| 927 | |
| 928 | VkMemoryAllocateInfo mem_alloc = {}; |
| 929 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 930 | mem_alloc.pNext = NULL; |
| 931 | mem_alloc.allocationSize = 0; |
| 932 | mem_alloc.memoryTypeIndex = 0; |
| 933 | |
| 934 | /* Create a mappable image. It will be the texture if linear images are ok |
| 935 | * to be textures or it will be the staging image if they are not. |
| 936 | */ |
| 937 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 938 | ASSERT_VK_SUCCESS(err); |
| 939 | |
| 940 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
| 941 | |
| 942 | mem_alloc.allocationSize = mem_reqs.size; |
| 943 | |
| 944 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, |
| 945 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 946 | if (!pass) { |
| 947 | vkDestroyImage(m_device->device(), image, NULL); |
| 948 | return; |
| 949 | } |
| 950 | |
| 951 | // VALDIATION FAILURE: |
| 952 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 953 | ASSERT_VK_SUCCESS(err); |
| 954 | |
| 955 | m_errorMonitor->VerifyNotFound(); |
| 956 | |
| 957 | vkDestroyBuffer(m_device->device(), buffer, NULL); |
| 958 | vkDestroyImage(m_device->device(), image, NULL); |
| 959 | } |
| 960 | |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 961 | TEST_F(VkLayerTest, EnableWsiBeforeUse) { |
| 962 | VkResult err; |
| 963 | bool pass; |
| 964 | |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 965 | // FIXME: After we turn on this code for non-Linux platforms, uncomment the |
| 966 | // following declaration (which is temporarily being moved below): |
| 967 | // VkSurfaceKHR surface = VK_NULL_HANDLE; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 968 | VkSwapchainKHR swapchain = VK_NULL_HANDLE; |
| 969 | VkSwapchainCreateInfoKHR swapchain_create_info = {}; |
| 970 | uint32_t swapchain_image_count = 0; |
| 971 | // VkImage swapchain_images[1] = {VK_NULL_HANDLE}; |
| 972 | uint32_t image_index = 0; |
| 973 | // VkPresentInfoKHR present_info = {}; |
| 974 | |
| 975 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 976 | |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 977 | #ifdef NEED_TO_TEST_THIS_ON_PLATFORM |
| 978 | #if defined(VK_USE_PLATFORM_ANDROID_KHR) |
| 979 | // Use the functions from the VK_KHR_android_surface extension without |
| 980 | // enabling that extension: |
| 981 | |
| 982 | // Create a surface: |
| 983 | VkAndroidSurfaceCreateInfoKHR android_create_info = {}; |
| 984 | #if 0 |
| 985 | #endif |
| 986 | m_errorMonitor->SetDesiredFailureMsg( |
| 987 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 988 | "extension was not enabled for this"); |
| 989 | err = vkCreateAndroidSurfaceKHR(instance(), &android_create_info, NULL, |
| 990 | &surface); |
| 991 | pass = (err != VK_SUCCESS); |
| 992 | ASSERT_TRUE(pass); |
| 993 | m_errorMonitor->VerifyFound(); |
| 994 | #endif // VK_USE_PLATFORM_ANDROID_KHR |
| 995 | |
| 996 | |
| 997 | #if defined(VK_USE_PLATFORM_MIR_KHR) |
| 998 | // Use the functions from the VK_KHR_mir_surface extension without enabling |
| 999 | // that extension: |
| 1000 | |
| 1001 | // Create a surface: |
| 1002 | VkMirSurfaceCreateInfoKHR mir_create_info = {}; |
| 1003 | #if 0 |
| 1004 | #endif |
| 1005 | m_errorMonitor->SetDesiredFailureMsg( |
| 1006 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1007 | "extension was not enabled for this"); |
| 1008 | err = vkCreateMirSurfaceKHR(instance(), &mir_create_info, NULL, &surface); |
| 1009 | pass = (err != VK_SUCCESS); |
| 1010 | ASSERT_TRUE(pass); |
| 1011 | m_errorMonitor->VerifyFound(); |
| 1012 | |
| 1013 | // Tell whether an mir_connection supports presentation: |
| 1014 | MirConnection *mir_connection = NULL; |
| 1015 | m_errorMonitor->SetDesiredFailureMsg( |
| 1016 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1017 | "extension was not enabled for this"); |
| 1018 | vkGetPhysicalDeviceMirPresentationSupportKHR(gpu(), 0, mir_connection, |
| 1019 | visual_id); |
| 1020 | m_errorMonitor->VerifyFound(); |
| 1021 | #endif // VK_USE_PLATFORM_MIR_KHR |
| 1022 | |
| 1023 | |
| 1024 | #if defined(VK_USE_PLATFORM_WAYLAND_KHR) |
| 1025 | // Use the functions from the VK_KHR_wayland_surface extension without |
| 1026 | // enabling that extension: |
| 1027 | |
| 1028 | // Create a surface: |
| 1029 | VkWaylandSurfaceCreateInfoKHR wayland_create_info = {}; |
| 1030 | #if 0 |
| 1031 | #endif |
| 1032 | m_errorMonitor->SetDesiredFailureMsg( |
| 1033 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1034 | "extension was not enabled for this"); |
| 1035 | err = vkCreateWaylandSurfaceKHR(instance(), &wayland_create_info, NULL, |
| 1036 | &surface); |
| 1037 | pass = (err != VK_SUCCESS); |
| 1038 | ASSERT_TRUE(pass); |
| 1039 | m_errorMonitor->VerifyFound(); |
| 1040 | |
| 1041 | // Tell whether an wayland_display supports presentation: |
| 1042 | struct wl_display wayland_display = {}; |
| 1043 | m_errorMonitor->SetDesiredFailureMsg( |
| 1044 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1045 | "extension was not enabled for this"); |
| 1046 | vkGetPhysicalDeviceWaylandPresentationSupportKHR(gpu(), 0, |
| 1047 | &wayland_display); |
| 1048 | m_errorMonitor->VerifyFound(); |
| 1049 | #endif // VK_USE_PLATFORM_WAYLAND_KHR |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1050 | #endif // NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1051 | |
| 1052 | |
| 1053 | #if defined(VK_USE_PLATFORM_WIN32_KHR) |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1054 | // FIXME: REMOVE THIS HERE, AND UNCOMMENT ABOVE, WHEN THIS TEST HAS BEEN PORTED |
| 1055 | // TO NON-LINUX PLATFORMS: |
| 1056 | VkSurfaceKHR surface = VK_NULL_HANDLE; |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1057 | // Use the functions from the VK_KHR_win32_surface extension without |
| 1058 | // enabling that extension: |
| 1059 | |
| 1060 | // Create a surface: |
| 1061 | VkWin32SurfaceCreateInfoKHR win32_create_info = {}; |
| 1062 | #if 0 |
| 1063 | #endif |
| 1064 | m_errorMonitor->SetDesiredFailureMsg( |
| 1065 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1066 | "extension was not enabled for this"); |
| 1067 | err = vkCreateWin32SurfaceKHR(instance(), &win32_create_info, NULL, |
| 1068 | &surface); |
| 1069 | pass = (err != VK_SUCCESS); |
| 1070 | ASSERT_TRUE(pass); |
| 1071 | m_errorMonitor->VerifyFound(); |
| 1072 | |
| 1073 | // Tell whether win32 supports presentation: |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1074 | m_errorMonitor->SetDesiredFailureMsg( |
| 1075 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1076 | "extension was not enabled for this"); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1077 | vkGetPhysicalDeviceWin32PresentationSupportKHR(gpu(), 0); |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1078 | m_errorMonitor->VerifyFound(); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1079 | // Set this (for now, until all platforms are supported and tested): |
| 1080 | #define NEED_TO_TEST_THIS_ON_PLATFORM |
| 1081 | #endif // VK_USE_PLATFORM_WIN32_KHR |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1082 | |
| 1083 | |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1084 | #if defined(VK_USE_PLATFORM_XCB_KHR) |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1085 | // FIXME: REMOVE THIS HERE, AND UNCOMMENT ABOVE, WHEN THIS TEST HAS BEEN PORTED |
| 1086 | // TO NON-LINUX PLATFORMS: |
| 1087 | VkSurfaceKHR surface = VK_NULL_HANDLE; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1088 | // Use the functions from the VK_KHR_xcb_surface extension without enabling |
| 1089 | // that extension: |
| 1090 | |
| 1091 | // Create a surface: |
| 1092 | VkXcbSurfaceCreateInfoKHR xcb_create_info = {}; |
| 1093 | #if 0 |
| 1094 | #endif |
| 1095 | m_errorMonitor->SetDesiredFailureMsg( |
| 1096 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1097 | "extension was not enabled for this"); |
| 1098 | err = vkCreateXcbSurfaceKHR(instance(), &xcb_create_info, NULL, &surface); |
| 1099 | pass = (err != VK_SUCCESS); |
| 1100 | ASSERT_TRUE(pass); |
| 1101 | m_errorMonitor->VerifyFound(); |
| 1102 | |
| 1103 | // Tell whether an xcb_visualid_t supports presentation: |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1104 | xcb_connection_t *xcb_connection = NULL; |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1105 | xcb_visualid_t visual_id = 0; |
| 1106 | m_errorMonitor->SetDesiredFailureMsg( |
| 1107 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1108 | "extension was not enabled for this"); |
Ian Elliott | 3f06ce5 | 2016-04-29 14:46:21 -0600 | [diff] [blame] | 1109 | vkGetPhysicalDeviceXcbPresentationSupportKHR(gpu(), 0, xcb_connection, |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1110 | visual_id); |
| 1111 | m_errorMonitor->VerifyFound(); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1112 | // Set this (for now, until all platforms are supported and tested): |
| 1113 | #define NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1114 | #endif // VK_USE_PLATFORM_XCB_KHR |
| 1115 | |
| 1116 | |
Ian Elliott | 1263081 | 2016-04-29 14:35:43 -0600 | [diff] [blame] | 1117 | #if defined(VK_USE_PLATFORM_XLIB_KHR) |
| 1118 | // Use the functions from the VK_KHR_xlib_surface extension without enabling |
| 1119 | // that extension: |
| 1120 | |
| 1121 | // Create a surface: |
| 1122 | VkXlibSurfaceCreateInfoKHR xlib_create_info = {}; |
| 1123 | #if 0 |
| 1124 | #endif |
| 1125 | m_errorMonitor->SetDesiredFailureMsg( |
| 1126 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1127 | "extension was not enabled for this"); |
| 1128 | err = vkCreateXlibSurfaceKHR(instance(), &xlib_create_info, NULL, &surface); |
| 1129 | pass = (err != VK_SUCCESS); |
| 1130 | ASSERT_TRUE(pass); |
| 1131 | m_errorMonitor->VerifyFound(); |
| 1132 | |
| 1133 | // Tell whether an Xlib VisualID supports presentation: |
| 1134 | Display *dpy = NULL; |
| 1135 | VisualID visual = 0; |
| 1136 | m_errorMonitor->SetDesiredFailureMsg( |
| 1137 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1138 | "extension was not enabled for this"); |
| 1139 | vkGetPhysicalDeviceXlibPresentationSupportKHR(gpu(), 0, dpy, visual); |
| 1140 | m_errorMonitor->VerifyFound(); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1141 | // Set this (for now, until all platforms are supported and tested): |
| 1142 | #define NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1263081 | 2016-04-29 14:35:43 -0600 | [diff] [blame] | 1143 | #endif // VK_USE_PLATFORM_XLIB_KHR |
| 1144 | |
| 1145 | |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1146 | // Use the functions from the VK_KHR_surface extension without enabling |
| 1147 | // that extension: |
| 1148 | |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1149 | #ifdef NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1150 | // Destroy a surface: |
| 1151 | m_errorMonitor->SetDesiredFailureMsg( |
| 1152 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1153 | "extension was not enabled for this"); |
| 1154 | vkDestroySurfaceKHR(instance(), surface, NULL); |
| 1155 | m_errorMonitor->VerifyFound(); |
| 1156 | |
| 1157 | // Check if surface supports presentation: |
| 1158 | VkBool32 supported = false; |
| 1159 | m_errorMonitor->SetDesiredFailureMsg( |
| 1160 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1161 | "extension was not enabled for this"); |
| 1162 | err = vkGetPhysicalDeviceSurfaceSupportKHR(gpu(), 0, surface, &supported); |
| 1163 | pass = (err != VK_SUCCESS); |
| 1164 | ASSERT_TRUE(pass); |
| 1165 | m_errorMonitor->VerifyFound(); |
| 1166 | |
| 1167 | // Check surface capabilities: |
| 1168 | VkSurfaceCapabilitiesKHR capabilities = {}; |
| 1169 | m_errorMonitor->SetDesiredFailureMsg( |
| 1170 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1171 | "extension was not enabled for this"); |
| 1172 | err = vkGetPhysicalDeviceSurfaceCapabilitiesKHR(gpu(), surface, |
| 1173 | &capabilities); |
| 1174 | pass = (err != VK_SUCCESS); |
| 1175 | ASSERT_TRUE(pass); |
| 1176 | m_errorMonitor->VerifyFound(); |
| 1177 | |
| 1178 | // Check surface formats: |
| 1179 | uint32_t format_count = 0; |
| 1180 | VkSurfaceFormatKHR *formats = NULL; |
| 1181 | m_errorMonitor->SetDesiredFailureMsg( |
| 1182 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1183 | "extension was not enabled for this"); |
| 1184 | err = vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, |
| 1185 | &format_count, formats); |
| 1186 | pass = (err != VK_SUCCESS); |
| 1187 | ASSERT_TRUE(pass); |
| 1188 | m_errorMonitor->VerifyFound(); |
| 1189 | |
| 1190 | // Check surface present modes: |
| 1191 | uint32_t present_mode_count = 0; |
| 1192 | VkSurfaceFormatKHR *present_modes = NULL; |
| 1193 | m_errorMonitor->SetDesiredFailureMsg( |
| 1194 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1195 | "extension was not enabled for this"); |
| 1196 | err = vkGetPhysicalDeviceSurfaceFormatsKHR(gpu(), surface, |
| 1197 | &present_mode_count, present_modes); |
| 1198 | pass = (err != VK_SUCCESS); |
| 1199 | ASSERT_TRUE(pass); |
| 1200 | m_errorMonitor->VerifyFound(); |
Ian Elliott | 489eec0 | 2016-05-05 14:12:44 -0600 | [diff] [blame] | 1201 | #endif // NEED_TO_TEST_THIS_ON_PLATFORM |
Ian Elliott | 1c32c77 | 2016-04-28 14:47:13 -0600 | [diff] [blame] | 1202 | |
| 1203 | |
| 1204 | // Use the functions from the VK_KHR_swapchain extension without enabling |
| 1205 | // that extension: |
| 1206 | |
| 1207 | // Create a swapchain: |
| 1208 | m_errorMonitor->SetDesiredFailureMsg( |
| 1209 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1210 | "extension was not enabled for this"); |
| 1211 | swapchain_create_info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR; |
| 1212 | swapchain_create_info.pNext = NULL; |
| 1213 | #if 0 |
| 1214 | swapchain_create_info.flags = 0; |
| 1215 | swapchain_create_info.surface = 0; |
| 1216 | swapchain_create_info.minImageCount = 0; |
| 1217 | swapchain_create_info.imageFormat = 0; |
| 1218 | swapchain_create_info.imageColorSpace = 0; |
| 1219 | swapchain_create_info.imageExtent.width = 0; |
| 1220 | swapchain_create_info.imageExtent.height = 0; |
| 1221 | swapchain_create_info.imageArrayLayers = 0; |
| 1222 | swapchain_create_info.imageUsage = 0; |
| 1223 | swapchain_create_info.imageSharingMode = 0; |
| 1224 | swapchain_create_info.queueFamilyIndexCount = 0; |
| 1225 | swapchain_create_info.preTransform = 0; |
| 1226 | swapchain_create_info.compositeAlpha = 0; |
| 1227 | swapchain_create_info.presentMode = 0; |
| 1228 | swapchain_create_info.clipped = 0; |
| 1229 | swapchain_create_info.oldSwapchain = NULL; |
| 1230 | #endif |
| 1231 | err = vkCreateSwapchainKHR(m_device->device(), &swapchain_create_info, |
| 1232 | NULL, &swapchain); |
| 1233 | pass = (err != VK_SUCCESS); |
| 1234 | ASSERT_TRUE(pass); |
| 1235 | m_errorMonitor->VerifyFound(); |
| 1236 | |
| 1237 | // Get the images from the swapchain: |
| 1238 | m_errorMonitor->SetDesiredFailureMsg( |
| 1239 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1240 | "extension was not enabled for this"); |
| 1241 | err = vkGetSwapchainImagesKHR(m_device->device(), swapchain, |
| 1242 | &swapchain_image_count, NULL); |
| 1243 | pass = (err != VK_SUCCESS); |
| 1244 | ASSERT_TRUE(pass); |
| 1245 | m_errorMonitor->VerifyFound(); |
| 1246 | |
| 1247 | // Try to acquire an image: |
| 1248 | m_errorMonitor->SetDesiredFailureMsg( |
| 1249 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1250 | "extension was not enabled for this"); |
| 1251 | err = vkAcquireNextImageKHR(m_device->device(), swapchain, 0, |
| 1252 | VK_NULL_HANDLE, VK_NULL_HANDLE, &image_index); |
| 1253 | pass = (err != VK_SUCCESS); |
| 1254 | ASSERT_TRUE(pass); |
| 1255 | m_errorMonitor->VerifyFound(); |
| 1256 | |
| 1257 | // Try to present an image: |
| 1258 | #if 0 // NOTE: Currently can't test this because a real swapchain is needed |
| 1259 | // (as opposed to the fake one we created) in order for the layer to |
| 1260 | // lookup the VkDevice used to enable the extension: |
| 1261 | m_errorMonitor->SetDesiredFailureMsg( |
| 1262 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1263 | "extension was not enabled for this"); |
| 1264 | present_info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR; |
| 1265 | present_info.pNext = NULL; |
| 1266 | #if 0 |
| 1267 | #endif |
| 1268 | err = vkQueuePresentKHR(m_device->m_queue, &present_info); |
| 1269 | pass = (err != VK_SUCCESS); |
| 1270 | ASSERT_TRUE(pass); |
| 1271 | m_errorMonitor->VerifyFound(); |
| 1272 | #endif |
| 1273 | |
| 1274 | // Destroy the swapchain: |
| 1275 | m_errorMonitor->SetDesiredFailureMsg( |
| 1276 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1277 | "extension was not enabled for this"); |
| 1278 | vkDestroySwapchainKHR(m_device->device(), swapchain, NULL); |
| 1279 | m_errorMonitor->VerifyFound(); |
| 1280 | } |
| 1281 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1282 | TEST_F(VkLayerTest, MapMemWithoutHostVisibleBit) { |
| 1283 | VkResult err; |
| 1284 | bool pass; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1285 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1286 | m_errorMonitor->SetDesiredFailureMsg( |
| 1287 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1288 | "Mapping Memory without VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT"); |
| 1289 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1290 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1291 | |
| 1292 | // 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] | 1293 | VkImage image; |
| 1294 | VkDeviceMemory mem; |
| 1295 | VkMemoryRequirements mem_reqs; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1296 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1297 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 1298 | const int32_t tex_width = 32; |
| 1299 | const int32_t tex_height = 32; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1300 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1301 | VkImageCreateInfo image_create_info = {}; |
| 1302 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1303 | image_create_info.pNext = NULL; |
| 1304 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1305 | image_create_info.format = tex_format; |
| 1306 | image_create_info.extent.width = tex_width; |
| 1307 | image_create_info.extent.height = tex_height; |
| 1308 | image_create_info.extent.depth = 1; |
| 1309 | image_create_info.mipLevels = 1; |
| 1310 | image_create_info.arrayLayers = 1; |
| 1311 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1312 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1313 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 1314 | image_create_info.flags = 0; |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1315 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1316 | VkMemoryAllocateInfo mem_alloc = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1317 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1318 | mem_alloc.pNext = NULL; |
| 1319 | mem_alloc.allocationSize = 0; |
| 1320 | // Introduce failure, do NOT set memProps to |
| 1321 | // VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
| 1322 | mem_alloc.memoryTypeIndex = 1; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1323 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1324 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1325 | ASSERT_VK_SUCCESS(err); |
| 1326 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1327 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1328 | |
Mark Lobodzinski | 2306535 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 1329 | mem_alloc.allocationSize = mem_reqs.size; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1330 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1331 | pass = |
| 1332 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0, |
| 1333 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 1334 | if (!pass) { // If we can't find any unmappable memory this test doesn't |
| 1335 | // make sense |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1336 | vkDestroyImage(m_device->device(), image, NULL); |
Tony Barbour | 02fdc7d | 2015-08-04 16:13:01 -0600 | [diff] [blame] | 1337 | return; |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1338 | } |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 1339 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1340 | // allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1341 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1342 | ASSERT_VK_SUCCESS(err); |
| 1343 | |
| 1344 | // Try to bind free memory that has been freed |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 1345 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1346 | ASSERT_VK_SUCCESS(err); |
| 1347 | |
| 1348 | // Map memory as if to initialize the image |
| 1349 | void *mappedAddress = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1350 | err = vkMapMemory(m_device->device(), mem, 0, VK_WHOLE_SIZE, 0, |
| 1351 | &mappedAddress); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1352 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1353 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1354 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1355 | vkDestroyImage(m_device->device(), image, NULL); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1356 | } |
| 1357 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1358 | TEST_F(VkLayerTest, RebindMemory) { |
| 1359 | VkResult err; |
| 1360 | bool pass; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1361 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1362 | m_errorMonitor->SetDesiredFailureMsg( |
| 1363 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1364 | "which has already been bound to mem object"); |
| 1365 | |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1366 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1367 | |
| 1368 | // 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] | 1369 | VkImage image; |
| 1370 | VkDeviceMemory mem1; |
| 1371 | VkDeviceMemory mem2; |
| 1372 | VkMemoryRequirements mem_reqs; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1373 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1374 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 1375 | const int32_t tex_width = 32; |
| 1376 | const int32_t tex_height = 32; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1377 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1378 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1379 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1380 | image_create_info.pNext = NULL; |
| 1381 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1382 | image_create_info.format = tex_format; |
| 1383 | image_create_info.extent.width = tex_width; |
| 1384 | image_create_info.extent.height = tex_height; |
| 1385 | image_create_info.extent.depth = 1; |
| 1386 | image_create_info.mipLevels = 1; |
| 1387 | image_create_info.arrayLayers = 1; |
| 1388 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1389 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1390 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 1391 | image_create_info.flags = 0; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1392 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1393 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1394 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1395 | mem_alloc.pNext = NULL; |
| 1396 | mem_alloc.allocationSize = 0; |
| 1397 | mem_alloc.memoryTypeIndex = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1398 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1399 | // Introduce failure, do NOT set memProps to |
| 1400 | // VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1401 | mem_alloc.memoryTypeIndex = 1; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1402 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1403 | ASSERT_VK_SUCCESS(err); |
| 1404 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1405 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1406 | |
| 1407 | mem_alloc.allocationSize = mem_reqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1408 | pass = |
| 1409 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 1410 | ASSERT_TRUE(pass); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1411 | |
| 1412 | // allocate 2 memory objects |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1413 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem1); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1414 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1415 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem2); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1416 | ASSERT_VK_SUCCESS(err); |
| 1417 | |
| 1418 | // Bind first memory object to Image object |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 1419 | err = vkBindImageMemory(m_device->device(), image, mem1, 0); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1420 | ASSERT_VK_SUCCESS(err); |
| 1421 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1422 | // Introduce validation failure, try to bind a different memory object to |
| 1423 | // the same image object |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 1424 | err = vkBindImageMemory(m_device->device(), image, mem2, 0); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1425 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1426 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1427 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1428 | vkDestroyImage(m_device->device(), image, NULL); |
| 1429 | vkFreeMemory(m_device->device(), mem1, NULL); |
| 1430 | vkFreeMemory(m_device->device(), mem2, NULL); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 1431 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 1432 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1433 | TEST_F(VkLayerTest, SubmitSignaledFence) { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1434 | vk_testing::Fence testFence; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1435 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1436 | m_errorMonitor->SetDesiredFailureMsg( |
| 1437 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "submitted in SIGNALED state. Fences " |
| 1438 | "must be reset before being submitted"); |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1439 | |
| 1440 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 1441 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 1442 | fenceInfo.pNext = NULL; |
| 1443 | fenceInfo.flags = VK_FENCE_CREATE_SIGNALED_BIT; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 1444 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 1445 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1446 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 1447 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1448 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1449 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1450 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 1451 | m_stencil_clear_color, NULL); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1452 | EndCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 1453 | |
| 1454 | testFence.init(*m_device, fenceInfo); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1455 | |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1456 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 1457 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1458 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1459 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1460 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 1461 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1462 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1463 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1464 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1465 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 1466 | |
| 1467 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1468 | vkQueueWaitIdle(m_device->m_queue); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 1469 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1470 | m_errorMonitor->VerifyFound(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 1471 | } |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 1472 | // This is a positive test. We used to expect error in this case but spec now |
| 1473 | // allows it |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1474 | TEST_F(VkLayerTest, ResetUnsignaledFence) { |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 1475 | m_errorMonitor->ExpectSuccess(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 1476 | vk_testing::Fence testFence; |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1477 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 1478 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 1479 | fenceInfo.pNext = NULL; |
| 1480 | |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 1481 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1482 | testFence.init(*m_device, fenceInfo); |
Chia-I Wu | d9e8e82 | 2015-07-03 11:45:55 +0800 | [diff] [blame] | 1483 | VkFence fences[1] = {testFence.handle()}; |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 1484 | VkResult result = vkResetFences(m_device->device(), 1, fences); |
| 1485 | ASSERT_VK_SUCCESS(result); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 1486 | |
Tobin Ehlis | aff7ae9 | 2016-04-18 15:45:20 -0600 | [diff] [blame] | 1487 | m_errorMonitor->VerifyNotFound(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 1488 | } |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 1489 | |
| 1490 | TEST_F(VkLayerTest, InvalidUsageBits) |
| 1491 | { |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 1492 | TEST_DESCRIPTION( |
Karl Schultz | b5bc11e | 2016-05-04 08:36:08 -0600 | [diff] [blame] | 1493 | "Specify wrong usage for image then create conflicting view of image " |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 1494 | "Initialize buffer with wrong usage then perform copy expecting errors " |
| 1495 | "from both the image and the buffer (2 calls)"); |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1496 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1497 | "Invalid usage flag for image "); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 1498 | |
| 1499 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 1500 | VkImageObj image(m_device); |
| 1501 | // Initialize image with USAGE_INPUT_ATTACHMENT |
| 1502 | image.init(128, 128, VK_FORMAT_D32_SFLOAT_S8_UINT, |
Karl Schultz | b5bc11e | 2016-05-04 08:36:08 -0600 | [diff] [blame] | 1503 | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
| 1504 | ASSERT_TRUE(image.initialized()); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 1505 | |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 1506 | VkImageView dsv; |
| 1507 | VkImageViewCreateInfo dsvci = {}; |
| 1508 | dsvci.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 1509 | dsvci.image = image.handle(); |
| 1510 | dsvci.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 1511 | dsvci.format = VK_FORMAT_D32_SFLOAT_S8_UINT; |
| 1512 | dsvci.subresourceRange.layerCount = 1; |
| 1513 | dsvci.subresourceRange.baseMipLevel = 0; |
| 1514 | dsvci.subresourceRange.levelCount = 1; |
| 1515 | dsvci.subresourceRange.aspectMask = |
| 1516 | VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 1517 | |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 1518 | // Create a view with depth / stencil aspect for image with different usage |
| 1519 | vkCreateImageView(m_device->device(), &dsvci, NULL, &dsv); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1520 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1521 | m_errorMonitor->VerifyFound(); |
Tony Barbour | f92621a | 2016-05-02 14:28:12 -0600 | [diff] [blame] | 1522 | |
| 1523 | // Initialize buffer with TRANSFER_DST usage |
| 1524 | vk_testing::Buffer buffer; |
| 1525 | VkMemoryPropertyFlags reqs = 0; |
| 1526 | buffer.init_as_dst(*m_device, 128 * 128, reqs); |
| 1527 | VkBufferImageCopy region = {}; |
| 1528 | region.bufferRowLength = 128; |
| 1529 | region.bufferImageHeight = 128; |
| 1530 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 1531 | region.imageSubresource.layerCount = 1; |
| 1532 | region.imageExtent.height = 16; |
| 1533 | region.imageExtent.width = 16; |
| 1534 | region.imageExtent.depth = 1; |
| 1535 | |
| 1536 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1537 | "Invalid usage flag for buffer "); |
| 1538 | // Buffer usage not set to TRANSFER_SRC and image usage not set to |
| 1539 | // TRANSFER_DST |
| 1540 | BeginCommandBuffer(); |
| 1541 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 1542 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 1543 | 1, ®ion); |
| 1544 | m_errorMonitor->VerifyFound(); |
| 1545 | |
| 1546 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1547 | "Invalid usage flag for image "); |
| 1548 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 1549 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 1550 | 1, ®ion); |
| 1551 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 1552 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 1553 | #endif // MEM_TRACKER_TESTS |
| 1554 | |
Tobin Ehlis | 4bf96d1 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 1555 | #if OBJ_TRACKER_TESTS |
Mark Lobodzinski | fc5cc66 | 2016-05-02 17:17:41 -0600 | [diff] [blame] | 1556 | |
| 1557 | TEST_F(VkLayerTest, LeakAnObject) { |
| 1558 | VkResult err; |
| 1559 | |
| 1560 | TEST_DESCRIPTION( |
| 1561 | "Create a fence and destroy its device without first destroying the fence."); |
| 1562 | |
| 1563 | // Note that we have to create a new device since destroying the |
| 1564 | // framework's device causes Teardown() to fail and just calling Teardown |
| 1565 | // will destroy the errorMonitor. |
| 1566 | |
| 1567 | m_errorMonitor->SetDesiredFailureMsg( |
| 1568 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1569 | "OBJ ERROR : VK_DEBUG_REPORT_OBJECT_TYPE_FENCE_EXT object"); |
| 1570 | |
| 1571 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1572 | |
| 1573 | const std::vector<VkQueueFamilyProperties> queue_props = |
| 1574 | m_device->queue_props; |
| 1575 | std::vector<VkDeviceQueueCreateInfo> queue_info; |
| 1576 | queue_info.reserve(queue_props.size()); |
| 1577 | std::vector<std::vector<float>> queue_priorities; |
| 1578 | for (uint32_t i = 0; i < (uint32_t)queue_props.size(); i++) { |
| 1579 | VkDeviceQueueCreateInfo qi = {}; |
| 1580 | qi.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO; |
| 1581 | qi.pNext = NULL; |
| 1582 | qi.queueFamilyIndex = i; |
| 1583 | qi.queueCount = queue_props[i].queueCount; |
| 1584 | queue_priorities.emplace_back(qi.queueCount, 0.0f); |
| 1585 | qi.pQueuePriorities = queue_priorities[i].data(); |
| 1586 | queue_info.push_back(qi); |
| 1587 | } |
| 1588 | |
| 1589 | std::vector<const char *> device_layer_names; |
| 1590 | std::vector<const char *> device_extension_names; |
| 1591 | device_layer_names.push_back("VK_LAYER_GOOGLE_threading"); |
| 1592 | device_layer_names.push_back("VK_LAYER_LUNARG_parameter_validation"); |
| 1593 | device_layer_names.push_back("VK_LAYER_LUNARG_object_tracker"); |
| 1594 | device_layer_names.push_back("VK_LAYER_LUNARG_core_validation"); |
| 1595 | device_layer_names.push_back("VK_LAYER_LUNARG_device_limits"); |
| 1596 | device_layer_names.push_back("VK_LAYER_LUNARG_image"); |
| 1597 | device_layer_names.push_back("VK_LAYER_GOOGLE_unique_objects"); |
| 1598 | |
| 1599 | // The sacrificial device object |
| 1600 | VkDevice testDevice; |
| 1601 | VkDeviceCreateInfo device_create_info = {}; |
| 1602 | auto features = m_device->phy().features(); |
| 1603 | device_create_info.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO; |
| 1604 | device_create_info.pNext = NULL; |
| 1605 | device_create_info.queueCreateInfoCount = queue_info.size(); |
| 1606 | device_create_info.pQueueCreateInfos = queue_info.data(); |
| 1607 | device_create_info.enabledLayerCount = device_layer_names.size(); |
| 1608 | device_create_info.ppEnabledLayerNames = device_layer_names.data(); |
| 1609 | device_create_info.pEnabledFeatures = &features; |
| 1610 | err = vkCreateDevice(gpu(), &device_create_info, NULL, &testDevice); |
| 1611 | ASSERT_VK_SUCCESS(err); |
| 1612 | |
| 1613 | VkFence fence; |
| 1614 | VkFenceCreateInfo fence_create_info = {}; |
| 1615 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 1616 | fence_create_info.pNext = NULL; |
| 1617 | fence_create_info.flags = 0; |
| 1618 | err = vkCreateFence(testDevice, &fence_create_info, NULL, &fence); |
| 1619 | ASSERT_VK_SUCCESS(err); |
| 1620 | |
| 1621 | // Induce failure by not calling vkDestroyFence |
| 1622 | vkDestroyDevice(testDevice, NULL); |
| 1623 | m_errorMonitor->VerifyFound(); |
| 1624 | } |
| 1625 | |
| 1626 | TEST_F(VkLayerTest, InvalidCommandPoolConsistency) { |
| 1627 | |
| 1628 | TEST_DESCRIPTION("Allocate command buffers from one command pool and " |
| 1629 | "attempt to delete them from another."); |
| 1630 | |
| 1631 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1632 | "FreeCommandBuffers is attempting to free Command Buffer"); |
| 1633 | |
| 1634 | VkCommandPool command_pool_one; |
| 1635 | VkCommandPool command_pool_two; |
| 1636 | |
| 1637 | VkCommandPoolCreateInfo pool_create_info{}; |
| 1638 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 1639 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 1640 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 1641 | |
| 1642 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 1643 | &command_pool_one); |
| 1644 | |
| 1645 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 1646 | &command_pool_two); |
| 1647 | |
| 1648 | VkCommandBuffer command_buffer[9]; |
| 1649 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 1650 | command_buffer_allocate_info.sType = |
| 1651 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 1652 | command_buffer_allocate_info.commandPool = command_pool_one; |
| 1653 | command_buffer_allocate_info.commandBufferCount = 9; |
| 1654 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 1655 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 1656 | command_buffer); |
| 1657 | |
| 1658 | vkFreeCommandBuffers(m_device->device(), command_pool_two, 4, |
| 1659 | &command_buffer[3]); |
| 1660 | |
| 1661 | m_errorMonitor->VerifyFound(); |
| 1662 | |
| 1663 | vkDestroyCommandPool(m_device->device(), command_pool_one, NULL); |
| 1664 | vkDestroyCommandPool(m_device->device(), command_pool_two, NULL); |
| 1665 | } |
| 1666 | |
| 1667 | TEST_F(VkLayerTest, InvalidDescriptorPoolConsistency) { |
| 1668 | VkResult err; |
| 1669 | |
| 1670 | TEST_DESCRIPTION("Allocate descriptor sets from one DS pool and " |
| 1671 | "attempt to delete them from another."); |
| 1672 | |
| 1673 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1674 | "FreeDescriptorSets is attempting to free descriptorSet"); |
| 1675 | |
| 1676 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1677 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1678 | |
| 1679 | VkDescriptorPoolSize ds_type_count = {}; |
| 1680 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 1681 | ds_type_count.descriptorCount = 1; |
| 1682 | |
| 1683 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1684 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1685 | ds_pool_ci.pNext = NULL; |
| 1686 | ds_pool_ci.flags = 0; |
| 1687 | ds_pool_ci.maxSets = 1; |
| 1688 | ds_pool_ci.poolSizeCount = 1; |
| 1689 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 1690 | |
| 1691 | VkDescriptorPool ds_pool_one; |
| 1692 | err = |
| 1693 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool_one); |
| 1694 | ASSERT_VK_SUCCESS(err); |
| 1695 | |
| 1696 | // Create a second descriptor pool |
| 1697 | VkDescriptorPool ds_pool_two; |
| 1698 | err = |
| 1699 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool_two); |
| 1700 | ASSERT_VK_SUCCESS(err); |
| 1701 | |
| 1702 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 1703 | dsl_binding.binding = 0; |
| 1704 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 1705 | dsl_binding.descriptorCount = 1; |
| 1706 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1707 | dsl_binding.pImmutableSamplers = NULL; |
| 1708 | |
| 1709 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1710 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1711 | ds_layout_ci.pNext = NULL; |
| 1712 | ds_layout_ci.bindingCount = 1; |
| 1713 | ds_layout_ci.pBindings = &dsl_binding; |
| 1714 | |
| 1715 | VkDescriptorSetLayout ds_layout; |
| 1716 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 1717 | &ds_layout); |
| 1718 | ASSERT_VK_SUCCESS(err); |
| 1719 | |
| 1720 | VkDescriptorSet descriptorSet; |
| 1721 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 1722 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 1723 | alloc_info.descriptorSetCount = 1; |
| 1724 | alloc_info.descriptorPool = ds_pool_one; |
| 1725 | alloc_info.pSetLayouts = &ds_layout; |
| 1726 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 1727 | &descriptorSet); |
| 1728 | ASSERT_VK_SUCCESS(err); |
| 1729 | |
| 1730 | err = vkFreeDescriptorSets(m_device->device(), ds_pool_two, 1, &descriptorSet); |
| 1731 | |
| 1732 | m_errorMonitor->VerifyFound(); |
| 1733 | |
| 1734 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1735 | vkDestroyDescriptorPool(m_device->device(), ds_pool_one, NULL); |
| 1736 | vkDestroyDescriptorPool(m_device->device(), ds_pool_two, NULL); |
| 1737 | } |
| 1738 | |
| 1739 | TEST_F(VkLayerTest, CreateUnknownObject) { |
| 1740 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1741 | "Invalid VkImage Object "); |
| 1742 | |
| 1743 | TEST_DESCRIPTION( |
| 1744 | "Pass an invalid image object handle into a Vulkan API call."); |
| 1745 | |
| 1746 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1747 | |
| 1748 | // Pass bogus handle into GetImageMemoryRequirements |
| 1749 | VkMemoryRequirements mem_reqs; |
| 1750 | uint64_t fakeImageHandle = 0xCADECADE; |
| 1751 | VkImage fauxImage = reinterpret_cast<VkImage &>(fakeImageHandle); |
| 1752 | |
| 1753 | vkGetImageMemoryRequirements(m_device->device(), fauxImage, &mem_reqs); |
| 1754 | |
| 1755 | m_errorMonitor->VerifyFound(); |
| 1756 | } |
| 1757 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1758 | TEST_F(VkLayerTest, PipelineNotBound) { |
| 1759 | VkResult err; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1760 | |
Mark Lobodzinski | fc5cc66 | 2016-05-02 17:17:41 -0600 | [diff] [blame] | 1761 | TEST_DESCRIPTION( |
| 1762 | "Pass in an invalid pipeline object handle into a Vulkan API call."); |
| 1763 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1764 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1765 | "Invalid VkPipeline Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1766 | |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1767 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1768 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1769 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1770 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1771 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1772 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1773 | |
| 1774 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1775 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1776 | ds_pool_ci.pNext = NULL; |
| 1777 | ds_pool_ci.maxSets = 1; |
| 1778 | ds_pool_ci.poolSizeCount = 1; |
| 1779 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1780 | |
| 1781 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1782 | err = |
| 1783 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1784 | ASSERT_VK_SUCCESS(err); |
| 1785 | |
| 1786 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1787 | dsl_binding.binding = 0; |
| 1788 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1789 | dsl_binding.descriptorCount = 1; |
| 1790 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1791 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1792 | |
| 1793 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1794 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1795 | ds_layout_ci.pNext = NULL; |
| 1796 | ds_layout_ci.bindingCount = 1; |
| 1797 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1798 | |
| 1799 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1800 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 1801 | &ds_layout); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1802 | ASSERT_VK_SUCCESS(err); |
| 1803 | |
| 1804 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1805 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1806 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 1807 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1808 | alloc_info.descriptorPool = ds_pool; |
| 1809 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1810 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 1811 | &descriptorSet); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1812 | ASSERT_VK_SUCCESS(err); |
| 1813 | |
| 1814 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1815 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 1816 | pipeline_layout_ci.pNext = NULL; |
| 1817 | pipeline_layout_ci.setLayoutCount = 1; |
| 1818 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1819 | |
| 1820 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1821 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 1822 | &pipeline_layout); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1823 | ASSERT_VK_SUCCESS(err); |
| 1824 | |
Mark Young | ad77905 | 2016-01-06 14:26:04 -0700 | [diff] [blame] | 1825 | VkPipeline badPipeline = (VkPipeline)((size_t)0xbaadb1be); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1826 | |
| 1827 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1828 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 1829 | VK_PIPELINE_BIND_POINT_GRAPHICS, badPipeline); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1830 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1831 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1832 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1833 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 1834 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1835 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1836 | } |
| 1837 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1838 | TEST_F(VkLayerTest, BindInvalidMemory) { |
| 1839 | VkResult err; |
| 1840 | bool pass; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1841 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 1842 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1843 | "Invalid VkDeviceMemory Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1844 | |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1845 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1846 | |
| 1847 | // 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] | 1848 | VkImage image; |
| 1849 | VkDeviceMemory mem; |
| 1850 | VkMemoryRequirements mem_reqs; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1851 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1852 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 1853 | const int32_t tex_width = 32; |
| 1854 | const int32_t tex_height = 32; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1855 | |
| 1856 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1857 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1858 | image_create_info.pNext = NULL; |
| 1859 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1860 | image_create_info.format = tex_format; |
| 1861 | image_create_info.extent.width = tex_width; |
| 1862 | image_create_info.extent.height = tex_height; |
| 1863 | image_create_info.extent.depth = 1; |
| 1864 | image_create_info.mipLevels = 1; |
| 1865 | image_create_info.arrayLayers = 1; |
| 1866 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1867 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1868 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 1869 | image_create_info.flags = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1870 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1871 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1872 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1873 | mem_alloc.pNext = NULL; |
| 1874 | mem_alloc.allocationSize = 0; |
| 1875 | mem_alloc.memoryTypeIndex = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1876 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1877 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1878 | ASSERT_VK_SUCCESS(err); |
| 1879 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1880 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1881 | |
| 1882 | mem_alloc.allocationSize = mem_reqs.size; |
| 1883 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1884 | pass = |
| 1885 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 1886 | ASSERT_TRUE(pass); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1887 | |
| 1888 | // allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1889 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1890 | ASSERT_VK_SUCCESS(err); |
| 1891 | |
| 1892 | // Introduce validation failure, free memory before binding |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1893 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1894 | |
| 1895 | // Try to bind free memory that has been freed |
| 1896 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 1897 | // This may very well return an error. |
| 1898 | (void)err; |
| 1899 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1900 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1901 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1902 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1903 | } |
| 1904 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1905 | TEST_F(VkLayerTest, BindMemoryToDestroyedObject) { |
| 1906 | VkResult err; |
| 1907 | bool pass; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1908 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1909 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 1910 | "Invalid VkImage Object "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1911 | |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1912 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1913 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1914 | // Create an image object, allocate memory, destroy the object and then try |
| 1915 | // to bind it |
| 1916 | VkImage image; |
| 1917 | VkDeviceMemory mem; |
| 1918 | VkMemoryRequirements mem_reqs; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1919 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1920 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 1921 | const int32_t tex_width = 32; |
| 1922 | const int32_t tex_height = 32; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1923 | |
| 1924 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1925 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1926 | image_create_info.pNext = NULL; |
| 1927 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1928 | image_create_info.format = tex_format; |
| 1929 | image_create_info.extent.width = tex_width; |
| 1930 | image_create_info.extent.height = tex_height; |
| 1931 | image_create_info.extent.depth = 1; |
| 1932 | image_create_info.mipLevels = 1; |
| 1933 | image_create_info.arrayLayers = 1; |
| 1934 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 1935 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1936 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 1937 | image_create_info.flags = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1938 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1939 | VkMemoryAllocateInfo mem_alloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1940 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 1941 | mem_alloc.pNext = NULL; |
| 1942 | mem_alloc.allocationSize = 0; |
| 1943 | mem_alloc.memoryTypeIndex = 0; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1944 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1945 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1946 | ASSERT_VK_SUCCESS(err); |
| 1947 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1948 | vkGetImageMemoryRequirements(m_device->device(), image, &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1949 | |
| 1950 | mem_alloc.allocationSize = mem_reqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1951 | pass = |
| 1952 | m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 1953 | ASSERT_TRUE(pass); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1954 | |
| 1955 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1956 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1957 | ASSERT_VK_SUCCESS(err); |
| 1958 | |
| 1959 | // Introduce validation failure, destroy Image object before binding |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1960 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1961 | ASSERT_VK_SUCCESS(err); |
| 1962 | |
| 1963 | // Now Try to bind memory to this destroyed object |
| 1964 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 1965 | // This may very well return an error. |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 1966 | (void)err; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1967 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 1968 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1969 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1970 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1971 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1972 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 1973 | #endif // OBJ_TRACKER_TESTS |
| 1974 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 1975 | #if DRAW_STATE_TESTS |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 1976 | |
| 1977 | // This is a positive test. No errors should be generated. |
| 1978 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceQWI) { |
| 1979 | |
| 1980 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 1981 | "submitted on separate queues followed by a QueueWaitIdle."); |
| 1982 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 1983 | if ((m_device->queue_props.empty()) || |
| 1984 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 1985 | return; |
| 1986 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 1987 | m_errorMonitor->ExpectSuccess(); |
| 1988 | |
| 1989 | VkSemaphore semaphore; |
| 1990 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 1991 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 1992 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 1993 | &semaphore); |
| 1994 | |
| 1995 | VkCommandPool command_pool; |
| 1996 | VkCommandPoolCreateInfo pool_create_info{}; |
| 1997 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 1998 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 1999 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2000 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2001 | &command_pool); |
| 2002 | |
| 2003 | VkCommandBuffer command_buffer[2]; |
| 2004 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2005 | command_buffer_allocate_info.sType = |
| 2006 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2007 | command_buffer_allocate_info.commandPool = command_pool; |
| 2008 | command_buffer_allocate_info.commandBufferCount = 2; |
| 2009 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2010 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2011 | command_buffer); |
| 2012 | |
| 2013 | VkQueue queue = VK_NULL_HANDLE; |
| 2014 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 2015 | 1, &queue); |
| 2016 | |
| 2017 | { |
| 2018 | VkCommandBufferBeginInfo begin_info{}; |
| 2019 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2020 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2021 | |
| 2022 | vkCmdPipelineBarrier(command_buffer[0], |
| 2023 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2024 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 2025 | 0, nullptr, 0, nullptr); |
| 2026 | |
| 2027 | VkViewport viewport{}; |
| 2028 | viewport.maxDepth = 1.0f; |
| 2029 | viewport.minDepth = 0.0f; |
| 2030 | viewport.width = 512; |
| 2031 | viewport.height = 512; |
| 2032 | viewport.x = 0; |
| 2033 | viewport.y = 0; |
| 2034 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 2035 | vkEndCommandBuffer(command_buffer[0]); |
| 2036 | } |
| 2037 | { |
| 2038 | VkCommandBufferBeginInfo begin_info{}; |
| 2039 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2040 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 2041 | |
| 2042 | VkViewport viewport{}; |
| 2043 | viewport.maxDepth = 1.0f; |
| 2044 | viewport.minDepth = 0.0f; |
| 2045 | viewport.width = 512; |
| 2046 | viewport.height = 512; |
| 2047 | viewport.x = 0; |
| 2048 | viewport.y = 0; |
| 2049 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 2050 | vkEndCommandBuffer(command_buffer[1]); |
| 2051 | } |
| 2052 | { |
| 2053 | VkSubmitInfo submit_info{}; |
| 2054 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2055 | submit_info.commandBufferCount = 1; |
| 2056 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 2057 | submit_info.signalSemaphoreCount = 1; |
| 2058 | submit_info.pSignalSemaphores = &semaphore; |
| 2059 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2060 | } |
| 2061 | { |
| 2062 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 2063 | VkSubmitInfo submit_info{}; |
| 2064 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2065 | submit_info.commandBufferCount = 1; |
| 2066 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 2067 | submit_info.waitSemaphoreCount = 1; |
| 2068 | submit_info.pWaitSemaphores = &semaphore; |
| 2069 | submit_info.pWaitDstStageMask = flags; |
| 2070 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2071 | } |
| 2072 | |
| 2073 | vkQueueWaitIdle(m_device->m_queue); |
| 2074 | |
| 2075 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 2076 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 2077 | &command_buffer[0]); |
| 2078 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2079 | |
| 2080 | m_errorMonitor->VerifyNotFound(); |
| 2081 | } |
| 2082 | |
| 2083 | // This is a positive test. No errors should be generated. |
| 2084 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceQWIFence) { |
| 2085 | |
| 2086 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 2087 | "submitted on separate queues, the second having a fence" |
| 2088 | "followed by a QueueWaitIdle."); |
| 2089 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 2090 | if ((m_device->queue_props.empty()) || |
| 2091 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 2092 | return; |
| 2093 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 2094 | m_errorMonitor->ExpectSuccess(); |
| 2095 | |
| 2096 | VkFence fence; |
| 2097 | VkFenceCreateInfo fence_create_info{}; |
| 2098 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2099 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 2100 | |
| 2101 | VkSemaphore semaphore; |
| 2102 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 2103 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 2104 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 2105 | &semaphore); |
| 2106 | |
| 2107 | VkCommandPool command_pool; |
| 2108 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2109 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2110 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2111 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2112 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2113 | &command_pool); |
| 2114 | |
| 2115 | VkCommandBuffer command_buffer[2]; |
| 2116 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2117 | command_buffer_allocate_info.sType = |
| 2118 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2119 | command_buffer_allocate_info.commandPool = command_pool; |
| 2120 | command_buffer_allocate_info.commandBufferCount = 2; |
| 2121 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2122 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2123 | command_buffer); |
| 2124 | |
| 2125 | VkQueue queue = VK_NULL_HANDLE; |
| 2126 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 2127 | 1, &queue); |
| 2128 | |
| 2129 | { |
| 2130 | VkCommandBufferBeginInfo begin_info{}; |
| 2131 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2132 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2133 | |
| 2134 | vkCmdPipelineBarrier(command_buffer[0], |
| 2135 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2136 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 2137 | 0, nullptr, 0, nullptr); |
| 2138 | |
| 2139 | VkViewport viewport{}; |
| 2140 | viewport.maxDepth = 1.0f; |
| 2141 | viewport.minDepth = 0.0f; |
| 2142 | viewport.width = 512; |
| 2143 | viewport.height = 512; |
| 2144 | viewport.x = 0; |
| 2145 | viewport.y = 0; |
| 2146 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 2147 | vkEndCommandBuffer(command_buffer[0]); |
| 2148 | } |
| 2149 | { |
| 2150 | VkCommandBufferBeginInfo begin_info{}; |
| 2151 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2152 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 2153 | |
| 2154 | VkViewport viewport{}; |
| 2155 | viewport.maxDepth = 1.0f; |
| 2156 | viewport.minDepth = 0.0f; |
| 2157 | viewport.width = 512; |
| 2158 | viewport.height = 512; |
| 2159 | viewport.x = 0; |
| 2160 | viewport.y = 0; |
| 2161 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 2162 | vkEndCommandBuffer(command_buffer[1]); |
| 2163 | } |
| 2164 | { |
| 2165 | VkSubmitInfo submit_info{}; |
| 2166 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2167 | submit_info.commandBufferCount = 1; |
| 2168 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 2169 | submit_info.signalSemaphoreCount = 1; |
| 2170 | submit_info.pSignalSemaphores = &semaphore; |
| 2171 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2172 | } |
| 2173 | { |
| 2174 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 2175 | VkSubmitInfo submit_info{}; |
| 2176 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2177 | submit_info.commandBufferCount = 1; |
| 2178 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 2179 | submit_info.waitSemaphoreCount = 1; |
| 2180 | submit_info.pWaitSemaphores = &semaphore; |
| 2181 | submit_info.pWaitDstStageMask = flags; |
| 2182 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 2183 | } |
| 2184 | |
| 2185 | vkQueueWaitIdle(m_device->m_queue); |
| 2186 | |
| 2187 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 2188 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 2189 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 2190 | &command_buffer[0]); |
| 2191 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2192 | |
| 2193 | m_errorMonitor->VerifyNotFound(); |
| 2194 | } |
| 2195 | |
| 2196 | // This is a positive test. No errors should be generated. |
| 2197 | TEST_F(VkLayerTest, |
| 2198 | TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFenceTwoWFF) { |
| 2199 | |
| 2200 | TEST_DESCRIPTION( |
| 2201 | "Two command buffers, each in a separate QueueSubmit call " |
| 2202 | "submitted on separate queues, the second having a fence" |
| 2203 | "followed by two consecutive WaitForFences calls on the same fence."); |
| 2204 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 2205 | if ((m_device->queue_props.empty()) || |
| 2206 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 2207 | return; |
| 2208 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 2209 | m_errorMonitor->ExpectSuccess(); |
| 2210 | |
| 2211 | VkFence fence; |
| 2212 | VkFenceCreateInfo fence_create_info{}; |
| 2213 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2214 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 2215 | |
| 2216 | VkSemaphore semaphore; |
| 2217 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 2218 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 2219 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 2220 | &semaphore); |
| 2221 | |
| 2222 | VkCommandPool command_pool; |
| 2223 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2224 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2225 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2226 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2227 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2228 | &command_pool); |
| 2229 | |
| 2230 | VkCommandBuffer command_buffer[2]; |
| 2231 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2232 | command_buffer_allocate_info.sType = |
| 2233 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2234 | command_buffer_allocate_info.commandPool = command_pool; |
| 2235 | command_buffer_allocate_info.commandBufferCount = 2; |
| 2236 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2237 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2238 | command_buffer); |
| 2239 | |
| 2240 | VkQueue queue = VK_NULL_HANDLE; |
| 2241 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 2242 | 1, &queue); |
| 2243 | |
| 2244 | { |
| 2245 | VkCommandBufferBeginInfo begin_info{}; |
| 2246 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2247 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2248 | |
| 2249 | vkCmdPipelineBarrier(command_buffer[0], |
| 2250 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2251 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 2252 | 0, nullptr, 0, nullptr); |
| 2253 | |
| 2254 | VkViewport viewport{}; |
| 2255 | viewport.maxDepth = 1.0f; |
| 2256 | viewport.minDepth = 0.0f; |
| 2257 | viewport.width = 512; |
| 2258 | viewport.height = 512; |
| 2259 | viewport.x = 0; |
| 2260 | viewport.y = 0; |
| 2261 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 2262 | vkEndCommandBuffer(command_buffer[0]); |
| 2263 | } |
| 2264 | { |
| 2265 | VkCommandBufferBeginInfo begin_info{}; |
| 2266 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2267 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 2268 | |
| 2269 | VkViewport viewport{}; |
| 2270 | viewport.maxDepth = 1.0f; |
| 2271 | viewport.minDepth = 0.0f; |
| 2272 | viewport.width = 512; |
| 2273 | viewport.height = 512; |
| 2274 | viewport.x = 0; |
| 2275 | viewport.y = 0; |
| 2276 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 2277 | vkEndCommandBuffer(command_buffer[1]); |
| 2278 | } |
| 2279 | { |
| 2280 | VkSubmitInfo submit_info{}; |
| 2281 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2282 | submit_info.commandBufferCount = 1; |
| 2283 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 2284 | submit_info.signalSemaphoreCount = 1; |
| 2285 | submit_info.pSignalSemaphores = &semaphore; |
| 2286 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2287 | } |
| 2288 | { |
| 2289 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 2290 | VkSubmitInfo submit_info{}; |
| 2291 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2292 | submit_info.commandBufferCount = 1; |
| 2293 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 2294 | submit_info.waitSemaphoreCount = 1; |
| 2295 | submit_info.pWaitSemaphores = &semaphore; |
| 2296 | submit_info.pWaitDstStageMask = flags; |
| 2297 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 2298 | } |
| 2299 | |
| 2300 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 2301 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 2302 | |
| 2303 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 2304 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 2305 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 2306 | &command_buffer[0]); |
| 2307 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2308 | |
| 2309 | m_errorMonitor->VerifyNotFound(); |
| 2310 | } |
| 2311 | |
| 2312 | // This is a positive test. No errors should be generated. |
| 2313 | TEST_F(VkLayerTest, TwoQueueSubmitsSeparateQueuesWithSemaphoreAndOneFence) { |
| 2314 | |
| 2315 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 2316 | "submitted on separate queues, the second having a fence, " |
| 2317 | "followed by a WaitForFences call."); |
| 2318 | |
Dustin Graves | 4845814 | 2016-04-29 16:11:55 -0600 | [diff] [blame] | 2319 | if ((m_device->queue_props.empty()) || |
| 2320 | (m_device->queue_props[0].queueCount < 2)) |
Tony Barbour | dc18b26 | 2016-04-22 14:49:48 -0600 | [diff] [blame] | 2321 | return; |
| 2322 | |
Mark Lobodzinski | c808d44 | 2016-04-14 10:57:23 -0600 | [diff] [blame] | 2323 | m_errorMonitor->ExpectSuccess(); |
| 2324 | |
| 2325 | VkFence fence; |
| 2326 | VkFenceCreateInfo fence_create_info{}; |
| 2327 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2328 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 2329 | |
| 2330 | VkSemaphore semaphore; |
| 2331 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 2332 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 2333 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 2334 | &semaphore); |
| 2335 | |
| 2336 | VkCommandPool command_pool; |
| 2337 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2338 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2339 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2340 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2341 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2342 | &command_pool); |
| 2343 | |
| 2344 | VkCommandBuffer command_buffer[2]; |
| 2345 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2346 | command_buffer_allocate_info.sType = |
| 2347 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2348 | command_buffer_allocate_info.commandPool = command_pool; |
| 2349 | command_buffer_allocate_info.commandBufferCount = 2; |
| 2350 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2351 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2352 | command_buffer); |
| 2353 | |
| 2354 | VkQueue queue = VK_NULL_HANDLE; |
| 2355 | vkGetDeviceQueue(m_device->device(), m_device->graphics_queue_node_index_, |
| 2356 | 1, &queue); |
| 2357 | |
| 2358 | |
| 2359 | { |
| 2360 | VkCommandBufferBeginInfo begin_info{}; |
| 2361 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2362 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2363 | |
| 2364 | vkCmdPipelineBarrier(command_buffer[0], |
| 2365 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2366 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 2367 | 0, nullptr, 0, nullptr); |
| 2368 | |
| 2369 | VkViewport viewport{}; |
| 2370 | viewport.maxDepth = 1.0f; |
| 2371 | viewport.minDepth = 0.0f; |
| 2372 | viewport.width = 512; |
| 2373 | viewport.height = 512; |
| 2374 | viewport.x = 0; |
| 2375 | viewport.y = 0; |
| 2376 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 2377 | vkEndCommandBuffer(command_buffer[0]); |
| 2378 | } |
| 2379 | { |
| 2380 | VkCommandBufferBeginInfo begin_info{}; |
| 2381 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2382 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 2383 | |
| 2384 | VkViewport viewport{}; |
| 2385 | viewport.maxDepth = 1.0f; |
| 2386 | viewport.minDepth = 0.0f; |
| 2387 | viewport.width = 512; |
| 2388 | viewport.height = 512; |
| 2389 | viewport.x = 0; |
| 2390 | viewport.y = 0; |
| 2391 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 2392 | vkEndCommandBuffer(command_buffer[1]); |
| 2393 | } |
| 2394 | { |
| 2395 | VkSubmitInfo submit_info{}; |
| 2396 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2397 | submit_info.commandBufferCount = 1; |
| 2398 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 2399 | submit_info.signalSemaphoreCount = 1; |
| 2400 | submit_info.pSignalSemaphores = &semaphore; |
| 2401 | vkQueueSubmit(queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2402 | } |
| 2403 | { |
| 2404 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 2405 | VkSubmitInfo submit_info{}; |
| 2406 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2407 | submit_info.commandBufferCount = 1; |
| 2408 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 2409 | submit_info.waitSemaphoreCount = 1; |
| 2410 | submit_info.pWaitSemaphores = &semaphore; |
| 2411 | submit_info.pWaitDstStageMask = flags; |
| 2412 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 2413 | } |
| 2414 | |
| 2415 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 2416 | |
| 2417 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 2418 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 2419 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 2420 | &command_buffer[0]); |
| 2421 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2422 | |
| 2423 | m_errorMonitor->VerifyNotFound(); |
| 2424 | } |
| 2425 | |
| 2426 | // This is a positive test. No errors should be generated. |
| 2427 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueWithSemaphoreAndOneFence) { |
| 2428 | |
| 2429 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 2430 | "on the same queue, sharing a signal/wait semaphore, the " |
| 2431 | "second having a fence, " |
| 2432 | "followed by a WaitForFences call."); |
| 2433 | |
| 2434 | m_errorMonitor->ExpectSuccess(); |
| 2435 | |
| 2436 | VkFence fence; |
| 2437 | VkFenceCreateInfo fence_create_info{}; |
| 2438 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2439 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 2440 | |
| 2441 | VkSemaphore semaphore; |
| 2442 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 2443 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 2444 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 2445 | &semaphore); |
| 2446 | |
| 2447 | VkCommandPool command_pool; |
| 2448 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2449 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2450 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2451 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2452 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2453 | &command_pool); |
| 2454 | |
| 2455 | VkCommandBuffer command_buffer[2]; |
| 2456 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2457 | command_buffer_allocate_info.sType = |
| 2458 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2459 | command_buffer_allocate_info.commandPool = command_pool; |
| 2460 | command_buffer_allocate_info.commandBufferCount = 2; |
| 2461 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2462 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2463 | command_buffer); |
| 2464 | |
| 2465 | { |
| 2466 | VkCommandBufferBeginInfo begin_info{}; |
| 2467 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2468 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2469 | |
| 2470 | vkCmdPipelineBarrier(command_buffer[0], |
| 2471 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2472 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 2473 | 0, nullptr, 0, nullptr); |
| 2474 | |
| 2475 | VkViewport viewport{}; |
| 2476 | viewport.maxDepth = 1.0f; |
| 2477 | viewport.minDepth = 0.0f; |
| 2478 | viewport.width = 512; |
| 2479 | viewport.height = 512; |
| 2480 | viewport.x = 0; |
| 2481 | viewport.y = 0; |
| 2482 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 2483 | vkEndCommandBuffer(command_buffer[0]); |
| 2484 | } |
| 2485 | { |
| 2486 | VkCommandBufferBeginInfo begin_info{}; |
| 2487 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2488 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 2489 | |
| 2490 | VkViewport viewport{}; |
| 2491 | viewport.maxDepth = 1.0f; |
| 2492 | viewport.minDepth = 0.0f; |
| 2493 | viewport.width = 512; |
| 2494 | viewport.height = 512; |
| 2495 | viewport.x = 0; |
| 2496 | viewport.y = 0; |
| 2497 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 2498 | vkEndCommandBuffer(command_buffer[1]); |
| 2499 | } |
| 2500 | { |
| 2501 | VkSubmitInfo submit_info{}; |
| 2502 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2503 | submit_info.commandBufferCount = 1; |
| 2504 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 2505 | submit_info.signalSemaphoreCount = 1; |
| 2506 | submit_info.pSignalSemaphores = &semaphore; |
| 2507 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2508 | } |
| 2509 | { |
| 2510 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 2511 | VkSubmitInfo submit_info{}; |
| 2512 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2513 | submit_info.commandBufferCount = 1; |
| 2514 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 2515 | submit_info.waitSemaphoreCount = 1; |
| 2516 | submit_info.pWaitSemaphores = &semaphore; |
| 2517 | submit_info.pWaitDstStageMask = flags; |
| 2518 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 2519 | } |
| 2520 | |
| 2521 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 2522 | |
| 2523 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 2524 | vkDestroySemaphore(m_device->device(), semaphore, nullptr); |
| 2525 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 2526 | &command_buffer[0]); |
| 2527 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2528 | |
| 2529 | m_errorMonitor->VerifyNotFound(); |
| 2530 | } |
| 2531 | |
| 2532 | // This is a positive test. No errors should be generated. |
| 2533 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueNullQueueSubmitWithFence) { |
| 2534 | |
| 2535 | TEST_DESCRIPTION( |
| 2536 | "Two command buffers, each in a separate QueueSubmit call " |
| 2537 | "on the same queue, no fences, followed by a third QueueSubmit with NO " |
| 2538 | "SubmitInfos but with a fence, followed by a WaitForFences call."); |
| 2539 | |
| 2540 | m_errorMonitor->ExpectSuccess(); |
| 2541 | |
| 2542 | VkFence fence; |
| 2543 | VkFenceCreateInfo fence_create_info{}; |
| 2544 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2545 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 2546 | |
| 2547 | VkCommandPool command_pool; |
| 2548 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2549 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2550 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2551 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2552 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2553 | &command_pool); |
| 2554 | |
| 2555 | VkCommandBuffer command_buffer[2]; |
| 2556 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2557 | command_buffer_allocate_info.sType = |
| 2558 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2559 | command_buffer_allocate_info.commandPool = command_pool; |
| 2560 | command_buffer_allocate_info.commandBufferCount = 2; |
| 2561 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2562 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2563 | command_buffer); |
| 2564 | |
| 2565 | { |
| 2566 | VkCommandBufferBeginInfo begin_info{}; |
| 2567 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2568 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2569 | |
| 2570 | vkCmdPipelineBarrier(command_buffer[0], |
| 2571 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2572 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 2573 | 0, nullptr, 0, nullptr); |
| 2574 | |
| 2575 | VkViewport viewport{}; |
| 2576 | viewport.maxDepth = 1.0f; |
| 2577 | viewport.minDepth = 0.0f; |
| 2578 | viewport.width = 512; |
| 2579 | viewport.height = 512; |
| 2580 | viewport.x = 0; |
| 2581 | viewport.y = 0; |
| 2582 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 2583 | vkEndCommandBuffer(command_buffer[0]); |
| 2584 | } |
| 2585 | { |
| 2586 | VkCommandBufferBeginInfo begin_info{}; |
| 2587 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2588 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 2589 | |
| 2590 | VkViewport viewport{}; |
| 2591 | viewport.maxDepth = 1.0f; |
| 2592 | viewport.minDepth = 0.0f; |
| 2593 | viewport.width = 512; |
| 2594 | viewport.height = 512; |
| 2595 | viewport.x = 0; |
| 2596 | viewport.y = 0; |
| 2597 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 2598 | vkEndCommandBuffer(command_buffer[1]); |
| 2599 | } |
| 2600 | { |
| 2601 | VkSubmitInfo submit_info{}; |
| 2602 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2603 | submit_info.commandBufferCount = 1; |
| 2604 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 2605 | submit_info.signalSemaphoreCount = 0; |
| 2606 | submit_info.pSignalSemaphores = VK_NULL_HANDLE; |
| 2607 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2608 | } |
| 2609 | { |
| 2610 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 2611 | VkSubmitInfo submit_info{}; |
| 2612 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2613 | submit_info.commandBufferCount = 1; |
| 2614 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 2615 | submit_info.waitSemaphoreCount = 0; |
| 2616 | submit_info.pWaitSemaphores = VK_NULL_HANDLE; |
| 2617 | submit_info.pWaitDstStageMask = flags; |
| 2618 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2619 | } |
| 2620 | |
| 2621 | vkQueueSubmit(m_device->m_queue, 0, NULL, fence); |
| 2622 | |
| 2623 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 2624 | |
| 2625 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 2626 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 2627 | &command_buffer[0]); |
| 2628 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2629 | |
| 2630 | m_errorMonitor->VerifyNotFound(); |
| 2631 | } |
| 2632 | |
| 2633 | // This is a positive test. No errors should be generated. |
| 2634 | TEST_F(VkLayerTest, TwoQueueSubmitsOneQueueOneFence) { |
| 2635 | |
| 2636 | TEST_DESCRIPTION("Two command buffers, each in a separate QueueSubmit call " |
| 2637 | "on the same queue, the second having a fence, followed " |
| 2638 | "by a WaitForFences call."); |
| 2639 | |
| 2640 | m_errorMonitor->ExpectSuccess(); |
| 2641 | |
| 2642 | VkFence fence; |
| 2643 | VkFenceCreateInfo fence_create_info{}; |
| 2644 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2645 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 2646 | |
| 2647 | VkCommandPool command_pool; |
| 2648 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2649 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2650 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2651 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2652 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2653 | &command_pool); |
| 2654 | |
| 2655 | VkCommandBuffer command_buffer[2]; |
| 2656 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2657 | command_buffer_allocate_info.sType = |
| 2658 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2659 | command_buffer_allocate_info.commandPool = command_pool; |
| 2660 | command_buffer_allocate_info.commandBufferCount = 2; |
| 2661 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2662 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2663 | command_buffer); |
| 2664 | |
| 2665 | { |
| 2666 | VkCommandBufferBeginInfo begin_info{}; |
| 2667 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2668 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2669 | |
| 2670 | vkCmdPipelineBarrier(command_buffer[0], |
| 2671 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2672 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 2673 | 0, nullptr, 0, nullptr); |
| 2674 | |
| 2675 | VkViewport viewport{}; |
| 2676 | viewport.maxDepth = 1.0f; |
| 2677 | viewport.minDepth = 0.0f; |
| 2678 | viewport.width = 512; |
| 2679 | viewport.height = 512; |
| 2680 | viewport.x = 0; |
| 2681 | viewport.y = 0; |
| 2682 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 2683 | vkEndCommandBuffer(command_buffer[0]); |
| 2684 | } |
| 2685 | { |
| 2686 | VkCommandBufferBeginInfo begin_info{}; |
| 2687 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2688 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 2689 | |
| 2690 | VkViewport viewport{}; |
| 2691 | viewport.maxDepth = 1.0f; |
| 2692 | viewport.minDepth = 0.0f; |
| 2693 | viewport.width = 512; |
| 2694 | viewport.height = 512; |
| 2695 | viewport.x = 0; |
| 2696 | viewport.y = 0; |
| 2697 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 2698 | vkEndCommandBuffer(command_buffer[1]); |
| 2699 | } |
| 2700 | { |
| 2701 | VkSubmitInfo submit_info{}; |
| 2702 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2703 | submit_info.commandBufferCount = 1; |
| 2704 | submit_info.pCommandBuffers = &command_buffer[0]; |
| 2705 | submit_info.signalSemaphoreCount = 0; |
| 2706 | submit_info.pSignalSemaphores = VK_NULL_HANDLE; |
| 2707 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, VK_NULL_HANDLE); |
| 2708 | } |
| 2709 | { |
| 2710 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 2711 | VkSubmitInfo submit_info{}; |
| 2712 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2713 | submit_info.commandBufferCount = 1; |
| 2714 | submit_info.pCommandBuffers = &command_buffer[1]; |
| 2715 | submit_info.waitSemaphoreCount = 0; |
| 2716 | submit_info.pWaitSemaphores = VK_NULL_HANDLE; |
| 2717 | submit_info.pWaitDstStageMask = flags; |
| 2718 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, fence); |
| 2719 | } |
| 2720 | |
| 2721 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 2722 | |
| 2723 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 2724 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 2725 | &command_buffer[0]); |
| 2726 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2727 | |
| 2728 | m_errorMonitor->VerifyNotFound(); |
| 2729 | } |
| 2730 | |
| 2731 | // This is a positive test. No errors should be generated. |
| 2732 | TEST_F(VkLayerTest, TwoSubmitInfosWithSemaphoreOneQueueSubmitsOneFence) { |
| 2733 | |
| 2734 | TEST_DESCRIPTION( |
| 2735 | "Two command buffers each in a separate SubmitInfo sent in a single " |
| 2736 | "QueueSubmit call followed by a WaitForFences call."); |
| 2737 | |
| 2738 | m_errorMonitor->ExpectSuccess(); |
| 2739 | |
| 2740 | VkFence fence; |
| 2741 | VkFenceCreateInfo fence_create_info{}; |
| 2742 | fence_create_info.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2743 | vkCreateFence(m_device->device(), &fence_create_info, nullptr, &fence); |
| 2744 | |
| 2745 | VkSemaphore semaphore; |
| 2746 | VkSemaphoreCreateInfo semaphore_create_info{}; |
| 2747 | semaphore_create_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; |
| 2748 | vkCreateSemaphore(m_device->device(), &semaphore_create_info, nullptr, |
| 2749 | &semaphore); |
| 2750 | |
| 2751 | VkCommandPool command_pool; |
| 2752 | VkCommandPoolCreateInfo pool_create_info{}; |
| 2753 | pool_create_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; |
| 2754 | pool_create_info.queueFamilyIndex = m_device->graphics_queue_node_index_; |
| 2755 | pool_create_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; |
| 2756 | vkCreateCommandPool(m_device->device(), &pool_create_info, nullptr, |
| 2757 | &command_pool); |
| 2758 | |
| 2759 | VkCommandBuffer command_buffer[2]; |
| 2760 | VkCommandBufferAllocateInfo command_buffer_allocate_info{}; |
| 2761 | command_buffer_allocate_info.sType = |
| 2762 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
| 2763 | command_buffer_allocate_info.commandPool = command_pool; |
| 2764 | command_buffer_allocate_info.commandBufferCount = 2; |
| 2765 | command_buffer_allocate_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; |
| 2766 | vkAllocateCommandBuffers(m_device->device(), &command_buffer_allocate_info, |
| 2767 | command_buffer); |
| 2768 | |
| 2769 | { |
| 2770 | VkCommandBufferBeginInfo begin_info{}; |
| 2771 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2772 | vkBeginCommandBuffer(command_buffer[0], &begin_info); |
| 2773 | |
| 2774 | vkCmdPipelineBarrier(command_buffer[0], |
| 2775 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, |
| 2776 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, |
| 2777 | 0, nullptr, 0, nullptr); |
| 2778 | |
| 2779 | VkViewport viewport{}; |
| 2780 | viewport.maxDepth = 1.0f; |
| 2781 | viewport.minDepth = 0.0f; |
| 2782 | viewport.width = 512; |
| 2783 | viewport.height = 512; |
| 2784 | viewport.x = 0; |
| 2785 | viewport.y = 0; |
| 2786 | vkCmdSetViewport(command_buffer[0], 0, 1, &viewport); |
| 2787 | vkEndCommandBuffer(command_buffer[0]); |
| 2788 | } |
| 2789 | { |
| 2790 | VkCommandBufferBeginInfo begin_info{}; |
| 2791 | begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2792 | vkBeginCommandBuffer(command_buffer[1], &begin_info); |
| 2793 | |
| 2794 | VkViewport viewport{}; |
| 2795 | viewport.maxDepth = 1.0f; |
| 2796 | viewport.minDepth = 0.0f; |
| 2797 | viewport.width = 512; |
| 2798 | viewport.height = 512; |
| 2799 | viewport.x = 0; |
| 2800 | viewport.y = 0; |
| 2801 | vkCmdSetViewport(command_buffer[1], 0, 1, &viewport); |
| 2802 | vkEndCommandBuffer(command_buffer[1]); |
| 2803 | } |
| 2804 | { |
| 2805 | VkSubmitInfo submit_info[2]; |
| 2806 | VkPipelineStageFlags flags[]{VK_PIPELINE_STAGE_ALL_COMMANDS_BIT}; |
| 2807 | |
| 2808 | submit_info[0].sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2809 | submit_info[0].pNext = NULL; |
| 2810 | submit_info[0].commandBufferCount = 1; |
| 2811 | submit_info[0].pCommandBuffers = &command_buffer[0]; |
| 2812 | submit_info[0].signalSemaphoreCount = 1; |
| 2813 | submit_info[0].pSignalSemaphores = &semaphore; |
| 2814 | submit_info[0].waitSemaphoreCount = 0; |
| 2815 | submit_info[0].pWaitSemaphores = NULL; |
| 2816 | submit_info[0].pWaitDstStageMask = 0; |
| 2817 | |
| 2818 | submit_info[1].sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2819 | submit_info[1].pNext = NULL; |
| 2820 | submit_info[1].commandBufferCount = 1; |
| 2821 | submit_info[1].pCommandBuffers = &command_buffer[1]; |
| 2822 | submit_info[1].waitSemaphoreCount = 1; |
| 2823 | submit_info[1].pWaitSemaphores = &semaphore; |
| 2824 | submit_info[1].pWaitDstStageMask = flags; |
| 2825 | submit_info[1].signalSemaphoreCount = 0; |
| 2826 | submit_info[1].pSignalSemaphores = NULL; |
| 2827 | vkQueueSubmit(m_device->m_queue, 2, &submit_info[0], fence); |
| 2828 | } |
| 2829 | |
| 2830 | vkWaitForFences(m_device->device(), 1, &fence, VK_TRUE, UINT64_MAX); |
| 2831 | |
| 2832 | vkDestroyFence(m_device->device(), fence, nullptr); |
| 2833 | vkFreeCommandBuffers(m_device->device(), command_pool, 2, |
| 2834 | &command_buffer[0]); |
| 2835 | vkDestroyCommandPool(m_device->device(), command_pool, NULL); |
| 2836 | |
| 2837 | m_errorMonitor->VerifyNotFound(); |
| 2838 | } |
| 2839 | |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2840 | TEST_F(VkLayerTest, DynamicStatesNotBound) { |
| 2841 | TEST_DESCRIPTION( |
| 2842 | "Run a series of simple draw calls to validate all the different " |
| 2843 | "failure cases that can occur when dynamic state is required but not " |
| 2844 | "correctly bound." |
| 2845 | "Here are the different dynamic state cases verified by this test:\n" |
| 2846 | "-Line Width\n-Depth Bias\n-Viewport State\n-Scissor State\n-Blend " |
| 2847 | "State\n-Depth Bounds\n-Stencil Read Mask\n-Stencil Write " |
| 2848 | "Mask\n-Stencil Reference"); |
| 2849 | |
| 2850 | // Dynamic line width |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2851 | m_errorMonitor->SetDesiredFailureMsg( |
| 2852 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2853 | "Dynamic line width state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2854 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2855 | BsoFailLineWidth); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2856 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2857 | // Dynamic depth bias |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2858 | m_errorMonitor->SetDesiredFailureMsg( |
| 2859 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2860 | "Dynamic depth bias state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2861 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2862 | BsoFailDepthBias); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2863 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2864 | // Dynamic viewport state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2865 | m_errorMonitor->SetDesiredFailureMsg( |
| 2866 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2867 | "Dynamic viewport state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2868 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2869 | BsoFailViewport); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2870 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2871 | // Dynamic scissor state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2872 | m_errorMonitor->SetDesiredFailureMsg( |
| 2873 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2874 | "Dynamic scissor state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2875 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2876 | BsoFailScissor); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2877 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2878 | // Dynamic blend state |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2879 | m_errorMonitor->SetDesiredFailureMsg( |
| 2880 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2881 | "Dynamic depth bounds state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2882 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2883 | BsoFailDepthBounds); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2884 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2885 | // Dynamic stencil read mask |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2886 | m_errorMonitor->SetDesiredFailureMsg( |
| 2887 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2888 | "Dynamic stencil read mask state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2889 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2890 | BsoFailStencilReadMask); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2891 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2892 | // Dynamic stencil write mask |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2893 | m_errorMonitor->SetDesiredFailureMsg( |
| 2894 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2895 | "Dynamic stencil write mask state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2896 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2897 | BsoFailStencilWriteMask); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2898 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a5200ef | 2016-05-03 10:34:08 -0600 | [diff] [blame] | 2899 | // Dynamic stencil reference |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2900 | m_errorMonitor->SetDesiredFailureMsg( |
| 2901 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2902 | "Dynamic stencil reference state not set for this command buffer"); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2903 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, |
| 2904 | BsoFailStencilReference); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2905 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 2906 | } |
| 2907 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2908 | TEST_F(VkLayerTest, CommandBufferTwoSubmits) { |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 2909 | vk_testing::Fence testFence; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2910 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2911 | m_errorMonitor->SetDesiredFailureMsg( |
| 2912 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 2913 | "was begun w/ VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set, but has " |
| 2914 | "been submitted"); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 2915 | |
| 2916 | VkFenceCreateInfo fenceInfo = {}; |
| 2917 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 2918 | fenceInfo.pNext = NULL; |
| 2919 | fenceInfo.flags = 0; |
| 2920 | |
| 2921 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2922 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 2923 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 2924 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2925 | // We luck out b/c by default the framework creates CB w/ the |
| 2926 | // VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 2927 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2928 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, |
| 2929 | m_stencil_clear_color, NULL); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 2930 | EndCommandBuffer(); |
| 2931 | |
| 2932 | testFence.init(*m_device, fenceInfo); |
| 2933 | |
| 2934 | // Bypass framework since it does the waits automatically |
| 2935 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2936 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 2937 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 2938 | submit_info.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2939 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2940 | submit_info.pWaitSemaphores = NULL; |
Jon Ashburn | 7f9716c | 2015-12-30 16:42:50 -0700 | [diff] [blame] | 2941 | submit_info.pWaitDstStageMask = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2942 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2943 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2944 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 2945 | submit_info.pSignalSemaphores = NULL; |
| 2946 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2947 | err = vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
| 2948 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 2949 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2950 | // Cause validation error by re-submitting cmd buffer that should only be |
| 2951 | // submitted once |
| 2952 | err = vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 2953 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 2954 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 2955 | } |
| 2956 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2957 | TEST_F(VkLayerTest, AllocDescriptorFromEmptyPool) { |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2958 | // Initiate Draw w/o a PSO bound |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2959 | VkResult err; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2960 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 2961 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2962 | "Unable to allocate 1 descriptors of " |
| 2963 | "type " |
| 2964 | "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2965 | |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2966 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2967 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2968 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2969 | // Create Pool w/ 1 Sampler descriptor, but try to alloc Uniform Buffer |
| 2970 | // descriptor from it |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2971 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2972 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 2973 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2974 | |
| 2975 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2976 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2977 | ds_pool_ci.pNext = NULL; |
| 2978 | ds_pool_ci.flags = 0; |
| 2979 | ds_pool_ci.maxSets = 1; |
| 2980 | ds_pool_ci.poolSizeCount = 1; |
| 2981 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2982 | |
| 2983 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2984 | err = |
| 2985 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2986 | ASSERT_VK_SUCCESS(err); |
| 2987 | |
| 2988 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2989 | dsl_binding.binding = 0; |
| 2990 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2991 | dsl_binding.descriptorCount = 1; |
| 2992 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2993 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 2994 | |
| 2995 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 2996 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2997 | ds_layout_ci.pNext = NULL; |
| 2998 | ds_layout_ci.bindingCount = 1; |
| 2999 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 3000 | |
| 3001 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3002 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3003 | &ds_layout); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 3004 | ASSERT_VK_SUCCESS(err); |
| 3005 | |
| 3006 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3007 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3008 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3009 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3010 | alloc_info.descriptorPool = ds_pool; |
| 3011 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3012 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3013 | &descriptorSet); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 3014 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3015 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 3016 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3017 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3018 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 3019 | } |
| 3020 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3021 | TEST_F(VkLayerTest, FreeDescriptorFromOneShotPool) { |
| 3022 | VkResult err; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3023 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3024 | m_errorMonitor->SetDesiredFailureMsg( |
| 3025 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3026 | "It is invalid to call vkFreeDescriptorSets() with a pool created " |
| 3027 | "without setting VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3028 | |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3029 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3030 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3031 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3032 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3033 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3034 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3035 | |
| 3036 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3037 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3038 | ds_pool_ci.pNext = NULL; |
| 3039 | ds_pool_ci.maxSets = 1; |
| 3040 | ds_pool_ci.poolSizeCount = 1; |
| 3041 | ds_pool_ci.flags = 0; |
| 3042 | // Not specifying VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT means |
| 3043 | // app can only call vkResetDescriptorPool on this pool.; |
| 3044 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3045 | |
| 3046 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3047 | err = |
| 3048 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3049 | ASSERT_VK_SUCCESS(err); |
| 3050 | |
| 3051 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3052 | dsl_binding.binding = 0; |
| 3053 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3054 | dsl_binding.descriptorCount = 1; |
| 3055 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3056 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3057 | |
| 3058 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3059 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3060 | ds_layout_ci.pNext = NULL; |
| 3061 | ds_layout_ci.bindingCount = 1; |
| 3062 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3063 | |
| 3064 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3065 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3066 | &ds_layout); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3067 | ASSERT_VK_SUCCESS(err); |
| 3068 | |
| 3069 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3070 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3071 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3072 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3073 | alloc_info.descriptorPool = ds_pool; |
| 3074 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3075 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3076 | &descriptorSet); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3077 | ASSERT_VK_SUCCESS(err); |
| 3078 | |
| 3079 | err = vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptorSet); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3080 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3081 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3082 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3083 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 3084 | } |
| 3085 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3086 | TEST_F(VkLayerTest, InvalidDescriptorPool) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3087 | // Attempt to clear Descriptor Pool with bad object. |
| 3088 | // ObjectTracker should catch this. |
| 3089 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3090 | "Invalid VkDescriptorPool Object 0xbaad6001"); |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 3091 | uint64_t fake_pool_handle = 0xbaad6001; |
| 3092 | VkDescriptorPool bad_pool = reinterpret_cast<VkDescriptorPool &>(fake_pool_handle); |
| 3093 | vkResetDescriptorPool(device(), bad_pool, 0); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3094 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3095 | } |
| 3096 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3097 | TEST_F(VkLayerTest, InvalidDescriptorSet) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3098 | // Attempt to bind an invalid Descriptor Set to a valid Command Buffer |
| 3099 | // ObjectTracker should catch this. |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3100 | // Create a valid cmd buffer |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3101 | // call vkCmdBindDescriptorSets w/ false Descriptor Set |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 3102 | |
| 3103 | uint64_t fake_set_handle = 0xbaad6001; |
| 3104 | VkDescriptorSet bad_set = reinterpret_cast<VkDescriptorSet &>(fake_set_handle); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3105 | VkResult err; |
| 3106 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3107 | "Invalid VkDescriptorSet Object 0xbaad6001"); |
| 3108 | |
| 3109 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3110 | |
| 3111 | VkDescriptorSetLayoutBinding layout_bindings[1] = {}; |
| 3112 | layout_bindings[0].binding = 0; |
| 3113 | layout_bindings[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3114 | layout_bindings[0].descriptorCount = 1; |
| 3115 | layout_bindings[0].stageFlags = VK_SHADER_STAGE_VERTEX_BIT; |
| 3116 | layout_bindings[0].pImmutableSamplers = NULL; |
| 3117 | |
| 3118 | VkDescriptorSetLayout descriptor_set_layout; |
| 3119 | VkDescriptorSetLayoutCreateInfo dslci = {}; |
| 3120 | dslci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3121 | dslci.pNext = NULL; |
| 3122 | dslci.bindingCount = 1; |
| 3123 | dslci.pBindings = layout_bindings; |
| 3124 | err = vkCreateDescriptorSetLayout(device(), &dslci, NULL, &descriptor_set_layout); |
Karl Schultz | 5cb2111 | 2016-04-21 17:17:40 -0600 | [diff] [blame] | 3125 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3126 | |
| 3127 | VkPipelineLayout pipeline_layout; |
| 3128 | VkPipelineLayoutCreateInfo plci = {}; |
| 3129 | plci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3130 | plci.pNext = NULL; |
| 3131 | plci.setLayoutCount = 1; |
| 3132 | plci.pSetLayouts = &descriptor_set_layout; |
| 3133 | err = vkCreatePipelineLayout(device(), &plci, NULL, &pipeline_layout); |
Karl Schultz | 5cb2111 | 2016-04-21 17:17:40 -0600 | [diff] [blame] | 3134 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3135 | |
| 3136 | BeginCommandBuffer(); |
| 3137 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 3138 | pipeline_layout, 0, 1, &bad_set, 0, NULL); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3139 | m_errorMonitor->VerifyFound(); |
| 3140 | EndCommandBuffer(); |
| 3141 | vkDestroyPipelineLayout(device(), pipeline_layout, NULL); |
| 3142 | vkDestroyDescriptorSetLayout(device(), descriptor_set_layout, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3143 | } |
| 3144 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3145 | TEST_F(VkLayerTest, InvalidDescriptorSetLayout) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3146 | // Attempt to create a Pipeline Layout with an invalid Descriptor Set Layout. |
| 3147 | // ObjectTracker should catch this. |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 3148 | uint64_t fake_layout_handle = 0xbaad6001; |
| 3149 | VkDescriptorSetLayout bad_layout = reinterpret_cast<VkDescriptorSetLayout &>(fake_layout_handle); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3150 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3151 | "Invalid VkDescriptorSetLayout Object 0xbaad6001"); |
| 3152 | |
| 3153 | VkPipelineLayout pipeline_layout; |
| 3154 | VkPipelineLayoutCreateInfo plci = {}; |
| 3155 | plci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3156 | plci.pNext = NULL; |
| 3157 | plci.setLayoutCount = 1; |
| 3158 | plci.pSetLayouts = &bad_layout; |
| 3159 | vkCreatePipelineLayout(device(), &plci, NULL, &pipeline_layout); |
| 3160 | |
| 3161 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3162 | } |
| 3163 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3164 | TEST_F(VkLayerTest, InvalidPipeline) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3165 | // Attempt to bind an invalid Pipeline to a valid Command Buffer |
| 3166 | // ObjectTracker should catch this. |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3167 | // Create a valid cmd buffer |
| 3168 | // call vkCmdBindPipeline w/ false Pipeline |
Mark Lobodzinski | 02bf89d | 2016-05-10 14:45:13 -0600 | [diff] [blame] | 3169 | uint64_t fake_pipeline_handle = 0xbaad6001; |
| 3170 | VkPipeline bad_pipeline = reinterpret_cast<VkPipeline &>(fake_pipeline_handle); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3171 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3172 | "Invalid VkPipeline Object 0xbaad6001"); |
| 3173 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3174 | BeginCommandBuffer(); |
| 3175 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 3176 | VK_PIPELINE_BIND_POINT_GRAPHICS, bad_pipeline); |
| 3177 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | b8b6b27 | 2016-05-02 13:26:06 -0600 | [diff] [blame] | 3178 | |
| 3179 | // Now issue a draw call with no pipeline bound |
| 3180 | m_errorMonitor->SetDesiredFailureMsg( |
| 3181 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3182 | "At Draw/Dispatch time no valid VkPipeline is bound!"); |
| 3183 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3184 | BeginCommandBuffer(); |
| 3185 | Draw(1, 0, 0, 0); |
| 3186 | m_errorMonitor->VerifyFound(); |
| 3187 | // Finally same check once more but with Dispatch/Compute |
| 3188 | m_errorMonitor->SetDesiredFailureMsg( |
| 3189 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3190 | "At Draw/Dispatch time no valid VkPipeline is bound!"); |
| 3191 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3192 | BeginCommandBuffer(); |
| 3193 | vkCmdDispatch(m_commandBuffer->GetBufferHandle(), 0, 0, 0); |
| 3194 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3195 | } |
| 3196 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3197 | TEST_F(VkLayerTest, DescriptorSetNotUpdated) { |
| 3198 | // Create and update CommandBuffer then call QueueSubmit w/o calling End on |
| 3199 | // CommandBuffer |
| 3200 | VkResult err; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3201 | |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 3202 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3203 | " bound but it was never updated. "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3204 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3205 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 3206 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 3207 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3208 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3209 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3210 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3211 | |
| 3212 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3213 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3214 | ds_pool_ci.pNext = NULL; |
| 3215 | ds_pool_ci.maxSets = 1; |
| 3216 | ds_pool_ci.poolSizeCount = 1; |
| 3217 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 3218 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3219 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3220 | err = |
| 3221 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3222 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3223 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3224 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3225 | dsl_binding.binding = 0; |
| 3226 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3227 | dsl_binding.descriptorCount = 1; |
| 3228 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3229 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3230 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3231 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3232 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3233 | ds_layout_ci.pNext = NULL; |
| 3234 | ds_layout_ci.bindingCount = 1; |
| 3235 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3236 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3237 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3238 | &ds_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3239 | ASSERT_VK_SUCCESS(err); |
| 3240 | |
| 3241 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3242 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3243 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3244 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3245 | alloc_info.descriptorPool = ds_pool; |
| 3246 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3247 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3248 | &descriptorSet); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3249 | ASSERT_VK_SUCCESS(err); |
| 3250 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3251 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3252 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3253 | pipeline_layout_ci.pNext = NULL; |
| 3254 | pipeline_layout_ci.setLayoutCount = 1; |
| 3255 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3256 | |
| 3257 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3258 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3259 | &pipeline_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3260 | ASSERT_VK_SUCCESS(err); |
| 3261 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3262 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 3263 | VK_SHADER_STAGE_VERTEX_BIT, this); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 3264 | // 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] | 3265 | // on more devices |
| 3266 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 3267 | VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3268 | |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 3269 | VkPipelineObj pipe(m_device); |
| 3270 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 3271 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 3272 | pipe.AddColorAttachment(); |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 3273 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 3274 | |
| 3275 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3276 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 3277 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 3278 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3279 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3280 | 1, &descriptorSet, 0, NULL); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3281 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3282 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3283 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3284 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3285 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3286 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3287 | } |
| 3288 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3289 | TEST_F(VkLayerTest, InvalidBufferViewObject) { |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3290 | // Create a single TEXEL_BUFFER descriptor and send it an invalid bufferView |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3291 | VkResult err; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3292 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3293 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 3294 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Attempted write update to texel buffer " |
| 3295 | "descriptor with invalid buffer view"); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3296 | |
| 3297 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3298 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3299 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 3300 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3301 | |
| 3302 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3303 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3304 | ds_pool_ci.pNext = NULL; |
| 3305 | ds_pool_ci.maxSets = 1; |
| 3306 | ds_pool_ci.poolSizeCount = 1; |
| 3307 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3308 | |
| 3309 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3310 | err = |
| 3311 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3312 | ASSERT_VK_SUCCESS(err); |
| 3313 | |
| 3314 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3315 | dsl_binding.binding = 0; |
| 3316 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 3317 | dsl_binding.descriptorCount = 1; |
| 3318 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3319 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3320 | |
| 3321 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3322 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3323 | ds_layout_ci.pNext = NULL; |
| 3324 | ds_layout_ci.bindingCount = 1; |
| 3325 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3326 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3327 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3328 | &ds_layout); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3329 | ASSERT_VK_SUCCESS(err); |
| 3330 | |
| 3331 | VkDescriptorSet descriptorSet; |
| 3332 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3333 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3334 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3335 | alloc_info.descriptorPool = ds_pool; |
| 3336 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3337 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3338 | &descriptorSet); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3339 | ASSERT_VK_SUCCESS(err); |
| 3340 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3341 | VkBufferView view = |
| 3342 | (VkBufferView)((size_t)0xbaadbeef); // invalid bufferView object |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3343 | VkWriteDescriptorSet descriptor_write; |
| 3344 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3345 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 3346 | descriptor_write.dstSet = descriptorSet; |
| 3347 | descriptor_write.dstBinding = 0; |
| 3348 | descriptor_write.descriptorCount = 1; |
| 3349 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 3350 | descriptor_write.pTexelBufferView = &view; |
| 3351 | |
| 3352 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3353 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3354 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | ba31cab | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 3355 | |
| 3356 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3357 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 3358 | } |
| 3359 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3360 | TEST_F(VkLayerTest, InvalidDynamicOffsetCases) { |
| 3361 | // Create a descriptorSet w/ dynamic descriptor and then hit 3 offset error |
| 3362 | // cases: |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3363 | // 1. No dynamicOffset supplied |
| 3364 | // 2. Too many dynamicOffsets supplied |
| 3365 | // 3. Dynamic offset oversteps buffer being updated |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3366 | VkResult err; |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 3367 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3368 | " requires 1 dynamicOffsets, but only " |
| 3369 | "0 dynamicOffsets are left in " |
| 3370 | "pDynamicOffsets "); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3371 | |
| 3372 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3373 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 3374 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3375 | |
| 3376 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3377 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 3378 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3379 | |
| 3380 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3381 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3382 | ds_pool_ci.pNext = NULL; |
| 3383 | ds_pool_ci.maxSets = 1; |
| 3384 | ds_pool_ci.poolSizeCount = 1; |
| 3385 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3386 | |
| 3387 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3388 | err = |
| 3389 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3390 | ASSERT_VK_SUCCESS(err); |
| 3391 | |
| 3392 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3393 | dsl_binding.binding = 0; |
| 3394 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 3395 | dsl_binding.descriptorCount = 1; |
| 3396 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3397 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3398 | |
| 3399 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3400 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3401 | ds_layout_ci.pNext = NULL; |
| 3402 | ds_layout_ci.bindingCount = 1; |
| 3403 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3404 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3405 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3406 | &ds_layout); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3407 | ASSERT_VK_SUCCESS(err); |
| 3408 | |
| 3409 | VkDescriptorSet descriptorSet; |
| 3410 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3411 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3412 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3413 | alloc_info.descriptorPool = ds_pool; |
| 3414 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3415 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3416 | &descriptorSet); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3417 | ASSERT_VK_SUCCESS(err); |
| 3418 | |
| 3419 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3420 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3421 | pipeline_layout_ci.pNext = NULL; |
| 3422 | pipeline_layout_ci.setLayoutCount = 1; |
| 3423 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3424 | |
| 3425 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3426 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3427 | &pipeline_layout); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3428 | ASSERT_VK_SUCCESS(err); |
| 3429 | |
| 3430 | // Create a buffer to update the descriptor with |
| 3431 | uint32_t qfi = 0; |
| 3432 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3433 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 3434 | buffCI.size = 1024; |
| 3435 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 3436 | buffCI.queueFamilyIndexCount = 1; |
| 3437 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3438 | |
| 3439 | VkBuffer dyub; |
| 3440 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 3441 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 3442 | // Allocate memory and bind to buffer so we can make it to the appropriate |
| 3443 | // error |
| 3444 | VkMemoryAllocateInfo mem_alloc = {}; |
| 3445 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 3446 | mem_alloc.pNext = NULL; |
| 3447 | mem_alloc.allocationSize = 1024; |
Chris Forbes | b6116cc | 2016-05-08 11:39:59 +1200 | [diff] [blame] | 3448 | mem_alloc.memoryTypeIndex = 0; |
| 3449 | |
| 3450 | VkMemoryRequirements memReqs; |
| 3451 | vkGetBufferMemoryRequirements(m_device->device(), dyub, &memReqs); |
| 3452 | bool pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &mem_alloc, |
| 3453 | 0); |
| 3454 | if (!pass) { |
| 3455 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
| 3456 | return; |
| 3457 | } |
| 3458 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 3459 | VkDeviceMemory mem; |
| 3460 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
| 3461 | ASSERT_VK_SUCCESS(err); |
| 3462 | err = vkBindBufferMemory(m_device->device(), dyub, mem, 0); |
| 3463 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3464 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 3465 | VkDescriptorBufferInfo buffInfo = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3466 | buffInfo.buffer = dyub; |
| 3467 | buffInfo.offset = 0; |
| 3468 | buffInfo.range = 1024; |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3469 | |
| 3470 | VkWriteDescriptorSet descriptor_write; |
| 3471 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3472 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 3473 | descriptor_write.dstSet = descriptorSet; |
| 3474 | descriptor_write.dstBinding = 0; |
| 3475 | descriptor_write.descriptorCount = 1; |
| 3476 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 3477 | descriptor_write.pBufferInfo = &buffInfo; |
| 3478 | |
| 3479 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3480 | |
| 3481 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3482 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3483 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3484 | 1, &descriptorSet, 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3485 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3486 | uint32_t pDynOff[2] = {512, 756}; |
| 3487 | // 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] | 3488 | m_errorMonitor->SetDesiredFailureMsg( |
| 3489 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3490 | "Attempting to bind 1 descriptorSets with 1 dynamic descriptors, but "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3491 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3492 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3493 | 1, &descriptorSet, 2, pDynOff); |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 3494 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3495 | // Finally cause error due to dynamicOffset being too big |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 3496 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3497 | " dynamic offset 512 combined with " |
| 3498 | "offset 0 and range 1024 that " |
| 3499 | "oversteps the buffer size of 1024"); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3500 | // Create PSO to be used for draw-time errors below |
| 3501 | char const *vsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 3502 | "#version 450\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3503 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 3504 | "out gl_PerVertex { \n" |
| 3505 | " vec4 gl_Position;\n" |
| 3506 | "};\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3507 | "void main(){\n" |
| 3508 | " gl_Position = vec4(1);\n" |
| 3509 | "}\n"; |
| 3510 | char const *fsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 3511 | "#version 450\n" |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3512 | "\n" |
| 3513 | "layout(location=0) out vec4 x;\n" |
| 3514 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 3515 | "void main(){\n" |
| 3516 | " x = vec4(bar.y);\n" |
| 3517 | "}\n"; |
| 3518 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 3519 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 3520 | VkPipelineObj pipe(m_device); |
| 3521 | pipe.AddShader(&vs); |
| 3522 | pipe.AddShader(&fs); |
| 3523 | pipe.AddColorAttachment(); |
| 3524 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 3525 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3526 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 3527 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 3528 | // This update should succeed, but offset size of 512 will overstep buffer |
| 3529 | // /w range 1024 & size 1024 |
| 3530 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3531 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3532 | 1, &descriptorSet, 1, pDynOff); |
Tobin Ehlis | f658505 | 2015-12-17 11:48:42 -0700 | [diff] [blame] | 3533 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3534 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3535 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 3536 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
Tobin Ehlis | 512098e | 2016-05-05 09:06:12 -0600 | [diff] [blame] | 3537 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 3538 | |
Tobin Ehlis | 49f903e | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 3539 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3540 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 3541 | } |
| 3542 | |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 3543 | TEST_F(VkLayerTest, InvalidPushConstants) { |
| 3544 | // Hit push constant error cases: |
| 3545 | // 1. Create PipelineLayout where push constant overstep maxPushConstantSize |
| 3546 | // 2. Incorrectly set push constant size to 0 |
| 3547 | // 3. Incorrectly set push constant size to non-multiple of 4 |
| 3548 | // 4. Attempt push constant update that exceeds maxPushConstantSize |
| 3549 | VkResult err; |
| 3550 | m_errorMonitor->SetDesiredFailureMsg( |
| 3551 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3552 | "vkCreatePipelineLayout() call has push constants with offset "); |
| 3553 | |
| 3554 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3555 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 3556 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3557 | |
| 3558 | VkPushConstantRange pc_range = {}; |
| 3559 | pc_range.size = 0xFFFFFFFFu; |
| 3560 | pc_range.stageFlags = VK_SHADER_STAGE_VERTEX_BIT; |
| 3561 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 3562 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3563 | pipeline_layout_ci.pushConstantRangeCount = 1; |
| 3564 | pipeline_layout_ci.pPushConstantRanges = &pc_range; |
| 3565 | |
| 3566 | VkPipelineLayout pipeline_layout; |
| 3567 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3568 | &pipeline_layout); |
| 3569 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3570 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 3571 | // Now cause errors due to size 0 and non-4 byte aligned size |
| 3572 | pc_range.size = 0; |
| 3573 | m_errorMonitor->SetDesiredFailureMsg( |
| 3574 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3575 | "vkCreatePipelineLayout() call has push constant index 0 with size 0"); |
| 3576 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3577 | &pipeline_layout); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3578 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 3579 | pc_range.size = 1; |
| 3580 | m_errorMonitor->SetDesiredFailureMsg( |
| 3581 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3582 | "vkCreatePipelineLayout() call has push constant index 0 with size 1"); |
| 3583 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3584 | &pipeline_layout); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3585 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 3586 | // Cause error due to bad size in vkCmdPushConstants() call |
| 3587 | m_errorMonitor->SetDesiredFailureMsg( |
| 3588 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3589 | "vkCmdPushConstants() call has push constants with offset "); |
| 3590 | pipeline_layout_ci.pushConstantRangeCount = 0; |
| 3591 | pipeline_layout_ci.pPushConstantRanges = NULL; |
| 3592 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3593 | &pipeline_layout); |
| 3594 | ASSERT_VK_SUCCESS(err); |
| 3595 | BeginCommandBuffer(); |
| 3596 | vkCmdPushConstants(m_commandBuffer->GetBufferHandle(), pipeline_layout, |
| 3597 | VK_SHADER_STAGE_VERTEX_BIT, 0, 0xFFFFFFFFu, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3598 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 3a23b6a | 2016-02-17 10:35:18 -0700 | [diff] [blame] | 3599 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3600 | } |
| 3601 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3602 | TEST_F(VkLayerTest, DescriptorSetCompatibility) { |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3603 | // Test various desriptorSet errors with bad binding combinations |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3604 | VkResult err; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3605 | |
| 3606 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3607 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 3608 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3609 | |
| 3610 | static const uint32_t NUM_DESCRIPTOR_TYPES = 5; |
| 3611 | VkDescriptorPoolSize ds_type_count[NUM_DESCRIPTOR_TYPES] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3612 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3613 | ds_type_count[0].descriptorCount = 10; |
| 3614 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 3615 | ds_type_count[1].descriptorCount = 2; |
| 3616 | ds_type_count[2].type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 3617 | ds_type_count[2].descriptorCount = 2; |
| 3618 | ds_type_count[3].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 3619 | ds_type_count[3].descriptorCount = 5; |
| 3620 | // TODO : LunarG ILO driver currently asserts in desc.c w/ INPUT_ATTACHMENT |
| 3621 | // type |
| 3622 | // ds_type_count[4].type = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; |
| 3623 | ds_type_count[4].type = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
| 3624 | ds_type_count[4].descriptorCount = 2; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3625 | |
| 3626 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3627 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3628 | ds_pool_ci.pNext = NULL; |
| 3629 | ds_pool_ci.maxSets = 5; |
| 3630 | ds_pool_ci.poolSizeCount = NUM_DESCRIPTOR_TYPES; |
| 3631 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3632 | |
| 3633 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3634 | err = |
| 3635 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3636 | ASSERT_VK_SUCCESS(err); |
| 3637 | |
| 3638 | static const uint32_t MAX_DS_TYPES_IN_LAYOUT = 2; |
| 3639 | VkDescriptorSetLayoutBinding dsl_binding[MAX_DS_TYPES_IN_LAYOUT] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3640 | dsl_binding[0].binding = 0; |
| 3641 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3642 | dsl_binding[0].descriptorCount = 5; |
| 3643 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 3644 | dsl_binding[0].pImmutableSamplers = NULL; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3645 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3646 | // Create layout identical to set0 layout but w/ different stageFlags |
| 3647 | VkDescriptorSetLayoutBinding dsl_fs_stage_only = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3648 | dsl_fs_stage_only.binding = 0; |
| 3649 | dsl_fs_stage_only.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3650 | dsl_fs_stage_only.descriptorCount = 5; |
| 3651 | dsl_fs_stage_only.stageFlags = |
| 3652 | VK_SHADER_STAGE_FRAGMENT_BIT; // Different stageFlags to cause error at |
| 3653 | // bind time |
| 3654 | dsl_fs_stage_only.pImmutableSamplers = NULL; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3655 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3656 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3657 | ds_layout_ci.pNext = NULL; |
| 3658 | ds_layout_ci.bindingCount = 1; |
| 3659 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3660 | static const uint32_t NUM_LAYOUTS = 4; |
| 3661 | VkDescriptorSetLayout ds_layout[NUM_LAYOUTS] = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3662 | VkDescriptorSetLayout ds_layout_fs_only = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3663 | // Create 4 unique layouts for full pipelineLayout, and 1 special fs-only |
| 3664 | // layout for error case |
| 3665 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3666 | &ds_layout[0]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3667 | ASSERT_VK_SUCCESS(err); |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 3668 | ds_layout_ci.pBindings = &dsl_fs_stage_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3669 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3670 | &ds_layout_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3671 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3672 | dsl_binding[0].binding = 0; |
| 3673 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3674 | dsl_binding[0].descriptorCount = 2; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 3675 | dsl_binding[1].binding = 1; |
| 3676 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 3677 | dsl_binding[1].descriptorCount = 2; |
| 3678 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 3679 | dsl_binding[1].pImmutableSamplers = NULL; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 3680 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3681 | ds_layout_ci.bindingCount = 2; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3682 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3683 | &ds_layout[1]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3684 | ASSERT_VK_SUCCESS(err); |
| 3685 | dsl_binding[0].binding = 0; |
| 3686 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3687 | dsl_binding[0].descriptorCount = 5; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3688 | ds_layout_ci.bindingCount = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3689 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3690 | &ds_layout[2]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3691 | ASSERT_VK_SUCCESS(err); |
| 3692 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3693 | dsl_binding[0].descriptorCount = 2; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3694 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 3695 | &ds_layout[3]); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3696 | ASSERT_VK_SUCCESS(err); |
| 3697 | |
| 3698 | static const uint32_t NUM_SETS = 4; |
| 3699 | VkDescriptorSet descriptorSet[NUM_SETS] = {}; |
| 3700 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3701 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3702 | alloc_info.descriptorSetCount = NUM_LAYOUTS; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3703 | alloc_info.descriptorPool = ds_pool; |
| 3704 | alloc_info.pSetLayouts = ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3705 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 3706 | descriptorSet); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3707 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3708 | VkDescriptorSet ds0_fs_only = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 3709 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3710 | alloc_info.pSetLayouts = &ds_layout_fs_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3711 | err = |
| 3712 | vkAllocateDescriptorSets(m_device->device(), &alloc_info, &ds0_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3713 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3714 | |
| 3715 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3716 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3717 | pipeline_layout_ci.pNext = NULL; |
| 3718 | pipeline_layout_ci.setLayoutCount = NUM_LAYOUTS; |
| 3719 | pipeline_layout_ci.pSetLayouts = ds_layout; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3720 | |
| 3721 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3722 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3723 | &pipeline_layout); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3724 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3725 | // Create pipelineLayout with only one setLayout |
| 3726 | pipeline_layout_ci.setLayoutCount = 1; |
| 3727 | VkPipelineLayout single_pipe_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3728 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3729 | &single_pipe_layout); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3730 | ASSERT_VK_SUCCESS(err); |
| 3731 | // Create pipelineLayout with 2 descriptor setLayout at index 0 |
| 3732 | pipeline_layout_ci.pSetLayouts = &ds_layout[3]; |
| 3733 | VkPipelineLayout pipe_layout_one_desc; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3734 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3735 | &pipe_layout_one_desc); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3736 | ASSERT_VK_SUCCESS(err); |
| 3737 | // Create pipelineLayout with 5 SAMPLER descriptor setLayout at index 0 |
| 3738 | pipeline_layout_ci.pSetLayouts = &ds_layout[2]; |
| 3739 | VkPipelineLayout pipe_layout_five_samp; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3740 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3741 | &pipe_layout_five_samp); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3742 | ASSERT_VK_SUCCESS(err); |
| 3743 | // Create pipelineLayout with UB type, but stageFlags for FS only |
| 3744 | pipeline_layout_ci.pSetLayouts = &ds_layout_fs_only; |
| 3745 | VkPipelineLayout pipe_layout_fs_only; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3746 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3747 | &pipe_layout_fs_only); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3748 | ASSERT_VK_SUCCESS(err); |
| 3749 | // Create pipelineLayout w/ incompatible set0 layout, but set1 is fine |
| 3750 | VkDescriptorSetLayout pl_bad_s0[2] = {}; |
| 3751 | pl_bad_s0[0] = ds_layout_fs_only; |
| 3752 | pl_bad_s0[1] = ds_layout[1]; |
| 3753 | pipeline_layout_ci.setLayoutCount = 2; |
| 3754 | pipeline_layout_ci.pSetLayouts = pl_bad_s0; |
| 3755 | VkPipelineLayout pipe_layout_bad_set0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3756 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 3757 | &pipe_layout_bad_set0); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3758 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3759 | |
| 3760 | // Create a buffer to update the descriptor with |
| 3761 | uint32_t qfi = 0; |
| 3762 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3763 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 3764 | buffCI.size = 1024; |
| 3765 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 3766 | buffCI.queueFamilyIndexCount = 1; |
| 3767 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3768 | |
| 3769 | VkBuffer dyub; |
| 3770 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 3771 | ASSERT_VK_SUCCESS(err); |
| 3772 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 3773 | static const uint32_t NUM_BUFFS = 5; |
| 3774 | VkDescriptorBufferInfo buffInfo[NUM_BUFFS] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3775 | for (uint32_t i = 0; i < NUM_BUFFS; ++i) { |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3776 | buffInfo[i].buffer = dyub; |
| 3777 | buffInfo[i].offset = 0; |
| 3778 | buffInfo[i].range = 1024; |
| 3779 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3780 | VkImage image; |
| 3781 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 3782 | const int32_t tex_width = 32; |
| 3783 | const int32_t tex_height = 32; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3784 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3785 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 3786 | image_create_info.pNext = NULL; |
| 3787 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 3788 | image_create_info.format = tex_format; |
| 3789 | image_create_info.extent.width = tex_width; |
| 3790 | image_create_info.extent.height = tex_height; |
| 3791 | image_create_info.extent.depth = 1; |
| 3792 | image_create_info.mipLevels = 1; |
| 3793 | image_create_info.arrayLayers = 1; |
| 3794 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 3795 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 3796 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 3797 | image_create_info.flags = 0; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3798 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 3799 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3800 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3801 | VkMemoryRequirements memReqs; |
| 3802 | VkDeviceMemory imageMem; |
| 3803 | bool pass; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 3804 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3805 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 3806 | memAlloc.pNext = NULL; |
| 3807 | memAlloc.allocationSize = 0; |
| 3808 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 3809 | vkGetImageMemoryRequirements(m_device->device(), image, &memReqs); |
| 3810 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3811 | pass = |
| 3812 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | 9c70cdb | 2016-01-06 14:14:17 -0700 | [diff] [blame] | 3813 | ASSERT_TRUE(pass); |
| 3814 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &imageMem); |
| 3815 | ASSERT_VK_SUCCESS(err); |
| 3816 | err = vkBindImageMemory(m_device->device(), image, imageMem, 0); |
| 3817 | ASSERT_VK_SUCCESS(err); |
| 3818 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3819 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3820 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 3821 | image_view_create_info.image = image; |
| 3822 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 3823 | image_view_create_info.format = tex_format; |
| 3824 | image_view_create_info.subresourceRange.layerCount = 1; |
| 3825 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 3826 | image_view_create_info.subresourceRange.levelCount = 1; |
| 3827 | image_view_create_info.subresourceRange.aspectMask = |
| 3828 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3829 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3830 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3831 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 3832 | &view); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3833 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 3834 | VkDescriptorImageInfo imageInfo[4] = {}; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3835 | imageInfo[0].imageView = view; |
| 3836 | imageInfo[0].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 3837 | imageInfo[1].imageView = view; |
| 3838 | imageInfo[1].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 3839 | imageInfo[2].imageView = view; |
| 3840 | imageInfo[2].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 3841 | imageInfo[3].imageView = view; |
| 3842 | imageInfo[3].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3843 | |
| 3844 | static const uint32_t NUM_SET_UPDATES = 3; |
| 3845 | VkWriteDescriptorSet descriptor_write[NUM_SET_UPDATES] = {}; |
| 3846 | descriptor_write[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 3847 | descriptor_write[0].dstSet = descriptorSet[0]; |
| 3848 | descriptor_write[0].dstBinding = 0; |
| 3849 | descriptor_write[0].descriptorCount = 5; |
| 3850 | descriptor_write[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3851 | descriptor_write[0].pBufferInfo = buffInfo; |
| 3852 | descriptor_write[1].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 3853 | descriptor_write[1].dstSet = descriptorSet[1]; |
| 3854 | descriptor_write[1].dstBinding = 0; |
| 3855 | descriptor_write[1].descriptorCount = 2; |
| 3856 | descriptor_write[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 3857 | descriptor_write[1].pImageInfo = imageInfo; |
| 3858 | descriptor_write[2].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 3859 | descriptor_write[2].dstSet = descriptorSet[1]; |
| 3860 | descriptor_write[2].dstBinding = 1; |
| 3861 | descriptor_write[2].descriptorCount = 2; |
| 3862 | descriptor_write[2].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 3863 | descriptor_write[2].pImageInfo = &imageInfo[2]; |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3864 | |
| 3865 | vkUpdateDescriptorSets(m_device->device(), 3, descriptor_write, 0, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3866 | |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3867 | // Create PSO to be used for draw-time errors below |
| 3868 | char const *vsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 3869 | "#version 450\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3870 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 3871 | "out gl_PerVertex {\n" |
| 3872 | " vec4 gl_Position;\n" |
| 3873 | "};\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3874 | "void main(){\n" |
| 3875 | " gl_Position = vec4(1);\n" |
| 3876 | "}\n"; |
| 3877 | char const *fsSource = |
Chris Forbes | 7b34280 | 2016-04-07 13:20:10 +1200 | [diff] [blame] | 3878 | "#version 450\n" |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3879 | "\n" |
| 3880 | "layout(location=0) out vec4 x;\n" |
| 3881 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 3882 | "void main(){\n" |
| 3883 | " x = vec4(bar.y);\n" |
| 3884 | "}\n"; |
| 3885 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 3886 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3887 | VkPipelineObj pipe(m_device); |
| 3888 | pipe.AddShader(&vs); |
| 3889 | pipe.AddShader(&fs); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3890 | pipe.AddColorAttachment(); |
| 3891 | pipe.CreateVKPipeline(pipe_layout_fs_only, renderPass()); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3892 | |
| 3893 | BeginCommandBuffer(); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3894 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3895 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 3896 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 3897 | // NOTE : I believe LunarG ilo driver has bug (LX#189) that requires binding |
| 3898 | // of PSO |
| 3899 | // here before binding DSs. Otherwise we assert in cmd_copy_dset_data() of |
| 3900 | // cmd_pipeline.c |
| 3901 | // due to the fact that cmd_alloc_dset_data() has not been called in |
| 3902 | // cmd_bind_graphics_pipeline() |
| 3903 | // TODO : Want to cause various binding incompatibility issues here to test |
| 3904 | // DrawState |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 3905 | // First cause various verify_layout_compatibility() fails |
| 3906 | // Second disturb early and late sets and verify INFO msgs |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3907 | // verify_set_layout_compatibility fail cases: |
| 3908 | // 1. invalid VkPipelineLayout (layout) passed into vkCmdBindDescriptorSets |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3909 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3910 | " due to: invalid VkPipelineLayout "); |
| 3911 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3912 | VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3913 | (VkPipelineLayout)((size_t)0xbaadb1be), 0, 1, |
| 3914 | &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3915 | m_errorMonitor->VerifyFound(); |
| 3916 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3917 | // 2. layoutIndex exceeds # of layouts in layout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3918 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3919 | " attempting to bind set to index 1"); |
| 3920 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3921 | VK_PIPELINE_BIND_POINT_GRAPHICS, single_pipe_layout, |
| 3922 | 0, 2, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3923 | m_errorMonitor->VerifyFound(); |
| 3924 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3925 | vkDestroyPipelineLayout(m_device->device(), single_pipe_layout, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3926 | // 3. Pipeline setLayout[0] has 2 descriptors, but set being bound has 5 |
| 3927 | // descriptors |
| 3928 | m_errorMonitor->SetDesiredFailureMsg( |
| 3929 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 3930 | " has 2 descriptors, but DescriptorSetLayout "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3931 | vkCmdBindDescriptorSets( |
| 3932 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3933 | pipe_layout_one_desc, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3934 | m_errorMonitor->VerifyFound(); |
| 3935 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3936 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_one_desc, NULL); |
| 3937 | // 4. same # of descriptors but mismatch in type |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3938 | m_errorMonitor->SetDesiredFailureMsg( |
| 3939 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 3940 | " is type 'VK_DESCRIPTOR_TYPE_SAMPLER' but binding "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3941 | vkCmdBindDescriptorSets( |
| 3942 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3943 | pipe_layout_five_samp, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3944 | m_errorMonitor->VerifyFound(); |
| 3945 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3946 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_five_samp, NULL); |
| 3947 | // 5. same # of descriptors but mismatch in stageFlags |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3948 | m_errorMonitor->SetDesiredFailureMsg( |
| 3949 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 2d9deec | 2016-04-21 14:19:26 -0600 | [diff] [blame] | 3950 | " has stageFlags 16 but binding 0 for DescriptorSetLayout "); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3951 | vkCmdBindDescriptorSets( |
| 3952 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3953 | pipe_layout_fs_only, 0, 1, &descriptorSet[0], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3954 | m_errorMonitor->VerifyFound(); |
| 3955 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3956 | // Cause INFO messages due to disturbing previously bound Sets |
| 3957 | // First bind sets 0 & 1 |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3958 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3959 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3960 | 2, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3961 | // 1. Disturb bound set0 by re-binding set1 w/ updated pipelineLayout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3962 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 3963 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3964 | " previously bound as set #0 was disturbed "); |
| 3965 | vkCmdBindDescriptorSets( |
| 3966 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3967 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3968 | m_errorMonitor->VerifyFound(); |
| 3969 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3970 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3971 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3972 | 2, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3973 | // 2. Disturb set after last bound set |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 3974 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3975 | " newly bound as set #0 so set #1 and " |
| 3976 | "any subsequent sets were disturbed "); |
| 3977 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3978 | VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3979 | pipe_layout_fs_only, 0, 1, &ds0_fs_only, 0, NULL); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3980 | m_errorMonitor->VerifyFound(); |
| 3981 | |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3982 | // Cause draw-time errors due to PSO incompatibilities |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3983 | // 1. Error due to not binding required set (we actually use same code as |
| 3984 | // above to disturb set0) |
| 3985 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 3986 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 3987 | 2, &descriptorSet[0], 0, NULL); |
| 3988 | vkCmdBindDescriptorSets( |
| 3989 | m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, |
| 3990 | pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
| 3991 | m_errorMonitor->SetDesiredFailureMsg( |
| 3992 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 3993 | " uses set #0 but that set is not bound."); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 3994 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 3995 | m_errorMonitor->VerifyFound(); |
| 3996 | |
Tobin Ehlis | 991d45a | 2016-01-06 08:48:41 -0700 | [diff] [blame] | 3997 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_bad_set0, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 3998 | // 2. Error due to bound set not being compatible with PSO's |
| 3999 | // VkPipelineLayout (diff stageFlags in this case) |
| 4000 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), |
| 4001 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, |
| 4002 | 2, &descriptorSet[0], 0, NULL); |
| 4003 | m_errorMonitor->SetDesiredFailureMsg( |
| 4004 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4005 | " bound as set #0 is not compatible with "); |
Tobin Ehlis | 8845283 | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 4006 | Draw(1, 0, 0, 0); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4007 | m_errorMonitor->VerifyFound(); |
| 4008 | |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4009 | // Remaining clean-up |
| 4010 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_fs_only, NULL); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4011 | for (uint32_t i = 0; i < NUM_LAYOUTS; ++i) { |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4012 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout[i], NULL); |
| 4013 | } |
| 4014 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout_fs_only, NULL); |
Tobin Ehlis | 9bfd449 | 2016-05-05 15:09:11 -0600 | [diff] [blame] | 4015 | vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &ds0_fs_only); |
| 4016 | vkFreeDescriptorSets(m_device->device(), ds_pool, NUM_SETS, descriptorSet); |
Tobin Ehlis | 8fab656 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 4017 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4018 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4019 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 4020 | } |
Tobin Ehlis | 559c638 | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 4021 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4022 | TEST_F(VkLayerTest, NoBeginCommandBuffer) { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4023 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4024 | m_errorMonitor->SetDesiredFailureMsg( |
| 4025 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4026 | "You must call vkBeginCommandBuffer() before this call to "); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4027 | |
| 4028 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4029 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4030 | // Call EndCommandBuffer() w/o calling BeginCommandBuffer() |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4031 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4032 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4033 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4034 | } |
| 4035 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4036 | TEST_F(VkLayerTest, SecondaryCommandBufferNullRenderpass) { |
| 4037 | VkResult err; |
| 4038 | VkCommandBuffer draw_cmd; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4039 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4040 | m_errorMonitor->SetDesiredFailureMsg( |
| 4041 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 61b36f3 | 2015-12-16 08:19:42 -0700 | [diff] [blame] | 4042 | " must specify a valid renderpass parameter."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4043 | |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 4044 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 4045 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4046 | VkCommandBufferAllocateInfo cmd = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4047 | cmd.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 4048 | cmd.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4049 | cmd.commandPool = m_commandPool; |
| 4050 | cmd.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4051 | cmd.commandBufferCount = 1; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 4052 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4053 | err = vkAllocateCommandBuffers(m_device->device(), &cmd, &draw_cmd); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 4054 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 4055 | |
| 4056 | // Force the failure by not setting the Renderpass and Framebuffer fields |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4057 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4058 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4059 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 4060 | cmd_buf_info.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4061 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT | |
| 4062 | VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4063 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 4064 | |
| 4065 | // The error should be caught by validation of the BeginCommandBuffer call |
| 4066 | vkBeginCommandBuffer(draw_cmd, &cmd_buf_info); |
| 4067 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4068 | m_errorMonitor->VerifyFound(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4069 | vkFreeCommandBuffers(m_device->device(), m_commandPool, 1, &draw_cmd); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 4070 | } |
| 4071 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4072 | TEST_F(VkLayerTest, CommandBufferResetErrors) { |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 4073 | // Cause error due to Begin while recording CB |
| 4074 | // Then cause 2 errors for attempting to reset CB w/o having |
| 4075 | // VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT set for the pool from |
| 4076 | // which CBs were allocated. Note that this bit is off by default. |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4077 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4078 | "Cannot call Begin on CB"); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 4079 | |
| 4080 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4081 | |
| 4082 | // Calls AllocateCommandBuffers |
| 4083 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
| 4084 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4085 | // Force the failure by setting the Renderpass and Framebuffer fields with |
| 4086 | // (fake) data |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 4087 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4088 | VkCommandBufferInheritanceInfo cmd_buf_hinfo = {}; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 4089 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 4090 | cmd_buf_info.pNext = NULL; |
| 4091 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4092 | cmd_buf_info.pInheritanceInfo = &cmd_buf_hinfo; |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 4093 | |
| 4094 | // Begin CB to transition to recording state |
| 4095 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
| 4096 | // Can't re-begin. This should trigger error |
| 4097 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4098 | m_errorMonitor->VerifyFound(); |
| 4099 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4100 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4101 | "Attempt to reset command buffer "); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 4102 | VkCommandBufferResetFlags flags = 0; // Don't care about flags for this test |
| 4103 | // Reset attempt will trigger error due to incorrect CommandPool state |
| 4104 | vkResetCommandBuffer(commandBuffer.GetBufferHandle(), flags); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4105 | m_errorMonitor->VerifyFound(); |
| 4106 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4107 | m_errorMonitor->SetDesiredFailureMsg( |
| 4108 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4109 | " attempts to implicitly reset cmdBuffer created from "); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 4110 | // Transition CB to RECORDED state |
| 4111 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
| 4112 | // Now attempting to Begin will implicitly reset, which triggers error |
| 4113 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4114 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | ac0ef84 | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 4115 | } |
| 4116 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4117 | TEST_F(VkLayerTest, InvalidPipelineCreateState) { |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4118 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4119 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4120 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4121 | m_errorMonitor->SetDesiredFailureMsg( |
| 4122 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4123 | "Invalid Pipeline CreateInfo State: Vtx Shader required"); |
| 4124 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4125 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4126 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4127 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4128 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4129 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4130 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4131 | |
| 4132 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4133 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4134 | ds_pool_ci.pNext = NULL; |
| 4135 | ds_pool_ci.maxSets = 1; |
| 4136 | ds_pool_ci.poolSizeCount = 1; |
| 4137 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4138 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4139 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4140 | err = |
| 4141 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4142 | ASSERT_VK_SUCCESS(err); |
| 4143 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4144 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4145 | dsl_binding.binding = 0; |
| 4146 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4147 | dsl_binding.descriptorCount = 1; |
| 4148 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4149 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4150 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4151 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4152 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4153 | ds_layout_ci.pNext = NULL; |
| 4154 | ds_layout_ci.bindingCount = 1; |
| 4155 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4156 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4157 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4158 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4159 | &ds_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4160 | ASSERT_VK_SUCCESS(err); |
| 4161 | |
| 4162 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4163 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4164 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4165 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4166 | alloc_info.descriptorPool = ds_pool; |
| 4167 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4168 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4169 | &descriptorSet); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4170 | ASSERT_VK_SUCCESS(err); |
| 4171 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4172 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4173 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4174 | pipeline_layout_ci.setLayoutCount = 1; |
| 4175 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4176 | |
| 4177 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4178 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4179 | &pipeline_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4180 | ASSERT_VK_SUCCESS(err); |
| 4181 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4182 | VkViewport vp = {}; // Just need dummy vp to point to |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4183 | VkRect2D sc = {}; // dummy scissor to point to |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4184 | |
| 4185 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4186 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 4187 | vp_state_ci.scissorCount = 1; |
| 4188 | vp_state_ci.pScissors = ≻ |
| 4189 | vp_state_ci.viewportCount = 1; |
| 4190 | vp_state_ci.pViewports = &vp; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4191 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 4192 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 4193 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 4194 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 4195 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 4196 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 4197 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 4198 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 4199 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 4200 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4201 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4202 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 4203 | gp_ci.pViewportState = &vp_state_ci; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 4204 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4205 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 4206 | gp_ci.layout = pipeline_layout; |
| 4207 | gp_ci.renderPass = renderPass(); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4208 | |
| 4209 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4210 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 4211 | pc_ci.initialDataSize = 0; |
| 4212 | pc_ci.pInitialData = 0; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4213 | |
| 4214 | VkPipeline pipeline; |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 4215 | VkPipelineCache pipelineCache; |
| 4216 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4217 | err = |
| 4218 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 4219 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4220 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4221 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 4222 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4223 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 4224 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4225 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 4226 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4227 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4228 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4229 | } |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4230 | /*// TODO : This test should be good, but needs Tess support in compiler to run |
| 4231 | TEST_F(VkLayerTest, InvalidPatchControlPoints) |
| 4232 | { |
| 4233 | // Attempt to Create Gfx Pipeline w/o a VS |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4234 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 4235 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 4236 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4237 | "Invalid Pipeline CreateInfo State: VK_PRIMITIVE_TOPOLOGY_PATCH |
| 4238 | primitive "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4239 | |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4240 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4241 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4242 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4243 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4244 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4245 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4246 | |
| 4247 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 4248 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4249 | ds_pool_ci.pNext = NULL; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4250 | ds_pool_ci.poolSizeCount = 1; |
| 4251 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4252 | |
| 4253 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4254 | err = vkCreateDescriptorPool(m_device->device(), |
| 4255 | 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] | 4256 | ASSERT_VK_SUCCESS(err); |
| 4257 | |
| 4258 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4259 | dsl_binding.binding = 0; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4260 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 4261 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4262 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4263 | dsl_binding.pImmutableSamplers = NULL; |
| 4264 | |
| 4265 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4266 | ds_layout_ci.sType = |
| 4267 | VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4268 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4269 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 4270 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4271 | |
| 4272 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4273 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4274 | &ds_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4275 | ASSERT_VK_SUCCESS(err); |
| 4276 | |
| 4277 | VkDescriptorSet descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4278 | err = vkAllocateDescriptorSets(m_device->device(), ds_pool, |
| 4279 | VK_DESCRIPTOR_SET_USAGE_NON_FREE, 1, &ds_layout, &descriptorSet); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4280 | ASSERT_VK_SUCCESS(err); |
| 4281 | |
| 4282 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4283 | pipeline_layout_ci.sType = |
| 4284 | VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4285 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4286 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4287 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 4288 | |
| 4289 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4290 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4291 | &pipeline_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4292 | ASSERT_VK_SUCCESS(err); |
| 4293 | |
| 4294 | VkPipelineShaderStageCreateInfo shaderStages[3]; |
| 4295 | memset(&shaderStages, 0, 3 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 4296 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4297 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, |
| 4298 | this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4299 | // 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] | 4300 | VkShaderObj |
| 4301 | tc(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, |
| 4302 | this); |
| 4303 | VkShaderObj |
| 4304 | te(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, |
| 4305 | this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4306 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4307 | shaderStages[0].sType = |
| 4308 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4309 | shaderStages[0].stage = VK_SHADER_STAGE_VERTEX_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4310 | shaderStages[0].shader = vs.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4311 | shaderStages[1].sType = |
| 4312 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4313 | shaderStages[1].stage = VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4314 | shaderStages[1].shader = tc.handle(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4315 | shaderStages[2].sType = |
| 4316 | VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4317 | shaderStages[2].stage = VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4318 | shaderStages[2].shader = te.handle(); |
| 4319 | |
| 4320 | VkPipelineInputAssemblyStateCreateInfo iaCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4321 | iaCI.sType = |
| 4322 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
Chia-I Wu | 515eb8f | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4323 | iaCI.topology = VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4324 | |
| 4325 | VkPipelineTessellationStateCreateInfo tsCI = {}; |
| 4326 | tsCI.sType = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO; |
| 4327 | tsCI.patchControlPoints = 0; // This will cause an error |
| 4328 | |
| 4329 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 4330 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 4331 | gp_ci.pNext = NULL; |
| 4332 | gp_ci.stageCount = 3; |
| 4333 | gp_ci.pStages = shaderStages; |
| 4334 | gp_ci.pVertexInputState = NULL; |
| 4335 | gp_ci.pInputAssemblyState = &iaCI; |
| 4336 | gp_ci.pTessellationState = &tsCI; |
| 4337 | gp_ci.pViewportState = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4338 | gp_ci.pRasterizationState = NULL; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4339 | gp_ci.pMultisampleState = NULL; |
| 4340 | gp_ci.pDepthStencilState = NULL; |
| 4341 | gp_ci.pColorBlendState = NULL; |
| 4342 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 4343 | gp_ci.layout = pipeline_layout; |
| 4344 | gp_ci.renderPass = renderPass(); |
| 4345 | |
| 4346 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 4347 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 4348 | pc_ci.pNext = NULL; |
| 4349 | pc_ci.initialSize = 0; |
| 4350 | pc_ci.initialData = 0; |
| 4351 | pc_ci.maxSize = 0; |
| 4352 | |
| 4353 | VkPipeline pipeline; |
| 4354 | VkPipelineCache pipelineCache; |
| 4355 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4356 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, |
| 4357 | &pipelineCache); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4358 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4359 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4360 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4361 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4362 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 4363 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4364 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 4365 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4366 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4367 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 4368 | } |
| 4369 | */ |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4370 | // Set scissor and viewport counts to different numbers |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4371 | TEST_F(VkLayerTest, PSOViewportScissorCountMismatch) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4372 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4373 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4374 | m_errorMonitor->SetDesiredFailureMsg( |
| 4375 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4376 | "Gfx Pipeline viewport count (1) must match scissor count (0)."); |
| 4377 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4378 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4379 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4380 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4381 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4382 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4383 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4384 | |
| 4385 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4386 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4387 | ds_pool_ci.maxSets = 1; |
| 4388 | ds_pool_ci.poolSizeCount = 1; |
| 4389 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4390 | |
| 4391 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4392 | err = |
| 4393 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4394 | ASSERT_VK_SUCCESS(err); |
| 4395 | |
| 4396 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4397 | dsl_binding.binding = 0; |
| 4398 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4399 | dsl_binding.descriptorCount = 1; |
| 4400 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4401 | |
| 4402 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4403 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4404 | ds_layout_ci.bindingCount = 1; |
| 4405 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4406 | |
| 4407 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4408 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4409 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4410 | ASSERT_VK_SUCCESS(err); |
| 4411 | |
| 4412 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4413 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4414 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4415 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4416 | alloc_info.descriptorPool = ds_pool; |
| 4417 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4418 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4419 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4420 | ASSERT_VK_SUCCESS(err); |
| 4421 | |
| 4422 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4423 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4424 | pipeline_layout_ci.setLayoutCount = 1; |
| 4425 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4426 | |
| 4427 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4428 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4429 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4430 | ASSERT_VK_SUCCESS(err); |
| 4431 | |
| 4432 | VkViewport vp = {}; // Just need dummy vp to point to |
| 4433 | |
| 4434 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4435 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 4436 | vp_state_ci.scissorCount = 0; |
| 4437 | vp_state_ci.viewportCount = 1; // Count mismatch should cause error |
| 4438 | vp_state_ci.pViewports = &vp; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4439 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 4440 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 4441 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 4442 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 4443 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 4444 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 4445 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 4446 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 4447 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 4448 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 4449 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4450 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4451 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4452 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4453 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4454 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4455 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4456 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4457 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4458 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 4459 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4460 | |
| 4461 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4462 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 4463 | gp_ci.stageCount = 2; |
| 4464 | gp_ci.pStages = shaderStages; |
| 4465 | gp_ci.pViewportState = &vp_state_ci; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 4466 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4467 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 4468 | gp_ci.layout = pipeline_layout; |
| 4469 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4470 | |
| 4471 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4472 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4473 | |
| 4474 | VkPipeline pipeline; |
| 4475 | VkPipelineCache pipelineCache; |
| 4476 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4477 | err = |
| 4478 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4479 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4480 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4481 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4482 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4483 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4484 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4485 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 4486 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4487 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4488 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4489 | } |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4490 | // Don't set viewport state in PSO. This is an error b/c we always need this |
| 4491 | // state |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4492 | // 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] | 4493 | TEST_F(VkLayerTest, PSOViewportStateNotSet) { |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4494 | // Attempt to Create Gfx Pipeline w/o a VS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4495 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4496 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4497 | m_errorMonitor->SetDesiredFailureMsg( |
| 4498 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4499 | "Gfx Pipeline pViewportState is null. Even if "); |
| 4500 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4501 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4502 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4503 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4504 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4505 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4506 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4507 | |
| 4508 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4509 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4510 | ds_pool_ci.maxSets = 1; |
| 4511 | ds_pool_ci.poolSizeCount = 1; |
| 4512 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4513 | |
| 4514 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4515 | err = |
| 4516 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4517 | ASSERT_VK_SUCCESS(err); |
| 4518 | |
| 4519 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4520 | dsl_binding.binding = 0; |
| 4521 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4522 | dsl_binding.descriptorCount = 1; |
| 4523 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4524 | |
| 4525 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4526 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4527 | ds_layout_ci.bindingCount = 1; |
| 4528 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4529 | |
| 4530 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4531 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4532 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4533 | ASSERT_VK_SUCCESS(err); |
| 4534 | |
| 4535 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4536 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4537 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4538 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4539 | alloc_info.descriptorPool = ds_pool; |
| 4540 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4541 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4542 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4543 | ASSERT_VK_SUCCESS(err); |
| 4544 | |
| 4545 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4546 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4547 | pipeline_layout_ci.setLayoutCount = 1; |
| 4548 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4549 | |
| 4550 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4551 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4552 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4553 | ASSERT_VK_SUCCESS(err); |
| 4554 | |
| 4555 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 4556 | // Set scissor as dynamic to avoid second error |
| 4557 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4558 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 4559 | dyn_state_ci.dynamicStateCount = 1; |
| 4560 | dyn_state_ci.pDynamicStates = &sc_state; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4561 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 4562 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4563 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4564 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4565 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4566 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4567 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4568 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4569 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4570 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4571 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 4572 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4573 | |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 4574 | |
| 4575 | VkPipelineRasterizationStateCreateInfo rs_state_ci = {}; |
| 4576 | rs_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 4577 | rs_state_ci.polygonMode = VK_POLYGON_MODE_FILL; |
| 4578 | rs_state_ci.cullMode = VK_CULL_MODE_BACK_BIT; |
| 4579 | rs_state_ci.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE; |
| 4580 | rs_state_ci.depthClampEnable = VK_FALSE; |
| 4581 | rs_state_ci.rasterizerDiscardEnable = VK_FALSE; |
| 4582 | rs_state_ci.depthBiasEnable = VK_FALSE; |
| 4583 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4584 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4585 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 4586 | gp_ci.stageCount = 2; |
| 4587 | gp_ci.pStages = shaderStages; |
Karl Schultz | dfdb8d4 | 2016-03-08 10:30:21 -0700 | [diff] [blame] | 4588 | gp_ci.pRasterizationState = &rs_state_ci; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4589 | gp_ci.pViewportState = NULL; // Not setting VP state w/o dynamic vp state |
| 4590 | // should cause validation error |
| 4591 | gp_ci.pDynamicState = &dyn_state_ci; |
| 4592 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 4593 | gp_ci.layout = pipeline_layout; |
| 4594 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4595 | |
| 4596 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4597 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4598 | |
| 4599 | VkPipeline pipeline; |
| 4600 | VkPipelineCache pipelineCache; |
| 4601 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4602 | err = |
| 4603 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4604 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4605 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4606 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4607 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4608 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4609 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4610 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 4611 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4612 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4613 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4614 | } |
| 4615 | // Create PSO w/o non-zero viewportCount but no viewport data |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4616 | // Then run second test where dynamic scissor count doesn't match PSO scissor |
| 4617 | // count |
| 4618 | TEST_F(VkLayerTest, PSOViewportCountWithoutDataAndDynScissorMismatch) { |
| 4619 | VkResult err; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4620 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4621 | m_errorMonitor->SetDesiredFailureMsg( |
| 4622 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4623 | "Gfx Pipeline viewportCount is 1, but pViewports is NULL. "); |
| 4624 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4625 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4626 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4627 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4628 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4629 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4630 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4631 | |
| 4632 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4633 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4634 | ds_pool_ci.maxSets = 1; |
| 4635 | ds_pool_ci.poolSizeCount = 1; |
| 4636 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4637 | |
| 4638 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4639 | err = |
| 4640 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4641 | ASSERT_VK_SUCCESS(err); |
| 4642 | |
| 4643 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4644 | dsl_binding.binding = 0; |
| 4645 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4646 | dsl_binding.descriptorCount = 1; |
| 4647 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4648 | |
| 4649 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4650 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4651 | ds_layout_ci.bindingCount = 1; |
| 4652 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4653 | |
| 4654 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4655 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4656 | &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4657 | ASSERT_VK_SUCCESS(err); |
| 4658 | |
| 4659 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4660 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4661 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 4662 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4663 | alloc_info.descriptorPool = ds_pool; |
| 4664 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4665 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4666 | &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4667 | ASSERT_VK_SUCCESS(err); |
| 4668 | |
| 4669 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4670 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4671 | pipeline_layout_ci.setLayoutCount = 1; |
| 4672 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4673 | |
| 4674 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4675 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4676 | &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4677 | ASSERT_VK_SUCCESS(err); |
| 4678 | |
| 4679 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4680 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 4681 | vp_state_ci.viewportCount = 1; |
| 4682 | vp_state_ci.pViewports = NULL; // Null vp w/ count of 1 should cause error |
| 4683 | vp_state_ci.scissorCount = 1; |
| 4684 | vp_state_ci.pScissors = |
| 4685 | NULL; // Scissor is dynamic (below) so this won't cause error |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4686 | |
| 4687 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 4688 | // Set scissor as dynamic to avoid that error |
| 4689 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4690 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 4691 | dyn_state_ci.dynamicStateCount = 1; |
| 4692 | dyn_state_ci.pDynamicStates = &sc_state; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4693 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 4694 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4695 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4696 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4697 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4698 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4699 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4700 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4701 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4702 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4703 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 4704 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4705 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 4706 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 4707 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 4708 | vi_ci.pNext = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4709 | vi_ci.vertexBindingDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 4710 | vi_ci.pVertexBindingDescriptions = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4711 | vi_ci.vertexAttributeDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 4712 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 4713 | |
| 4714 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 4715 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 4716 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 4717 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4718 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4719 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 4720 | rs_ci.pNext = nullptr; |
| 4721 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 4722 | VkPipelineColorBlendAttachmentState att = {}; |
| 4723 | att.blendEnable = VK_FALSE; |
| 4724 | att.colorWriteMask = 0xf; |
| 4725 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 4726 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 4727 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 4728 | cb_ci.pNext = nullptr; |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 4729 | cb_ci.attachmentCount = 1; |
| 4730 | cb_ci.pAttachments = &att; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 4731 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4732 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4733 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 4734 | gp_ci.stageCount = 2; |
| 4735 | gp_ci.pStages = shaderStages; |
| 4736 | gp_ci.pVertexInputState = &vi_ci; |
| 4737 | gp_ci.pInputAssemblyState = &ia_ci; |
| 4738 | gp_ci.pViewportState = &vp_state_ci; |
| 4739 | gp_ci.pRasterizationState = &rs_ci; |
| 4740 | gp_ci.pColorBlendState = &cb_ci; |
| 4741 | gp_ci.pDynamicState = &dyn_state_ci; |
| 4742 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 4743 | gp_ci.layout = pipeline_layout; |
| 4744 | gp_ci.renderPass = renderPass(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4745 | |
| 4746 | VkPipelineCacheCreateInfo pc_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4747 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4748 | |
| 4749 | VkPipeline pipeline; |
| 4750 | VkPipelineCache pipelineCache; |
| 4751 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4752 | err = |
| 4753 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4754 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4755 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4756 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4757 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4758 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4759 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4760 | // 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] | 4761 | // First need to successfully create the PSO from above by setting |
| 4762 | // pViewports |
| 4763 | m_errorMonitor->SetDesiredFailureMsg( |
| 4764 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4765 | "Dynamic scissorCount from vkCmdSetScissor() is 2, but PSO " |
| 4766 | "scissorCount is 1. These counts must match."); |
| 4767 | |
| 4768 | VkViewport vp = {}; // Just need dummy vp to point to |
| 4769 | vp_state_ci.pViewports = &vp; |
| 4770 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4771 | &gp_ci, NULL, &pipeline); |
| 4772 | ASSERT_VK_SUCCESS(err); |
| 4773 | BeginCommandBuffer(); |
| 4774 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4775 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
| 4776 | VkRect2D scissors[2] = {}; // don't care about data |
| 4777 | // Count of 2 doesn't match PSO count of 1 |
| 4778 | vkCmdSetScissor(m_commandBuffer->GetBufferHandle(), 0, 2, scissors); |
| 4779 | Draw(1, 0, 0, 0); |
| 4780 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4781 | m_errorMonitor->VerifyFound(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4782 | |
| 4783 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 4784 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4785 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4786 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 4787 | } |
| 4788 | // Create PSO w/o non-zero scissorCount but no scissor data |
| 4789 | // Then run second test where dynamic viewportCount doesn't match PSO |
| 4790 | // viewportCount |
| 4791 | TEST_F(VkLayerTest, PSOScissorCountWithoutDataAndDynViewportMismatch) { |
| 4792 | VkResult err; |
| 4793 | |
| 4794 | m_errorMonitor->SetDesiredFailureMsg( |
| 4795 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4796 | "Gfx Pipeline scissorCount is 1, but pScissors is NULL. "); |
| 4797 | |
| 4798 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4799 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4800 | |
| 4801 | VkDescriptorPoolSize ds_type_count = {}; |
| 4802 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4803 | ds_type_count.descriptorCount = 1; |
| 4804 | |
| 4805 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 4806 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4807 | ds_pool_ci.maxSets = 1; |
| 4808 | ds_pool_ci.poolSizeCount = 1; |
| 4809 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 4810 | |
| 4811 | VkDescriptorPool ds_pool; |
| 4812 | err = |
| 4813 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 4814 | ASSERT_VK_SUCCESS(err); |
| 4815 | |
| 4816 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 4817 | dsl_binding.binding = 0; |
| 4818 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4819 | dsl_binding.descriptorCount = 1; |
| 4820 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4821 | |
| 4822 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 4823 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4824 | ds_layout_ci.bindingCount = 1; |
| 4825 | ds_layout_ci.pBindings = &dsl_binding; |
| 4826 | |
| 4827 | VkDescriptorSetLayout ds_layout; |
| 4828 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 4829 | &ds_layout); |
| 4830 | ASSERT_VK_SUCCESS(err); |
| 4831 | |
| 4832 | VkDescriptorSet descriptorSet; |
| 4833 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 4834 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 4835 | alloc_info.descriptorSetCount = 1; |
| 4836 | alloc_info.descriptorPool = ds_pool; |
| 4837 | alloc_info.pSetLayouts = &ds_layout; |
| 4838 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 4839 | &descriptorSet); |
| 4840 | ASSERT_VK_SUCCESS(err); |
| 4841 | |
| 4842 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 4843 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4844 | pipeline_layout_ci.setLayoutCount = 1; |
| 4845 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 4846 | |
| 4847 | VkPipelineLayout pipeline_layout; |
| 4848 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 4849 | &pipeline_layout); |
| 4850 | ASSERT_VK_SUCCESS(err); |
| 4851 | |
| 4852 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 4853 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 4854 | vp_state_ci.scissorCount = 1; |
| 4855 | vp_state_ci.pScissors = |
| 4856 | NULL; // Null scissor w/ count of 1 should cause error |
| 4857 | vp_state_ci.viewportCount = 1; |
| 4858 | vp_state_ci.pViewports = |
| 4859 | NULL; // vp is dynamic (below) so this won't cause error |
| 4860 | |
| 4861 | VkDynamicState vp_state = VK_DYNAMIC_STATE_VIEWPORT; |
| 4862 | // Set scissor as dynamic to avoid that error |
| 4863 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 4864 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 4865 | dyn_state_ci.dynamicStateCount = 1; |
| 4866 | dyn_state_ci.pDynamicStates = &vp_state; |
| 4867 | |
| 4868 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 4869 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 4870 | |
| 4871 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 4872 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4873 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 4874 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 4875 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4876 | // but add it to be able to run on more devices |
| 4877 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 4878 | shaderStages[1] = fs.GetStageCreateInfo(); |
| 4879 | |
| 4880 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 4881 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 4882 | vi_ci.pNext = nullptr; |
| 4883 | vi_ci.vertexBindingDescriptionCount = 0; |
| 4884 | vi_ci.pVertexBindingDescriptions = nullptr; |
| 4885 | vi_ci.vertexAttributeDescriptionCount = 0; |
| 4886 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 4887 | |
| 4888 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 4889 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 4890 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 4891 | |
| 4892 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
| 4893 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 4894 | rs_ci.pNext = nullptr; |
| 4895 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 4896 | VkPipelineColorBlendAttachmentState att = {}; |
| 4897 | att.blendEnable = VK_FALSE; |
| 4898 | att.colorWriteMask = 0xf; |
| 4899 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4900 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 4901 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 4902 | cb_ci.pNext = nullptr; |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 4903 | cb_ci.attachmentCount = 1; |
| 4904 | cb_ci.pAttachments = &att; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4905 | |
| 4906 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 4907 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 4908 | gp_ci.stageCount = 2; |
| 4909 | gp_ci.pStages = shaderStages; |
| 4910 | gp_ci.pVertexInputState = &vi_ci; |
| 4911 | gp_ci.pInputAssemblyState = &ia_ci; |
| 4912 | gp_ci.pViewportState = &vp_state_ci; |
| 4913 | gp_ci.pRasterizationState = &rs_ci; |
| 4914 | gp_ci.pColorBlendState = &cb_ci; |
| 4915 | gp_ci.pDynamicState = &dyn_state_ci; |
| 4916 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 4917 | gp_ci.layout = pipeline_layout; |
| 4918 | gp_ci.renderPass = renderPass(); |
| 4919 | |
| 4920 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 4921 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 4922 | |
| 4923 | VkPipeline pipeline; |
| 4924 | VkPipelineCache pipelineCache; |
| 4925 | |
| 4926 | err = |
| 4927 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 4928 | ASSERT_VK_SUCCESS(err); |
| 4929 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4930 | &gp_ci, NULL, &pipeline); |
| 4931 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4932 | m_errorMonitor->VerifyFound(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4933 | |
| 4934 | // Now hit second fail case where we set scissor w/ different count than PSO |
| 4935 | // First need to successfully create the PSO from above by setting |
| 4936 | // pViewports |
| 4937 | m_errorMonitor->SetDesiredFailureMsg( |
| 4938 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 4939 | "Dynamic viewportCount from vkCmdSetViewport() is 2, but PSO " |
| 4940 | "viewportCount is 1. These counts must match."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4941 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4942 | VkRect2D sc = {}; // Just need dummy vp to point to |
| 4943 | vp_state_ci.pScissors = ≻ |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4944 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 4945 | &gp_ci, NULL, &pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4946 | ASSERT_VK_SUCCESS(err); |
| 4947 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 4948 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 4949 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4950 | VkViewport viewports[2] = {}; // don't care about data |
| 4951 | // Count of 2 doesn't match PSO count of 1 |
Jon Ashburn | 19d3bf1 | 2015-12-30 14:06:55 -0700 | [diff] [blame] | 4952 | vkCmdSetViewport(m_commandBuffer->GetBufferHandle(), 0, 2, viewports); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4953 | Draw(1, 0, 0, 0); |
| 4954 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 4955 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4956 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4957 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 4958 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4959 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4960 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 4961 | } |
| 4962 | |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 4963 | TEST_F(VkLayerTest, PSOLineWidthInvalid) { |
| 4964 | VkResult err; |
| 4965 | |
| 4966 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 4967 | "Attempt to set lineWidth to -1"); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 4968 | |
| 4969 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4970 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4971 | |
| 4972 | VkDescriptorPoolSize ds_type_count = {}; |
| 4973 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4974 | ds_type_count.descriptorCount = 1; |
| 4975 | |
| 4976 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 4977 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4978 | ds_pool_ci.maxSets = 1; |
| 4979 | ds_pool_ci.poolSizeCount = 1; |
| 4980 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 4981 | |
| 4982 | VkDescriptorPool ds_pool; |
| 4983 | err = |
| 4984 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 4985 | ASSERT_VK_SUCCESS(err); |
| 4986 | |
| 4987 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 4988 | dsl_binding.binding = 0; |
| 4989 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 4990 | dsl_binding.descriptorCount = 1; |
| 4991 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4992 | |
| 4993 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 4994 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4995 | ds_layout_ci.bindingCount = 1; |
| 4996 | ds_layout_ci.pBindings = &dsl_binding; |
| 4997 | |
| 4998 | VkDescriptorSetLayout ds_layout; |
| 4999 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5000 | &ds_layout); |
| 5001 | ASSERT_VK_SUCCESS(err); |
| 5002 | |
| 5003 | VkDescriptorSet descriptorSet; |
| 5004 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 5005 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 5006 | alloc_info.descriptorSetCount = 1; |
| 5007 | alloc_info.descriptorPool = ds_pool; |
| 5008 | alloc_info.pSetLayouts = &ds_layout; |
| 5009 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5010 | &descriptorSet); |
| 5011 | ASSERT_VK_SUCCESS(err); |
| 5012 | |
| 5013 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 5014 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 5015 | pipeline_layout_ci.setLayoutCount = 1; |
| 5016 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 5017 | |
| 5018 | VkPipelineLayout pipeline_layout; |
| 5019 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 5020 | &pipeline_layout); |
| 5021 | ASSERT_VK_SUCCESS(err); |
| 5022 | |
| 5023 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 5024 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 5025 | vp_state_ci.scissorCount = 1; |
| 5026 | vp_state_ci.pScissors = NULL; |
| 5027 | vp_state_ci.viewportCount = 1; |
| 5028 | vp_state_ci.pViewports = NULL; |
| 5029 | |
| 5030 | VkDynamicState dynamic_states[3] = {VK_DYNAMIC_STATE_VIEWPORT, |
| 5031 | VK_DYNAMIC_STATE_SCISSOR, |
| 5032 | VK_DYNAMIC_STATE_LINE_WIDTH}; |
| 5033 | // Set scissor as dynamic to avoid that error |
| 5034 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 5035 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 5036 | dyn_state_ci.dynamicStateCount = 2; |
| 5037 | dyn_state_ci.pDynamicStates = dynamic_states; |
| 5038 | |
| 5039 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 5040 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 5041 | |
| 5042 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 5043 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5044 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 5045 | VK_SHADER_STAGE_FRAGMENT_BIT, |
| 5046 | this); // TODO - We shouldn't need a fragment shader |
| 5047 | // but add it to be able to run on more devices |
| 5048 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 5049 | shaderStages[1] = fs.GetStageCreateInfo(); |
| 5050 | |
| 5051 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 5052 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 5053 | vi_ci.pNext = nullptr; |
| 5054 | vi_ci.vertexBindingDescriptionCount = 0; |
| 5055 | vi_ci.pVertexBindingDescriptions = nullptr; |
| 5056 | vi_ci.vertexAttributeDescriptionCount = 0; |
| 5057 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 5058 | |
| 5059 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 5060 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 5061 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 5062 | |
| 5063 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
| 5064 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
| 5065 | rs_ci.pNext = nullptr; |
| 5066 | |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 5067 | // Check too low (line width of -1.0f). |
| 5068 | rs_ci.lineWidth = -1.0f; |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 5069 | |
| 5070 | VkPipelineColorBlendAttachmentState att = {}; |
| 5071 | att.blendEnable = VK_FALSE; |
| 5072 | att.colorWriteMask = 0xf; |
| 5073 | |
| 5074 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 5075 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 5076 | cb_ci.pNext = nullptr; |
| 5077 | cb_ci.attachmentCount = 1; |
| 5078 | cb_ci.pAttachments = &att; |
| 5079 | |
| 5080 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 5081 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 5082 | gp_ci.stageCount = 2; |
| 5083 | gp_ci.pStages = shaderStages; |
| 5084 | gp_ci.pVertexInputState = &vi_ci; |
| 5085 | gp_ci.pInputAssemblyState = &ia_ci; |
| 5086 | gp_ci.pViewportState = &vp_state_ci; |
| 5087 | gp_ci.pRasterizationState = &rs_ci; |
| 5088 | gp_ci.pColorBlendState = &cb_ci; |
| 5089 | gp_ci.pDynamicState = &dyn_state_ci; |
| 5090 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 5091 | gp_ci.layout = pipeline_layout; |
| 5092 | gp_ci.renderPass = renderPass(); |
| 5093 | |
| 5094 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 5095 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 5096 | |
| 5097 | VkPipeline pipeline; |
| 5098 | VkPipelineCache pipelineCache; |
| 5099 | |
| 5100 | err = |
| 5101 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 5102 | ASSERT_VK_SUCCESS(err); |
| 5103 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 5104 | &gp_ci, NULL, &pipeline); |
| 5105 | |
| 5106 | m_errorMonitor->VerifyFound(); |
| 5107 | |
| 5108 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5109 | "Attempt to set lineWidth to 65536"); |
| 5110 | |
| 5111 | // Check too high (line width of 65536.0f). |
| 5112 | rs_ci.lineWidth = 65536.0f; |
| 5113 | |
| 5114 | err = |
| 5115 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 5116 | ASSERT_VK_SUCCESS(err); |
| 5117 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 5118 | &gp_ci, NULL, &pipeline); |
| 5119 | |
| 5120 | m_errorMonitor->VerifyFound(); |
| 5121 | |
| 5122 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 5123 | "Attempt to set lineWidth to -1"); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 5124 | |
| 5125 | dyn_state_ci.dynamicStateCount = 3; |
| 5126 | |
| 5127 | rs_ci.lineWidth = 1.0f; |
| 5128 | |
| 5129 | err = |
| 5130 | vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
| 5131 | ASSERT_VK_SUCCESS(err); |
| 5132 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, |
| 5133 | &gp_ci, NULL, &pipeline); |
| 5134 | BeginCommandBuffer(); |
| 5135 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 5136 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
| 5137 | |
| 5138 | // Check too low with dynamic setting. |
Mark Young | 4710795 | 2016-05-02 15:59:55 -0600 | [diff] [blame] | 5139 | vkCmdSetLineWidth(m_commandBuffer->GetBufferHandle(), -1.0f); |
Mark Young | 7394fdd | 2016-03-31 14:56:43 -0600 | [diff] [blame] | 5140 | m_errorMonitor->VerifyFound(); |
| 5141 | |
| 5142 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5143 | "Attempt to set lineWidth to 65536"); |
| 5144 | |
| 5145 | // Check too high with dynamic setting. |
| 5146 | vkCmdSetLineWidth(m_commandBuffer->GetBufferHandle(), 65536.0f); |
| 5147 | m_errorMonitor->VerifyFound(); |
| 5148 | EndCommandBuffer(); |
| 5149 | |
| 5150 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 5151 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 5152 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5153 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 5154 | } |
| 5155 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5156 | TEST_F(VkLayerTest, NullRenderPass) { |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 5157 | // Bind a NULL RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5158 | m_errorMonitor->SetDesiredFailureMsg( |
| 5159 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5160 | "You cannot use a NULL RenderPass object in vkCmdBeginRenderPass()"); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 5161 | |
| 5162 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5163 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 5164 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 5165 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5166 | // Don't care about RenderPass handle b/c error should be flagged before |
| 5167 | // that |
| 5168 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), NULL, |
| 5169 | VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 5170 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5171 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 5172 | } |
| 5173 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5174 | TEST_F(VkLayerTest, RenderPassWithinRenderPass) { |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5175 | // Bind a BeginRenderPass within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5176 | m_errorMonitor->SetDesiredFailureMsg( |
| 5177 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5178 | "It is invalid to issue this call inside an active render pass"); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5179 | |
| 5180 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5181 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5182 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 5183 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5184 | // Just create a dummy Renderpass that's non-NULL so we can get to the |
| 5185 | // proper error |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5186 | VkRenderPassBeginInfo rp_begin = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5187 | rp_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; |
| 5188 | rp_begin.pNext = NULL; |
| 5189 | rp_begin.renderPass = renderPass(); |
| 5190 | rp_begin.framebuffer = framebuffer(); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 5191 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5192 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &rp_begin, |
| 5193 | VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 5194 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5195 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5196 | } |
| 5197 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5198 | TEST_F(VkLayerTest, FillBufferWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5199 | // Call CmdFillBuffer within an active renderpass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5200 | m_errorMonitor->SetDesiredFailureMsg( |
| 5201 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5202 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5203 | |
| 5204 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5205 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5206 | |
| 5207 | // Renderpass is started here |
| 5208 | BeginCommandBuffer(); |
| 5209 | |
| 5210 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5211 | vk_testing::Buffer dstBuffer; |
| 5212 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5213 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5214 | m_commandBuffer->FillBuffer(dstBuffer.handle(), 0, 4, 0x11111111); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5215 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5216 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5217 | } |
| 5218 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5219 | TEST_F(VkLayerTest, UpdateBufferWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5220 | // Call CmdUpdateBuffer within an active renderpass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5221 | m_errorMonitor->SetDesiredFailureMsg( |
| 5222 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5223 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5224 | |
| 5225 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5226 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5227 | |
| 5228 | // Renderpass is started here |
| 5229 | BeginCommandBuffer(); |
| 5230 | |
| 5231 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5232 | vk_testing::Buffer dstBuffer; |
| 5233 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5234 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5235 | VkDeviceSize dstOffset = 0; |
| 5236 | VkDeviceSize dataSize = 1024; |
| 5237 | const uint32_t *pData = NULL; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5238 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5239 | vkCmdUpdateBuffer(m_commandBuffer->GetBufferHandle(), dstBuffer.handle(), |
| 5240 | dstOffset, dataSize, pData); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5241 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5242 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5243 | } |
| 5244 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5245 | TEST_F(VkLayerTest, ClearColorImageWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5246 | // Call CmdClearColorImage within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5247 | m_errorMonitor->SetDesiredFailureMsg( |
| 5248 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5249 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5250 | |
| 5251 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5252 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5253 | |
| 5254 | // Renderpass is started here |
| 5255 | BeginCommandBuffer(); |
| 5256 | |
Michael Lentine | 0a369f6 | 2016-02-03 16:51:46 -0600 | [diff] [blame] | 5257 | VkClearColorValue clear_color; |
| 5258 | memset(clear_color.uint32, 0, sizeof(uint32_t) * 4); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5259 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 5260 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5261 | const int32_t tex_width = 32; |
| 5262 | const int32_t tex_height = 32; |
| 5263 | VkImageCreateInfo image_create_info = {}; |
| 5264 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5265 | image_create_info.pNext = NULL; |
| 5266 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5267 | image_create_info.format = tex_format; |
| 5268 | image_create_info.extent.width = tex_width; |
| 5269 | image_create_info.extent.height = tex_height; |
| 5270 | image_create_info.extent.depth = 1; |
| 5271 | image_create_info.mipLevels = 1; |
| 5272 | image_create_info.arrayLayers = 1; |
| 5273 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 5274 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 5275 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5276 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5277 | vk_testing::Image dstImage; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5278 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 5279 | reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5280 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5281 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
| 5282 | image_create_info, VK_IMAGE_ASPECT_COLOR_BIT); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5283 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5284 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), dstImage.handle(), |
| 5285 | VK_IMAGE_LAYOUT_GENERAL, &clear_color, 1, &range); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5286 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5287 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5288 | } |
| 5289 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5290 | TEST_F(VkLayerTest, ClearDepthStencilImageWithinRenderPass) { |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5291 | // Call CmdClearDepthStencilImage within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5292 | m_errorMonitor->SetDesiredFailureMsg( |
| 5293 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5294 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5295 | |
| 5296 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5297 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5298 | |
| 5299 | // Renderpass is started here |
| 5300 | BeginCommandBuffer(); |
| 5301 | |
| 5302 | VkClearDepthStencilValue clear_value = {0}; |
Dustin Graves | a2e5c94 | 2016-02-11 18:28:06 -0700 | [diff] [blame] | 5303 | VkMemoryPropertyFlags reqs = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5304 | VkImageCreateInfo image_create_info = vk_testing::Image::create_info(); |
| 5305 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5306 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 5307 | image_create_info.extent.width = 64; |
| 5308 | image_create_info.extent.height = 64; |
| 5309 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 5310 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5311 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5312 | vk_testing::Image dstImage; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5313 | dstImage.init(*m_device, (const VkImageCreateInfo &)image_create_info, |
| 5314 | reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5315 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5316 | const VkImageSubresourceRange range = vk_testing::Image::subresource_range( |
| 5317 | image_create_info, VK_IMAGE_ASPECT_DEPTH_BIT); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5318 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5319 | vkCmdClearDepthStencilImage( |
| 5320 | m_commandBuffer->GetBufferHandle(), dstImage.handle(), |
| 5321 | VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, &clear_value, 1, |
| 5322 | &range); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5323 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5324 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5325 | } |
| 5326 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5327 | TEST_F(VkLayerTest, ClearColorAttachmentsOutsideRenderPass) { |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 5328 | // Call CmdClearAttachmentss outside of an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5329 | VkResult err; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5330 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5331 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5332 | "vkCmdClearAttachments: This call " |
| 5333 | "must be issued inside an active " |
| 5334 | "render pass"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5335 | |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5336 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5337 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5338 | |
| 5339 | // Start no RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5340 | err = m_commandBuffer->BeginCommandBuffer(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5341 | ASSERT_VK_SUCCESS(err); |
| 5342 | |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 5343 | VkClearAttachment color_attachment; |
| 5344 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 5345 | color_attachment.clearValue.color.float32[0] = 0; |
| 5346 | color_attachment.clearValue.color.float32[1] = 0; |
| 5347 | color_attachment.clearValue.color.float32[2] = 0; |
| 5348 | color_attachment.clearValue.color.float32[3] = 0; |
| 5349 | color_attachment.colorAttachment = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5350 | VkClearRect clear_rect = {{{0, 0}, {32, 32}}}; |
| 5351 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
| 5352 | &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5353 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5354 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 5355 | } |
| 5356 | |
Karl Schultz | 9e66a29 | 2016-04-21 15:57:51 -0600 | [diff] [blame] | 5357 | TEST_F(VkLayerTest, BufferMemoryBarrierNoBuffer) { |
| 5358 | // Try to add a buffer memory barrier with no buffer. |
| 5359 | m_errorMonitor->SetDesiredFailureMsg( |
| 5360 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5361 | "required parameter pBufferMemoryBarriers[i].buffer specified as VK_NULL_HANDLE"); |
| 5362 | |
| 5363 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5364 | BeginCommandBuffer(); |
| 5365 | |
| 5366 | VkBufferMemoryBarrier buf_barrier = {}; |
| 5367 | buf_barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; |
| 5368 | buf_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 5369 | buf_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 5370 | buf_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 5371 | buf_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 5372 | buf_barrier.buffer = VK_NULL_HANDLE; |
| 5373 | buf_barrier.offset = 0; |
| 5374 | buf_barrier.size = VK_WHOLE_SIZE; |
| 5375 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 5376 | VK_PIPELINE_STAGE_HOST_BIT, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, |
| 5377 | 0, 0, nullptr, 1, &buf_barrier, 0, nullptr); |
| 5378 | |
| 5379 | m_errorMonitor->VerifyFound(); |
| 5380 | } |
| 5381 | |
Tony Barbour | 7fd5c0f | 2016-05-03 16:11:53 -0600 | [diff] [blame] | 5382 | TEST_F(VkLayerTest, InvalidBarriers) { |
| 5383 | TEST_DESCRIPTION("A variety of ways to get VK_INVALID_BARRIER "); |
| 5384 | |
| 5385 | m_errorMonitor->SetDesiredFailureMsg( |
| 5386 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "Barriers cannot be set during subpass"); |
| 5387 | |
| 5388 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5389 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5390 | |
| 5391 | VkMemoryBarrier mem_barrier = {}; |
| 5392 | mem_barrier.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER; |
| 5393 | mem_barrier.pNext = NULL; |
| 5394 | mem_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 5395 | mem_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 5396 | BeginCommandBuffer(); |
| 5397 | // BeginCommandBuffer() starts a render pass |
| 5398 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 5399 | VK_PIPELINE_STAGE_HOST_BIT, |
| 5400 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 1, |
| 5401 | &mem_barrier, 0, nullptr, 0, nullptr); |
| 5402 | m_errorMonitor->VerifyFound(); |
| 5403 | |
| 5404 | m_errorMonitor->SetDesiredFailureMsg( |
| 5405 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5406 | "Image Layout cannot be transitioned to UNDEFINED"); |
| 5407 | VkImageObj image(m_device); |
| 5408 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 5409 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, 0); |
| 5410 | ASSERT_TRUE(image.initialized()); |
| 5411 | VkImageMemoryBarrier img_barrier = {}; |
| 5412 | img_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; |
| 5413 | img_barrier.pNext = NULL; |
| 5414 | img_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 5415 | img_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 5416 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 5417 | // New layout can't be UNDEFINED |
| 5418 | img_barrier.newLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 5419 | img_barrier.image = image.handle(); |
| 5420 | img_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 5421 | img_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 5422 | img_barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 5423 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 5424 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 5425 | img_barrier.subresourceRange.layerCount = 1; |
| 5426 | img_barrier.subresourceRange.levelCount = 1; |
| 5427 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 5428 | VK_PIPELINE_STAGE_HOST_BIT, |
| 5429 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 5430 | nullptr, 1, &img_barrier); |
| 5431 | m_errorMonitor->VerifyFound(); |
| 5432 | img_barrier.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 5433 | |
| 5434 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5435 | "Subresource must have the sum of the " |
| 5436 | "baseArrayLayer"); |
| 5437 | // baseArrayLayer + layerCount must be <= image's arrayLayers |
| 5438 | img_barrier.subresourceRange.baseArrayLayer = 1; |
| 5439 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 5440 | VK_PIPELINE_STAGE_HOST_BIT, |
| 5441 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 5442 | nullptr, 1, &img_barrier); |
| 5443 | m_errorMonitor->VerifyFound(); |
| 5444 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 5445 | |
| 5446 | m_errorMonitor->SetDesiredFailureMsg( |
| 5447 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5448 | "Subresource must have the sum of the baseMipLevel"); |
| 5449 | // baseMipLevel + levelCount must be <= image's mipLevels |
| 5450 | img_barrier.subresourceRange.baseMipLevel = 1; |
| 5451 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 5452 | VK_PIPELINE_STAGE_HOST_BIT, |
| 5453 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 5454 | nullptr, 1, &img_barrier); |
| 5455 | m_errorMonitor->VerifyFound(); |
| 5456 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 5457 | |
| 5458 | m_errorMonitor->SetDesiredFailureMsg( |
| 5459 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5460 | "Buffer Barriers cannot be used during a render pass"); |
| 5461 | vk_testing::Buffer buffer; |
| 5462 | buffer.init(*m_device, 256); |
| 5463 | VkBufferMemoryBarrier buf_barrier = {}; |
| 5464 | buf_barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER; |
| 5465 | buf_barrier.pNext = NULL; |
| 5466 | buf_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 5467 | buf_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 5468 | buf_barrier.buffer = buffer.handle(); |
| 5469 | buf_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 5470 | buf_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 5471 | buf_barrier.offset = 0; |
| 5472 | buf_barrier.size = VK_WHOLE_SIZE; |
| 5473 | // Can't send buffer barrier during a render pass |
| 5474 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 5475 | VK_PIPELINE_STAGE_HOST_BIT, |
| 5476 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 5477 | &buf_barrier, 0, nullptr); |
| 5478 | m_errorMonitor->VerifyFound(); |
| 5479 | vkCmdEndRenderPass(m_commandBuffer->GetBufferHandle()); |
| 5480 | |
| 5481 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5482 | "which is not less than total size"); |
| 5483 | buf_barrier.offset = 257; |
| 5484 | // Offset greater than total size |
| 5485 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 5486 | VK_PIPELINE_STAGE_HOST_BIT, |
| 5487 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 5488 | &buf_barrier, 0, nullptr); |
| 5489 | m_errorMonitor->VerifyFound(); |
| 5490 | buf_barrier.offset = 0; |
| 5491 | |
| 5492 | m_errorMonitor->SetDesiredFailureMsg( |
| 5493 | VK_DEBUG_REPORT_ERROR_BIT_EXT, "whose sum is greater than total size"); |
| 5494 | buf_barrier.size = 257; |
| 5495 | // Size greater than total size |
| 5496 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 5497 | VK_PIPELINE_STAGE_HOST_BIT, |
| 5498 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 1, |
| 5499 | &buf_barrier, 0, nullptr); |
| 5500 | m_errorMonitor->VerifyFound(); |
| 5501 | buf_barrier.size = VK_WHOLE_SIZE; |
| 5502 | |
| 5503 | m_errorMonitor->SetDesiredFailureMsg( |
| 5504 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5505 | "Image is a depth and stencil format and thus must " |
| 5506 | "have both VK_IMAGE_ASPECT_DEPTH_BIT and " |
| 5507 | "VK_IMAGE_ASPECT_STENCIL_BIT set."); |
| 5508 | VkDepthStencilObj ds_image(m_device); |
| 5509 | ds_image.Init(m_device, 128, 128, VK_FORMAT_D24_UNORM_S8_UINT); |
| 5510 | ASSERT_TRUE(ds_image.initialized()); |
| 5511 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 5512 | img_barrier.newLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; |
| 5513 | img_barrier.image = ds_image.handle(); |
| 5514 | // Leave aspectMask at COLOR on purpose |
| 5515 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 5516 | VK_PIPELINE_STAGE_HOST_BIT, |
| 5517 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 5518 | nullptr, 1, &img_barrier); |
| 5519 | m_errorMonitor->VerifyFound(); |
| 5520 | } |
| 5521 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5522 | TEST_F(VkLayerTest, IdxBufferAlignmentError) { |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5523 | // Bind a BeginRenderPass within an active RenderPass |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5524 | VkResult err; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5525 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5526 | m_errorMonitor->SetDesiredFailureMsg( |
| 5527 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5528 | "vkCmdBindIndexBuffer() offset (0x7) does not fall on "); |
| 5529 | |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5530 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5531 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5532 | uint32_t qfi = 0; |
| 5533 | VkBufferCreateInfo buffCI = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5534 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 5535 | buffCI.size = 1024; |
| 5536 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
| 5537 | buffCI.queueFamilyIndexCount = 1; |
| 5538 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5539 | |
| 5540 | VkBuffer ib; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5541 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5542 | ASSERT_VK_SUCCESS(err); |
| 5543 | |
| 5544 | BeginCommandBuffer(); |
| 5545 | ASSERT_VK_SUCCESS(err); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5546 | // vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 5547 | // VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5548 | // 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] | 5549 | vkCmdBindIndexBuffer(m_commandBuffer->GetBufferHandle(), ib, 7, |
| 5550 | VK_INDEX_TYPE_UINT16); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5551 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5552 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5553 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5554 | vkDestroyBuffer(m_device->device(), ib, NULL); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 5555 | } |
| 5556 | |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 5557 | TEST_F(VkLayerTest, InvalidQueueFamilyIndex) { |
| 5558 | // Create an out-of-range queueFamilyIndex |
| 5559 | m_errorMonitor->SetDesiredFailureMsg( |
| 5560 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 5561 | "queueFamilyIndex 777, must have been given when the device was created."); |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 5562 | |
| 5563 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5564 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5565 | VkBufferCreateInfo buffCI = {}; |
| 5566 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 5567 | buffCI.size = 1024; |
| 5568 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
| 5569 | buffCI.queueFamilyIndexCount = 1; |
| 5570 | // Introduce failure by specifying invalid queue_family_index |
| 5571 | uint32_t qfi = 777; |
| 5572 | buffCI.pQueueFamilyIndices = &qfi; |
Tobin Ehlis | 24aab04 | 2016-03-24 10:54:18 -0600 | [diff] [blame] | 5573 | buffCI.sharingMode = VK_SHARING_MODE_CONCURRENT; // qfi only matters in CONCURRENT mode |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 5574 | |
| 5575 | VkBuffer ib; |
| 5576 | vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
| 5577 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5578 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 52a6e7d | 2016-02-25 15:09:52 -0700 | [diff] [blame] | 5579 | } |
| 5580 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5581 | TEST_F(VkLayerTest, ExecuteCommandsPrimaryCB) { |
| 5582 | // Attempt vkCmdExecuteCommands w/ a primary cmd buffer (should only be |
| 5583 | // secondary) |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5584 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5585 | m_errorMonitor->SetDesiredFailureMsg( |
| 5586 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5587 | "vkCmdExecuteCommands() called w/ Primary Cmd Buffer "); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 5588 | |
| 5589 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5590 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 5591 | |
| 5592 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5593 | // ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5594 | VkCommandBuffer primCB = m_commandBuffer->GetBufferHandle(); |
| 5595 | vkCmdExecuteCommands(m_commandBuffer->GetBufferHandle(), 1, &primCB); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 5596 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5597 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 5598 | } |
| 5599 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5600 | TEST_F(VkLayerTest, DSTypeMismatch) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5601 | // 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] | 5602 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5603 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5604 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5605 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5606 | " binding #0 with type VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER but update " |
| 5607 | "type is VK_DESCRIPTOR_TYPE_SAMPLER"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5608 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5609 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5610 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5611 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5612 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5613 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5614 | |
| 5615 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5616 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5617 | ds_pool_ci.pNext = NULL; |
| 5618 | ds_pool_ci.maxSets = 1; |
| 5619 | ds_pool_ci.poolSizeCount = 1; |
| 5620 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5621 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5622 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5623 | err = |
| 5624 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5625 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5626 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5627 | dsl_binding.binding = 0; |
| 5628 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5629 | dsl_binding.descriptorCount = 1; |
| 5630 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5631 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5632 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5633 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5634 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5635 | ds_layout_ci.pNext = NULL; |
| 5636 | ds_layout_ci.bindingCount = 1; |
| 5637 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5638 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5639 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5640 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5641 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5642 | ASSERT_VK_SUCCESS(err); |
| 5643 | |
| 5644 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5645 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5646 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5647 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5648 | alloc_info.descriptorPool = ds_pool; |
| 5649 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5650 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5651 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5652 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5653 | |
Tobin Ehlis | 30db8f8 | 2016-05-05 08:19:48 -0600 | [diff] [blame] | 5654 | VkSamplerCreateInfo sampler_ci = {}; |
| 5655 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 5656 | sampler_ci.pNext = NULL; |
| 5657 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 5658 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 5659 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 5660 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5661 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5662 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5663 | sampler_ci.mipLodBias = 1.0; |
| 5664 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 5665 | sampler_ci.maxAnisotropy = 1; |
| 5666 | sampler_ci.compareEnable = VK_FALSE; |
| 5667 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 5668 | sampler_ci.minLod = 1.0; |
| 5669 | sampler_ci.maxLod = 1.0; |
| 5670 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 5671 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
| 5672 | VkSampler sampler; |
| 5673 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
| 5674 | ASSERT_VK_SUCCESS(err); |
| 5675 | |
| 5676 | VkDescriptorImageInfo info = {}; |
| 5677 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5678 | |
| 5679 | VkWriteDescriptorSet descriptor_write; |
| 5680 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 5681 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5682 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5683 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5684 | // This is a mismatched type for the layout which expects BUFFER |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5685 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 5686 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5687 | |
| 5688 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5689 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5690 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5691 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5692 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 5693 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5694 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5695 | } |
| 5696 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5697 | TEST_F(VkLayerTest, DSUpdateOutOfBounds) { |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5698 | // For overlapping Update, have arrayIndex exceed that of layout |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5699 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5700 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5701 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5702 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5703 | " binding #0 with 1 total descriptors but update of 1 descriptors " |
| 5704 | "starting at binding offset of 0 combined with update array element " |
| 5705 | "offset of 1 oversteps the size of this descriptor set."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5706 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5707 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5708 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5709 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5710 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5711 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5712 | |
| 5713 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5714 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5715 | ds_pool_ci.pNext = NULL; |
| 5716 | ds_pool_ci.maxSets = 1; |
| 5717 | ds_pool_ci.poolSizeCount = 1; |
| 5718 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5719 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5720 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5721 | err = |
| 5722 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5723 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5724 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5725 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5726 | dsl_binding.binding = 0; |
| 5727 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5728 | dsl_binding.descriptorCount = 1; |
| 5729 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5730 | dsl_binding.pImmutableSamplers = NULL; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5731 | |
| 5732 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5733 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5734 | ds_layout_ci.pNext = NULL; |
| 5735 | ds_layout_ci.bindingCount = 1; |
| 5736 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5737 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5738 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5739 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5740 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5741 | ASSERT_VK_SUCCESS(err); |
| 5742 | |
| 5743 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5744 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5745 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5746 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5747 | alloc_info.descriptorPool = ds_pool; |
| 5748 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5749 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5750 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5751 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5752 | |
Tobin Ehlis | 30db8f8 | 2016-05-05 08:19:48 -0600 | [diff] [blame] | 5753 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 5754 | VkDescriptorBufferInfo buff_info = {}; |
| 5755 | buff_info.buffer = |
| 5756 | VkBuffer(0); // Don't care about buffer handle for this test |
| 5757 | buff_info.offset = 0; |
| 5758 | buff_info.range = 1024; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5759 | |
| 5760 | VkWriteDescriptorSet descriptor_write; |
| 5761 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 5762 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5763 | descriptor_write.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5764 | descriptor_write.dstArrayElement = |
| 5765 | 1; /* This index out of bounds for the update */ |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5766 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5767 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5768 | descriptor_write.pBufferInfo = &buff_info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5769 | |
| 5770 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5771 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5772 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5773 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5774 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5775 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5776 | } |
| 5777 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5778 | TEST_F(VkLayerTest, InvalidDSUpdateIndex) { |
| 5779 | // Create layout w/ count of 1 and attempt update to that layout w/ binding |
| 5780 | // index 2 |
| 5781 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5782 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5783 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 5784 | " does not have binding 2."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5785 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5786 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5787 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5788 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5789 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5790 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5791 | |
| 5792 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5793 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5794 | ds_pool_ci.pNext = NULL; |
| 5795 | ds_pool_ci.maxSets = 1; |
| 5796 | ds_pool_ci.poolSizeCount = 1; |
| 5797 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 5798 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5799 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5800 | err = |
| 5801 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5802 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5803 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5804 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5805 | dsl_binding.binding = 0; |
| 5806 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5807 | dsl_binding.descriptorCount = 1; |
| 5808 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5809 | dsl_binding.pImmutableSamplers = NULL; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5810 | |
| 5811 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5812 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5813 | ds_layout_ci.pNext = NULL; |
| 5814 | ds_layout_ci.bindingCount = 1; |
| 5815 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5816 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5817 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5818 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5819 | ASSERT_VK_SUCCESS(err); |
| 5820 | |
| 5821 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5822 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5823 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5824 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5825 | alloc_info.descriptorPool = ds_pool; |
| 5826 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5827 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5828 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5829 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5830 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5831 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5832 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 5833 | sampler_ci.pNext = NULL; |
| 5834 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 5835 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 5836 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 5837 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5838 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5839 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5840 | sampler_ci.mipLodBias = 1.0; |
| 5841 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 5842 | sampler_ci.maxAnisotropy = 1; |
| 5843 | sampler_ci.compareEnable = VK_FALSE; |
| 5844 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 5845 | sampler_ci.minLod = 1.0; |
| 5846 | sampler_ci.maxLod = 1.0; |
| 5847 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 5848 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5849 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5850 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5851 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5852 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5853 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 5854 | VkDescriptorImageInfo info = {}; |
| 5855 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5856 | |
| 5857 | VkWriteDescriptorSet descriptor_write; |
| 5858 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 5859 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5860 | descriptor_write.dstSet = descriptorSet; |
| 5861 | descriptor_write.dstBinding = 2; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5862 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5863 | // 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] | 5864 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 5865 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5866 | |
| 5867 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5868 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5869 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5870 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5871 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 5872 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5873 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5874 | } |
| 5875 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5876 | TEST_F(VkLayerTest, InvalidDSUpdateStruct) { |
| 5877 | // Call UpdateDS w/ struct type other than valid VK_STRUCTUR_TYPE_UPDATE_* |
| 5878 | // types |
| 5879 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5880 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 5881 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5882 | "Unexpected UPDATE struct of type "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5883 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5884 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 5885 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5886 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5887 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5888 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5889 | |
| 5890 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5891 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5892 | ds_pool_ci.pNext = NULL; |
| 5893 | ds_pool_ci.maxSets = 1; |
| 5894 | ds_pool_ci.poolSizeCount = 1; |
| 5895 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 5896 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5897 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5898 | err = |
| 5899 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5900 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5901 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5902 | dsl_binding.binding = 0; |
| 5903 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 5904 | dsl_binding.descriptorCount = 1; |
| 5905 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5906 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5907 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5908 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5909 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5910 | ds_layout_ci.pNext = NULL; |
| 5911 | ds_layout_ci.bindingCount = 1; |
| 5912 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5913 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5914 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5915 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 5916 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5917 | ASSERT_VK_SUCCESS(err); |
| 5918 | |
| 5919 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5920 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5921 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 5922 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 5923 | alloc_info.descriptorPool = ds_pool; |
| 5924 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5925 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 5926 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5927 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5928 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 5929 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5930 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 5931 | sampler_ci.pNext = NULL; |
| 5932 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 5933 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 5934 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 5935 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5936 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5937 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 5938 | sampler_ci.mipLodBias = 1.0; |
| 5939 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 5940 | sampler_ci.maxAnisotropy = 1; |
| 5941 | sampler_ci.compareEnable = VK_FALSE; |
| 5942 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 5943 | sampler_ci.minLod = 1.0; |
| 5944 | sampler_ci.maxLod = 1.0; |
| 5945 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 5946 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5947 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5948 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5949 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5950 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 5951 | VkDescriptorImageInfo info = {}; |
| 5952 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5953 | |
| 5954 | VkWriteDescriptorSet descriptor_write; |
| 5955 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5956 | descriptor_write.sType = |
| 5957 | (VkStructureType)0x99999999; /* Intentionally broken struct type */ |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5958 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5959 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 5960 | // 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] | 5961 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 5962 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 5963 | |
| 5964 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 5965 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 5966 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 5967 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5968 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 5969 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5970 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 5971 | } |
| 5972 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5973 | TEST_F(VkLayerTest, SampleDescriptorUpdateError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5974 | // Create a single Sampler descriptor and send it an invalid Sampler |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5975 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5976 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5977 | m_errorMonitor->SetDesiredFailureMsg( |
| 5978 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 5979 | "Attempted write update to sampler descriptor with invalid sampler"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5980 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5981 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5982 | // TODO : Farm Descriptor setup code to helper function(s) to reduce copied |
| 5983 | // code |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5984 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5985 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 5986 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5987 | |
| 5988 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5989 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5990 | ds_pool_ci.pNext = NULL; |
| 5991 | ds_pool_ci.maxSets = 1; |
| 5992 | ds_pool_ci.poolSizeCount = 1; |
| 5993 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5994 | |
| 5995 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 5996 | err = |
| 5997 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5998 | ASSERT_VK_SUCCESS(err); |
| 5999 | |
| 6000 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6001 | dsl_binding.binding = 0; |
| 6002 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 6003 | dsl_binding.descriptorCount = 1; |
| 6004 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6005 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6006 | |
| 6007 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6008 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6009 | ds_layout_ci.pNext = NULL; |
| 6010 | ds_layout_ci.bindingCount = 1; |
| 6011 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6012 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6013 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6014 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6015 | ASSERT_VK_SUCCESS(err); |
| 6016 | |
| 6017 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6018 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6019 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6020 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6021 | alloc_info.descriptorPool = ds_pool; |
| 6022 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6023 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6024 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6025 | ASSERT_VK_SUCCESS(err); |
| 6026 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6027 | VkSampler sampler = |
| 6028 | (VkSampler)((size_t)0xbaadbeef); // Sampler with invalid handle |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6029 | |
| 6030 | VkDescriptorImageInfo descriptor_info; |
| 6031 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 6032 | descriptor_info.sampler = sampler; |
| 6033 | |
| 6034 | VkWriteDescriptorSet descriptor_write; |
| 6035 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 6036 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6037 | descriptor_write.dstSet = descriptorSet; |
| 6038 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6039 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6040 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 6041 | descriptor_write.pImageInfo = &descriptor_info; |
| 6042 | |
| 6043 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 6044 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6045 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6046 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6047 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6048 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6049 | } |
| 6050 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6051 | TEST_F(VkLayerTest, ImageViewDescriptorUpdateError) { |
| 6052 | // Create a single combined Image/Sampler descriptor and send it an invalid |
| 6053 | // imageView |
| 6054 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6055 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 6056 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6057 | "Attempted write update to combined " |
| 6058 | "image sampler descriptor failed due " |
Tobin Ehlis | 63c4b8a | 2016-05-09 10:29:34 -0600 | [diff] [blame] | 6059 | "to: Invalid VkImageView:"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6060 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6061 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6062 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6063 | ds_type_count.type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 6064 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6065 | |
| 6066 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6067 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6068 | ds_pool_ci.pNext = NULL; |
| 6069 | ds_pool_ci.maxSets = 1; |
| 6070 | ds_pool_ci.poolSizeCount = 1; |
| 6071 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6072 | |
| 6073 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6074 | err = |
| 6075 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6076 | ASSERT_VK_SUCCESS(err); |
| 6077 | |
| 6078 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6079 | dsl_binding.binding = 0; |
| 6080 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 6081 | dsl_binding.descriptorCount = 1; |
| 6082 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6083 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6084 | |
| 6085 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6086 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6087 | ds_layout_ci.pNext = NULL; |
| 6088 | ds_layout_ci.bindingCount = 1; |
| 6089 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6090 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6091 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6092 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6093 | ASSERT_VK_SUCCESS(err); |
| 6094 | |
| 6095 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6096 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6097 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6098 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6099 | alloc_info.descriptorPool = ds_pool; |
| 6100 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6101 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6102 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6103 | ASSERT_VK_SUCCESS(err); |
| 6104 | |
| 6105 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6106 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 6107 | sampler_ci.pNext = NULL; |
| 6108 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 6109 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 6110 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 6111 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 6112 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 6113 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 6114 | sampler_ci.mipLodBias = 1.0; |
| 6115 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 6116 | sampler_ci.maxAnisotropy = 1; |
| 6117 | sampler_ci.compareEnable = VK_FALSE; |
| 6118 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 6119 | sampler_ci.minLod = 1.0; |
| 6120 | sampler_ci.maxLod = 1.0; |
| 6121 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 6122 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6123 | |
| 6124 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6125 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6126 | ASSERT_VK_SUCCESS(err); |
| 6127 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6128 | VkImageView view = |
| 6129 | (VkImageView)((size_t)0xbaadbeef); // invalid imageView object |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6130 | |
| 6131 | VkDescriptorImageInfo descriptor_info; |
| 6132 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 6133 | descriptor_info.sampler = sampler; |
| 6134 | descriptor_info.imageView = view; |
| 6135 | |
| 6136 | VkWriteDescriptorSet descriptor_write; |
| 6137 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 6138 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6139 | descriptor_write.dstSet = descriptorSet; |
| 6140 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6141 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6142 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 6143 | descriptor_write.pImageInfo = &descriptor_info; |
| 6144 | |
| 6145 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 6146 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6147 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6148 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6149 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 6150 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6151 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6152 | } |
| 6153 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6154 | TEST_F(VkLayerTest, CopyDescriptorUpdateErrors) { |
| 6155 | // Create DS w/ layout of 2 types, write update 1 and attempt to copy-update |
| 6156 | // into the other |
| 6157 | VkResult err; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6158 | |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 6159 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6160 | " binding #1 with type " |
| 6161 | "VK_DESCRIPTOR_TYPE_SAMPLER. Types do " |
| 6162 | "not match."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6163 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6164 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6165 | // VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6166 | VkDescriptorPoolSize ds_type_count[2] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6167 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6168 | ds_type_count[0].descriptorCount = 1; |
| 6169 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 6170 | ds_type_count[1].descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6171 | |
| 6172 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6173 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6174 | ds_pool_ci.pNext = NULL; |
| 6175 | ds_pool_ci.maxSets = 1; |
| 6176 | ds_pool_ci.poolSizeCount = 2; |
| 6177 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6178 | |
| 6179 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6180 | err = |
| 6181 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6182 | ASSERT_VK_SUCCESS(err); |
| 6183 | VkDescriptorSetLayoutBinding dsl_binding[2] = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6184 | dsl_binding[0].binding = 0; |
| 6185 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6186 | dsl_binding[0].descriptorCount = 1; |
| 6187 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 6188 | dsl_binding[0].pImmutableSamplers = NULL; |
| 6189 | dsl_binding[1].binding = 1; |
| 6190 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 6191 | dsl_binding[1].descriptorCount = 1; |
| 6192 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 6193 | dsl_binding[1].pImmutableSamplers = NULL; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6194 | |
| 6195 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6196 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6197 | ds_layout_ci.pNext = NULL; |
| 6198 | ds_layout_ci.bindingCount = 2; |
| 6199 | ds_layout_ci.pBindings = dsl_binding; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6200 | |
| 6201 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6202 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6203 | &ds_layout); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6204 | ASSERT_VK_SUCCESS(err); |
| 6205 | |
| 6206 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6207 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6208 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6209 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6210 | alloc_info.descriptorPool = ds_pool; |
| 6211 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6212 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6213 | &descriptorSet); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6214 | ASSERT_VK_SUCCESS(err); |
| 6215 | |
| 6216 | VkSamplerCreateInfo sampler_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6217 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 6218 | sampler_ci.pNext = NULL; |
| 6219 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 6220 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 6221 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST; |
| 6222 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 6223 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 6224 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 6225 | sampler_ci.mipLodBias = 1.0; |
| 6226 | sampler_ci.anisotropyEnable = VK_FALSE; |
| 6227 | sampler_ci.maxAnisotropy = 1; |
| 6228 | sampler_ci.compareEnable = VK_FALSE; |
| 6229 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 6230 | sampler_ci.minLod = 1.0; |
| 6231 | sampler_ci.maxLod = 1.0; |
| 6232 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 6233 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6234 | |
| 6235 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6236 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6237 | ASSERT_VK_SUCCESS(err); |
| 6238 | |
| 6239 | VkDescriptorImageInfo info = {}; |
| 6240 | info.sampler = sampler; |
| 6241 | |
| 6242 | VkWriteDescriptorSet descriptor_write; |
| 6243 | memset(&descriptor_write, 0, sizeof(VkWriteDescriptorSet)); |
| 6244 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6245 | descriptor_write.dstSet = descriptorSet; |
| 6246 | descriptor_write.dstBinding = 1; // SAMPLER binding from layout above |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6247 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6248 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 6249 | descriptor_write.pImageInfo = &info; |
| 6250 | // This write update should succeed |
| 6251 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 6252 | // Now perform a copy update that fails due to type mismatch |
| 6253 | VkCopyDescriptorSet copy_ds_update; |
| 6254 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 6255 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 6256 | copy_ds_update.srcSet = descriptorSet; |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 6257 | copy_ds_update.srcBinding = 1; // Copy from SAMPLER binding |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6258 | copy_ds_update.dstSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6259 | copy_ds_update.dstBinding = 0; // ERROR : copy to UNIFORM binding |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6260 | copy_ds_update.descriptorCount = 1; // copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6261 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 6262 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6263 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6264 | // 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] | 6265 | m_errorMonitor->SetDesiredFailureMsg( |
| 6266 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 6267 | " does not have copy update src binding of 3."); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6268 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 6269 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 6270 | copy_ds_update.srcSet = descriptorSet; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6271 | copy_ds_update.srcBinding = |
| 6272 | 3; // ERROR : Invalid binding for matching layout |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6273 | copy_ds_update.dstSet = descriptorSet; |
| 6274 | copy_ds_update.dstBinding = 0; |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 6275 | copy_ds_update.descriptorCount = 1; // Copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6276 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 6277 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6278 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6279 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6280 | // 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] | 6281 | m_errorMonitor->SetDesiredFailureMsg( |
Tobin Ehlis | 0a43bde | 2016-05-03 08:31:08 -0600 | [diff] [blame] | 6282 | VK_DEBUG_REPORT_ERROR_BIT_EXT, " binding#1 with offset index of 1 plus " |
| 6283 | "update array offset of 0 and update of " |
| 6284 | "5 descriptors oversteps total number " |
| 6285 | "of descriptors in set: 2."); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6286 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6287 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 6288 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 6289 | copy_ds_update.srcSet = descriptorSet; |
| 6290 | copy_ds_update.srcBinding = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6291 | copy_ds_update.dstSet = descriptorSet; |
| 6292 | copy_ds_update.dstBinding = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6293 | copy_ds_update.descriptorCount = |
| 6294 | 5; // ERROR copy 5 descriptors (out of bounds for layout) |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6295 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 6296 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6297 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6298 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6299 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 6300 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6301 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 6302 | } |
| 6303 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6304 | TEST_F(VkLayerTest, NumSamplesMismatch) { |
| 6305 | // Create CommandBuffer where MSAA samples doesn't match RenderPass |
| 6306 | // sampleCount |
| 6307 | VkResult err; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6308 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6309 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6310 | "Num samples mismatch! "); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6311 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6312 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6313 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6314 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6315 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6316 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6317 | |
| 6318 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6319 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6320 | ds_pool_ci.pNext = NULL; |
| 6321 | ds_pool_ci.maxSets = 1; |
| 6322 | ds_pool_ci.poolSizeCount = 1; |
| 6323 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 6324 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6325 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6326 | err = |
| 6327 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6328 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6329 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6330 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 6331 | dsl_binding.binding = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6332 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 0212448 | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 6333 | dsl_binding.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6334 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6335 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6336 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6337 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 6338 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6339 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6340 | ds_layout_ci.bindingCount = 1; |
Jon Ashburn | 6e23c1f | 2015-12-30 18:01:16 -0700 | [diff] [blame] | 6341 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6342 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6343 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6344 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6345 | &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6346 | ASSERT_VK_SUCCESS(err); |
| 6347 | |
| 6348 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6349 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6350 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6351 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 6352 | alloc_info.descriptorPool = ds_pool; |
| 6353 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6354 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6355 | &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6356 | ASSERT_VK_SUCCESS(err); |
| 6357 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6358 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6359 | pipe_ms_state_ci.sType = |
| 6360 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 6361 | pipe_ms_state_ci.pNext = NULL; |
| 6362 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
| 6363 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 6364 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 6365 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6366 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6367 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6368 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6369 | pipeline_layout_ci.pNext = NULL; |
| 6370 | pipeline_layout_ci.setLayoutCount = 1; |
| 6371 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6372 | |
| 6373 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6374 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6375 | &pipeline_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6376 | ASSERT_VK_SUCCESS(err); |
| 6377 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6378 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6379 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6380 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6381 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6382 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6383 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 6384 | VkPipelineObj pipe(m_device); |
| 6385 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 6386 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6387 | pipe.AddColorAttachment(); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 6388 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 6389 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6390 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 6391 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6392 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 6393 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 6394 | |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 6395 | // Render triangle (the error should trigger on the attempt to draw). |
| 6396 | Draw(3, 1, 0, 0); |
| 6397 | |
| 6398 | // Finalize recording of the command buffer |
| 6399 | EndCommandBuffer(); |
| 6400 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6401 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 6402 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6403 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6404 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6405 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 6406 | } |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 6407 | |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6408 | TEST_F(VkLayerTest, NumBlendAttachMismatch) { |
| 6409 | // Create Pipeline where the number of blend attachments doesn't match the |
| 6410 | // number of color attachments. In this case, we don't add any color |
| 6411 | // blend attachments even though we have a color attachment. |
| 6412 | VkResult err; |
| 6413 | |
| 6414 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 6415 | "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] | 6416 | |
| 6417 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6418 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6419 | VkDescriptorPoolSize ds_type_count = {}; |
| 6420 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6421 | ds_type_count.descriptorCount = 1; |
| 6422 | |
| 6423 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 6424 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6425 | ds_pool_ci.pNext = NULL; |
| 6426 | ds_pool_ci.maxSets = 1; |
| 6427 | ds_pool_ci.poolSizeCount = 1; |
| 6428 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 6429 | |
| 6430 | VkDescriptorPool ds_pool; |
| 6431 | err = |
| 6432 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 6433 | ASSERT_VK_SUCCESS(err); |
| 6434 | |
| 6435 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 6436 | dsl_binding.binding = 0; |
| 6437 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6438 | dsl_binding.descriptorCount = 1; |
| 6439 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6440 | dsl_binding.pImmutableSamplers = NULL; |
| 6441 | |
| 6442 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 6443 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6444 | ds_layout_ci.pNext = NULL; |
| 6445 | ds_layout_ci.bindingCount = 1; |
| 6446 | ds_layout_ci.pBindings = &dsl_binding; |
| 6447 | |
| 6448 | VkDescriptorSetLayout ds_layout; |
| 6449 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6450 | &ds_layout); |
| 6451 | ASSERT_VK_SUCCESS(err); |
| 6452 | |
| 6453 | VkDescriptorSet descriptorSet; |
| 6454 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 6455 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
| 6456 | alloc_info.descriptorSetCount = 1; |
| 6457 | alloc_info.descriptorPool = ds_pool; |
| 6458 | alloc_info.pSetLayouts = &ds_layout; |
| 6459 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6460 | &descriptorSet); |
| 6461 | ASSERT_VK_SUCCESS(err); |
| 6462 | |
| 6463 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 6464 | pipe_ms_state_ci.sType = |
| 6465 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 6466 | pipe_ms_state_ci.pNext = NULL; |
| 6467 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 6468 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 6469 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 6470 | pipe_ms_state_ci.pSampleMask = NULL; |
| 6471 | |
| 6472 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 6473 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6474 | pipeline_layout_ci.pNext = NULL; |
| 6475 | pipeline_layout_ci.setLayoutCount = 1; |
| 6476 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 6477 | |
| 6478 | VkPipelineLayout pipeline_layout; |
| 6479 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6480 | &pipeline_layout); |
| 6481 | ASSERT_VK_SUCCESS(err); |
| 6482 | |
| 6483 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6484 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6485 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6486 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6487 | this); // We shouldn't need a fragment shader |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6488 | // but add it to be able to run on more devices |
| 6489 | VkPipelineObj pipe(m_device); |
| 6490 | pipe.AddShader(&vs); |
| 6491 | pipe.AddShader(&fs); |
| 6492 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 6493 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 6494 | |
| 6495 | BeginCommandBuffer(); |
| 6496 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 6497 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 6498 | |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 6499 | // Render triangle (the error should trigger on the attempt to draw). |
| 6500 | Draw(3, 1, 0, 0); |
| 6501 | |
| 6502 | // Finalize recording of the command buffer |
| 6503 | EndCommandBuffer(); |
| 6504 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6505 | m_errorMonitor->VerifyFound(); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6506 | |
| 6507 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6508 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6509 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 6510 | } |
Mark Young | 2992748 | 2016-05-04 14:38:51 -0600 | [diff] [blame] | 6511 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6512 | TEST_F(VkLayerTest, ClearCmdNoDraw) { |
| 6513 | // Create CommandBuffer where we add ClearCmd for FB Color attachment prior |
| 6514 | // to issuing a Draw |
| 6515 | VkResult err; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6516 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6517 | m_errorMonitor->SetDesiredFailureMsg( |
Tony Barbour | 7e56d30 | 2016-03-02 15:12:01 -0700 | [diff] [blame] | 6518 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6519 | "vkCmdClearAttachments() issued on CB object "); |
| 6520 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6521 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6522 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6523 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6524 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6525 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6526 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6527 | |
| 6528 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6529 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6530 | ds_pool_ci.pNext = NULL; |
| 6531 | ds_pool_ci.maxSets = 1; |
| 6532 | ds_pool_ci.poolSizeCount = 1; |
| 6533 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6534 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6535 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6536 | err = |
| 6537 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6538 | ASSERT_VK_SUCCESS(err); |
| 6539 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6540 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6541 | dsl_binding.binding = 0; |
| 6542 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6543 | dsl_binding.descriptorCount = 1; |
| 6544 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6545 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6546 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6547 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6548 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6549 | ds_layout_ci.pNext = NULL; |
| 6550 | ds_layout_ci.bindingCount = 1; |
| 6551 | ds_layout_ci.pBindings = &dsl_binding; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6552 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6553 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6554 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6555 | &ds_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6556 | ASSERT_VK_SUCCESS(err); |
| 6557 | |
| 6558 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6559 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6560 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6561 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 6562 | alloc_info.descriptorPool = ds_pool; |
| 6563 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6564 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6565 | &descriptorSet); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6566 | ASSERT_VK_SUCCESS(err); |
| 6567 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6568 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6569 | pipe_ms_state_ci.sType = |
| 6570 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 6571 | pipe_ms_state_ci.pNext = NULL; |
| 6572 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
| 6573 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 6574 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 6575 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6576 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6577 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6578 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6579 | pipeline_layout_ci.pNext = NULL; |
| 6580 | pipeline_layout_ci.setLayoutCount = 1; |
| 6581 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6582 | |
| 6583 | VkPipelineLayout pipeline_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6584 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6585 | &pipeline_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6586 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6587 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6588 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6589 | VK_SHADER_STAGE_VERTEX_BIT, this); |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6590 | // 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] | 6591 | // on more devices |
| 6592 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6593 | VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6594 | |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 6595 | VkPipelineObj pipe(m_device); |
| 6596 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 6597 | pipe.AddShader(&fs); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 6598 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 6599 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 6600 | |
| 6601 | BeginCommandBuffer(); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6602 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6603 | // Main thing we care about for this test is that the VkImage obj we're |
| 6604 | // clearing matches Color Attachment of FB |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6605 | // Also pass down other dummy params to keep driver and paramchecker happy |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 6606 | VkClearAttachment color_attachment; |
| 6607 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 6608 | color_attachment.clearValue.color.float32[0] = 1.0; |
| 6609 | color_attachment.clearValue.color.float32[1] = 1.0; |
| 6610 | color_attachment.clearValue.color.float32[2] = 1.0; |
| 6611 | color_attachment.clearValue.color.float32[3] = 1.0; |
| 6612 | color_attachment.colorAttachment = 0; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6613 | VkClearRect clear_rect = { |
| 6614 | {{0, 0}, {(uint32_t)m_width, (uint32_t)m_height}}}; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6615 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6616 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, |
| 6617 | &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6618 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6619 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 6620 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6621 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6622 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6623 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 6624 | } |
| 6625 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6626 | TEST_F(VkLayerTest, VtxBufferBadIndex) { |
| 6627 | VkResult err; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6628 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6629 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 6630 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Mark Lobodzinski | dfcd9b6 | 2015-12-14 15:14:10 -0700 | [diff] [blame] | 6631 | "but no vertex buffers are attached to this Pipeline State Object"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6632 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6633 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6634 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6635 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6636 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6637 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6638 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6639 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6640 | |
| 6641 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6642 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6643 | ds_pool_ci.pNext = NULL; |
| 6644 | ds_pool_ci.maxSets = 1; |
| 6645 | ds_pool_ci.poolSizeCount = 1; |
| 6646 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6647 | |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 6648 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6649 | err = |
| 6650 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6651 | ASSERT_VK_SUCCESS(err); |
| 6652 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6653 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6654 | dsl_binding.binding = 0; |
| 6655 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 6656 | dsl_binding.descriptorCount = 1; |
| 6657 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6658 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6659 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6660 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6661 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6662 | ds_layout_ci.pNext = NULL; |
| 6663 | ds_layout_ci.bindingCount = 1; |
| 6664 | ds_layout_ci.pBindings = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6665 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6666 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6667 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 6668 | &ds_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6669 | ASSERT_VK_SUCCESS(err); |
| 6670 | |
| 6671 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6672 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6673 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 6674 | alloc_info.descriptorSetCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 6675 | alloc_info.descriptorPool = ds_pool; |
| 6676 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6677 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 6678 | &descriptorSet); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6679 | ASSERT_VK_SUCCESS(err); |
| 6680 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6681 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6682 | pipe_ms_state_ci.sType = |
| 6683 | VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 6684 | pipe_ms_state_ci.pNext = NULL; |
| 6685 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
| 6686 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 6687 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 6688 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6689 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 6690 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6691 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 6692 | pipeline_layout_ci.pNext = NULL; |
| 6693 | pipeline_layout_ci.setLayoutCount = 1; |
| 6694 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 6695 | VkPipelineLayout pipeline_layout; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6696 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6697 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, |
| 6698 | &pipeline_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6699 | ASSERT_VK_SUCCESS(err); |
| 6700 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6701 | VkShaderObj vs(m_device, bindStateVertShaderText, |
| 6702 | VK_SHADER_STAGE_VERTEX_BIT, this); |
| 6703 | VkShaderObj fs(m_device, bindStateFragShaderText, |
| 6704 | VK_SHADER_STAGE_FRAGMENT_BIT, |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 6705 | this); // We shouldn't need a fragment shader |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6706 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 6707 | VkPipelineObj pipe(m_device); |
| 6708 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 6709 | pipe.AddShader(&fs); |
Mark Young | c89c631 | 2016-03-31 16:03:20 -0600 | [diff] [blame] | 6710 | pipe.AddColorAttachment(); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 6711 | pipe.SetMSAA(&pipe_ms_state_ci); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 6712 | pipe.SetViewport(m_viewports); |
| 6713 | pipe.SetScissor(m_scissors); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 6714 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 6715 | |
| 6716 | BeginCommandBuffer(); |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6717 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), |
| 6718 | VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 6719 | // Don't care about actual data, just need to get to draw to flag error |
| 6720 | static const float vbo_data[3] = {1.f, 0.f, 1.f}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6721 | VkConstantBufferObj vbo(m_device, sizeof(vbo_data), sizeof(float), |
| 6722 | (const void *)&vbo_data); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 6723 | 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] | 6724 | Draw(1, 0, 0, 0); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6725 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6726 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 6727 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6728 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 6729 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6730 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 6731 | } |
Tobin Ehlis | c555a3c | 2016-05-04 14:08:34 -0600 | [diff] [blame] | 6732 | // INVALID_IMAGE_LAYOUT tests (one other case is hit by MapMemWithoutHostVisibleBit and not here) |
| 6733 | TEST_F(VkLayerTest, InvalidImageLayout) { |
| 6734 | TEST_DESCRIPTION("Hit all possible validation checks associated with the " |
| 6735 | "DRAWSTATE_INVALID_IMAGE_LAYOUT enum. Generally these involve having" |
| 6736 | "images in the wrong layout when they're copied or transitioned."); |
| 6737 | // 3 in ValidateCmdBufImageLayouts |
| 6738 | // * -1 Attempt to submit cmd buf w/ deleted image |
| 6739 | // * -2 Cmd buf submit of image w/ layout not matching first use w/ subresource |
| 6740 | // * -3 Cmd buf submit of image w/ layout not matching first use w/o subresource |
| 6741 | m_errorMonitor->SetDesiredFailureMsg( |
| 6742 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 6743 | "Layout for input image should be TRANSFER_SRC_OPTIMAL instead of GENERAL."); |
| 6744 | |
| 6745 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6746 | // Create src & dst images to use for copy operations |
| 6747 | VkImage src_image; |
| 6748 | VkImage dst_image; |
| 6749 | |
| 6750 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6751 | const int32_t tex_width = 32; |
| 6752 | const int32_t tex_height = 32; |
| 6753 | |
| 6754 | VkImageCreateInfo image_create_info = {}; |
| 6755 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6756 | image_create_info.pNext = NULL; |
| 6757 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6758 | image_create_info.format = tex_format; |
| 6759 | image_create_info.extent.width = tex_width; |
| 6760 | image_create_info.extent.height = tex_height; |
| 6761 | image_create_info.extent.depth = 1; |
| 6762 | image_create_info.mipLevels = 1; |
| 6763 | image_create_info.arrayLayers = 4; |
| 6764 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 6765 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 6766 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 6767 | image_create_info.flags = 0; |
| 6768 | |
| 6769 | VkResult err = vkCreateImage(m_device->device(), &image_create_info, NULL, &src_image); |
| 6770 | ASSERT_VK_SUCCESS(err); |
| 6771 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dst_image); |
| 6772 | ASSERT_VK_SUCCESS(err); |
| 6773 | |
| 6774 | BeginCommandBuffer(); |
| 6775 | VkImageCopy copyRegion; |
| 6776 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 6777 | copyRegion.srcSubresource.mipLevel = 0; |
| 6778 | copyRegion.srcSubresource.baseArrayLayer = 0; |
| 6779 | copyRegion.srcSubresource.layerCount = 1; |
| 6780 | copyRegion.srcOffset.x = 0; |
| 6781 | copyRegion.srcOffset.y = 0; |
| 6782 | copyRegion.srcOffset.z = 0; |
| 6783 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 6784 | copyRegion.dstSubresource.mipLevel = 0; |
| 6785 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 6786 | copyRegion.dstSubresource.layerCount = 1; |
| 6787 | copyRegion.dstOffset.x = 0; |
| 6788 | copyRegion.dstOffset.y = 0; |
| 6789 | copyRegion.dstOffset.z = 0; |
| 6790 | copyRegion.extent.width = 1; |
| 6791 | copyRegion.extent.height = 1; |
| 6792 | copyRegion.extent.depth = 1; |
| 6793 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 6794 | m_errorMonitor->VerifyFound(); |
| 6795 | // Now cause error due to src image layout changing |
| 6796 | m_errorMonitor->SetDesiredFailureMsg( |
| 6797 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6798 | "Cannot copy from an image whose source layout is VK_IMAGE_LAYOUT_UNDEFINED and doesn't match the current layout VK_IMAGE_LAYOUT_GENERAL."); |
| 6799 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_UNDEFINED, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 6800 | m_errorMonitor->VerifyFound(); |
| 6801 | // Final src error is due to bad layout type |
| 6802 | m_errorMonitor->SetDesiredFailureMsg( |
| 6803 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6804 | "Layout for input image is VK_IMAGE_LAYOUT_UNDEFINED but can only be TRANSFER_SRC_OPTIMAL or GENERAL."); |
| 6805 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_UNDEFINED, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 6806 | m_errorMonitor->VerifyFound(); |
| 6807 | // Now verify same checks for dst |
| 6808 | m_errorMonitor->SetDesiredFailureMsg( |
| 6809 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 6810 | "Layout for output image should be TRANSFER_DST_OPTIMAL instead of GENERAL."); |
| 6811 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 6812 | m_errorMonitor->VerifyFound(); |
| 6813 | // Now cause error due to src image layout changing |
| 6814 | m_errorMonitor->SetDesiredFailureMsg( |
| 6815 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6816 | "Cannot copy from an image whose dest layout is VK_IMAGE_LAYOUT_UNDEFINED and doesn't match the current layout VK_IMAGE_LAYOUT_GENERAL."); |
| 6817 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_UNDEFINED, 1, ©Region); |
| 6818 | m_errorMonitor->VerifyFound(); |
| 6819 | m_errorMonitor->SetDesiredFailureMsg( |
| 6820 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6821 | "Layout for output image is VK_IMAGE_LAYOUT_UNDEFINED but can only be TRANSFER_DST_OPTIMAL or GENERAL."); |
| 6822 | m_commandBuffer->CopyImage(src_image, VK_IMAGE_LAYOUT_GENERAL, dst_image, VK_IMAGE_LAYOUT_UNDEFINED, 1, ©Region); |
| 6823 | m_errorMonitor->VerifyFound(); |
| 6824 | // Now cause error due to bad image layout transition in PipelineBarrier |
| 6825 | VkImageMemoryBarrier image_barrier[1] = {}; |
| 6826 | image_barrier[0].oldLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; |
| 6827 | image_barrier[0].image = src_image; |
| 6828 | image_barrier[0].subresourceRange.layerCount = 2; |
| 6829 | image_barrier[0].subresourceRange.levelCount = 2; |
| 6830 | image_barrier[0].subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 6831 | m_errorMonitor->SetDesiredFailureMsg( |
| 6832 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6833 | "You cannot transition the layout from VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL when current layout is VK_IMAGE_LAYOUT_GENERAL."); |
| 6834 | vkCmdPipelineBarrier(m_commandBuffer->handle(), VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, NULL, 0, NULL, 1, image_barrier); |
| 6835 | m_errorMonitor->VerifyFound(); |
| 6836 | |
| 6837 | // Finally some layout errors at RenderPass create time |
| 6838 | // Just hacking in specific state to get to the errors we want so don't copy this unless you know what you're doing. |
| 6839 | VkAttachmentReference attach = {}; |
| 6840 | // perf warning for GENERAL layout w/ non-DS input attachment |
| 6841 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 6842 | VkSubpassDescription subpass = {}; |
| 6843 | subpass.inputAttachmentCount = 1; |
| 6844 | subpass.pInputAttachments = &attach; |
| 6845 | VkRenderPassCreateInfo rpci = {}; |
| 6846 | rpci.subpassCount = 1; |
| 6847 | rpci.pSubpasses = &subpass; |
| 6848 | rpci.attachmentCount = 1; |
| 6849 | VkAttachmentDescription attach_desc = {}; |
| 6850 | attach_desc.format = VK_FORMAT_UNDEFINED; |
| 6851 | rpci.pAttachments = &attach_desc; |
Tobin Ehlis | 1efce02 | 2016-05-11 10:40:34 -0600 | [diff] [blame] | 6852 | rpci.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; |
Tobin Ehlis | c555a3c | 2016-05-04 14:08:34 -0600 | [diff] [blame] | 6853 | VkRenderPass rp; |
| 6854 | m_errorMonitor->SetDesiredFailureMsg( |
| 6855 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 6856 | "Layout for input attachment is GENERAL but should be READ_ONLY_OPTIMAL."); |
| 6857 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 6858 | m_errorMonitor->VerifyFound(); |
| 6859 | // error w/ non-general layout |
| 6860 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; |
| 6861 | |
| 6862 | m_errorMonitor->SetDesiredFailureMsg( |
| 6863 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6864 | "Layout for input attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be READ_ONLY_OPTIMAL or GENERAL."); |
| 6865 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 6866 | m_errorMonitor->VerifyFound(); |
| 6867 | subpass.inputAttachmentCount = 0; |
| 6868 | subpass.colorAttachmentCount = 1; |
| 6869 | subpass.pColorAttachments = &attach; |
| 6870 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 6871 | // perf warning for GENERAL layout on color attachment |
| 6872 | m_errorMonitor->SetDesiredFailureMsg( |
| 6873 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 6874 | "Layout for color attachment is GENERAL but should be COLOR_ATTACHMENT_OPTIMAL."); |
| 6875 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 6876 | m_errorMonitor->VerifyFound(); |
| 6877 | // error w/ non-color opt or GENERAL layout for color attachment |
| 6878 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; |
| 6879 | m_errorMonitor->SetDesiredFailureMsg( |
| 6880 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6881 | "Layout for color attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be COLOR_ATTACHMENT_OPTIMAL or GENERAL."); |
| 6882 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 6883 | m_errorMonitor->VerifyFound(); |
| 6884 | subpass.colorAttachmentCount = 0; |
| 6885 | subpass.pDepthStencilAttachment = &attach; |
| 6886 | attach.layout = VK_IMAGE_LAYOUT_GENERAL; |
| 6887 | // perf warning for GENERAL layout on DS attachment |
| 6888 | m_errorMonitor->SetDesiredFailureMsg( |
| 6889 | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
| 6890 | "Layout for depth attachment is GENERAL but should be DEPTH_STENCIL_ATTACHMENT_OPTIMAL."); |
| 6891 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 6892 | m_errorMonitor->VerifyFound(); |
| 6893 | // error w/ non-ds opt or GENERAL layout for color attachment |
| 6894 | attach.layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; |
| 6895 | m_errorMonitor->SetDesiredFailureMsg( |
| 6896 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6897 | "Layout for depth attachment is VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL but can only be DEPTH_STENCIL_ATTACHMENT_OPTIMAL or GENERAL."); |
| 6898 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 6899 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | 1efce02 | 2016-05-11 10:40:34 -0600 | [diff] [blame] | 6900 | // For this error we need a valid renderpass so create default one |
| 6901 | attach.layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; |
| 6902 | attach.attachment = 0; |
| 6903 | attach_desc.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 6904 | attach_desc.samples = VK_SAMPLE_COUNT_1_BIT; |
| 6905 | attach_desc.storeOp = VK_ATTACHMENT_STORE_OP_STORE; |
| 6906 | attach_desc.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; |
| 6907 | attach_desc.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; |
| 6908 | // Can't do a CLEAR load on READ_ONLY initialLayout |
| 6909 | attach_desc.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; |
| 6910 | attach_desc.initialLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; |
| 6911 | attach_desc.finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 6912 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6913 | " with invalid first layout " |
| 6914 | "VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_" |
| 6915 | "ONLY_OPTIMAL"); |
| 6916 | vkCreateRenderPass(m_device->device(), &rpci, NULL, &rp); |
| 6917 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | c555a3c | 2016-05-04 14:08:34 -0600 | [diff] [blame] | 6918 | |
| 6919 | vkDestroyImage(m_device->device(), src_image, NULL); |
| 6920 | vkDestroyImage(m_device->device(), dst_image, NULL); |
| 6921 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6922 | #endif // DRAW_STATE_TESTS |
| 6923 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 6924 | #if THREADING_TESTS |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6925 | #if GTEST_IS_THREADSAFE |
| 6926 | struct thread_data_struct { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6927 | VkCommandBuffer commandBuffer; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6928 | VkEvent event; |
| 6929 | bool bailout; |
| 6930 | }; |
| 6931 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6932 | extern "C" void *AddToCommandBuffer(void *arg) { |
| 6933 | struct thread_data_struct *data = (struct thread_data_struct *)arg; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6934 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6935 | for (int i = 0; i < 10000; i++) { |
| 6936 | vkCmdSetEvent(data->commandBuffer, data->event, |
| 6937 | VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6938 | if (data->bailout) { |
| 6939 | break; |
| 6940 | } |
| 6941 | } |
| 6942 | return NULL; |
| 6943 | } |
| 6944 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6945 | TEST_F(VkLayerTest, ThreadCommandBufferCollision) { |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 6946 | test_platform_thread thread; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6947 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6948 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 6949 | "THREADING ERROR"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6950 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6951 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 6952 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 6953 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 6954 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6955 | // Calls AllocateCommandBuffers |
| 6956 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 6957 | |
| 6958 | // Avoid creating RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6959 | commandBuffer.BeginCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6960 | |
| 6961 | VkEventCreateInfo event_info; |
| 6962 | VkEvent event; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6963 | VkResult err; |
| 6964 | |
| 6965 | memset(&event_info, 0, sizeof(event_info)); |
| 6966 | event_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 6967 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6968 | err = vkCreateEvent(device(), &event_info, NULL, &event); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6969 | ASSERT_VK_SUCCESS(err); |
| 6970 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6971 | err = vkResetEvent(device(), event); |
| 6972 | ASSERT_VK_SUCCESS(err); |
| 6973 | |
| 6974 | struct thread_data_struct data; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6975 | data.commandBuffer = commandBuffer.GetBufferHandle(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6976 | data.event = event; |
| 6977 | data.bailout = false; |
| 6978 | m_errorMonitor->SetBailout(&data.bailout); |
| 6979 | // Add many entries to command buffer from another thread. |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 6980 | test_platform_thread_create(&thread, AddToCommandBuffer, (void *)&data); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6981 | // Add many entries to command buffer from this thread at the same time. |
| 6982 | AddToCommandBuffer(&data); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 6983 | |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 6984 | test_platform_thread_join(thread, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6985 | commandBuffer.EndCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6986 | |
Mike Stroyan | 10b8cb7 | 2016-01-22 15:22:03 -0700 | [diff] [blame] | 6987 | m_errorMonitor->SetBailout(NULL); |
| 6988 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 6989 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6990 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6991 | vkDestroyEvent(device(), event, NULL); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 6992 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 6993 | #endif // GTEST_IS_THREADSAFE |
| 6994 | #endif // THREADING_TESTS |
| 6995 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 6996 | #if SHADER_CHECKER_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 6997 | TEST_F(VkLayerTest, InvalidSPIRVCodeSize) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 6998 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 6999 | "Invalid SPIR-V header"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7000 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 7001 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7002 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7003 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 7004 | VkShaderModule module; |
| 7005 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 7006 | struct icd_spv_header spv; |
| 7007 | |
| 7008 | spv.magic = ICD_SPV_MAGIC; |
| 7009 | spv.version = ICD_SPV_VERSION; |
| 7010 | spv.gen_magic = 0; |
| 7011 | |
| 7012 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 7013 | moduleCreateInfo.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7014 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 7015 | moduleCreateInfo.codeSize = 4; |
| 7016 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7017 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 7018 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7019 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 7020 | } |
| 7021 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7022 | TEST_F(VkLayerTest, InvalidSPIRVMagic) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7023 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 7024 | "Invalid SPIR-V magic number"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7025 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 7026 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7027 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7028 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 7029 | VkShaderModule module; |
| 7030 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 7031 | struct icd_spv_header spv; |
| 7032 | |
| 7033 | spv.magic = ~ICD_SPV_MAGIC; |
| 7034 | spv.version = ICD_SPV_VERSION; |
| 7035 | spv.gen_magic = 0; |
| 7036 | |
| 7037 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 7038 | moduleCreateInfo.pNext = NULL; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7039 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 7040 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 7041 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7042 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 7043 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7044 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 7045 | } |
| 7046 | |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 7047 | #if 0 |
| 7048 | // Not currently covered by SPIRV-Tools validator |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7049 | TEST_F(VkLayerTest, InvalidSPIRVVersion) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7050 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 7051 | "Invalid SPIR-V header"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7052 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 7053 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7054 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7055 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 7056 | VkShaderModule module; |
| 7057 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 7058 | struct icd_spv_header spv; |
| 7059 | |
| 7060 | spv.magic = ICD_SPV_MAGIC; |
| 7061 | spv.version = ~ICD_SPV_VERSION; |
| 7062 | spv.gen_magic = 0; |
| 7063 | |
| 7064 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 7065 | moduleCreateInfo.pNext = NULL; |
| 7066 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7067 | moduleCreateInfo.pCode = (const uint32_t *)&spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 7068 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 7069 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 7070 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 7071 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7072 | m_errorMonitor->VerifyFound(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 7073 | } |
Chris Forbes | b4afd0f | 2016-04-04 10:48:35 +1200 | [diff] [blame] | 7074 | #endif |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 7075 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7076 | TEST_F(VkLayerTest, CreatePipelineVertexOutputNotConsumed) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 7077 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7078 | "not consumed by fragment shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7079 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 7080 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 7081 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 7082 | |
| 7083 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7084 | "#version 450\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 7085 | "\n" |
| 7086 | "layout(location=0) out float x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7087 | "out gl_PerVertex {\n" |
| 7088 | " vec4 gl_Position;\n" |
| 7089 | "};\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 7090 | "void main(){\n" |
| 7091 | " gl_Position = vec4(1);\n" |
| 7092 | " x = 0;\n" |
| 7093 | "}\n"; |
| 7094 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7095 | "#version 450\n" |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 7096 | "\n" |
| 7097 | "layout(location=0) out vec4 color;\n" |
| 7098 | "void main(){\n" |
| 7099 | " color = vec4(1);\n" |
| 7100 | "}\n"; |
| 7101 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 7102 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7103 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 7104 | |
| 7105 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 7106 | pipe.AddColorAttachment(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 7107 | pipe.AddShader(&vs); |
| 7108 | pipe.AddShader(&fs); |
| 7109 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 7110 | VkDescriptorSetObj descriptorSet(m_device); |
| 7111 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7112 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 7113 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 7114 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 7115 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7116 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 7117 | } |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 7118 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7119 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvided) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7120 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7121 | "not written by vertex shader"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7122 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 7123 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 7124 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 7125 | |
| 7126 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7127 | "#version 450\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 7128 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7129 | "out gl_PerVertex {\n" |
| 7130 | " vec4 gl_Position;\n" |
| 7131 | "};\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 7132 | "void main(){\n" |
| 7133 | " gl_Position = vec4(1);\n" |
| 7134 | "}\n"; |
| 7135 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7136 | "#version 450\n" |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 7137 | "\n" |
| 7138 | "layout(location=0) in float x;\n" |
| 7139 | "layout(location=0) out vec4 color;\n" |
| 7140 | "void main(){\n" |
| 7141 | " color = vec4(x);\n" |
| 7142 | "}\n"; |
| 7143 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 7144 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7145 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 7146 | |
| 7147 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 7148 | pipe.AddColorAttachment(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 7149 | pipe.AddShader(&vs); |
| 7150 | pipe.AddShader(&fs); |
| 7151 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 7152 | VkDescriptorSetObj descriptorSet(m_device); |
| 7153 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7154 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 7155 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 7156 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 7157 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7158 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 7159 | } |
| 7160 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7161 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvidedInBlock) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 7162 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7163 | "not written by vertex shader"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 7164 | |
| 7165 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7166 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7167 | |
| 7168 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7169 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 7170 | "\n" |
| 7171 | "out gl_PerVertex {\n" |
| 7172 | " vec4 gl_Position;\n" |
| 7173 | "};\n" |
| 7174 | "void main(){\n" |
| 7175 | " gl_Position = vec4(1);\n" |
| 7176 | "}\n"; |
| 7177 | char const *fsSource = |
| 7178 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 7179 | "\n" |
| 7180 | "in block { layout(location=0) float x; } ins;\n" |
| 7181 | "layout(location=0) out vec4 color;\n" |
| 7182 | "void main(){\n" |
| 7183 | " color = vec4(ins.x);\n" |
| 7184 | "}\n"; |
| 7185 | |
| 7186 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7187 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7188 | |
| 7189 | VkPipelineObj pipe(m_device); |
| 7190 | pipe.AddColorAttachment(); |
| 7191 | pipe.AddShader(&vs); |
| 7192 | pipe.AddShader(&fs); |
| 7193 | |
| 7194 | VkDescriptorSetObj descriptorSet(m_device); |
| 7195 | descriptorSet.AppendDummy(); |
| 7196 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7197 | |
| 7198 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7199 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7200 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 7201 | } |
| 7202 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7203 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchArraySize) { |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 7204 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 7205 | "Type mismatch on location 0.0: 'ptr to " |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7206 | "output arr[2] of float32' vs 'ptr to " |
| 7207 | "input arr[3] of float32'"); |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 7208 | |
| 7209 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7210 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7211 | |
| 7212 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7213 | "#version 450\n" |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 7214 | "\n" |
| 7215 | "layout(location=0) out float x[2];\n" |
| 7216 | "out gl_PerVertex {\n" |
| 7217 | " vec4 gl_Position;\n" |
| 7218 | "};\n" |
| 7219 | "void main(){\n" |
| 7220 | " x[0] = 0; x[1] = 0;\n" |
| 7221 | " gl_Position = vec4(1);\n" |
| 7222 | "}\n"; |
| 7223 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7224 | "#version 450\n" |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 7225 | "\n" |
| 7226 | "layout(location=0) in float x[3];\n" |
| 7227 | "layout(location=0) out vec4 color;\n" |
| 7228 | "void main(){\n" |
| 7229 | " color = vec4(x[0] + x[1] + x[2]);\n" |
| 7230 | "}\n"; |
| 7231 | |
| 7232 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7233 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7234 | |
| 7235 | VkPipelineObj pipe(m_device); |
| 7236 | pipe.AddColorAttachment(); |
| 7237 | pipe.AddShader(&vs); |
| 7238 | pipe.AddShader(&fs); |
| 7239 | |
| 7240 | VkDescriptorSetObj descriptorSet(m_device); |
| 7241 | descriptorSet.AppendDummy(); |
| 7242 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7243 | |
| 7244 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7245 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7246 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 0036fd1 | 2016-01-26 14:19:49 +1300 | [diff] [blame] | 7247 | } |
| 7248 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7249 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatch) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 7250 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7251 | "Type mismatch on location 0"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7252 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 7253 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 7254 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 7255 | |
| 7256 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7257 | "#version 450\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 7258 | "\n" |
| 7259 | "layout(location=0) out int x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7260 | "out gl_PerVertex {\n" |
| 7261 | " vec4 gl_Position;\n" |
| 7262 | "};\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 7263 | "void main(){\n" |
| 7264 | " x = 0;\n" |
| 7265 | " gl_Position = vec4(1);\n" |
| 7266 | "}\n"; |
| 7267 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7268 | "#version 450\n" |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 7269 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7270 | "layout(location=0) in float x;\n" /* VS writes int */ |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 7271 | "layout(location=0) out vec4 color;\n" |
| 7272 | "void main(){\n" |
| 7273 | " color = vec4(x);\n" |
| 7274 | "}\n"; |
| 7275 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 7276 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7277 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 7278 | |
| 7279 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 7280 | pipe.AddColorAttachment(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 7281 | pipe.AddShader(&vs); |
| 7282 | pipe.AddShader(&fs); |
| 7283 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 7284 | VkDescriptorSetObj descriptorSet(m_device); |
| 7285 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7286 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 7287 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 7288 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 7289 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7290 | m_errorMonitor->VerifyFound(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 7291 | } |
| 7292 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7293 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatchInBlock) { |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 7294 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7295 | "Type mismatch on location 0"); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 7296 | |
| 7297 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7298 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7299 | |
| 7300 | char const *vsSource = |
| 7301 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 7302 | "\n" |
| 7303 | "out block { layout(location=0) int x; } outs;\n" |
| 7304 | "out gl_PerVertex {\n" |
| 7305 | " vec4 gl_Position;\n" |
| 7306 | "};\n" |
| 7307 | "void main(){\n" |
| 7308 | " outs.x = 0;\n" |
| 7309 | " gl_Position = vec4(1);\n" |
| 7310 | "}\n"; |
| 7311 | char const *fsSource = |
| 7312 | "#version 450\n" |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 7313 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7314 | "in block { layout(location=0) float x; } ins;\n" /* VS writes int */ |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 7315 | "layout(location=0) out vec4 color;\n" |
| 7316 | "void main(){\n" |
| 7317 | " color = vec4(ins.x);\n" |
| 7318 | "}\n"; |
| 7319 | |
| 7320 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7321 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7322 | |
| 7323 | VkPipelineObj pipe(m_device); |
| 7324 | pipe.AddColorAttachment(); |
| 7325 | pipe.AddShader(&vs); |
| 7326 | pipe.AddShader(&fs); |
| 7327 | |
| 7328 | VkDescriptorSetObj descriptorSet(m_device); |
| 7329 | descriptorSet.AppendDummy(); |
| 7330 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7331 | |
| 7332 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7333 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7334 | m_errorMonitor->VerifyFound(); |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 7335 | } |
| 7336 | |
| 7337 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByLocation) { |
| 7338 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7339 | "location 0.0 which is not written by vertex shader"); |
| 7340 | |
| 7341 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7342 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7343 | |
| 7344 | char const *vsSource = |
| 7345 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 7346 | "\n" |
| 7347 | "out block { layout(location=1) float x; } outs;\n" |
| 7348 | "out gl_PerVertex {\n" |
| 7349 | " vec4 gl_Position;\n" |
| 7350 | "};\n" |
| 7351 | "void main(){\n" |
| 7352 | " outs.x = 0;\n" |
| 7353 | " gl_Position = vec4(1);\n" |
| 7354 | "}\n"; |
| 7355 | char const *fsSource = |
| 7356 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 7357 | "\n" |
| 7358 | "in block { layout(location=0) float x; } ins;\n" |
| 7359 | "layout(location=0) out vec4 color;\n" |
| 7360 | "void main(){\n" |
| 7361 | " color = vec4(ins.x);\n" |
| 7362 | "}\n"; |
| 7363 | |
| 7364 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7365 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7366 | |
| 7367 | VkPipelineObj pipe(m_device); |
| 7368 | pipe.AddColorAttachment(); |
| 7369 | pipe.AddShader(&vs); |
| 7370 | pipe.AddShader(&fs); |
| 7371 | |
| 7372 | VkDescriptorSetObj descriptorSet(m_device); |
| 7373 | descriptorSet.AppendDummy(); |
| 7374 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7375 | |
| 7376 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7377 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7378 | m_errorMonitor->VerifyFound(); |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 7379 | } |
| 7380 | |
| 7381 | TEST_F(VkLayerTest, CreatePipelineVsFsMismatchByComponent) { |
| 7382 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7383 | "location 0.1 which is not written by vertex shader"); |
| 7384 | |
| 7385 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7386 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7387 | |
| 7388 | char const *vsSource = |
| 7389 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 7390 | "\n" |
| 7391 | "out block { layout(location=0, component=0) float x; } outs;\n" |
| 7392 | "out gl_PerVertex {\n" |
| 7393 | " vec4 gl_Position;\n" |
| 7394 | "};\n" |
| 7395 | "void main(){\n" |
| 7396 | " outs.x = 0;\n" |
| 7397 | " gl_Position = vec4(1);\n" |
| 7398 | "}\n"; |
| 7399 | char const *fsSource = |
| 7400 | "#version 450\n" |
Chris Forbes | e992882 | 2016-02-17 14:44:52 +1300 | [diff] [blame] | 7401 | "\n" |
| 7402 | "in block { layout(location=0, component=1) float x; } ins;\n" |
| 7403 | "layout(location=0) out vec4 color;\n" |
| 7404 | "void main(){\n" |
| 7405 | " color = vec4(ins.x);\n" |
| 7406 | "}\n"; |
| 7407 | |
| 7408 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7409 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7410 | |
| 7411 | VkPipelineObj pipe(m_device); |
| 7412 | pipe.AddColorAttachment(); |
| 7413 | pipe.AddShader(&vs); |
| 7414 | pipe.AddShader(&fs); |
| 7415 | |
| 7416 | VkDescriptorSetObj descriptorSet(m_device); |
| 7417 | descriptorSet.AppendDummy(); |
| 7418 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7419 | |
| 7420 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7421 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7422 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a3e85f6 | 2016-01-15 14:53:11 +1300 | [diff] [blame] | 7423 | } |
| 7424 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7425 | TEST_F(VkLayerTest, CreatePipelineAttribNotConsumed) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 7426 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7427 | "location 0 not consumed by VS"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7428 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7429 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 7430 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7431 | |
| 7432 | VkVertexInputBindingDescription input_binding; |
| 7433 | memset(&input_binding, 0, sizeof(input_binding)); |
| 7434 | |
| 7435 | VkVertexInputAttributeDescription input_attrib; |
| 7436 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 7437 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 7438 | |
| 7439 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7440 | "#version 450\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7441 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7442 | "out gl_PerVertex {\n" |
| 7443 | " vec4 gl_Position;\n" |
| 7444 | "};\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7445 | "void main(){\n" |
| 7446 | " gl_Position = vec4(1);\n" |
| 7447 | "}\n"; |
| 7448 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7449 | "#version 450\n" |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7450 | "\n" |
| 7451 | "layout(location=0) out vec4 color;\n" |
| 7452 | "void main(){\n" |
| 7453 | " color = vec4(1);\n" |
| 7454 | "}\n"; |
| 7455 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 7456 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7457 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7458 | |
| 7459 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 7460 | pipe.AddColorAttachment(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7461 | pipe.AddShader(&vs); |
| 7462 | pipe.AddShader(&fs); |
| 7463 | |
| 7464 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 7465 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 7466 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7467 | VkDescriptorSetObj descriptorSet(m_device); |
| 7468 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7469 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7470 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 7471 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7472 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7473 | m_errorMonitor->VerifyFound(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 7474 | } |
| 7475 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7476 | TEST_F(VkLayerTest, CreatePipelineAttribLocationMismatch) { |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 7477 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7478 | "location 0 not consumed by VS"); |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 7479 | |
| 7480 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7481 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7482 | |
| 7483 | VkVertexInputBindingDescription input_binding; |
| 7484 | memset(&input_binding, 0, sizeof(input_binding)); |
| 7485 | |
| 7486 | VkVertexInputAttributeDescription input_attrib; |
| 7487 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 7488 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 7489 | |
| 7490 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7491 | "#version 450\n" |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 7492 | "\n" |
| 7493 | "layout(location=1) in float x;\n" |
| 7494 | "out gl_PerVertex {\n" |
| 7495 | " vec4 gl_Position;\n" |
| 7496 | "};\n" |
| 7497 | "void main(){\n" |
| 7498 | " gl_Position = vec4(x);\n" |
| 7499 | "}\n"; |
| 7500 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7501 | "#version 450\n" |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 7502 | "\n" |
| 7503 | "layout(location=0) out vec4 color;\n" |
| 7504 | "void main(){\n" |
| 7505 | " color = vec4(1);\n" |
| 7506 | "}\n"; |
| 7507 | |
| 7508 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7509 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7510 | |
| 7511 | VkPipelineObj pipe(m_device); |
| 7512 | pipe.AddColorAttachment(); |
| 7513 | pipe.AddShader(&vs); |
| 7514 | pipe.AddShader(&fs); |
| 7515 | |
| 7516 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 7517 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 7518 | |
| 7519 | VkDescriptorSetObj descriptorSet(m_device); |
| 7520 | descriptorSet.AppendDummy(); |
| 7521 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7522 | |
| 7523 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7524 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7525 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 7d83cd5 | 2016-01-15 11:32:03 +1300 | [diff] [blame] | 7526 | } |
| 7527 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7528 | TEST_F(VkLayerTest, CreatePipelineAttribNotProvided) { |
| 7529 | m_errorMonitor->SetDesiredFailureMsg( |
| 7530 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7531 | "VS consumes input at location 0 but not provided"); |
| 7532 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7533 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 7534 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7535 | |
| 7536 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7537 | "#version 450\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7538 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7539 | "layout(location=0) in vec4 x;\n" /* not provided */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7540 | "out gl_PerVertex {\n" |
| 7541 | " vec4 gl_Position;\n" |
| 7542 | "};\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7543 | "void main(){\n" |
| 7544 | " gl_Position = x;\n" |
| 7545 | "}\n"; |
| 7546 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7547 | "#version 450\n" |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7548 | "\n" |
| 7549 | "layout(location=0) out vec4 color;\n" |
| 7550 | "void main(){\n" |
| 7551 | " color = vec4(1);\n" |
| 7552 | "}\n"; |
| 7553 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 7554 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7555 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7556 | |
| 7557 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 7558 | pipe.AddColorAttachment(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7559 | pipe.AddShader(&vs); |
| 7560 | pipe.AddShader(&fs); |
| 7561 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7562 | VkDescriptorSetObj descriptorSet(m_device); |
| 7563 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7564 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7565 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 7566 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7567 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7568 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 7569 | } |
| 7570 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7571 | TEST_F(VkLayerTest, CreatePipelineAttribTypeMismatch) { |
| 7572 | m_errorMonitor->SetDesiredFailureMsg( |
| 7573 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 7574 | "location 0 does not match VS input type"); |
| 7575 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7576 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 7577 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7578 | |
| 7579 | VkVertexInputBindingDescription input_binding; |
| 7580 | memset(&input_binding, 0, sizeof(input_binding)); |
| 7581 | |
| 7582 | VkVertexInputAttributeDescription input_attrib; |
| 7583 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 7584 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 7585 | |
| 7586 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7587 | "#version 450\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7588 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7589 | "layout(location=0) in int x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7590 | "out gl_PerVertex {\n" |
| 7591 | " vec4 gl_Position;\n" |
| 7592 | "};\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7593 | "void main(){\n" |
| 7594 | " gl_Position = vec4(x);\n" |
| 7595 | "}\n"; |
| 7596 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7597 | "#version 450\n" |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7598 | "\n" |
| 7599 | "layout(location=0) out vec4 color;\n" |
| 7600 | "void main(){\n" |
| 7601 | " color = vec4(1);\n" |
| 7602 | "}\n"; |
| 7603 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 7604 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7605 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7606 | |
| 7607 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 7608 | pipe.AddColorAttachment(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7609 | pipe.AddShader(&vs); |
| 7610 | pipe.AddShader(&fs); |
| 7611 | |
| 7612 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 7613 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 7614 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7615 | VkDescriptorSetObj descriptorSet(m_device); |
| 7616 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 7617 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7618 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 7619 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7620 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7621 | m_errorMonitor->VerifyFound(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 7622 | } |
| 7623 | |
Chris Forbes | c68b43c | 2016-04-06 11:18:47 +1200 | [diff] [blame] | 7624 | TEST_F(VkLayerTest, CreatePipelineDuplicateStage) { |
| 7625 | m_errorMonitor->SetDesiredFailureMsg( |
| 7626 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 7627 | "Multiple shaders provided for stage VK_SHADER_STAGE_VERTEX_BIT"); |
| 7628 | |
| 7629 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7630 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7631 | |
| 7632 | char const *vsSource = |
| 7633 | "#version 450\n" |
| 7634 | "\n" |
| 7635 | "out gl_PerVertex {\n" |
| 7636 | " vec4 gl_Position;\n" |
| 7637 | "};\n" |
| 7638 | "void main(){\n" |
| 7639 | " gl_Position = vec4(1);\n" |
| 7640 | "}\n"; |
| 7641 | char const *fsSource = |
| 7642 | "#version 450\n" |
| 7643 | "\n" |
| 7644 | "layout(location=0) out vec4 color;\n" |
| 7645 | "void main(){\n" |
| 7646 | " color = vec4(1);\n" |
| 7647 | "}\n"; |
| 7648 | |
| 7649 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7650 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7651 | |
| 7652 | VkPipelineObj pipe(m_device); |
| 7653 | pipe.AddColorAttachment(); |
| 7654 | pipe.AddShader(&vs); |
| 7655 | pipe.AddShader(&vs); |
| 7656 | pipe.AddShader(&fs); |
| 7657 | |
| 7658 | VkDescriptorSetObj descriptorSet(m_device); |
| 7659 | descriptorSet.AppendDummy(); |
| 7660 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7661 | |
| 7662 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7663 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7664 | m_errorMonitor->VerifyFound(); |
Chris Forbes | c68b43c | 2016-04-06 11:18:47 +1200 | [diff] [blame] | 7665 | } |
| 7666 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 7667 | TEST_F(VkLayerTest, CreatePipelineAttribMatrixType) { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7668 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7669 | |
| 7670 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7671 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7672 | |
| 7673 | VkVertexInputBindingDescription input_binding; |
| 7674 | memset(&input_binding, 0, sizeof(input_binding)); |
| 7675 | |
| 7676 | VkVertexInputAttributeDescription input_attribs[2]; |
| 7677 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 7678 | |
| 7679 | for (int i = 0; i < 2; i++) { |
| 7680 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 7681 | input_attribs[i].location = i; |
| 7682 | } |
| 7683 | |
| 7684 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7685 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7686 | "\n" |
| 7687 | "layout(location=0) in mat2x4 x;\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7688 | "out gl_PerVertex {\n" |
| 7689 | " vec4 gl_Position;\n" |
| 7690 | "};\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7691 | "void main(){\n" |
| 7692 | " gl_Position = x[0] + x[1];\n" |
| 7693 | "}\n"; |
| 7694 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7695 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7696 | "\n" |
| 7697 | "layout(location=0) out vec4 color;\n" |
| 7698 | "void main(){\n" |
| 7699 | " color = vec4(1);\n" |
| 7700 | "}\n"; |
| 7701 | |
| 7702 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7703 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7704 | |
| 7705 | VkPipelineObj pipe(m_device); |
| 7706 | pipe.AddColorAttachment(); |
| 7707 | pipe.AddShader(&vs); |
| 7708 | pipe.AddShader(&fs); |
| 7709 | |
| 7710 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 7711 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 7712 | |
| 7713 | VkDescriptorSetObj descriptorSet(m_device); |
| 7714 | descriptorSet.AppendDummy(); |
| 7715 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7716 | |
| 7717 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7718 | |
| 7719 | /* expect success */ |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7720 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7721 | } |
| 7722 | |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7723 | TEST_F(VkLayerTest, CreatePipelineAttribArrayType) |
| 7724 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7725 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7726 | |
| 7727 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7728 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7729 | |
| 7730 | VkVertexInputBindingDescription input_binding; |
| 7731 | memset(&input_binding, 0, sizeof(input_binding)); |
| 7732 | |
| 7733 | VkVertexInputAttributeDescription input_attribs[2]; |
| 7734 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 7735 | |
| 7736 | for (int i = 0; i < 2; i++) { |
| 7737 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 7738 | input_attribs[i].location = i; |
| 7739 | } |
| 7740 | |
| 7741 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7742 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7743 | "\n" |
| 7744 | "layout(location=0) in vec4 x[2];\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 7745 | "out gl_PerVertex {\n" |
| 7746 | " vec4 gl_Position;\n" |
| 7747 | "};\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7748 | "void main(){\n" |
| 7749 | " gl_Position = x[0] + x[1];\n" |
| 7750 | "}\n"; |
| 7751 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 7752 | "#version 450\n" |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7753 | "\n" |
| 7754 | "layout(location=0) out vec4 color;\n" |
| 7755 | "void main(){\n" |
| 7756 | " color = vec4(1);\n" |
| 7757 | "}\n"; |
| 7758 | |
| 7759 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7760 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7761 | |
| 7762 | VkPipelineObj pipe(m_device); |
| 7763 | pipe.AddColorAttachment(); |
| 7764 | pipe.AddShader(&vs); |
| 7765 | pipe.AddShader(&fs); |
| 7766 | |
| 7767 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 7768 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 7769 | |
| 7770 | VkDescriptorSetObj descriptorSet(m_device); |
| 7771 | descriptorSet.AppendDummy(); |
| 7772 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7773 | |
| 7774 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7775 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7776 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7777 | } |
Chris Forbes | 2682b24 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 7778 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7779 | TEST_F(VkLayerTest, CreatePipelineSimplePositive) |
| 7780 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7781 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7782 | |
| 7783 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7784 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7785 | |
| 7786 | char const *vsSource = |
| 7787 | "#version 450\n" |
| 7788 | "out gl_PerVertex {\n" |
| 7789 | " vec4 gl_Position;\n" |
| 7790 | "};\n" |
| 7791 | "void main(){\n" |
| 7792 | " gl_Position = vec4(0);\n" |
| 7793 | "}\n"; |
| 7794 | char const *fsSource = |
| 7795 | "#version 450\n" |
| 7796 | "\n" |
| 7797 | "layout(location=0) out vec4 color;\n" |
| 7798 | "void main(){\n" |
| 7799 | " color = vec4(1);\n" |
| 7800 | "}\n"; |
| 7801 | |
| 7802 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7803 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7804 | |
| 7805 | VkPipelineObj pipe(m_device); |
| 7806 | pipe.AddColorAttachment(); |
| 7807 | pipe.AddShader(&vs); |
| 7808 | pipe.AddShader(&fs); |
| 7809 | |
| 7810 | VkDescriptorSetObj descriptorSet(m_device); |
| 7811 | descriptorSet.AppendDummy(); |
| 7812 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7813 | |
| 7814 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7815 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7816 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7817 | } |
| 7818 | |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 7819 | TEST_F(VkLayerTest, CreatePipelineRelaxedTypeMatch) |
| 7820 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7821 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 7822 | |
| 7823 | // VK 1.0.8 Specification, 14.1.3 "Additionally,..." block |
| 7824 | |
| 7825 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7826 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7827 | |
| 7828 | char const *vsSource = |
| 7829 | "#version 450\n" |
| 7830 | "out gl_PerVertex {\n" |
| 7831 | " vec4 gl_Position;\n" |
| 7832 | "};\n" |
| 7833 | "layout(location=0) out vec3 x;\n" |
| 7834 | "layout(location=1) out ivec3 y;\n" |
| 7835 | "layout(location=2) out vec3 z;\n" |
| 7836 | "void main(){\n" |
| 7837 | " gl_Position = vec4(0);\n" |
| 7838 | " x = vec3(0); y = ivec3(0); z = vec3(0);\n" |
| 7839 | "}\n"; |
| 7840 | char const *fsSource = |
| 7841 | "#version 450\n" |
| 7842 | "\n" |
| 7843 | "layout(location=0) out vec4 color;\n" |
| 7844 | "layout(location=0) in float x;\n" |
| 7845 | "layout(location=1) flat in int y;\n" |
| 7846 | "layout(location=2) in vec2 z;\n" |
| 7847 | "void main(){\n" |
| 7848 | " color = vec4(1 + x + y + z.x);\n" |
| 7849 | "}\n"; |
| 7850 | |
| 7851 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7852 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7853 | |
| 7854 | VkPipelineObj pipe(m_device); |
| 7855 | pipe.AddColorAttachment(); |
| 7856 | pipe.AddShader(&vs); |
| 7857 | pipe.AddShader(&fs); |
| 7858 | |
| 7859 | VkDescriptorSetObj descriptorSet(m_device); |
| 7860 | descriptorSet.AppendDummy(); |
| 7861 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7862 | |
| 7863 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7864 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7865 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 912c919 | 2016-04-05 17:50:35 +1200 | [diff] [blame] | 7866 | } |
| 7867 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7868 | TEST_F(VkLayerTest, CreatePipelineTessPerVertex) |
| 7869 | { |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7870 | m_errorMonitor->ExpectSuccess(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7871 | |
| 7872 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7873 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7874 | |
Chris Forbes | c1e852d | 2016-04-04 19:26:42 +1200 | [diff] [blame] | 7875 | if (!m_device->phy().features().tessellationShader) { |
| 7876 | printf("Device does not support tessellation shaders; skipped.\n"); |
| 7877 | return; |
| 7878 | } |
| 7879 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7880 | char const *vsSource = |
| 7881 | "#version 450\n" |
| 7882 | "void main(){}\n"; |
| 7883 | char const *tcsSource = |
| 7884 | "#version 450\n" |
| 7885 | "layout(location=0) out int x[];\n" |
| 7886 | "layout(vertices=3) out;\n" |
| 7887 | "void main(){\n" |
| 7888 | " gl_TessLevelOuter[0] = gl_TessLevelOuter[1] = gl_TessLevelOuter[2] = 1;\n" |
| 7889 | " gl_TessLevelInner[0] = 1;\n" |
| 7890 | " x[gl_InvocationID] = gl_InvocationID;\n" |
| 7891 | "}\n"; |
| 7892 | char const *tesSource = |
| 7893 | "#version 450\n" |
| 7894 | "layout(triangles, equal_spacing, cw) in;\n" |
| 7895 | "layout(location=0) in int x[];\n" |
| 7896 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 7897 | "void main(){\n" |
| 7898 | " gl_Position.xyz = gl_TessCoord;\n" |
| 7899 | " gl_Position.w = x[0] + x[1] + x[2];\n" |
| 7900 | "}\n"; |
| 7901 | char const *fsSource = |
| 7902 | "#version 450\n" |
| 7903 | "layout(location=0) out vec4 color;\n" |
| 7904 | "void main(){\n" |
| 7905 | " color = vec4(1);\n" |
| 7906 | "}\n"; |
| 7907 | |
| 7908 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7909 | VkShaderObj tcs(m_device, tcsSource, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 7910 | VkShaderObj tes(m_device, tesSource, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
| 7911 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7912 | |
| 7913 | VkPipelineInputAssemblyStateCreateInfo iasci{ |
| 7914 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, |
| 7915 | nullptr, |
| 7916 | 0, |
| 7917 | VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, |
| 7918 | VK_FALSE}; |
| 7919 | |
Chris Forbes | b4cacb6 | 2016-04-04 19:15:00 +1200 | [diff] [blame] | 7920 | VkPipelineTessellationStateCreateInfo tsci{ |
| 7921 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, |
| 7922 | nullptr, |
| 7923 | 0, |
| 7924 | 3}; |
| 7925 | |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7926 | VkPipelineObj pipe(m_device); |
| 7927 | pipe.SetInputAssembly(&iasci); |
Chris Forbes | b4cacb6 | 2016-04-04 19:15:00 +1200 | [diff] [blame] | 7928 | pipe.SetTessellation(&tsci); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7929 | pipe.AddColorAttachment(); |
| 7930 | pipe.AddShader(&vs); |
| 7931 | pipe.AddShader(&tcs); |
| 7932 | pipe.AddShader(&tes); |
| 7933 | pipe.AddShader(&fs); |
| 7934 | |
| 7935 | VkDescriptorSetObj descriptorSet(m_device); |
| 7936 | descriptorSet.AppendDummy(); |
| 7937 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7938 | |
| 7939 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7940 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 7941 | m_errorMonitor->VerifyNotFound(); |
Chris Forbes | 4ea14fc | 2016-04-04 18:52:54 +1200 | [diff] [blame] | 7942 | } |
| 7943 | |
Chris Forbes | a0ab815 | 2016-04-20 13:34:27 +1200 | [diff] [blame] | 7944 | TEST_F(VkLayerTest, CreatePipelineGeometryInputBlockPositive) |
| 7945 | { |
| 7946 | m_errorMonitor->ExpectSuccess(); |
| 7947 | |
| 7948 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 7949 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 7950 | |
| 7951 | if (!m_device->phy().features().geometryShader) { |
| 7952 | printf("Device does not support geometry shaders; skipped.\n"); |
| 7953 | return; |
| 7954 | } |
| 7955 | |
| 7956 | char const *vsSource = |
| 7957 | "#version 450\n" |
| 7958 | "layout(location=0) out VertexData { vec4 x; } vs_out;\n" |
| 7959 | "void main(){\n" |
| 7960 | " vs_out.x = vec4(1);\n" |
| 7961 | "}\n"; |
| 7962 | char const *gsSource = |
| 7963 | "#version 450\n" |
| 7964 | "layout(triangles) in;\n" |
| 7965 | "layout(triangle_strip, max_vertices=3) out;\n" |
| 7966 | "layout(location=0) in VertexData { vec4 x; } gs_in[];\n" |
| 7967 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 7968 | "void main() {\n" |
| 7969 | " gl_Position = gs_in[0].x;\n" |
| 7970 | " EmitVertex();\n" |
| 7971 | "}\n"; |
| 7972 | char const *fsSource = |
| 7973 | "#version 450\n" |
| 7974 | "layout(location=0) out vec4 color;\n" |
| 7975 | "void main(){\n" |
| 7976 | " color = vec4(1);\n" |
| 7977 | "}\n"; |
| 7978 | |
| 7979 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 7980 | VkShaderObj gs(m_device, gsSource, VK_SHADER_STAGE_GEOMETRY_BIT, this); |
| 7981 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 7982 | |
| 7983 | VkPipelineObj pipe(m_device); |
| 7984 | pipe.AddColorAttachment(); |
| 7985 | pipe.AddShader(&vs); |
| 7986 | pipe.AddShader(&gs); |
| 7987 | pipe.AddShader(&fs); |
| 7988 | |
| 7989 | VkDescriptorSetObj descriptorSet(m_device); |
| 7990 | descriptorSet.AppendDummy(); |
| 7991 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 7992 | |
| 7993 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 7994 | |
| 7995 | m_errorMonitor->VerifyNotFound(); |
| 7996 | } |
| 7997 | |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 7998 | TEST_F(VkLayerTest, CreatePipelineTessPatchDecorationMismatch) |
| 7999 | { |
| 8000 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8001 | "is per-vertex in tessellation control shader stage " |
| 8002 | "but per-patch in tessellation evaluation shader stage"); |
| 8003 | |
| 8004 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8005 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8006 | |
Chris Forbes | c1e852d | 2016-04-04 19:26:42 +1200 | [diff] [blame] | 8007 | if (!m_device->phy().features().tessellationShader) { |
| 8008 | printf("Device does not support tessellation shaders; skipped.\n"); |
| 8009 | return; |
| 8010 | } |
| 8011 | |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 8012 | char const *vsSource = |
| 8013 | "#version 450\n" |
| 8014 | "void main(){}\n"; |
| 8015 | char const *tcsSource = |
| 8016 | "#version 450\n" |
| 8017 | "layout(location=0) out int x[];\n" |
| 8018 | "layout(vertices=3) out;\n" |
| 8019 | "void main(){\n" |
| 8020 | " gl_TessLevelOuter[0] = gl_TessLevelOuter[1] = gl_TessLevelOuter[2] = 1;\n" |
| 8021 | " gl_TessLevelInner[0] = 1;\n" |
| 8022 | " x[gl_InvocationID] = gl_InvocationID;\n" |
| 8023 | "}\n"; |
| 8024 | char const *tesSource = |
| 8025 | "#version 450\n" |
| 8026 | "layout(triangles, equal_spacing, cw) in;\n" |
| 8027 | "layout(location=0) patch in int x;\n" |
| 8028 | "out gl_PerVertex { vec4 gl_Position; };\n" |
| 8029 | "void main(){\n" |
| 8030 | " gl_Position.xyz = gl_TessCoord;\n" |
| 8031 | " gl_Position.w = x;\n" |
| 8032 | "}\n"; |
| 8033 | char const *fsSource = |
| 8034 | "#version 450\n" |
| 8035 | "layout(location=0) out vec4 color;\n" |
| 8036 | "void main(){\n" |
| 8037 | " color = vec4(1);\n" |
| 8038 | "}\n"; |
| 8039 | |
| 8040 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8041 | VkShaderObj tcs(m_device, tcsSource, VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 8042 | VkShaderObj tes(m_device, tesSource, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
| 8043 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8044 | |
| 8045 | VkPipelineInputAssemblyStateCreateInfo iasci{ |
| 8046 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, |
| 8047 | nullptr, |
| 8048 | 0, |
| 8049 | VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, |
| 8050 | VK_FALSE}; |
| 8051 | |
| 8052 | VkPipelineTessellationStateCreateInfo tsci{ |
| 8053 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, |
| 8054 | nullptr, |
| 8055 | 0, |
| 8056 | 3}; |
| 8057 | |
| 8058 | VkPipelineObj pipe(m_device); |
| 8059 | pipe.SetInputAssembly(&iasci); |
| 8060 | pipe.SetTessellation(&tsci); |
| 8061 | pipe.AddColorAttachment(); |
| 8062 | pipe.AddShader(&vs); |
| 8063 | pipe.AddShader(&tcs); |
| 8064 | pipe.AddShader(&tes); |
| 8065 | pipe.AddShader(&fs); |
| 8066 | |
| 8067 | VkDescriptorSetObj descriptorSet(m_device); |
| 8068 | descriptorSet.AppendDummy(); |
| 8069 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8070 | |
| 8071 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8072 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8073 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a0193bc | 2016-04-04 19:19:47 +1200 | [diff] [blame] | 8074 | } |
| 8075 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8076 | TEST_F(VkLayerTest, CreatePipelineAttribBindingConflict) { |
| 8077 | m_errorMonitor->SetDesiredFailureMsg( |
| 8078 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8079 | "Duplicate vertex input binding descriptions for binding 0"); |
| 8080 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 8081 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 8082 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 8083 | |
| 8084 | /* Two binding descriptions for binding 0 */ |
| 8085 | VkVertexInputBindingDescription input_bindings[2]; |
| 8086 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 8087 | |
| 8088 | VkVertexInputAttributeDescription input_attrib; |
| 8089 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 8090 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 8091 | |
| 8092 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8093 | "#version 450\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 8094 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8095 | "layout(location=0) in float x;\n" /* attrib provided float */ |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8096 | "out gl_PerVertex {\n" |
| 8097 | " vec4 gl_Position;\n" |
| 8098 | "};\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 8099 | "void main(){\n" |
| 8100 | " gl_Position = vec4(x);\n" |
| 8101 | "}\n"; |
| 8102 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8103 | "#version 450\n" |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 8104 | "\n" |
| 8105 | "layout(location=0) out vec4 color;\n" |
| 8106 | "void main(){\n" |
| 8107 | " color = vec4(1);\n" |
| 8108 | "}\n"; |
| 8109 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8110 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8111 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 8112 | |
| 8113 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 8114 | pipe.AddColorAttachment(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 8115 | pipe.AddShader(&vs); |
| 8116 | pipe.AddShader(&fs); |
| 8117 | |
| 8118 | pipe.AddVertexInputBindings(input_bindings, 2); |
| 8119 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 8120 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 8121 | VkDescriptorSetObj descriptorSet(m_device); |
| 8122 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8123 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 8124 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 8125 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 8126 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8127 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 8128 | } |
Chris Forbes | 8f68b56 | 2015-05-25 11:13:32 +1200 | [diff] [blame] | 8129 | |
Chris Forbes | 35efec7 | 2016-04-21 14:32:08 +1200 | [diff] [blame] | 8130 | TEST_F(VkLayerTest, CreatePipeline64BitAttributesPositive) { |
| 8131 | m_errorMonitor->ExpectSuccess(); |
| 8132 | |
| 8133 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8134 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8135 | |
| 8136 | if (!m_device->phy().features().tessellationShader) { |
| 8137 | printf("Device does not support 64bit vertex attributes; skipped.\n"); |
| 8138 | return; |
| 8139 | } |
| 8140 | |
| 8141 | VkVertexInputBindingDescription input_bindings[1]; |
| 8142 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 8143 | |
| 8144 | VkVertexInputAttributeDescription input_attribs[4]; |
| 8145 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 8146 | input_attribs[0].location = 0; |
| 8147 | input_attribs[0].offset = 0; |
| 8148 | input_attribs[0].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 8149 | input_attribs[1].location = 2; |
| 8150 | input_attribs[1].offset = 32; |
| 8151 | input_attribs[1].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 8152 | input_attribs[2].location = 4; |
| 8153 | input_attribs[2].offset = 64; |
| 8154 | input_attribs[2].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 8155 | input_attribs[3].location = 6; |
| 8156 | input_attribs[3].offset = 96; |
| 8157 | input_attribs[3].format = VK_FORMAT_R64G64B64A64_SFLOAT; |
| 8158 | |
| 8159 | char const *vsSource = |
| 8160 | "#version 450\n" |
| 8161 | "\n" |
| 8162 | "layout(location=0) in dmat4 x;\n" |
| 8163 | "out gl_PerVertex {\n" |
| 8164 | " vec4 gl_Position;\n" |
| 8165 | "};\n" |
| 8166 | "void main(){\n" |
| 8167 | " gl_Position = vec4(x[0][0]);\n" |
| 8168 | "}\n"; |
| 8169 | char const *fsSource = |
| 8170 | "#version 450\n" |
| 8171 | "\n" |
| 8172 | "layout(location=0) out vec4 color;\n" |
| 8173 | "void main(){\n" |
| 8174 | " color = vec4(1);\n" |
| 8175 | "}\n"; |
| 8176 | |
| 8177 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8178 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8179 | |
| 8180 | VkPipelineObj pipe(m_device); |
| 8181 | pipe.AddColorAttachment(); |
| 8182 | pipe.AddShader(&vs); |
| 8183 | pipe.AddShader(&fs); |
| 8184 | |
| 8185 | pipe.AddVertexInputBindings(input_bindings, 1); |
| 8186 | pipe.AddVertexInputAttribs(input_attribs, 4); |
| 8187 | |
| 8188 | VkDescriptorSetObj descriptorSet(m_device); |
| 8189 | descriptorSet.AppendDummy(); |
| 8190 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8191 | |
| 8192 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8193 | |
| 8194 | m_errorMonitor->VerifyNotFound(); |
| 8195 | } |
| 8196 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8197 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotWritten) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8198 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8199 | "Attachment 0 not written by FS"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8200 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 8201 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 8202 | |
| 8203 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8204 | "#version 450\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 8205 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8206 | "out gl_PerVertex {\n" |
| 8207 | " vec4 gl_Position;\n" |
| 8208 | "};\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 8209 | "void main(){\n" |
| 8210 | " gl_Position = vec4(1);\n" |
| 8211 | "}\n"; |
| 8212 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8213 | "#version 450\n" |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 8214 | "\n" |
| 8215 | "void main(){\n" |
| 8216 | "}\n"; |
| 8217 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8218 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8219 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 8220 | |
| 8221 | VkPipelineObj pipe(m_device); |
| 8222 | pipe.AddShader(&vs); |
| 8223 | pipe.AddShader(&fs); |
| 8224 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 8225 | /* set up CB 0, not written */ |
| 8226 | pipe.AddColorAttachment(); |
| 8227 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 8228 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 8229 | VkDescriptorSetObj descriptorSet(m_device); |
| 8230 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8231 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 8232 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 8233 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 8234 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8235 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 8236 | } |
| 8237 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8238 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotConsumed) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8239 | m_errorMonitor->SetDesiredFailureMsg( |
Mark Lobodzinski | 510e20d | 2016-02-11 09:26:16 -0700 | [diff] [blame] | 8240 | VK_DEBUG_REPORT_WARNING_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8241 | "FS writes to output location 1 with no matching attachment"); |
| 8242 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 8243 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 8244 | |
| 8245 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8246 | "#version 450\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 8247 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8248 | "out gl_PerVertex {\n" |
| 8249 | " vec4 gl_Position;\n" |
| 8250 | "};\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 8251 | "void main(){\n" |
| 8252 | " gl_Position = vec4(1);\n" |
| 8253 | "}\n"; |
| 8254 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8255 | "#version 450\n" |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 8256 | "\n" |
| 8257 | "layout(location=0) out vec4 x;\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8258 | "layout(location=1) out vec4 y;\n" /* no matching attachment for this */ |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 8259 | "void main(){\n" |
| 8260 | " x = vec4(1);\n" |
| 8261 | " y = vec4(1);\n" |
| 8262 | "}\n"; |
| 8263 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8264 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8265 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 8266 | |
| 8267 | VkPipelineObj pipe(m_device); |
| 8268 | pipe.AddShader(&vs); |
| 8269 | pipe.AddShader(&fs); |
| 8270 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 8271 | /* set up CB 0, not written */ |
| 8272 | pipe.AddColorAttachment(); |
| 8273 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 8274 | /* FS writes CB 1, but we don't configure it */ |
| 8275 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 8276 | VkDescriptorSetObj descriptorSet(m_device); |
| 8277 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8278 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 8279 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 8280 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 8281 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8282 | m_errorMonitor->VerifyFound(); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 8283 | } |
| 8284 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8285 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputTypeMismatch) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8286 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8287 | "does not match FS output type"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8288 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 8289 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 8290 | |
| 8291 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8292 | "#version 450\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 8293 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8294 | "out gl_PerVertex {\n" |
| 8295 | " vec4 gl_Position;\n" |
| 8296 | "};\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 8297 | "void main(){\n" |
| 8298 | " gl_Position = vec4(1);\n" |
| 8299 | "}\n"; |
| 8300 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8301 | "#version 450\n" |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 8302 | "\n" |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8303 | "layout(location=0) out ivec4 x;\n" /* not UNORM */ |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 8304 | "void main(){\n" |
| 8305 | " x = ivec4(1);\n" |
| 8306 | "}\n"; |
| 8307 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8308 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8309 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 8310 | |
| 8311 | VkPipelineObj pipe(m_device); |
| 8312 | pipe.AddShader(&vs); |
| 8313 | pipe.AddShader(&fs); |
| 8314 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 8315 | /* set up CB 0; type is UNORM by default */ |
| 8316 | pipe.AddColorAttachment(); |
| 8317 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 8318 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 8319 | VkDescriptorSetObj descriptorSet(m_device); |
| 8320 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8321 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 8322 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 8323 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 8324 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8325 | m_errorMonitor->VerifyFound(); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 8326 | } |
Chris Forbes | 7b1b893 | 2015-06-05 14:43:36 +1200 | [diff] [blame] | 8327 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8328 | TEST_F(VkLayerTest, CreatePipelineUniformBlockNotProvided) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8329 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8330 | "not declared in pipeline layout"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8331 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 8332 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 8333 | |
| 8334 | char const *vsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8335 | "#version 450\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 8336 | "\n" |
Tony Barbour | e804d20 | 2016-01-05 13:37:45 -0700 | [diff] [blame] | 8337 | "out gl_PerVertex {\n" |
| 8338 | " vec4 gl_Position;\n" |
| 8339 | "};\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 8340 | "void main(){\n" |
| 8341 | " gl_Position = vec4(1);\n" |
| 8342 | "}\n"; |
| 8343 | char const *fsSource = |
Chris Forbes | 3846771 | 2016-04-04 17:28:05 +1200 | [diff] [blame] | 8344 | "#version 450\n" |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 8345 | "\n" |
| 8346 | "layout(location=0) out vec4 x;\n" |
| 8347 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 8348 | "void main(){\n" |
| 8349 | " x = vec4(bar.y);\n" |
| 8350 | "}\n"; |
| 8351 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 8352 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8353 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 8354 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 8355 | VkPipelineObj pipe(m_device); |
| 8356 | pipe.AddShader(&vs); |
| 8357 | pipe.AddShader(&fs); |
| 8358 | |
| 8359 | /* set up CB 0; type is UNORM by default */ |
| 8360 | pipe.AddColorAttachment(); |
| 8361 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8362 | |
| 8363 | VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8364 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 8365 | |
| 8366 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8367 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8368 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 8369 | } |
| 8370 | |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 8371 | TEST_F(VkLayerTest, CreatePipelinePushConstantsNotInLayout) { |
| 8372 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8373 | "not declared in layout"); |
| 8374 | |
| 8375 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8376 | |
| 8377 | char const *vsSource = |
| 8378 | "#version 450\n" |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 8379 | "\n" |
| 8380 | "layout(push_constant, std430) uniform foo { float x; } consts;\n" |
| 8381 | "out gl_PerVertex {\n" |
| 8382 | " vec4 gl_Position;\n" |
| 8383 | "};\n" |
| 8384 | "void main(){\n" |
| 8385 | " gl_Position = vec4(consts.x);\n" |
| 8386 | "}\n"; |
| 8387 | char const *fsSource = |
| 8388 | "#version 450\n" |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 8389 | "\n" |
| 8390 | "layout(location=0) out vec4 x;\n" |
| 8391 | "void main(){\n" |
| 8392 | " x = vec4(1);\n" |
| 8393 | "}\n"; |
| 8394 | |
| 8395 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 8396 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 8397 | |
| 8398 | VkPipelineObj pipe(m_device); |
| 8399 | pipe.AddShader(&vs); |
| 8400 | pipe.AddShader(&fs); |
| 8401 | |
| 8402 | /* set up CB 0; type is UNORM by default */ |
| 8403 | pipe.AddColorAttachment(); |
| 8404 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8405 | |
| 8406 | VkDescriptorSetObj descriptorSet(m_device); |
| 8407 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 8408 | |
| 8409 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 8410 | |
| 8411 | /* should have generated an error -- no push constant ranges provided! */ |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8412 | m_errorMonitor->VerifyFound(); |
Chris Forbes | 5c59e90 | 2016-02-26 16:56:09 +1300 | [diff] [blame] | 8413 | } |
| 8414 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 8415 | #endif // SHADER_CHECKER_TESTS |
| 8416 | |
| 8417 | #if DEVICE_LIMITS_TESTS |
Mark Young | c48c4c1 | 2016-04-11 14:26:49 -0600 | [diff] [blame] | 8418 | TEST_F(VkLayerTest, CreateImageLimitsViolationMaxWidth) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8419 | m_errorMonitor->SetDesiredFailureMsg( |
| 8420 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8421 | "CreateImage extents exceed allowable limits for format"); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 8422 | |
| 8423 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 8424 | |
| 8425 | // Create an image |
| 8426 | VkImage image; |
| 8427 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8428 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8429 | const int32_t tex_width = 32; |
| 8430 | const int32_t tex_height = 32; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 8431 | |
| 8432 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8433 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8434 | image_create_info.pNext = NULL; |
| 8435 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8436 | image_create_info.format = tex_format; |
| 8437 | image_create_info.extent.width = tex_width; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 8438 | image_create_info.extent.height = tex_height; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8439 | image_create_info.extent.depth = 1; |
| 8440 | image_create_info.mipLevels = 1; |
| 8441 | image_create_info.arrayLayers = 1; |
| 8442 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8443 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 8444 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 8445 | image_create_info.flags = 0; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 8446 | |
| 8447 | // Introduce error by sending down a bogus width extent |
| 8448 | image_create_info.extent.width = 65536; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8449 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 8450 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8451 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 8452 | } |
| 8453 | |
Mark Young | c48c4c1 | 2016-04-11 14:26:49 -0600 | [diff] [blame] | 8454 | TEST_F(VkLayerTest, CreateImageLimitsViolationMinWidth) { |
| 8455 | m_errorMonitor->SetDesiredFailureMsg( |
| 8456 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8457 | "CreateImage extents is 0 for at least one required dimension"); |
| 8458 | |
| 8459 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8460 | |
| 8461 | // Create an image |
| 8462 | VkImage image; |
| 8463 | |
| 8464 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8465 | const int32_t tex_width = 32; |
| 8466 | const int32_t tex_height = 32; |
| 8467 | |
| 8468 | VkImageCreateInfo image_create_info = {}; |
| 8469 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8470 | image_create_info.pNext = NULL; |
| 8471 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8472 | image_create_info.format = tex_format; |
| 8473 | image_create_info.extent.width = tex_width; |
| 8474 | image_create_info.extent.height = tex_height; |
| 8475 | image_create_info.extent.depth = 1; |
| 8476 | image_create_info.mipLevels = 1; |
| 8477 | image_create_info.arrayLayers = 1; |
| 8478 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8479 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 8480 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 8481 | image_create_info.flags = 0; |
| 8482 | |
| 8483 | // Introduce error by sending down a bogus width extent |
| 8484 | image_create_info.extent.width = 0; |
| 8485 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 8486 | |
| 8487 | m_errorMonitor->VerifyFound(); |
| 8488 | } |
| 8489 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8490 | TEST_F(VkLayerTest, UpdateBufferAlignment) { |
| 8491 | uint32_t updateData[] = {1, 2, 3, 4, 5, 6, 7, 8}; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8492 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8493 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8494 | "dstOffset, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8495 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8496 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8497 | |
| 8498 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 8499 | vk_testing::Buffer buffer; |
| 8500 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 8501 | |
| 8502 | BeginCommandBuffer(); |
| 8503 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8504 | m_commandBuffer->UpdateBuffer(buffer.handle(), 1, 4, updateData); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8505 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8506 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8507 | // Introduce failure by using size that is not multiple of 4 |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8508 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8509 | "dataSize, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8510 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8511 | m_commandBuffer->UpdateBuffer(buffer.handle(), 0, 6, updateData); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8512 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8513 | EndCommandBuffer(); |
| 8514 | } |
| 8515 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8516 | TEST_F(VkLayerTest, FillBufferAlignment) { |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8517 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8518 | "dstOffset, is not a multiple of 4"); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8519 | |
| 8520 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8521 | |
| 8522 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 8523 | vk_testing::Buffer buffer; |
| 8524 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 8525 | |
| 8526 | BeginCommandBuffer(); |
| 8527 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8528 | m_commandBuffer->FillBuffer(buffer.handle(), 1, 4, 0x11111111); |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8529 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8530 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8531 | // Introduce failure by using size that is not multiple of 4 |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8532 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8533 | "size, is not a multiple of 4"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8534 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8535 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 6, 0x11111111); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8536 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8537 | m_errorMonitor->VerifyFound(); |
| 8538 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8539 | EndCommandBuffer(); |
| 8540 | } |
| 8541 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 8542 | #endif // DEVICE_LIMITS_TESTS |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 8543 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8544 | #if IMAGE_TESTS |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8545 | TEST_F(VkLayerTest, InvalidImageView) { |
| 8546 | VkResult err; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8547 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8548 | m_errorMonitor->SetDesiredFailureMsg( |
| 8549 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8550 | "vkCreateImageView called with baseMipLevel 10 "); |
| 8551 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8552 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8553 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8554 | // Create an image and try to create a view with bad baseMipLevel |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8555 | VkImage image; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8556 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8557 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8558 | const int32_t tex_width = 32; |
| 8559 | const int32_t tex_height = 32; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8560 | |
| 8561 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8562 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8563 | image_create_info.pNext = NULL; |
| 8564 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8565 | image_create_info.format = tex_format; |
| 8566 | image_create_info.extent.width = tex_width; |
| 8567 | image_create_info.extent.height = tex_height; |
| 8568 | image_create_info.extent.depth = 1; |
| 8569 | image_create_info.mipLevels = 1; |
| 8570 | image_create_info.arrayLayers = 1; |
| 8571 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8572 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 8573 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 8574 | image_create_info.flags = 0; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8575 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8576 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8577 | ASSERT_VK_SUCCESS(err); |
| 8578 | |
| 8579 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8580 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8581 | image_view_create_info.image = image; |
| 8582 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 8583 | image_view_create_info.format = tex_format; |
| 8584 | image_view_create_info.subresourceRange.layerCount = 1; |
| 8585 | image_view_create_info.subresourceRange.baseMipLevel = 10; // cause an error |
| 8586 | image_view_create_info.subresourceRange.levelCount = 1; |
| 8587 | image_view_create_info.subresourceRange.aspectMask = |
| 8588 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8589 | |
| 8590 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8591 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 8592 | &view); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8593 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8594 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 8595 | } |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8596 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8597 | TEST_F(VkLayerTest, InvalidImageViewAspect) { |
| 8598 | VkResult err; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 8599 | |
Courtney Goeltzenleuchter | 7415d5a | 2015-12-09 15:48:16 -0700 | [diff] [blame] | 8600 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8601 | "vkCreateImageView: Color image " |
| 8602 | "formats must have ONLY the " |
| 8603 | "VK_IMAGE_ASPECT_COLOR_BIT set"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8604 | |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 8605 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 8606 | |
| 8607 | // 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] | 8608 | VkImage image; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 8609 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8610 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8611 | const int32_t tex_width = 32; |
| 8612 | const int32_t tex_height = 32; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 8613 | |
| 8614 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8615 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8616 | image_create_info.pNext = NULL; |
| 8617 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8618 | image_create_info.format = tex_format; |
| 8619 | image_create_info.extent.width = tex_width; |
| 8620 | image_create_info.extent.height = tex_height; |
| 8621 | image_create_info.extent.depth = 1; |
| 8622 | image_create_info.mipLevels = 1; |
| 8623 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8624 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 8625 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 8626 | image_create_info.flags = 0; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 8627 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8628 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 8629 | ASSERT_VK_SUCCESS(err); |
| 8630 | |
| 8631 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8632 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8633 | image_view_create_info.image = image; |
| 8634 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 8635 | image_view_create_info.format = tex_format; |
| 8636 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 8637 | image_view_create_info.subresourceRange.levelCount = 1; |
| 8638 | // Cause an error by setting an invalid image aspect |
| 8639 | image_view_create_info.subresourceRange.aspectMask = |
| 8640 | VK_IMAGE_ASPECT_METADATA_BIT; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 8641 | |
| 8642 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8643 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 8644 | &view); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 8645 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8646 | m_errorMonitor->VerifyFound(); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 8647 | } |
| 8648 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 8649 | TEST_F(VkLayerTest, CopyImageLayerCountMismatch) { |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8650 | VkResult err; |
| 8651 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8652 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8653 | m_errorMonitor->SetDesiredFailureMsg( |
| 8654 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 8655 | "vkCmdCopyImage: number of layers in source and destination subresources for pRegions"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 8656 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8657 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8658 | |
| 8659 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8660 | VkImage srcImage; |
| 8661 | VkImage dstImage; |
| 8662 | VkDeviceMemory srcMem; |
| 8663 | VkDeviceMemory destMem; |
| 8664 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8665 | |
| 8666 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8667 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8668 | image_create_info.pNext = NULL; |
| 8669 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8670 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8671 | image_create_info.extent.width = 32; |
| 8672 | image_create_info.extent.height = 32; |
| 8673 | image_create_info.extent.depth = 1; |
| 8674 | image_create_info.mipLevels = 1; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 8675 | image_create_info.arrayLayers = 4; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8676 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8677 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 8678 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 8679 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8680 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8681 | err = |
| 8682 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8683 | ASSERT_VK_SUCCESS(err); |
| 8684 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8685 | err = |
| 8686 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8687 | ASSERT_VK_SUCCESS(err); |
| 8688 | |
| 8689 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8690 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8691 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 8692 | memAlloc.pNext = NULL; |
| 8693 | memAlloc.allocationSize = 0; |
| 8694 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8695 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 8696 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8697 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8698 | pass = |
| 8699 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 8700 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8701 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8702 | ASSERT_VK_SUCCESS(err); |
| 8703 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8704 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8705 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8706 | pass = |
| 8707 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8708 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8709 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8710 | ASSERT_VK_SUCCESS(err); |
| 8711 | |
| 8712 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 8713 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8714 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8715 | ASSERT_VK_SUCCESS(err); |
| 8716 | |
| 8717 | BeginCommandBuffer(); |
| 8718 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8719 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8720 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 8721 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 8722 | copyRegion.srcSubresource.layerCount = 1; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8723 | copyRegion.srcOffset.x = 0; |
| 8724 | copyRegion.srcOffset.y = 0; |
| 8725 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 8726 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8727 | copyRegion.dstSubresource.mipLevel = 0; |
| 8728 | copyRegion.dstSubresource.baseArrayLayer = 0; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 8729 | // Introduce failure by forcing the dst layerCount to differ from src |
| 8730 | copyRegion.dstSubresource.layerCount = 3; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8731 | copyRegion.dstOffset.x = 0; |
| 8732 | copyRegion.dstOffset.y = 0; |
| 8733 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8734 | copyRegion.extent.width = 1; |
| 8735 | copyRegion.extent.height = 1; |
| 8736 | copyRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 8737 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 8738 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8739 | EndCommandBuffer(); |
| 8740 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 8741 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8742 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8743 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 8744 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 8745 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 8746 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 8747 | } |
| 8748 | |
Tony Barbour | d667364 | 2016-05-05 14:46:39 -0600 | [diff] [blame] | 8749 | TEST_F(VkLayerTest, ImageLayerUnsupportedFormat) { |
| 8750 | |
| 8751 | TEST_DESCRIPTION("Creating images with unsuported formats "); |
| 8752 | |
| 8753 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8754 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 8755 | VkImageObj image(m_device); |
| 8756 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 8757 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 8758 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 8759 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 8760 | ASSERT_TRUE(image.initialized()); |
| 8761 | |
| 8762 | VkFormat unsupported = VK_FORMAT_UNDEFINED; |
| 8763 | for (int f = VK_FORMAT_BEGIN_RANGE; f <= VK_FORMAT_END_RANGE; f++) { |
| 8764 | VkFormat format = static_cast<VkFormat>(f); |
| 8765 | VkFormatProperties fProps = m_device->format_properties(format); |
| 8766 | if (format != VK_FORMAT_UNDEFINED && fProps.linearTilingFeatures == 0 && |
| 8767 | fProps.optimalTilingFeatures == 0) { |
| 8768 | unsupported = format; |
| 8769 | break; |
| 8770 | } |
| 8771 | } |
| 8772 | if (unsupported != VK_FORMAT_UNDEFINED) { |
| 8773 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8774 | "vkCreateImage parameter, " |
| 8775 | "VkFormat pCreateInfo->format, " |
| 8776 | "contains unsupported format"); |
| 8777 | // Create image with unsupported format - Expect FORMAT_UNSUPPORTED |
| 8778 | VkImageCreateInfo image_create_info; |
| 8779 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 8780 | image_create_info.pNext = NULL; |
| 8781 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 8782 | image_create_info.format = unsupported; |
| 8783 | image_create_info.extent.width = 32; |
| 8784 | image_create_info.extent.height = 32; |
| 8785 | image_create_info.extent.depth = 1; |
| 8786 | image_create_info.mipLevels = 1; |
| 8787 | image_create_info.arrayLayers = 1; |
| 8788 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8789 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 8790 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 8791 | image_create_info.flags = 0; |
| 8792 | |
| 8793 | VkImage localImage; |
| 8794 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &localImage); |
| 8795 | m_errorMonitor->VerifyFound(); |
| 8796 | |
| 8797 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8798 | "vkCreateRenderPass parameter, " |
| 8799 | "VkFormat in " |
| 8800 | "pCreateInfo->pAttachments"); |
| 8801 | // Create renderpass with unsupported format - Expect FORMAT_UNSUPPORTED |
| 8802 | VkAttachmentDescription att; |
| 8803 | att.format = unsupported; |
| 8804 | att.samples = VK_SAMPLE_COUNT_1_BIT; |
| 8805 | att.loadOp = VK_ATTACHMENT_LOAD_OP_LOAD; |
| 8806 | att.storeOp = VK_ATTACHMENT_STORE_OP_STORE; |
| 8807 | att.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; |
| 8808 | att.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; |
| 8809 | att.initialLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 8810 | att.finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 8811 | |
| 8812 | VkRenderPassCreateInfo rp_info = {}; |
| 8813 | VkRenderPass rp; |
| 8814 | rp_info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; |
| 8815 | rp_info.attachmentCount = 1; |
| 8816 | rp_info.pAttachments = &att; |
| 8817 | rp_info.subpassCount = 0; |
| 8818 | rp_info.pSubpasses = NULL; |
| 8819 | vkCreateRenderPass(m_device->handle(), &rp_info, NULL, &rp); |
| 8820 | m_errorMonitor->VerifyFound(); |
| 8821 | } |
| 8822 | } |
| 8823 | |
| 8824 | TEST_F(VkLayerTest, ImageLayerViewTests) { |
| 8825 | VkResult ret; |
| 8826 | TEST_DESCRIPTION("Passing bad parameters to CreateImageView"); |
| 8827 | |
| 8828 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8829 | |
| 8830 | VkImageObj image(m_device); |
| 8831 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 8832 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 8833 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 8834 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 8835 | ASSERT_TRUE(image.initialized()); |
| 8836 | |
| 8837 | VkImageView imgView; |
| 8838 | VkImageViewCreateInfo imgViewInfo = {}; |
| 8839 | imgViewInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 8840 | imgViewInfo.image = image.handle(); |
| 8841 | imgViewInfo.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 8842 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8843 | imgViewInfo.subresourceRange.layerCount = 1; |
| 8844 | imgViewInfo.subresourceRange.baseMipLevel = 0; |
| 8845 | imgViewInfo.subresourceRange.levelCount = 1; |
| 8846 | imgViewInfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8847 | |
| 8848 | m_errorMonitor->SetDesiredFailureMsg( |
| 8849 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8850 | "vkCreateImageView called with baseMipLevel"); |
| 8851 | // View can't have baseMipLevel >= image's mipLevels - Expect |
| 8852 | // VIEW_CREATE_ERROR |
| 8853 | imgViewInfo.subresourceRange.baseMipLevel = 1; |
| 8854 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 8855 | m_errorMonitor->VerifyFound(); |
| 8856 | imgViewInfo.subresourceRange.baseMipLevel = 0; |
| 8857 | |
| 8858 | m_errorMonitor->SetDesiredFailureMsg( |
| 8859 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8860 | "vkCreateImageView called with baseArrayLayer"); |
| 8861 | // View can't have baseArrayLayer >= image's arraySize - Expect |
| 8862 | // VIEW_CREATE_ERROR |
| 8863 | imgViewInfo.subresourceRange.baseArrayLayer = 1; |
| 8864 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 8865 | m_errorMonitor->VerifyFound(); |
| 8866 | imgViewInfo.subresourceRange.baseArrayLayer = 0; |
| 8867 | |
| 8868 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8869 | "vkCreateImageView called with 0 in " |
| 8870 | "pCreateInfo->subresourceRange." |
| 8871 | "levelCount"); |
| 8872 | // View's levelCount can't be 0 - Expect VIEW_CREATE_ERROR |
| 8873 | imgViewInfo.subresourceRange.levelCount = 0; |
| 8874 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 8875 | m_errorMonitor->VerifyFound(); |
| 8876 | imgViewInfo.subresourceRange.levelCount = 1; |
| 8877 | |
| 8878 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8879 | "vkCreateImageView called with 0 in " |
| 8880 | "pCreateInfo->subresourceRange." |
| 8881 | "layerCount"); |
| 8882 | // View's layerCount can't be 0 - Expect VIEW_CREATE_ERROR |
| 8883 | imgViewInfo.subresourceRange.layerCount = 0; |
| 8884 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 8885 | m_errorMonitor->VerifyFound(); |
| 8886 | imgViewInfo.subresourceRange.layerCount = 1; |
| 8887 | |
| 8888 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8889 | "but both must be color formats"); |
| 8890 | // Can't use depth format for view into color image - Expect INVALID_FORMAT |
| 8891 | imgViewInfo.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 8892 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 8893 | m_errorMonitor->VerifyFound(); |
| 8894 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8895 | |
| 8896 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8897 | "Formats MUST be IDENTICAL unless " |
| 8898 | "VK_IMAGE_CREATE_MUTABLE_FORMAT BIT " |
| 8899 | "was set on image creation."); |
| 8900 | // Same compatibility class but no MUTABLE_FORMAT bit - Expect |
| 8901 | // VIEW_CREATE_ERROR |
| 8902 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UINT; |
| 8903 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 8904 | m_errorMonitor->VerifyFound(); |
| 8905 | imgViewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 8906 | |
| 8907 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8908 | "can support ImageViews with " |
| 8909 | "differing formats but they must be " |
| 8910 | "in the same compatibility class."); |
| 8911 | // Have MUTABLE_FORMAT bit but not in same compatibility class - Expect |
| 8912 | // VIEW_CREATE_ERROR |
| 8913 | VkImageCreateInfo mutImgInfo = image.create_info(); |
| 8914 | VkImage mutImage; |
| 8915 | mutImgInfo.format = VK_FORMAT_R8_UINT; |
| 8916 | assert( |
| 8917 | m_device->format_properties(VK_FORMAT_R8_UINT).optimalTilingFeatures & |
| 8918 | VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT); |
| 8919 | mutImgInfo.flags = VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT; |
| 8920 | mutImgInfo.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 8921 | ret = vkCreateImage(m_device->handle(), &mutImgInfo, NULL, &mutImage); |
| 8922 | ASSERT_VK_SUCCESS(ret); |
| 8923 | imgViewInfo.image = mutImage; |
| 8924 | vkCreateImageView(m_device->handle(), &imgViewInfo, NULL, &imgView); |
| 8925 | m_errorMonitor->VerifyFound(); |
| 8926 | imgViewInfo.image = image.handle(); |
| 8927 | vkDestroyImage(m_device->handle(), mutImage, NULL); |
| 8928 | } |
| 8929 | |
| 8930 | TEST_F(VkLayerTest, MiscImageLayerTests) { |
| 8931 | |
| 8932 | TEST_DESCRIPTION("Image layer tests that don't belong elsewhare"); |
| 8933 | |
| 8934 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 8935 | |
| 8936 | VkImageObj image(m_device); |
| 8937 | image.init(128, 128, VK_FORMAT_B8G8R8A8_UNORM, |
| 8938 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 8939 | VK_IMAGE_USAGE_TRANSFER_DST_BIT, |
| 8940 | VK_IMAGE_TILING_OPTIMAL, 0); |
| 8941 | ASSERT_TRUE(image.initialized()); |
| 8942 | |
| 8943 | m_errorMonitor->SetDesiredFailureMsg( |
| 8944 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8945 | "number of layers in image subresource is zero"); |
| 8946 | vk_testing::Buffer buffer; |
| 8947 | VkMemoryPropertyFlags reqs = 0; |
| 8948 | buffer.init_as_src(*m_device, 128 * 128 * 4, reqs); |
| 8949 | VkBufferImageCopy region = {}; |
| 8950 | region.bufferRowLength = 128; |
| 8951 | region.bufferImageHeight = 128; |
| 8952 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8953 | // layerCount can't be 0 - Expect MISMATCHED_IMAGE_ASPECT |
| 8954 | region.imageSubresource.layerCount = 0; |
| 8955 | region.imageExtent.height = 4; |
| 8956 | region.imageExtent.width = 4; |
| 8957 | region.imageExtent.depth = 1; |
| 8958 | m_commandBuffer->BeginCommandBuffer(); |
| 8959 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 8960 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 8961 | 1, ®ion); |
| 8962 | m_errorMonitor->VerifyFound(); |
| 8963 | region.imageSubresource.layerCount = 1; |
| 8964 | |
| 8965 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8966 | "aspectMasks for each region must " |
| 8967 | "specify only COLOR or DEPTH or " |
| 8968 | "STENCIL"); |
| 8969 | // Expect MISMATCHED_IMAGE_ASPECT |
| 8970 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_METADATA_BIT; |
| 8971 | vkCmdCopyBufferToImage(m_commandBuffer->GetBufferHandle(), buffer.handle(), |
| 8972 | image.handle(), VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 8973 | 1, ®ion); |
| 8974 | m_errorMonitor->VerifyFound(); |
| 8975 | region.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8976 | |
| 8977 | m_errorMonitor->SetDesiredFailureMsg( |
| 8978 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 8979 | "If the format of srcImage is a depth, stencil, depth stencil or " |
| 8980 | "integer-based format then filter must be VK_FILTER_NEAREST"); |
| 8981 | // Expect INVALID_FILTER |
| 8982 | VkImageObj intImage1(m_device); |
| 8983 | intImage1.init(128, 128, VK_FORMAT_R8_UINT, |
| 8984 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, |
| 8985 | 0); |
| 8986 | VkImageObj intImage2(m_device); |
| 8987 | intImage2.init(128, 128, VK_FORMAT_R8_UINT, |
| 8988 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, VK_IMAGE_TILING_OPTIMAL, |
| 8989 | 0); |
| 8990 | VkImageBlit blitRegion = {}; |
| 8991 | blitRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8992 | blitRegion.srcSubresource.baseArrayLayer = 0; |
| 8993 | blitRegion.srcSubresource.layerCount = 1; |
| 8994 | blitRegion.srcSubresource.mipLevel = 0; |
| 8995 | blitRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 8996 | blitRegion.dstSubresource.baseArrayLayer = 0; |
| 8997 | blitRegion.dstSubresource.layerCount = 1; |
| 8998 | blitRegion.dstSubresource.mipLevel = 0; |
| 8999 | |
| 9000 | vkCmdBlitImage(m_commandBuffer->GetBufferHandle(), intImage1.handle(), |
| 9001 | intImage1.layout(), intImage2.handle(), intImage2.layout(), |
| 9002 | 16, &blitRegion, VK_FILTER_LINEAR); |
| 9003 | m_errorMonitor->VerifyFound(); |
| 9004 | |
| 9005 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9006 | "called with 0 in ppMemoryBarriers"); |
| 9007 | VkImageMemoryBarrier img_barrier; |
| 9008 | img_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; |
| 9009 | img_barrier.pNext = NULL; |
| 9010 | img_barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT; |
| 9011 | img_barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT; |
| 9012 | img_barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 9013 | img_barrier.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 9014 | img_barrier.image = image.handle(); |
| 9015 | img_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 9016 | img_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; |
| 9017 | img_barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 9018 | img_barrier.subresourceRange.baseArrayLayer = 0; |
| 9019 | img_barrier.subresourceRange.baseMipLevel = 0; |
| 9020 | // layerCount should not be 0 - Expect INVALID_IMAGE_RESOURCE |
| 9021 | img_barrier.subresourceRange.layerCount = 0; |
| 9022 | img_barrier.subresourceRange.levelCount = 1; |
| 9023 | vkCmdPipelineBarrier(m_commandBuffer->GetBufferHandle(), |
| 9024 | VK_PIPELINE_STAGE_HOST_BIT, |
| 9025 | VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, 0, 0, nullptr, 0, |
| 9026 | nullptr, 1, &img_barrier); |
| 9027 | m_errorMonitor->VerifyFound(); |
| 9028 | img_barrier.subresourceRange.layerCount = 1; |
| 9029 | } |
| 9030 | |
| 9031 | TEST_F(VkLayerTest, ImageFormatLimits) { |
| 9032 | |
| 9033 | TEST_DESCRIPTION("Exceed the limits of image format "); |
| 9034 | |
| 9035 | m_errorMonitor->SetDesiredFailureMsg( |
| 9036 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9037 | "CreateImage extents exceed allowable limits for format"); |
| 9038 | VkImageCreateInfo image_create_info = {}; |
| 9039 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9040 | image_create_info.pNext = NULL; |
| 9041 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 9042 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 9043 | image_create_info.extent.width = 32; |
| 9044 | image_create_info.extent.height = 32; |
| 9045 | image_create_info.extent.depth = 1; |
| 9046 | image_create_info.mipLevels = 1; |
| 9047 | image_create_info.arrayLayers = 1; |
| 9048 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 9049 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 9050 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 9051 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 9052 | image_create_info.flags = 0; |
| 9053 | |
| 9054 | VkImage nullImg; |
| 9055 | VkImageFormatProperties imgFmtProps; |
| 9056 | vkGetPhysicalDeviceImageFormatProperties( |
| 9057 | gpu(), image_create_info.format, image_create_info.imageType, |
| 9058 | image_create_info.tiling, image_create_info.usage, |
| 9059 | image_create_info.flags, &imgFmtProps); |
| 9060 | image_create_info.extent.depth = imgFmtProps.maxExtent.depth + 1; |
| 9061 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 9062 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 9063 | m_errorMonitor->VerifyFound(); |
| 9064 | image_create_info.extent.depth = 1; |
| 9065 | |
| 9066 | m_errorMonitor->SetDesiredFailureMsg( |
| 9067 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9068 | "exceeds allowable maximum supported by format of"); |
| 9069 | image_create_info.mipLevels = imgFmtProps.maxMipLevels + 1; |
| 9070 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 9071 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 9072 | m_errorMonitor->VerifyFound(); |
| 9073 | image_create_info.mipLevels = 1; |
| 9074 | |
| 9075 | m_errorMonitor->SetDesiredFailureMsg( |
| 9076 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9077 | "exceeds allowable maximum supported by format of"); |
| 9078 | image_create_info.arrayLayers = imgFmtProps.maxArrayLayers + 1; |
| 9079 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 9080 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 9081 | m_errorMonitor->VerifyFound(); |
| 9082 | image_create_info.arrayLayers = 1; |
| 9083 | |
| 9084 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9085 | "is not supported by format"); |
| 9086 | int samples = imgFmtProps.sampleCounts >> 1; |
| 9087 | image_create_info.samples = (VkSampleCountFlagBits)samples; |
| 9088 | // Expect INVALID_FORMAT_LIMITS_VIOLATION |
| 9089 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 9090 | m_errorMonitor->VerifyFound(); |
| 9091 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 9092 | |
| 9093 | m_errorMonitor->SetDesiredFailureMsg(VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9094 | "pCreateInfo->initialLayout, must be " |
| 9095 | "VK_IMAGE_LAYOUT_UNDEFINED or " |
| 9096 | "VK_IMAGE_LAYOUT_PREINITIALIZED"); |
| 9097 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
| 9098 | // Expect INVALID_LAYOUT |
| 9099 | vkCreateImage(m_device->handle(), &image_create_info, NULL, &nullImg); |
| 9100 | m_errorMonitor->VerifyFound(); |
| 9101 | image_create_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; |
| 9102 | } |
| 9103 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9104 | TEST_F(VkLayerTest, CopyImageFormatSizeMismatch) { |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 9105 | VkResult err; |
| 9106 | bool pass; |
| 9107 | |
| 9108 | // Create color images with different format sizes and try to copy between them |
| 9109 | m_errorMonitor->SetDesiredFailureMsg( |
| 9110 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
| 9111 | "vkCmdCopyImage called with unmatched source and dest image format sizes"); |
| 9112 | |
| 9113 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 9114 | |
| 9115 | // Create two images of different types and try to copy between them |
| 9116 | VkImage srcImage; |
| 9117 | VkImage dstImage; |
| 9118 | VkDeviceMemory srcMem; |
| 9119 | VkDeviceMemory destMem; |
| 9120 | VkMemoryRequirements memReqs; |
| 9121 | |
| 9122 | VkImageCreateInfo image_create_info = {}; |
| 9123 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9124 | image_create_info.pNext = NULL; |
| 9125 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 9126 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 9127 | image_create_info.extent.width = 32; |
| 9128 | image_create_info.extent.height = 32; |
| 9129 | image_create_info.extent.depth = 1; |
| 9130 | image_create_info.mipLevels = 1; |
| 9131 | image_create_info.arrayLayers = 1; |
| 9132 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 9133 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 9134 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 9135 | image_create_info.flags = 0; |
| 9136 | |
| 9137 | err = |
| 9138 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
| 9139 | ASSERT_VK_SUCCESS(err); |
| 9140 | |
| 9141 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 9142 | // Introduce failure by creating second image with a different-sized format. |
| 9143 | image_create_info.format = VK_FORMAT_R5G5B5A1_UNORM_PACK16; |
| 9144 | |
| 9145 | err = |
| 9146 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
| 9147 | ASSERT_VK_SUCCESS(err); |
| 9148 | |
| 9149 | // Allocate memory |
| 9150 | VkMemoryAllocateInfo memAlloc = {}; |
| 9151 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 9152 | memAlloc.pNext = NULL; |
| 9153 | memAlloc.allocationSize = 0; |
| 9154 | memAlloc.memoryTypeIndex = 0; |
| 9155 | |
| 9156 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
| 9157 | memAlloc.allocationSize = memReqs.size; |
| 9158 | pass = |
| 9159 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 9160 | ASSERT_TRUE(pass); |
| 9161 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
| 9162 | ASSERT_VK_SUCCESS(err); |
| 9163 | |
| 9164 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
| 9165 | memAlloc.allocationSize = memReqs.size; |
| 9166 | pass = |
| 9167 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 9168 | ASSERT_TRUE(pass); |
| 9169 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
| 9170 | ASSERT_VK_SUCCESS(err); |
| 9171 | |
| 9172 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 9173 | ASSERT_VK_SUCCESS(err); |
| 9174 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
| 9175 | ASSERT_VK_SUCCESS(err); |
| 9176 | |
| 9177 | BeginCommandBuffer(); |
| 9178 | VkImageCopy copyRegion; |
| 9179 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 9180 | copyRegion.srcSubresource.mipLevel = 0; |
| 9181 | copyRegion.srcSubresource.baseArrayLayer = 0; |
| 9182 | copyRegion.srcSubresource.layerCount = 0; |
| 9183 | copyRegion.srcOffset.x = 0; |
| 9184 | copyRegion.srcOffset.y = 0; |
| 9185 | copyRegion.srcOffset.z = 0; |
| 9186 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 9187 | copyRegion.dstSubresource.mipLevel = 0; |
| 9188 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 9189 | copyRegion.dstSubresource.layerCount = 0; |
| 9190 | copyRegion.dstOffset.x = 0; |
| 9191 | copyRegion.dstOffset.y = 0; |
| 9192 | copyRegion.dstOffset.z = 0; |
| 9193 | copyRegion.extent.width = 1; |
| 9194 | copyRegion.extent.height = 1; |
| 9195 | copyRegion.extent.depth = 1; |
| 9196 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 9197 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
| 9198 | EndCommandBuffer(); |
| 9199 | |
| 9200 | m_errorMonitor->VerifyFound(); |
| 9201 | |
| 9202 | vkDestroyImage(m_device->device(), srcImage, NULL); |
| 9203 | vkDestroyImage(m_device->device(), dstImage, NULL); |
| 9204 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 9205 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9206 | } |
| 9207 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9208 | TEST_F(VkLayerTest, CopyImageDepthStencilFormatMismatch) { |
| 9209 | VkResult err; |
| 9210 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9211 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 9212 | // 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] | 9213 | m_errorMonitor->SetDesiredFailureMsg( |
| 9214 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 9215 | "vkCmdCopyImage called with unmatched source and dest image depth"); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9216 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9217 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9218 | |
| 9219 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9220 | VkImage srcImage; |
| 9221 | VkImage dstImage; |
| 9222 | VkDeviceMemory srcMem; |
| 9223 | VkDeviceMemory destMem; |
| 9224 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9225 | |
| 9226 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9227 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9228 | image_create_info.pNext = NULL; |
| 9229 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 9230 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 9231 | image_create_info.extent.width = 32; |
| 9232 | image_create_info.extent.height = 32; |
| 9233 | image_create_info.extent.depth = 1; |
| 9234 | image_create_info.mipLevels = 1; |
| 9235 | image_create_info.arrayLayers = 1; |
| 9236 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 9237 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 9238 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 9239 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9240 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9241 | err = |
| 9242 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9243 | ASSERT_VK_SUCCESS(err); |
| 9244 | |
Karl Schultz | bdb7595 | 2016-04-19 11:36:49 -0600 | [diff] [blame] | 9245 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
| 9246 | |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 9247 | // Introduce failure by creating second image with a depth/stencil format |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9248 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
Mark Lobodzinski | db11763 | 2016-03-31 10:45:56 -0600 | [diff] [blame] | 9249 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 9250 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9251 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9252 | err = |
| 9253 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9254 | ASSERT_VK_SUCCESS(err); |
| 9255 | |
| 9256 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9257 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9258 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 9259 | memAlloc.pNext = NULL; |
| 9260 | memAlloc.allocationSize = 0; |
| 9261 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9262 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 9263 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9264 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9265 | pass = |
| 9266 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 9267 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9268 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9269 | ASSERT_VK_SUCCESS(err); |
| 9270 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9271 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9272 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9273 | pass = |
| 9274 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 9275 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9276 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9277 | ASSERT_VK_SUCCESS(err); |
| 9278 | |
| 9279 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 9280 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9281 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9282 | ASSERT_VK_SUCCESS(err); |
| 9283 | |
| 9284 | BeginCommandBuffer(); |
| 9285 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 9286 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9287 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 9288 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9289 | copyRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9290 | copyRegion.srcOffset.x = 0; |
| 9291 | copyRegion.srcOffset.y = 0; |
| 9292 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 9293 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9294 | copyRegion.dstSubresource.mipLevel = 0; |
| 9295 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 9296 | copyRegion.dstSubresource.layerCount = 0; |
| 9297 | copyRegion.dstOffset.x = 0; |
| 9298 | copyRegion.dstOffset.y = 0; |
| 9299 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9300 | copyRegion.extent.width = 1; |
| 9301 | copyRegion.extent.height = 1; |
| 9302 | copyRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9303 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 9304 | VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9305 | EndCommandBuffer(); |
| 9306 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9307 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9308 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9309 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9310 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9311 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 9312 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9313 | } |
| 9314 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9315 | TEST_F(VkLayerTest, ResolveImageLowSampleCount) { |
| 9316 | VkResult err; |
| 9317 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9318 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9319 | m_errorMonitor->SetDesiredFailureMsg( |
| 9320 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9321 | "vkCmdResolveImage called with source sample count less than 2."); |
| 9322 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9323 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9324 | |
| 9325 | // 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] | 9326 | VkImage srcImage; |
| 9327 | VkImage dstImage; |
| 9328 | VkDeviceMemory srcMem; |
| 9329 | VkDeviceMemory destMem; |
| 9330 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9331 | |
| 9332 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9333 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9334 | image_create_info.pNext = NULL; |
| 9335 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 9336 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 9337 | image_create_info.extent.width = 32; |
| 9338 | image_create_info.extent.height = 1; |
| 9339 | image_create_info.extent.depth = 1; |
| 9340 | image_create_info.mipLevels = 1; |
| 9341 | image_create_info.arrayLayers = 1; |
| 9342 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 9343 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 9344 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
| 9345 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9346 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9347 | err = |
| 9348 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9349 | ASSERT_VK_SUCCESS(err); |
| 9350 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9351 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9352 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9353 | err = |
| 9354 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9355 | ASSERT_VK_SUCCESS(err); |
| 9356 | |
| 9357 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9358 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9359 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 9360 | memAlloc.pNext = NULL; |
| 9361 | memAlloc.allocationSize = 0; |
| 9362 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9363 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 9364 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9365 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9366 | pass = |
| 9367 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 9368 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9369 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9370 | ASSERT_VK_SUCCESS(err); |
| 9371 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9372 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9373 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9374 | pass = |
| 9375 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 9376 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9377 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9378 | ASSERT_VK_SUCCESS(err); |
| 9379 | |
| 9380 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 9381 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9382 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9383 | ASSERT_VK_SUCCESS(err); |
| 9384 | |
| 9385 | BeginCommandBuffer(); |
| 9386 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9387 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 9388 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9389 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 9390 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9391 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 9392 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9393 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9394 | resolveRegion.srcOffset.x = 0; |
| 9395 | resolveRegion.srcOffset.y = 0; |
| 9396 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 9397 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9398 | resolveRegion.dstSubresource.mipLevel = 0; |
| 9399 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 9400 | resolveRegion.dstSubresource.layerCount = 0; |
| 9401 | resolveRegion.dstOffset.x = 0; |
| 9402 | resolveRegion.dstOffset.y = 0; |
| 9403 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9404 | resolveRegion.extent.width = 1; |
| 9405 | resolveRegion.extent.height = 1; |
| 9406 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9407 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 9408 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9409 | EndCommandBuffer(); |
| 9410 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9411 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9412 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9413 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9414 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9415 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 9416 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9417 | } |
| 9418 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9419 | TEST_F(VkLayerTest, ResolveImageHighSampleCount) { |
| 9420 | VkResult err; |
| 9421 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9422 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9423 | m_errorMonitor->SetDesiredFailureMsg( |
| 9424 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9425 | "vkCmdResolveImage called with dest sample count greater than 1."); |
| 9426 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9427 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9428 | |
Chris Forbes | a753069 | 2016-05-08 12:35:39 +1200 | [diff] [blame] | 9429 | // 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] | 9430 | VkImage srcImage; |
| 9431 | VkImage dstImage; |
| 9432 | VkDeviceMemory srcMem; |
| 9433 | VkDeviceMemory destMem; |
| 9434 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9435 | |
| 9436 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9437 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9438 | image_create_info.pNext = NULL; |
| 9439 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 9440 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 9441 | image_create_info.extent.width = 32; |
| 9442 | image_create_info.extent.height = 1; |
| 9443 | image_create_info.extent.depth = 1; |
| 9444 | image_create_info.mipLevels = 1; |
| 9445 | image_create_info.arrayLayers = 1; |
Chris Forbes | a753069 | 2016-05-08 12:35:39 +1200 | [diff] [blame] | 9446 | image_create_info.samples = VK_SAMPLE_COUNT_4_BIT; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9447 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 9448 | // Note: Some implementations expect color attachment usage for any |
| 9449 | // multisample surface |
| 9450 | image_create_info.usage = |
| 9451 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 9452 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9453 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9454 | err = |
| 9455 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9456 | ASSERT_VK_SUCCESS(err); |
| 9457 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9458 | // Note: Some implementations expect color attachment usage for any |
| 9459 | // multisample surface |
| 9460 | image_create_info.usage = |
| 9461 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9462 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9463 | err = |
| 9464 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9465 | ASSERT_VK_SUCCESS(err); |
| 9466 | |
| 9467 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9468 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9469 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 9470 | memAlloc.pNext = NULL; |
| 9471 | memAlloc.allocationSize = 0; |
| 9472 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9473 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 9474 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9475 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9476 | pass = |
| 9477 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 9478 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9479 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9480 | ASSERT_VK_SUCCESS(err); |
| 9481 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9482 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9483 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9484 | pass = |
| 9485 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 9486 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9487 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9488 | ASSERT_VK_SUCCESS(err); |
| 9489 | |
| 9490 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 9491 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9492 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9493 | ASSERT_VK_SUCCESS(err); |
| 9494 | |
| 9495 | BeginCommandBuffer(); |
| 9496 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9497 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 9498 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9499 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 9500 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9501 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 9502 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9503 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9504 | resolveRegion.srcOffset.x = 0; |
| 9505 | resolveRegion.srcOffset.y = 0; |
| 9506 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 9507 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9508 | resolveRegion.dstSubresource.mipLevel = 0; |
| 9509 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 9510 | resolveRegion.dstSubresource.layerCount = 0; |
| 9511 | resolveRegion.dstOffset.x = 0; |
| 9512 | resolveRegion.dstOffset.y = 0; |
| 9513 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9514 | resolveRegion.extent.width = 1; |
| 9515 | resolveRegion.extent.height = 1; |
| 9516 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9517 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 9518 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9519 | EndCommandBuffer(); |
| 9520 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9521 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9522 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9523 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9524 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9525 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 9526 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9527 | } |
| 9528 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9529 | TEST_F(VkLayerTest, ResolveImageFormatMismatch) { |
| 9530 | VkResult err; |
| 9531 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9532 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9533 | m_errorMonitor->SetDesiredFailureMsg( |
| 9534 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9535 | "vkCmdResolveImage called with unmatched source and dest formats."); |
| 9536 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9537 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9538 | |
| 9539 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9540 | VkImage srcImage; |
| 9541 | VkImage dstImage; |
| 9542 | VkDeviceMemory srcMem; |
| 9543 | VkDeviceMemory destMem; |
| 9544 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9545 | |
| 9546 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9547 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9548 | image_create_info.pNext = NULL; |
| 9549 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 9550 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 9551 | image_create_info.extent.width = 32; |
| 9552 | image_create_info.extent.height = 1; |
| 9553 | image_create_info.extent.depth = 1; |
| 9554 | image_create_info.mipLevels = 1; |
| 9555 | image_create_info.arrayLayers = 1; |
| 9556 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 9557 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 9558 | // Note: Some implementations expect color attachment usage for any |
| 9559 | // multisample surface |
| 9560 | image_create_info.usage = |
| 9561 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 9562 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9563 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9564 | err = |
| 9565 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9566 | ASSERT_VK_SUCCESS(err); |
| 9567 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9568 | // Set format to something other than source image |
| 9569 | image_create_info.format = VK_FORMAT_R32_SFLOAT; |
| 9570 | // Note: Some implementations expect color attachment usage for any |
| 9571 | // multisample surface |
| 9572 | image_create_info.usage = |
| 9573 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 9574 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9575 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9576 | err = |
| 9577 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9578 | ASSERT_VK_SUCCESS(err); |
| 9579 | |
| 9580 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9581 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9582 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 9583 | memAlloc.pNext = NULL; |
| 9584 | memAlloc.allocationSize = 0; |
| 9585 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9586 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 9587 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9588 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9589 | pass = |
| 9590 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 9591 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9592 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9593 | ASSERT_VK_SUCCESS(err); |
| 9594 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9595 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9596 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9597 | pass = |
| 9598 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 9599 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9600 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9601 | ASSERT_VK_SUCCESS(err); |
| 9602 | |
| 9603 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 9604 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9605 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9606 | ASSERT_VK_SUCCESS(err); |
| 9607 | |
| 9608 | BeginCommandBuffer(); |
| 9609 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9610 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 9611 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9612 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 9613 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9614 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 9615 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9616 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9617 | resolveRegion.srcOffset.x = 0; |
| 9618 | resolveRegion.srcOffset.y = 0; |
| 9619 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 9620 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9621 | resolveRegion.dstSubresource.mipLevel = 0; |
| 9622 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 9623 | resolveRegion.dstSubresource.layerCount = 0; |
| 9624 | resolveRegion.dstOffset.x = 0; |
| 9625 | resolveRegion.dstOffset.y = 0; |
| 9626 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9627 | resolveRegion.extent.width = 1; |
| 9628 | resolveRegion.extent.height = 1; |
| 9629 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9630 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 9631 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9632 | EndCommandBuffer(); |
| 9633 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9634 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9635 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9636 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9637 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9638 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 9639 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9640 | } |
| 9641 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9642 | TEST_F(VkLayerTest, ResolveImageTypeMismatch) { |
| 9643 | VkResult err; |
| 9644 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9645 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9646 | m_errorMonitor->SetDesiredFailureMsg( |
| 9647 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9648 | "vkCmdResolveImage called with unmatched source and dest image types."); |
| 9649 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9650 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9651 | |
| 9652 | // Create two images of different types and try to copy between them |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9653 | VkImage srcImage; |
| 9654 | VkImage dstImage; |
| 9655 | VkDeviceMemory srcMem; |
| 9656 | VkDeviceMemory destMem; |
| 9657 | VkMemoryRequirements memReqs; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9658 | |
| 9659 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9660 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9661 | image_create_info.pNext = NULL; |
| 9662 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 9663 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 9664 | image_create_info.extent.width = 32; |
| 9665 | image_create_info.extent.height = 1; |
| 9666 | image_create_info.extent.depth = 1; |
| 9667 | image_create_info.mipLevels = 1; |
| 9668 | image_create_info.arrayLayers = 1; |
| 9669 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
| 9670 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 9671 | // Note: Some implementations expect color attachment usage for any |
| 9672 | // multisample surface |
| 9673 | image_create_info.usage = |
| 9674 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 9675 | image_create_info.flags = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9676 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9677 | err = |
| 9678 | vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9679 | ASSERT_VK_SUCCESS(err); |
| 9680 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9681 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
| 9682 | // Note: Some implementations expect color attachment usage for any |
| 9683 | // multisample surface |
| 9684 | image_create_info.usage = |
| 9685 | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 9686 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9687 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9688 | err = |
| 9689 | vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9690 | ASSERT_VK_SUCCESS(err); |
| 9691 | |
| 9692 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9693 | VkMemoryAllocateInfo memAlloc = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9694 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
| 9695 | memAlloc.pNext = NULL; |
| 9696 | memAlloc.allocationSize = 0; |
| 9697 | memAlloc.memoryTypeIndex = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9698 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 9699 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9700 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9701 | pass = |
| 9702 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 9703 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9704 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9705 | ASSERT_VK_SUCCESS(err); |
| 9706 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9707 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9708 | memAlloc.allocationSize = memReqs.size; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9709 | pass = |
| 9710 | m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 9711 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9712 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9713 | ASSERT_VK_SUCCESS(err); |
| 9714 | |
| 9715 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 9716 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9717 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9718 | ASSERT_VK_SUCCESS(err); |
| 9719 | |
| 9720 | BeginCommandBuffer(); |
| 9721 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9722 | // VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 9723 | // VK_IMAGE_LAYOUT_GENERAL = 1, |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9724 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 9725 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9726 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 9727 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9728 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9729 | resolveRegion.srcOffset.x = 0; |
| 9730 | resolveRegion.srcOffset.y = 0; |
| 9731 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 9732 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9733 | resolveRegion.dstSubresource.mipLevel = 0; |
| 9734 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 9735 | resolveRegion.dstSubresource.layerCount = 0; |
| 9736 | resolveRegion.dstOffset.x = 0; |
| 9737 | resolveRegion.dstOffset.y = 0; |
| 9738 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9739 | resolveRegion.extent.width = 1; |
| 9740 | resolveRegion.extent.height = 1; |
| 9741 | resolveRegion.extent.depth = 1; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9742 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, |
| 9743 | VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9744 | EndCommandBuffer(); |
| 9745 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9746 | m_errorMonitor->VerifyFound(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9747 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9748 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9749 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9750 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 9751 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 9752 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9753 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9754 | TEST_F(VkLayerTest, DepthStencilImageViewWithColorAspectBitError) { |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9755 | // 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] | 9756 | // to using a DS format, then cause it to hit error due to COLOR_BIT not |
| 9757 | // set in aspect |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9758 | // The image format check comes 2nd in validation so we trigger it first, |
| 9759 | // 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] | 9760 | VkResult err; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9761 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9762 | m_errorMonitor->SetDesiredFailureMsg( |
| 9763 | VK_DEBUG_REPORT_ERROR_BIT_EXT, |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9764 | "Combination depth/stencil image formats can have only the "); |
| 9765 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9766 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9767 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 9768 | VkDescriptorPoolSize ds_type_count = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9769 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 9770 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9771 | |
| 9772 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9773 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 9774 | ds_pool_ci.pNext = NULL; |
| 9775 | ds_pool_ci.maxSets = 1; |
| 9776 | ds_pool_ci.poolSizeCount = 1; |
| 9777 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9778 | |
| 9779 | VkDescriptorPool ds_pool; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9780 | err = |
| 9781 | vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9782 | ASSERT_VK_SUCCESS(err); |
| 9783 | |
| 9784 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9785 | dsl_binding.binding = 0; |
| 9786 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 9787 | dsl_binding.descriptorCount = 1; |
| 9788 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 9789 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9790 | |
| 9791 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9792 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 9793 | ds_layout_ci.pNext = NULL; |
| 9794 | ds_layout_ci.bindingCount = 1; |
| 9795 | ds_layout_ci.pBindings = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9796 | VkDescriptorSetLayout ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9797 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, |
| 9798 | &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9799 | ASSERT_VK_SUCCESS(err); |
| 9800 | |
| 9801 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 9802 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | 00ce540 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 9803 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Jon Ashburn | f19916e | 2016-01-11 13:12:43 -0700 | [diff] [blame] | 9804 | alloc_info.descriptorSetCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9805 | alloc_info.descriptorPool = ds_pool; |
| 9806 | alloc_info.pSetLayouts = &ds_layout; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9807 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, |
| 9808 | &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9809 | ASSERT_VK_SUCCESS(err); |
| 9810 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9811 | VkImage image_bad; |
| 9812 | VkImage image_good; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9813 | // One bad format and one good format for Color attachment |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9814 | const VkFormat tex_format_bad = VK_FORMAT_D32_SFLOAT_S8_UINT; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9815 | const VkFormat tex_format_good = VK_FORMAT_B8G8R8A8_UNORM; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9816 | const int32_t tex_width = 32; |
| 9817 | const int32_t tex_height = 32; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9818 | |
| 9819 | VkImageCreateInfo image_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9820 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9821 | image_create_info.pNext = NULL; |
| 9822 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 9823 | image_create_info.format = tex_format_bad; |
| 9824 | image_create_info.extent.width = tex_width; |
| 9825 | image_create_info.extent.height = tex_height; |
| 9826 | image_create_info.extent.depth = 1; |
| 9827 | image_create_info.mipLevels = 1; |
| 9828 | image_create_info.arrayLayers = 1; |
| 9829 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 9830 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 9831 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT | |
| 9832 | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 9833 | image_create_info.flags = 0; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9834 | |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9835 | err = |
| 9836 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image_bad); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9837 | ASSERT_VK_SUCCESS(err); |
| 9838 | image_create_info.format = tex_format_good; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9839 | image_create_info.usage = |
| 9840 | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 9841 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, |
| 9842 | &image_good); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9843 | ASSERT_VK_SUCCESS(err); |
| 9844 | |
| 9845 | VkImageViewCreateInfo image_view_create_info = {}; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9846 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 9847 | image_view_create_info.image = image_bad; |
| 9848 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 9849 | image_view_create_info.format = tex_format_bad; |
| 9850 | image_view_create_info.subresourceRange.baseArrayLayer = 0; |
| 9851 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 9852 | image_view_create_info.subresourceRange.layerCount = 1; |
| 9853 | image_view_create_info.subresourceRange.levelCount = 1; |
| 9854 | image_view_create_info.subresourceRange.aspectMask = |
| 9855 | VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9856 | |
| 9857 | VkImageView view; |
Karl Schultz | 6addd81 | 2016-02-02 17:17:23 -0700 | [diff] [blame] | 9858 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, |
| 9859 | &view); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 9860 | |
Chris Forbes | 8f36a8a | 2016-04-07 13:21:07 +1200 | [diff] [blame] | 9861 | m_errorMonitor->VerifyFound(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9862 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9863 | vkDestroyImage(m_device->device(), image_bad, NULL); |
| 9864 | vkDestroyImage(m_device->device(), image_good, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 9865 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 9866 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 9867 | } |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 9868 | #endif // IMAGE_TESTS |
| 9869 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 9870 | int main(int argc, char **argv) { |
| 9871 | int result; |
| 9872 | |
Cody Northrop | 8e54a40 | 2016-03-08 22:25:52 -0700 | [diff] [blame] | 9873 | #ifdef ANDROID |
| 9874 | int vulkanSupport = InitVulkan(); |
| 9875 | if (vulkanSupport == 0) |
| 9876 | return 1; |
| 9877 | #endif |
| 9878 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 9879 | ::testing::InitGoogleTest(&argc, argv); |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 9880 | VkTestFramework::InitArgs(&argc, argv); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 9881 | |
| 9882 | ::testing::AddGlobalTestEnvironment(new TestEnvironment); |
| 9883 | |
| 9884 | result = RUN_ALL_TESTS(); |
| 9885 | |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 9886 | VkTestFramework::Finish(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 9887 | return result; |
| 9888 | } |