Tony Barbour | d04e8df | 2015-11-17 10:02:56 -0700 | [diff] [blame] | 1 | // |
| 2 | // Copyright (C) 2015 Valve Corporation |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 3 | // Copyright (C) 2015 Google, Inc. |
Tony Barbour | d04e8df | 2015-11-17 10:02:56 -0700 | [diff] [blame] | 4 | // |
| 5 | // Permission is hereby granted, free of charge, to any person obtaining a |
| 6 | // copy of this software and associated documentation files (the "Software"), |
| 7 | // to deal in the Software without restriction, including without limitation |
| 8 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 9 | // and/or sell copies of the Software, and to permit persons to whom the |
| 10 | // Software is furnished to do so, subject to the following conditions: |
| 11 | // |
| 12 | // The above copyright notice and this permission notice shall be included |
| 13 | // in all copies or substantial portions of the Software. |
| 14 | // |
| 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 18 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 20 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 21 | // DEALINGS IN THE SOFTWARE. |
| 22 | // |
| 23 | // Author: Chia-I Wu <olvaffe@gmail.com> |
| 24 | // Author: Chris Forbes <chrisf@ijw.co.nz> |
| 25 | // Author: Courtney Goeltzenleuchter <courtney@LunarG.com> |
| 26 | // Author: Mark Lobodzinski <mark@lunarg.com> |
| 27 | // Author: Mike Stroyan <mike@LunarG.com> |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 28 | // Author: Tobin Ehlis <tobine@google.com> |
Tony Barbour | d04e8df | 2015-11-17 10:02:56 -0700 | [diff] [blame] | 29 | // Author: Tony Barbour <tony@LunarG.com> |
| 30 | |
| 31 | |
David Pinedo | 329ca9e | 2015-11-06 12:54:48 -0700 | [diff] [blame] | 32 | #include <vulkan/vulkan.h> |
David Pinedo | a31fe0b | 2015-11-24 09:00:24 -0700 | [diff] [blame] | 33 | #include "vulkan/vk_lunarg_debug_report.h" |
Courtney Goeltzenleuchter | 0abdb66 | 2015-10-07 13:28:58 -0600 | [diff] [blame] | 34 | #include "test_common.h" |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 35 | #include "vkrenderframework.h" |
Tobin Ehlis | 56d204a | 2015-07-03 10:15:26 -0600 | [diff] [blame] | 36 | #include "vk_layer_config.h" |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 37 | #include "../icd/common/icd-spv.h" |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 38 | |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 39 | #define GLM_FORCE_RADIANS |
| 40 | #include "glm/glm.hpp" |
| 41 | #include <glm/gtc/matrix_transform.hpp> |
| 42 | |
Tobin Ehlis | 57e6a61 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 43 | #define MEM_TRACKER_TESTS 1 |
| 44 | #define OBJ_TRACKER_TESTS 1 |
| 45 | #define DRAW_STATE_TESTS 1 |
| 46 | #define THREADING_TESTS 1 |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 47 | #define SHADER_CHECKER_TESTS 1 |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 48 | #define DEVICE_LIMITS_TESTS 1 |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 49 | #define IMAGE_TESTS 1 |
Tobin Ehlis | 57e6a61 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 50 | |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 51 | //-------------------------------------------------------------------------------------- |
| 52 | // Mesh and VertexFormat Data |
| 53 | //-------------------------------------------------------------------------------------- |
| 54 | struct Vertex |
| 55 | { |
| 56 | float posX, posY, posZ, posW; // Position data |
| 57 | float r, g, b, a; // Color |
| 58 | }; |
| 59 | |
| 60 | #define XYZ1(_x_, _y_, _z_) (_x_), (_y_), (_z_), 1.f |
| 61 | |
| 62 | typedef enum _BsoFailSelect { |
| 63 | BsoFailNone = 0x00000000, |
Cody Northrop | e4bc694 | 2015-08-26 10:01:32 -0600 | [diff] [blame] | 64 | BsoFailLineWidth = 0x00000001, |
| 65 | BsoFailDepthBias = 0x00000002, |
Cody Northrop | f5bd225 | 2015-08-17 11:10:49 -0600 | [diff] [blame] | 66 | BsoFailViewport = 0x00000004, |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 67 | BsoFailScissor = 0x00000008, |
| 68 | BsoFailBlend = 0x00000010, |
| 69 | BsoFailDepthBounds = 0x00000020, |
| 70 | BsoFailStencilReadMask = 0x00000040, |
| 71 | BsoFailStencilWriteMask = 0x00000080, |
| 72 | BsoFailStencilReference = 0x00000100, |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 73 | } BsoFailSelect; |
| 74 | |
| 75 | struct vktriangle_vs_uniform { |
| 76 | // Must start with MVP |
| 77 | float mvp[4][4]; |
| 78 | float position[3][4]; |
| 79 | float color[3][4]; |
| 80 | }; |
| 81 | |
Mark Lobodzinski | 6bbdff1 | 2015-06-02 09:41:30 -0500 | [diff] [blame] | 82 | static const char bindStateVertShaderText[] = |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 83 | "#version 130\n" |
| 84 | "vec2 vertices[3];\n" |
| 85 | "void main() {\n" |
| 86 | " vertices[0] = vec2(-1.0, -1.0);\n" |
| 87 | " vertices[1] = vec2( 1.0, -1.0);\n" |
| 88 | " vertices[2] = vec2( 0.0, 1.0);\n" |
| 89 | " gl_Position = vec4(vertices[gl_VertexID % 3], 0.0, 1.0);\n" |
| 90 | "}\n"; |
| 91 | |
Mark Lobodzinski | 6bbdff1 | 2015-06-02 09:41:30 -0500 | [diff] [blame] | 92 | static const char bindStateFragShaderText[] = |
Cody Northrop | 74a2d2c | 2015-06-16 17:32:04 -0600 | [diff] [blame] | 93 | "#version 140\n" |
| 94 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 95 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 96 | "\n" |
| 97 | "layout(location = 0) out vec4 uFragColor;\n" |
| 98 | "void main(){\n" |
| 99 | " uFragColor = vec4(0,1,0,1);\n" |
| 100 | "}\n"; |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 101 | |
Courtney Goeltzenleuchter | 0d6857f | 2015-09-04 13:52:24 -0600 | [diff] [blame] | 102 | static VkBool32 myDbgFunc( |
Tony Barbour | e84a8d6 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 103 | VkFlags msgFlags, |
| 104 | VkDbgObjectType objType, |
| 105 | uint64_t srcObject, |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 106 | size_t location, |
| 107 | int32_t msgCode, |
| 108 | const char* pLayerPrefix, |
| 109 | const char* pMsg, |
| 110 | void* pUserData); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 111 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 112 | // ******************************************************** |
| 113 | // ErrorMonitor Usage: |
| 114 | // |
| 115 | // Call SetDesiredFailureMsg with a string to be compared against all |
| 116 | // encountered log messages. Passing NULL will match all log messages. |
| 117 | // logMsg will return true for skipCall only if msg is matched or NULL. |
| 118 | // |
| 119 | // Call DesiredMsgFound to determine if the desired failure message |
| 120 | // was encountered. |
| 121 | |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 122 | class ErrorMonitor { |
| 123 | public: |
Tony Barbour | 0c1bdc6 | 2015-04-29 17:34:29 -0600 | [diff] [blame] | 124 | ErrorMonitor() |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 125 | { |
Mike Stroyan | 7016f4f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 126 | test_platform_thread_create_mutex(&m_mutex); |
| 127 | test_platform_thread_lock_mutex(&m_mutex); |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 128 | m_msgFlags = VK_DBG_REPORT_INFO_BIT; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 129 | m_bailout = NULL; |
Mike Stroyan | 7016f4f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 130 | test_platform_thread_unlock_mutex(&m_mutex); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 131 | } |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 132 | |
| 133 | void SetDesiredFailureMsg(VkFlags msgFlags, const char *msgString) |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 134 | { |
Mike Stroyan | 7016f4f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 135 | test_platform_thread_lock_mutex(&m_mutex); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 136 | m_desiredMsg.clear(); |
| 137 | m_failureMsg.clear(); |
| 138 | m_otherMsgs.clear(); |
| 139 | m_desiredMsg = msgString; |
| 140 | m_msgFound = VK_FALSE; |
| 141 | m_msgFlags = msgFlags; |
Mike Stroyan | 7016f4f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 142 | test_platform_thread_unlock_mutex(&m_mutex); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 143 | } |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 144 | |
| 145 | VkBool32 CheckForDesiredMsg(VkFlags msgFlags, const char *msgString) |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 146 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 147 | VkBool32 result = VK_FALSE; |
Mike Stroyan | 7016f4f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 148 | test_platform_thread_lock_mutex(&m_mutex); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 149 | if (m_bailout != NULL) { |
| 150 | *m_bailout = true; |
| 151 | } |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 152 | string errorString(msgString); |
| 153 | if (msgFlags & m_msgFlags) { |
| 154 | if (errorString.find(m_desiredMsg) != string::npos) { |
| 155 | m_failureMsg = errorString; |
| 156 | m_msgFound = VK_TRUE; |
| 157 | result = VK_TRUE; |
| 158 | } else { |
| 159 | m_otherMsgs.push_back(errorString); |
| 160 | } |
| 161 | } |
Mike Stroyan | 7016f4f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 162 | test_platform_thread_unlock_mutex(&m_mutex); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 163 | return result; |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 164 | } |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 165 | |
| 166 | vector<string> GetOtherFailureMsgs(void) |
| 167 | { |
| 168 | return m_otherMsgs; |
| 169 | } |
| 170 | |
| 171 | string GetFailureMsg(void) |
| 172 | { |
| 173 | return m_failureMsg; |
| 174 | } |
| 175 | |
| 176 | VkBool32 DesiredMsgFound(void) |
| 177 | { |
| 178 | return m_msgFound; |
| 179 | } |
| 180 | |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 181 | void SetBailout(bool *bailout) |
| 182 | { |
| 183 | m_bailout = bailout; |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 184 | } |
| 185 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 186 | void DumpFailureMsgs(void) |
| 187 | { |
| 188 | vector<string> otherMsgs = GetOtherFailureMsgs(); |
| 189 | cout << "Other error messages logged for this test were:" << endl; |
| 190 | for (auto iter = otherMsgs.begin(); iter != otherMsgs.end(); iter++) { |
| 191 | cout << " " << *iter << endl; |
| 192 | } |
| 193 | } |
| 194 | |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 195 | private: |
Mike Stroyan | 7016f4f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 196 | VkFlags m_msgFlags; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 197 | string m_desiredMsg; |
| 198 | string m_failureMsg; |
| 199 | vector<string> m_otherMsgs; |
Mike Stroyan | 7016f4f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 200 | test_platform_thread_mutex m_mutex; |
| 201 | bool* m_bailout; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 202 | VkBool32 m_msgFound; |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 203 | }; |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 204 | |
Courtney Goeltzenleuchter | 0d6857f | 2015-09-04 13:52:24 -0600 | [diff] [blame] | 205 | static VkBool32 myDbgFunc( |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 206 | VkFlags msgFlags, |
Tony Barbour | e84a8d6 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 207 | VkDbgObjectType objType, |
| 208 | uint64_t srcObject, |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 209 | size_t location, |
| 210 | int32_t msgCode, |
| 211 | const char* pLayerPrefix, |
| 212 | const char* pMsg, |
| 213 | void* pUserData) |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 214 | { |
Tony Barbour | 192f02b | 2015-11-06 14:21:31 -0700 | [diff] [blame] | 215 | if (msgFlags & (VK_DBG_REPORT_WARN_BIT | VK_DBG_REPORT_PERF_WARN_BIT | VK_DBG_REPORT_ERROR_BIT)) { |
Tony Barbour | 8508b8e | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 216 | ErrorMonitor *errMonitor = (ErrorMonitor *)pUserData; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 217 | return errMonitor->CheckForDesiredMsg(msgFlags, pMsg); |
Tony Barbour | 8508b8e | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 218 | } |
Courtney Goeltzenleuchter | 0d6857f | 2015-09-04 13:52:24 -0600 | [diff] [blame] | 219 | return false; |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 220 | } |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 221 | |
Tony Barbour | 0199918 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 222 | class VkLayerTest : public VkRenderFramework |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 223 | { |
| 224 | public: |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 225 | VkResult BeginCommandBuffer(VkCommandBufferObj &commandBuffer); |
| 226 | VkResult EndCommandBuffer(VkCommandBufferObj &commandBuffer); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 227 | void VKTriangleTest(const char *vertShaderText, const char *fragShaderText, BsoFailSelect failMask); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 228 | void GenericDrawPreparation(VkCommandBufferObj *commandBuffer, VkPipelineObj &pipelineobj, VkDescriptorSetObj &descriptorSet, BsoFailSelect failMask); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 229 | void GenericDrawPreparation(VkPipelineObj &pipelineobj, VkDescriptorSetObj &descriptorSet, BsoFailSelect failMask) |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 230 | { GenericDrawPreparation(m_commandBuffer, pipelineobj, descriptorSet, failMask); } |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 231 | |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 232 | /* Convenience functions that use built-in command buffer */ |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 233 | VkResult BeginCommandBuffer() { return BeginCommandBuffer(*m_commandBuffer); } |
| 234 | VkResult EndCommandBuffer() { return EndCommandBuffer(*m_commandBuffer); } |
Courtney Goeltzenleuchter | 4ff11cc | 2015-09-23 12:31:50 -0600 | [diff] [blame] | 235 | void Draw(uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance) |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 236 | { m_commandBuffer->Draw(vertexCount, instanceCount, firstVertex, firstInstance); } |
Courtney Goeltzenleuchter | 4ff11cc | 2015-09-23 12:31:50 -0600 | [diff] [blame] | 237 | void DrawIndexed(uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t vertexOffset, uint32_t firstInstance) |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 238 | { m_commandBuffer->DrawIndexed(indexCount, instanceCount, firstIndex, vertexOffset, firstInstance); } |
| 239 | void QueueCommandBuffer() { m_commandBuffer->QueueCommandBuffer(); } |
| 240 | void QueueCommandBuffer(const VkFence& fence) { m_commandBuffer->QueueCommandBuffer(fence); } |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 241 | void BindVertexBuffer(VkConstantBufferObj *vertexBuffer, VkDeviceSize offset, uint32_t binding) |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 242 | { m_commandBuffer->BindVertexBuffer(vertexBuffer, offset, binding); } |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 243 | void BindIndexBuffer(VkIndexBufferObj *indexBuffer, VkDeviceSize offset) |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 244 | { m_commandBuffer->BindIndexBuffer(indexBuffer, offset); } |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 245 | protected: |
Tony Barbour | 0199918 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 246 | ErrorMonitor *m_errorMonitor; |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 247 | |
| 248 | virtual void SetUp() { |
Courtney Goeltzenleuchter | f5c6195 | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 249 | std::vector<const char *> instance_layer_names; |
| 250 | std::vector<const char *> device_layer_names; |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 251 | std::vector<const char *> instance_extension_names; |
| 252 | std::vector<const char *> device_extension_names; |
Tony Barbour | 950ebc0 | 2015-04-23 12:55:36 -0600 | [diff] [blame] | 253 | |
Courtney Goeltzenleuchter | 846298c | 2015-07-30 11:32:46 -0600 | [diff] [blame] | 254 | instance_extension_names.push_back(VK_DEBUG_REPORT_EXTENSION_NAME); |
Courtney Goeltzenleuchter | de53c5b | 2015-06-16 15:59:11 -0600 | [diff] [blame] | 255 | /* |
| 256 | * Since CreateDbgMsgCallback is an instance level extension call |
| 257 | * any extension / layer that utilizes that feature also needs |
| 258 | * to be enabled at create instance time. |
| 259 | */ |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 260 | // Use Threading layer first to protect others from ThreadCommandBufferCollision test |
Jon Ashburn | 1068ad5 | 2015-11-25 08:56:58 -0700 | [diff] [blame] | 261 | instance_layer_names.push_back("VK_LAYER_LUNARG_Threading"); |
| 262 | instance_layer_names.push_back("VK_LAYER_LUNARG_ObjectTracker"); |
| 263 | instance_layer_names.push_back("VK_LAYER_LUNARG_MemTracker"); |
| 264 | instance_layer_names.push_back("VK_LAYER_LUNARG_DrawState"); |
Jon Ashburn | 1068ad5 | 2015-11-25 08:56:58 -0700 | [diff] [blame] | 265 | instance_layer_names.push_back("VK_LAYER_LUNARG_DeviceLimits"); |
| 266 | instance_layer_names.push_back("VK_LAYER_LUNARG_Image"); |
Courtney Goeltzenleuchter | 23b5f8d | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 267 | |
Jon Ashburn | 1068ad5 | 2015-11-25 08:56:58 -0700 | [diff] [blame] | 268 | device_layer_names.push_back("VK_LAYER_LUNARG_Threading"); |
| 269 | device_layer_names.push_back("VK_LAYER_LUNARG_ObjectTracker"); |
| 270 | device_layer_names.push_back("VK_LAYER_LUNARG_MemTracker"); |
| 271 | device_layer_names.push_back("VK_LAYER_LUNARG_DrawState"); |
Jon Ashburn | 1068ad5 | 2015-11-25 08:56:58 -0700 | [diff] [blame] | 272 | device_layer_names.push_back("VK_LAYER_LUNARG_DeviceLimits"); |
| 273 | device_layer_names.push_back("VK_LAYER_LUNARG_Image"); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 274 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 275 | this->app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 276 | this->app_info.pNext = NULL; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 277 | this->app_info.pApplicationName = "layer_tests"; |
| 278 | this->app_info.applicationVersion = 1; |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 279 | this->app_info.pEngineName = "unittest"; |
| 280 | this->app_info.engineVersion = 1; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 281 | this->app_info.apiVersion = VK_API_VERSION; |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 282 | |
Tony Barbour | 0c1bdc6 | 2015-04-29 17:34:29 -0600 | [diff] [blame] | 283 | m_errorMonitor = new ErrorMonitor; |
Courtney Goeltzenleuchter | f5c6195 | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 284 | InitFramework(instance_layer_names, device_layer_names, |
| 285 | instance_extension_names, device_extension_names, |
| 286 | myDbgFunc, m_errorMonitor); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 287 | } |
| 288 | |
| 289 | virtual void TearDown() { |
| 290 | // Clean up resources before we reset |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 291 | ShutdownFramework(); |
Tony Barbour | 8508b8e | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 292 | delete m_errorMonitor; |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 293 | } |
| 294 | }; |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 295 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 296 | VkResult VkLayerTest::BeginCommandBuffer(VkCommandBufferObj &commandBuffer) |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 297 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 298 | VkResult result; |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 299 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 300 | result = commandBuffer.BeginCommandBuffer(); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 301 | |
| 302 | /* |
| 303 | * For render test all drawing happens in a single render pass |
| 304 | * on a single command buffer. |
| 305 | */ |
Chris Forbes | fe133ef | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 306 | if (VK_SUCCESS == result && renderPass()) { |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 307 | commandBuffer.BeginRenderPass(renderPassBeginInfo()); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 308 | } |
| 309 | |
| 310 | return result; |
| 311 | } |
| 312 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 313 | VkResult VkLayerTest::EndCommandBuffer(VkCommandBufferObj &commandBuffer) |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 314 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 315 | VkResult result; |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 316 | |
Chris Forbes | fe133ef | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 317 | if (renderPass()) { |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 318 | commandBuffer.EndRenderPass(); |
Chris Forbes | fe133ef | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 319 | } |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 320 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 321 | result = commandBuffer.EndCommandBuffer(); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 322 | |
| 323 | return result; |
| 324 | } |
| 325 | |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 326 | void VkLayerTest::VKTriangleTest(const char *vertShaderText, const char *fragShaderText, BsoFailSelect failMask) |
| 327 | { |
| 328 | // Create identity matrix |
| 329 | int i; |
| 330 | struct vktriangle_vs_uniform data; |
| 331 | |
| 332 | glm::mat4 Projection = glm::mat4(1.0f); |
| 333 | glm::mat4 View = glm::mat4(1.0f); |
| 334 | glm::mat4 Model = glm::mat4(1.0f); |
| 335 | glm::mat4 MVP = Projection * View * Model; |
| 336 | const int matrixSize = sizeof(MVP); |
| 337 | const int bufSize = sizeof(vktriangle_vs_uniform) / sizeof(float); |
| 338 | |
| 339 | memcpy(&data.mvp, &MVP[0][0], matrixSize); |
| 340 | |
| 341 | static const Vertex tri_data[] = |
| 342 | { |
| 343 | { XYZ1( -1, -1, 0 ), XYZ1( 1.f, 0.f, 0.f ) }, |
| 344 | { XYZ1( 1, -1, 0 ), XYZ1( 0.f, 1.f, 0.f ) }, |
| 345 | { XYZ1( 0, 1, 0 ), XYZ1( 0.f, 0.f, 1.f ) }, |
| 346 | }; |
| 347 | |
| 348 | for (i=0; i<3; i++) { |
| 349 | data.position[i][0] = tri_data[i].posX; |
| 350 | data.position[i][1] = tri_data[i].posY; |
| 351 | data.position[i][2] = tri_data[i].posZ; |
| 352 | data.position[i][3] = tri_data[i].posW; |
| 353 | data.color[i][0] = tri_data[i].r; |
| 354 | data.color[i][1] = tri_data[i].g; |
| 355 | data.color[i][2] = tri_data[i].b; |
| 356 | data.color[i][3] = tri_data[i].a; |
| 357 | } |
| 358 | |
| 359 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 360 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 361 | |
| 362 | VkConstantBufferObj constantBuffer(m_device, bufSize*2, sizeof(float), (const void*) &data); |
| 363 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 364 | VkShaderObj vs(m_device,vertShaderText,VK_SHADER_STAGE_VERTEX_BIT, this); |
| 365 | VkShaderObj ps(m_device,fragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 366 | |
| 367 | VkPipelineObj pipelineobj(m_device); |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 368 | pipelineobj.AddColorAttachment(); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 369 | pipelineobj.AddShader(&vs); |
| 370 | pipelineobj.AddShader(&ps); |
Courtney Goeltzenleuchter | 2f5deb5 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 371 | if (failMask & BsoFailLineWidth) { |
| 372 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_LINE_WIDTH); |
| 373 | } |
| 374 | if (failMask & BsoFailDepthBias) { |
| 375 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_DEPTH_BIAS); |
| 376 | } |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 377 | // Viewport and scissors must stay in synch or other errors will occur than the ones we want |
Courtney Goeltzenleuchter | 2f5deb5 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 378 | if (failMask & BsoFailViewport) { |
| 379 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_VIEWPORT); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 380 | m_viewports.clear(); |
| 381 | m_scissors.clear(); |
Courtney Goeltzenleuchter | 2f5deb5 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 382 | } |
| 383 | if (failMask & BsoFailScissor) { |
| 384 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_SCISSOR); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 385 | m_scissors.clear(); |
| 386 | m_viewports.clear(); |
Courtney Goeltzenleuchter | 2f5deb5 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 387 | } |
| 388 | if (failMask & BsoFailBlend) { |
| 389 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_BLEND_CONSTANTS); |
| 390 | } |
| 391 | if (failMask & BsoFailDepthBounds) { |
| 392 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_DEPTH_BOUNDS); |
| 393 | } |
| 394 | if (failMask & BsoFailStencilReadMask) { |
| 395 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK); |
| 396 | } |
| 397 | if (failMask & BsoFailStencilWriteMask) { |
| 398 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_WRITE_MASK); |
| 399 | } |
| 400 | if (failMask & BsoFailStencilReference) { |
| 401 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_REFERENCE); |
| 402 | } |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 403 | |
| 404 | VkDescriptorSetObj descriptorSet(m_device); |
| 405 | descriptorSet.AppendBuffer(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, constantBuffer); |
| 406 | |
| 407 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 408 | ASSERT_VK_SUCCESS(BeginCommandBuffer()); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 409 | |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 410 | GenericDrawPreparation(pipelineobj, descriptorSet, failMask); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 411 | |
| 412 | // render triangle |
Courtney Goeltzenleuchter | 4ff11cc | 2015-09-23 12:31:50 -0600 | [diff] [blame] | 413 | Draw(3, 1, 0, 0); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 414 | |
| 415 | // finalize recording of the command buffer |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 416 | EndCommandBuffer(); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 417 | |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 418 | QueueCommandBuffer(); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 419 | } |
| 420 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 421 | void VkLayerTest::GenericDrawPreparation(VkCommandBufferObj *commandBuffer, VkPipelineObj &pipelineobj, VkDescriptorSetObj &descriptorSet, BsoFailSelect failMask) |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 422 | { |
| 423 | if (m_depthStencil->Initialized()) { |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 424 | commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, m_stencil_clear_color, m_depthStencil); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 425 | } else { |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 426 | commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, m_stencil_clear_color, NULL); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 427 | } |
| 428 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 429 | commandBuffer->PrepareAttachments(); |
Cody Northrop | 2605cb0 | 2015-08-18 15:21:16 -0600 | [diff] [blame] | 430 | // Make sure depthWriteEnable is set so that Depth fail test will work correctly |
| 431 | // Make sure stencilTestEnable is set so that Stencil fail test will work correctly |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 432 | VkStencilOpState stencil = {}; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 433 | stencil.failOp = VK_STENCIL_OP_KEEP; |
| 434 | stencil.passOp = VK_STENCIL_OP_KEEP; |
| 435 | stencil.depthFailOp = VK_STENCIL_OP_KEEP; |
| 436 | stencil.compareOp = VK_COMPARE_OP_NEVER; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 437 | |
| 438 | VkPipelineDepthStencilStateCreateInfo ds_ci = {}; |
| 439 | ds_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO; |
Courtney Goeltzenleuchter | 2f5deb5 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 440 | ds_ci.pNext = NULL; |
| 441 | ds_ci.depthTestEnable = VK_FALSE; |
| 442 | ds_ci.depthWriteEnable = VK_TRUE; |
| 443 | ds_ci.depthCompareOp = VK_COMPARE_OP_NEVER; |
| 444 | ds_ci.depthBoundsTestEnable = VK_FALSE; |
| 445 | ds_ci.stencilTestEnable = VK_TRUE; |
| 446 | ds_ci.front = stencil; |
| 447 | ds_ci.back = stencil; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 448 | |
Tobin Ehlis | 40e9f52 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 449 | pipelineobj.SetDepthStencil(&ds_ci); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 450 | pipelineobj.SetViewport(m_viewports); |
| 451 | pipelineobj.SetScissor(m_scissors); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 452 | descriptorSet.CreateVKDescriptorSet(commandBuffer); |
Cody Northrop | ccfa96d | 2015-08-27 10:20:35 -0600 | [diff] [blame] | 453 | VkResult err = pipelineobj.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 454 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 455 | commandBuffer->BindPipeline(pipelineobj); |
| 456 | commandBuffer->BindDescriptorSet(descriptorSet); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 457 | } |
| 458 | |
| 459 | // ******************************************************************************************************************** |
| 460 | // ******************************************************************************************************************** |
| 461 | // ******************************************************************************************************************** |
| 462 | // ******************************************************************************************************************** |
Tobin Ehlis | 57e6a61 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 463 | #if MEM_TRACKER_TESTS |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 464 | #if 0 |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 465 | TEST_F(VkLayerTest, CallResetCommandBufferBeforeCompletion) |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 466 | { |
| 467 | vk_testing::Fence testFence; |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 468 | VkFenceCreateInfo fenceInfo = {}; |
| 469 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 470 | fenceInfo.pNext = NULL; |
| 471 | fenceInfo.flags = 0; |
| 472 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 473 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, "Resetting CB"); |
| 474 | |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 475 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tony Barbour | e389b88 | 2015-07-20 13:00:10 -0600 | [diff] [blame] | 476 | |
| 477 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 478 | vk_testing::Buffer buffer; |
| 479 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 480 | |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 481 | BeginCommandBuffer(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 482 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 4, 0x11111111); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 483 | EndCommandBuffer(); |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 484 | |
| 485 | testFence.init(*m_device, fenceInfo); |
| 486 | |
| 487 | // Bypass framework since it does the waits automatically |
| 488 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 1a748e9 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 489 | VkSubmitInfo submit_info; |
Chia-I Wu | 6ec33a0 | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 490 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 491 | submit_info.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 492 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 1a748e9 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 493 | submit_info.pWaitSemaphores = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 494 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 495 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 496 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 1a748e9 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 497 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 3ec3162 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 498 | |
| 499 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 500 | ASSERT_VK_SUCCESS( err ); |
| 501 | |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 502 | // Introduce failure by calling begin again before checking fence |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 503 | vkResetCommandBuffer(m_commandBuffer->handle(), 0); |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 504 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 505 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 506 | FAIL() << "Did not receive Error 'Resetting CB (0xaddress) before it has completed. You must check CB flag before.'"; |
| 507 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 508 | } |
| 509 | } |
| 510 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 511 | TEST_F(VkLayerTest, CallBeginCommandBufferBeforeCompletion) |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 512 | { |
| 513 | vk_testing::Fence testFence; |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 514 | VkFenceCreateInfo fenceInfo = {}; |
| 515 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 516 | fenceInfo.pNext = NULL; |
| 517 | fenceInfo.flags = 0; |
| 518 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 519 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, "Calling vkBeginCommandBuffer() on active CB"); |
| 520 | |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 521 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 522 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 523 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 524 | |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 525 | BeginCommandBuffer(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 526 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, m_stencil_clear_color, NULL); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 527 | EndCommandBuffer(); |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 528 | |
| 529 | testFence.init(*m_device, fenceInfo); |
| 530 | |
| 531 | // Bypass framework since it does the waits automatically |
| 532 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 1a748e9 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 533 | VkSubmitInfo submit_info; |
Chia-I Wu | 6ec33a0 | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 534 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 535 | submit_info.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 536 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 1a748e9 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 537 | submit_info.pWaitSemaphores = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 538 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 539 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 540 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 1a748e9 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 541 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 3ec3162 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 542 | |
| 543 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 544 | ASSERT_VK_SUCCESS( err ); |
| 545 | |
Mark Lobodzinski | 87db501 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 546 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 547 | VkCommandBufferBeginInfo info = {}; |
| 548 | info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
| 549 | info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Mark Lobodzinski | 87db501 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 550 | info.renderPass = VK_NULL_HANDLE; |
| 551 | info.subpass = 0; |
| 552 | info.framebuffer = VK_NULL_HANDLE; |
Chia-I Wu | fdc1cd0 | 2015-11-11 10:18:12 +0800 | [diff] [blame] | 553 | info.occlusionQueryEnable = VK_FALSE; |
| 554 | info.queryFlags = 0; |
| 555 | info.pipelineStatistics = 0; |
Mark Lobodzinski | 87db501 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 556 | |
| 557 | // Introduce failure by calling BCB again before checking fence |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 558 | vkBeginCommandBuffer(m_commandBuffer->handle(), &info); |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 559 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 560 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 561 | FAIL() << "Did not receive Error 'Calling vkBeginCommandBuffer() on an active CB (0xaddress) before it has completed'"; |
| 562 | m_errorMonitor->DumpFailureMsgs(); |
| 563 | |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 564 | } |
| 565 | } |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 566 | #endif |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 567 | TEST_F(VkLayerTest, MapMemWithoutHostVisibleBit) |
| 568 | { |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 569 | VkResult err; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 570 | bool pass; |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 571 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 572 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 573 | "Mapping Memory without VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT"); |
| 574 | |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 575 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 576 | |
| 577 | // Create an image, allocate memory, free it, and then try to bind it |
| 578 | VkImage image; |
Mark Lobodzinski | 2318261 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 579 | VkDeviceMemory mem; |
| 580 | VkMemoryRequirements mem_reqs; |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 581 | |
| 582 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 583 | const int32_t tex_width = 32; |
| 584 | const int32_t tex_height = 32; |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 585 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 586 | VkImageCreateInfo image_create_info = {}; |
| 587 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 588 | image_create_info.pNext = NULL; |
| 589 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 590 | image_create_info.format = tex_format; |
| 591 | image_create_info.extent.width = tex_width; |
| 592 | image_create_info.extent.height = tex_height; |
| 593 | image_create_info.extent.depth = 1; |
| 594 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 595 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 596 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 597 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 598 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 599 | image_create_info.flags = 0; |
Mark Lobodzinski | 87db501 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 600 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 601 | VkMemoryAllocateInfo mem_alloc = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 602 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 603 | mem_alloc.pNext = NULL; |
| 604 | mem_alloc.allocationSize = 0; |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 605 | // Introduce failure, do NOT set memProps to VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 606 | mem_alloc.memoryTypeIndex = 1; |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 607 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 608 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 609 | ASSERT_VK_SUCCESS(err); |
| 610 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 611 | vkGetImageMemoryRequirements(m_device->device(), |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 612 | image, |
Mark Lobodzinski | 2318261 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 613 | &mem_reqs); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 614 | |
Mark Lobodzinski | 2318261 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 615 | mem_alloc.allocationSize = mem_reqs.size; |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 616 | |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 617 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 618 | if(!pass) { // If we can't find any unmappable memory this test doesn't make sense |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 619 | vkDestroyImage(m_device->device(), image, NULL); |
Tony Barbour | 49a3b65 | 2015-08-04 16:13:01 -0600 | [diff] [blame] | 620 | return; |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 621 | } |
Mike Stroyan | d72da75 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 622 | |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 623 | // allocate memory |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 624 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 625 | ASSERT_VK_SUCCESS(err); |
| 626 | |
| 627 | // Try to bind free memory that has been freed |
Tony Barbour | e84a8d6 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 628 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 629 | ASSERT_VK_SUCCESS(err); |
| 630 | |
| 631 | // Map memory as if to initialize the image |
| 632 | void *mappedAddress = NULL; |
Mark Lobodzinski | 2318261 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 633 | err = vkMapMemory(m_device->device(), mem, 0, 0, 0, &mappedAddress); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 634 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 635 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 636 | FAIL() << "Did not receive Error 'Error received did not match expected error message from vkMapMemory in MemTracker'"; |
| 637 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 638 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 639 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 640 | vkDestroyImage(m_device->device(), image, NULL); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 641 | } |
| 642 | |
Tobin Ehlis | 33ce8fd | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 643 | // TODO : Is this test still valid. Not sure it is with updates to memory binding model |
| 644 | // Verify and delete the test of fix the check |
| 645 | //TEST_F(VkLayerTest, FreeBoundMemory) |
| 646 | //{ |
Tobin Ehlis | 33ce8fd | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 647 | // VkResult err; |
| 648 | // |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 649 | // m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_WARN_BIT, |
| 650 | // "Freeing memory object while it still has references"); |
Tobin Ehlis | 33ce8fd | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 651 | // |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 652 | // ASSERT_NO_FATAL_FAILURE(InitState()); |
| 653 | |
Tobin Ehlis | 33ce8fd | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 654 | // // Create an image, allocate memory, free it, and then try to bind it |
| 655 | // VkImage image; |
| 656 | // VkDeviceMemory mem; |
| 657 | // VkMemoryRequirements mem_reqs; |
| 658 | // |
| 659 | // const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 660 | // const int32_t tex_width = 32; |
| 661 | // const int32_t tex_height = 32; |
| 662 | // |
| 663 | // const VkImageCreateInfo image_create_info = { |
| 664 | // .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, |
| 665 | // .pNext = NULL, |
| 666 | // .imageType = VK_IMAGE_TYPE_2D, |
| 667 | // .format = tex_format, |
| 668 | // .extent = { tex_width, tex_height, 1 }, |
| 669 | // .mipLevels = 1, |
| 670 | // .arraySize = 1, |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 671 | // .samples = VK_SAMPLE_COUNT_1_BIT, |
Tobin Ehlis | 33ce8fd | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 672 | // .tiling = VK_IMAGE_TILING_LINEAR, |
| 673 | // .usage = VK_IMAGE_USAGE_SAMPLED_BIT, |
| 674 | // .flags = 0, |
| 675 | // }; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 676 | // VkMemoryAllocateInfo mem_alloc = { |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 677 | // .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO, |
Tobin Ehlis | 33ce8fd | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 678 | // .pNext = NULL, |
| 679 | // .allocationSize = 0, |
| 680 | // .memoryTypeIndex = 0, |
| 681 | // }; |
| 682 | // |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 683 | // err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | 33ce8fd | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 684 | // ASSERT_VK_SUCCESS(err); |
| 685 | // |
| 686 | // err = vkGetImageMemoryRequirements(m_device->device(), |
| 687 | // image, |
| 688 | // &mem_reqs); |
| 689 | // ASSERT_VK_SUCCESS(err); |
| 690 | // |
| 691 | // mem_alloc.allocationSize = mem_reqs.size; |
| 692 | // |
| 693 | // err = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
| 694 | // ASSERT_VK_SUCCESS(err); |
| 695 | // |
| 696 | // // allocate memory |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 697 | // err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | 33ce8fd | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 698 | // ASSERT_VK_SUCCESS(err); |
| 699 | // |
| 700 | // // Bind memory to Image object |
| 701 | // err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 702 | // ASSERT_VK_SUCCESS(err); |
| 703 | // |
| 704 | // // Introduce validation failure, free memory while still bound to object |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 705 | // vkFreeMemory(m_device->device(), mem, NULL); |
Courtney Goeltzenleuchter | 0d6857f | 2015-09-04 13:52:24 -0600 | [diff] [blame] | 706 | // |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 707 | // if (!m_errorMonitor->DesiredMsgFound()) { |
| 708 | // FAIL() << "Did not receive Warning 'Freeing memory object while it still has references'"); |
| 709 | // m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 33ce8fd | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 710 | // } |
| 711 | //} |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 712 | |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 713 | TEST_F(VkLayerTest, RebindMemory) |
| 714 | { |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 715 | VkResult err; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 716 | bool pass; |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 717 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 718 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 719 | "which has already been bound to mem object"); |
| 720 | |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 721 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 722 | |
| 723 | // Create an image, allocate memory, free it, and then try to bind it |
| 724 | VkImage image; |
| 725 | VkDeviceMemory mem1; |
| 726 | VkDeviceMemory mem2; |
| 727 | VkMemoryRequirements mem_reqs; |
| 728 | |
| 729 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 730 | const int32_t tex_width = 32; |
| 731 | const int32_t tex_height = 32; |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 732 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 733 | VkImageCreateInfo image_create_info = {}; |
| 734 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 735 | image_create_info.pNext = NULL; |
| 736 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 737 | image_create_info.format = tex_format; |
| 738 | image_create_info.extent.width = tex_width; |
| 739 | image_create_info.extent.height = tex_height; |
| 740 | image_create_info.extent.depth = 1; |
| 741 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 742 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 743 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 744 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 745 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 746 | image_create_info.flags = 0; |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 747 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 748 | VkMemoryAllocateInfo mem_alloc = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 749 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 750 | mem_alloc.pNext = NULL; |
| 751 | mem_alloc.allocationSize = 0; |
| 752 | mem_alloc.memoryTypeIndex = 0; |
| 753 | |
| 754 | // Introduce failure, do NOT set memProps to VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
| 755 | mem_alloc.memoryTypeIndex = 1; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 756 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 757 | ASSERT_VK_SUCCESS(err); |
| 758 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 759 | vkGetImageMemoryRequirements(m_device->device(), |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 760 | image, |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 761 | &mem_reqs); |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 762 | |
| 763 | mem_alloc.allocationSize = mem_reqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 764 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
| 765 | ASSERT_TRUE(pass); |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 766 | |
| 767 | // allocate 2 memory objects |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 768 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem1); |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 769 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 770 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem2); |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 771 | ASSERT_VK_SUCCESS(err); |
| 772 | |
| 773 | // Bind first memory object to Image object |
Tony Barbour | e84a8d6 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 774 | err = vkBindImageMemory(m_device->device(), image, mem1, 0); |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 775 | ASSERT_VK_SUCCESS(err); |
| 776 | |
| 777 | // Introduce validation failure, try to bind a different memory object to the same image object |
Tony Barbour | e84a8d6 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 778 | err = vkBindImageMemory(m_device->device(), image, mem2, 0); |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 779 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 780 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 781 | FAIL() << "Did not receive Error when rebinding memory to an object"; |
| 782 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 783 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 784 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 785 | vkDestroyImage(m_device->device(), image, NULL); |
| 786 | vkFreeMemory(m_device->device(), mem1, NULL); |
| 787 | vkFreeMemory(m_device->device(), mem2, NULL); |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 788 | } |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 789 | |
Tony Barbour | 8508b8e | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 790 | TEST_F(VkLayerTest, SubmitSignaledFence) |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 791 | { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 792 | vk_testing::Fence testFence; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 793 | |
| 794 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 795 | "submitted in SIGNALED state. Fences must be reset before being submitted"); |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 796 | |
| 797 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 8508b8e | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 798 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 799 | fenceInfo.pNext = NULL; |
| 800 | fenceInfo.flags = VK_FENCE_CREATE_SIGNALED_BIT; |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 801 | |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 802 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 803 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 804 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 805 | |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 806 | BeginCommandBuffer(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 807 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, m_stencil_clear_color, NULL); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 808 | EndCommandBuffer(); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 809 | |
| 810 | testFence.init(*m_device, fenceInfo); |
Mark Lobodzinski | 87db501 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 811 | |
Courtney Goeltzenleuchter | 1a748e9 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 812 | VkSubmitInfo submit_info; |
Chia-I Wu | 6ec33a0 | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 813 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 814 | submit_info.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 815 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 1a748e9 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 816 | submit_info.pWaitSemaphores = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 817 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 818 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 819 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 1a748e9 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 820 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 3ec3162 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 821 | |
| 822 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
Mark Lobodzinski | 87db501 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 823 | vkQueueWaitIdle(m_device->m_queue ); |
Mark Lobodzinski | 87db501 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 824 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 825 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 826 | FAIL() << "Did not receive Error 'VkQueueSubmit with fence in SIGNALED_STATE'"; |
| 827 | m_errorMonitor->DumpFailureMsgs(); |
Tony Barbour | 8508b8e | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 828 | } |
Tony Barbour | 8508b8e | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 829 | } |
| 830 | |
| 831 | TEST_F(VkLayerTest, ResetUnsignaledFence) |
| 832 | { |
| 833 | vk_testing::Fence testFence; |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 834 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 8508b8e | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 835 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 836 | fenceInfo.pNext = NULL; |
| 837 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 838 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_WARN_BIT, |
| 839 | "submitted to VkResetFences in UNSIGNALED STATE"); |
| 840 | |
Tony Barbour | 8508b8e | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 841 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 842 | testFence.init(*m_device, fenceInfo); |
Chia-I Wu | a499234 | 2015-07-03 11:45:55 +0800 | [diff] [blame] | 843 | VkFence fences[1] = {testFence.handle()}; |
Tony Barbour | 8508b8e | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 844 | vkResetFences(m_device->device(), 1, fences); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 845 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 846 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 847 | FAIL() << "Did not receive Error 'VkResetFences with fence in UNSIGNALED_STATE'"; |
| 848 | m_errorMonitor->DumpFailureMsgs(); |
| 849 | } |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 850 | } |
Tobin Ehlis | d94ba72 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 851 | |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 852 | /* TODO: Update for changes due to bug-14075 tiling across render passes */ |
| 853 | #if 0 |
Tobin Ehlis | d94ba72 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 854 | TEST_F(VkLayerTest, InvalidUsageBits) |
| 855 | { |
| 856 | // Initiate Draw w/o a PSO bound |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 857 | |
| 858 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 859 | "Invalid usage flag for image "); |
Tobin Ehlis | d94ba72 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 860 | |
| 861 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 862 | VkCommandBufferObj commandBuffer(m_device); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 863 | BeginCommandBuffer(); |
Tobin Ehlis | d94ba72 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 864 | |
| 865 | const VkExtent3D e3d = { |
| 866 | .width = 128, |
| 867 | .height = 128, |
| 868 | .depth = 1, |
| 869 | }; |
| 870 | const VkImageCreateInfo ici = { |
| 871 | .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, |
| 872 | .pNext = NULL, |
| 873 | .imageType = VK_IMAGE_TYPE_2D, |
| 874 | .format = VK_FORMAT_D32_SFLOAT_S8_UINT, |
| 875 | .extent = e3d, |
| 876 | .mipLevels = 1, |
| 877 | .arraySize = 1, |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 878 | .samples = VK_SAMPLE_COUNT_1_BIT, |
Tobin Ehlis | d94ba72 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 879 | .tiling = VK_IMAGE_TILING_LINEAR, |
Courtney Goeltzenleuchter | c3b8eea | 2015-09-10 14:14:11 -0600 | [diff] [blame] | 880 | .usage = 0, // Not setting VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
Tobin Ehlis | d94ba72 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 881 | .flags = 0, |
| 882 | }; |
| 883 | |
| 884 | VkImage dsi; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 885 | vkCreateImage(m_device->device(), &ici, NULL, &dsi); |
Tobin Ehlis | d94ba72 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 886 | VkDepthStencilView dsv; |
| 887 | const VkDepthStencilViewCreateInfo dsvci = { |
| 888 | .sType = VK_STRUCTURE_TYPE_DEPTH_STENCIL_VIEW_CREATE_INFO, |
| 889 | .pNext = NULL, |
| 890 | .image = dsi, |
| 891 | .mipLevel = 0, |
Courtney Goeltzenleuchter | 3dee808 | 2015-09-10 16:38:41 -0600 | [diff] [blame] | 892 | .baseArrayLayer = 0, |
Tobin Ehlis | d94ba72 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 893 | .arraySize = 1, |
| 894 | .flags = 0, |
| 895 | }; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 896 | vkCreateDepthStencilView(m_device->device(), &dsvci, NULL, &dsv); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 897 | |
| 898 | if (!m_errorMonitor->DesiredMsgFound()) { |
Tobin Ehlis | d94ba72 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 899 | FAIL() << "Error received was not 'Invalid usage flag for image...'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 900 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | d94ba72 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 901 | } |
| 902 | } |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 903 | #endif // 0 |
| 904 | #endif // MEM_TRACKER_TESTS |
| 905 | |
Tobin Ehlis | 40e9f52 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 906 | #if OBJ_TRACKER_TESTS |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 907 | TEST_F(VkLayerTest, PipelineNotBound) |
| 908 | { |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 909 | VkResult err; |
| 910 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 911 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 912 | "Invalid VkPipeline Object "); |
| 913 | |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 914 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 915 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 916 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 917 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 918 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 919 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 920 | |
| 921 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 922 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 923 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 924 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 925 | ds_pool_ci.poolSizeCount = 1; |
| 926 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 927 | |
| 928 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 929 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 930 | ASSERT_VK_SUCCESS(err); |
| 931 | |
| 932 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 933 | dsl_binding.binding = 0; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 934 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 935 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 936 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 937 | dsl_binding.pImmutableSamplers = NULL; |
| 938 | |
| 939 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 940 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 941 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 942 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 943 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 944 | |
| 945 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 946 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 947 | ASSERT_VK_SUCCESS(err); |
| 948 | |
| 949 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 950 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 951 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 952 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 953 | alloc_info.descriptorPool = ds_pool; |
| 954 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 955 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 956 | ASSERT_VK_SUCCESS(err); |
| 957 | |
| 958 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 959 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 960 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 961 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 962 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 963 | |
| 964 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 965 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 966 | ASSERT_VK_SUCCESS(err); |
| 967 | |
| 968 | VkPipeline badPipeline = (VkPipeline)0xbaadb1be; |
| 969 | |
| 970 | BeginCommandBuffer(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 971 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, badPipeline); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 972 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 973 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 974 | FAIL() << "Error received was not 'Invalid VkPipeline Object 0xbaadb1be'" << endl; |
| 975 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 976 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 977 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 978 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 979 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 980 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 981 | } |
| 982 | |
| 983 | TEST_F(VkLayerTest, BindInvalidMemory) |
| 984 | { |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 985 | VkResult err; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 986 | bool pass; |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 987 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 988 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 989 | "Invalid VkDeviceMemory Object "); |
| 990 | |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 991 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 992 | |
| 993 | // Create an image, allocate memory, free it, and then try to bind it |
| 994 | VkImage image; |
| 995 | VkDeviceMemory mem; |
| 996 | VkMemoryRequirements mem_reqs; |
| 997 | |
| 998 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 999 | const int32_t tex_width = 32; |
| 1000 | const int32_t tex_height = 32; |
| 1001 | |
| 1002 | VkImageCreateInfo image_create_info = {}; |
| 1003 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1004 | image_create_info.pNext = NULL; |
| 1005 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1006 | image_create_info.format = tex_format; |
| 1007 | image_create_info.extent.width = tex_width; |
| 1008 | image_create_info.extent.height = tex_height; |
| 1009 | image_create_info.extent.depth = 1; |
| 1010 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 1011 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1012 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1013 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1014 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 1015 | image_create_info.flags = 0; |
| 1016 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1017 | VkMemoryAllocateInfo mem_alloc = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1018 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1019 | mem_alloc.pNext = NULL; |
| 1020 | mem_alloc.allocationSize = 0; |
| 1021 | mem_alloc.memoryTypeIndex = 0; |
| 1022 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1023 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1024 | ASSERT_VK_SUCCESS(err); |
| 1025 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 1026 | vkGetImageMemoryRequirements(m_device->device(), |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1027 | image, |
| 1028 | &mem_reqs); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1029 | |
| 1030 | mem_alloc.allocationSize = mem_reqs.size; |
| 1031 | |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 1032 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
| 1033 | ASSERT_TRUE(pass); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1034 | |
| 1035 | // allocate memory |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1036 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1037 | ASSERT_VK_SUCCESS(err); |
| 1038 | |
| 1039 | // Introduce validation failure, free memory before binding |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1040 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1041 | |
| 1042 | // Try to bind free memory that has been freed |
| 1043 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 1044 | // This may very well return an error. |
| 1045 | (void)err; |
| 1046 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1047 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1048 | FAIL() << "Did not receive Error 'Invalid VkDeviceMemory Object 0x<handle>'"; |
| 1049 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1050 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1051 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1052 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1053 | } |
| 1054 | |
| 1055 | TEST_F(VkLayerTest, BindMemoryToDestroyedObject) |
| 1056 | { |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1057 | VkResult err; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 1058 | bool pass; |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1059 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1060 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, "Invalid VkImage Object "); |
| 1061 | |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1062 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1063 | |
| 1064 | // Create an image object, allocate memory, destroy the object and then try to bind it |
| 1065 | VkImage image; |
| 1066 | VkDeviceMemory mem; |
| 1067 | VkMemoryRequirements mem_reqs; |
| 1068 | |
| 1069 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 1070 | const int32_t tex_width = 32; |
| 1071 | const int32_t tex_height = 32; |
| 1072 | |
| 1073 | VkImageCreateInfo image_create_info = {}; |
| 1074 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1075 | image_create_info.pNext = NULL; |
| 1076 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1077 | image_create_info.format = tex_format; |
| 1078 | image_create_info.extent.width = tex_width; |
| 1079 | image_create_info.extent.height = tex_height; |
| 1080 | image_create_info.extent.depth = 1; |
| 1081 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 1082 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1083 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1084 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1085 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 1086 | image_create_info.flags = 0; |
| 1087 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1088 | VkMemoryAllocateInfo mem_alloc = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1089 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1090 | mem_alloc.pNext = NULL; |
| 1091 | mem_alloc.allocationSize = 0; |
| 1092 | mem_alloc.memoryTypeIndex = 0; |
| 1093 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1094 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1095 | ASSERT_VK_SUCCESS(err); |
| 1096 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 1097 | vkGetImageMemoryRequirements(m_device->device(), |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1098 | image, |
| 1099 | &mem_reqs); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1100 | |
| 1101 | mem_alloc.allocationSize = mem_reqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 1102 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
| 1103 | ASSERT_TRUE(pass); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1104 | |
| 1105 | // Allocate memory |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1106 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1107 | ASSERT_VK_SUCCESS(err); |
| 1108 | |
| 1109 | // Introduce validation failure, destroy Image object before binding |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1110 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1111 | ASSERT_VK_SUCCESS(err); |
| 1112 | |
| 1113 | // Now Try to bind memory to this destroyed object |
| 1114 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 1115 | // This may very well return an error. |
| 1116 | (void) err; |
| 1117 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1118 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1119 | FAIL() << "Did not receive Error 'Invalid VkImage Object 0x<handle>'"; |
| 1120 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1121 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1122 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1123 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1124 | } |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1125 | |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 1126 | #endif // OBJ_TRACKER_TESTS |
| 1127 | |
Tobin Ehlis | 57e6a61 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 1128 | #if DRAW_STATE_TESTS |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1129 | TEST_F(VkLayerTest, LineWidthStateNotBound) |
| 1130 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1131 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1132 | "Dynamic line width state not set for this command buffer"); |
| 1133 | |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1134 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a line width state object is not bound beforehand"); |
| 1135 | |
| 1136 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailLineWidth); |
| 1137 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1138 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1139 | FAIL() << "Did not receive Error 'Dynamic line width state not set for this command buffer'"; |
| 1140 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1141 | } |
| 1142 | } |
| 1143 | |
| 1144 | TEST_F(VkLayerTest, DepthBiasStateNotBound) |
| 1145 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1146 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1147 | "Dynamic depth bias state not set for this command buffer"); |
| 1148 | |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1149 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a depth bias state object is not bound beforehand"); |
| 1150 | |
| 1151 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailDepthBias); |
| 1152 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1153 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1154 | FAIL() << "Did not receive Error 'Dynamic depth bias state not set for this command buffer'"; |
| 1155 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1156 | } |
| 1157 | } |
| 1158 | |
Cody Northrop | bca3bcd | 2015-10-27 16:54:28 -0600 | [diff] [blame] | 1159 | // Disable these two tests until we can sort out how to track multiple layer errors |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1160 | TEST_F(VkLayerTest, ViewportStateNotBound) |
| 1161 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1162 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1163 | "Dynamic viewport state not set for this command buffer"); |
| 1164 | |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1165 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a viewport state object is not bound beforehand"); |
| 1166 | |
| 1167 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailViewport); |
| 1168 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1169 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1170 | FAIL() << "Did not recieve Error 'Dynamic scissor state not set for this command buffer'"; |
| 1171 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1172 | } |
| 1173 | } |
| 1174 | |
| 1175 | TEST_F(VkLayerTest, ScissorStateNotBound) |
| 1176 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1177 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1178 | "Dynamic scissor state not set for this command buffer"); |
| 1179 | |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1180 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a viewport state object is not bound beforehand"); |
| 1181 | |
| 1182 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailScissor); |
| 1183 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1184 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1185 | FAIL() << "Did not recieve Error ' Expected: 'Dynamic scissor state not set for this command buffer'"; |
| 1186 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1187 | } |
| 1188 | } |
| 1189 | |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1190 | TEST_F(VkLayerTest, BlendStateNotBound) |
| 1191 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1192 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1193 | "Dynamic blend object state not set for this command buffer"); |
| 1194 | |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1195 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a blend state object is not bound beforehand"); |
| 1196 | |
| 1197 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailBlend); |
| 1198 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1199 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1200 | FAIL() << "Did not recieve Error 'Dynamic blend object state not set for this command buffer'"; |
| 1201 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1202 | } |
| 1203 | } |
| 1204 | |
| 1205 | TEST_F(VkLayerTest, DepthBoundsStateNotBound) |
| 1206 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1207 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1208 | "Dynamic depth bounds state not set for this command buffer"); |
| 1209 | |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1210 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a depth bounds state object is not bound beforehand"); |
| 1211 | |
| 1212 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailDepthBounds); |
| 1213 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1214 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1215 | FAIL() << "Did not receive Error 'Dynamic depth bounds state not set for this command buffer'"; |
| 1216 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1217 | } |
| 1218 | } |
| 1219 | |
| 1220 | TEST_F(VkLayerTest, StencilReadMaskNotSet) |
| 1221 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1222 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1223 | "Dynamic stencil read mask state not set for this command buffer"); |
| 1224 | |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1225 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1226 | |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1227 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a stencil read mask is not set beforehand"); |
| 1228 | |
| 1229 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailStencilReadMask); |
| 1230 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1231 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1232 | FAIL() << "Did not receive Error 'Dynamic stencil read mask state not set for this command buffer'"; |
| 1233 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1234 | } |
| 1235 | } |
| 1236 | |
| 1237 | TEST_F(VkLayerTest, StencilWriteMaskNotSet) |
| 1238 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1239 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1240 | "Dynamic stencil write mask state not set for this command buffer"); |
| 1241 | |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1242 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1243 | |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1244 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a stencil write mask is not set beforehand"); |
| 1245 | |
| 1246 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailStencilWriteMask); |
| 1247 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1248 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1249 | FAIL() << "Did not receive Error 'Dynamic stencil write mask state not set for this command buffer'"; |
| 1250 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1251 | } |
| 1252 | } |
| 1253 | |
| 1254 | TEST_F(VkLayerTest, StencilReferenceNotSet) |
| 1255 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1256 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1257 | "Dynamic stencil reference state not set for this command buffer"); |
| 1258 | |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1259 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a stencil reference is not set beforehand"); |
| 1260 | |
| 1261 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailStencilReference); |
| 1262 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1263 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1264 | FAIL() << "Did not receive Error 'Dynamic stencil reference state not set for this command buffer'"; |
| 1265 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1266 | } |
| 1267 | } |
| 1268 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1269 | TEST_F(VkLayerTest, CommandBufferTwoSubmits) |
Tobin Ehlis | 0cea408 | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1270 | { |
| 1271 | vk_testing::Fence testFence; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1272 | |
| 1273 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1274 | "was begun w/ VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set, but has been submitted"); |
Tobin Ehlis | 0cea408 | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1275 | |
| 1276 | VkFenceCreateInfo fenceInfo = {}; |
| 1277 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 1278 | fenceInfo.pNext = NULL; |
| 1279 | fenceInfo.flags = 0; |
| 1280 | |
| 1281 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1282 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 1283 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1284 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1285 | // We luck out b/c by default the framework creates CB w/ the VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set |
Tobin Ehlis | 0cea408 | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1286 | BeginCommandBuffer(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1287 | m_commandBuffer->ClearAllBuffers(m_clear_color, m_depth_clear_color, m_stencil_clear_color, NULL); |
Tobin Ehlis | 0cea408 | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1288 | EndCommandBuffer(); |
| 1289 | |
| 1290 | testFence.init(*m_device, fenceInfo); |
| 1291 | |
| 1292 | // Bypass framework since it does the waits automatically |
| 1293 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 1a748e9 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1294 | VkSubmitInfo submit_info; |
Chia-I Wu | 6ec33a0 | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 1295 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1296 | submit_info.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1297 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 1a748e9 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1298 | submit_info.pWaitSemaphores = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1299 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1300 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1301 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 1a748e9 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1302 | submit_info.pSignalSemaphores = NULL; |
| 1303 | |
Courtney Goeltzenleuchter | 3ec3162 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 1304 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Tobin Ehlis | 0cea408 | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1305 | ASSERT_VK_SUCCESS( err ); |
| 1306 | |
Tobin Ehlis | 0cea408 | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1307 | // Cause validation error by re-submitting cmd buffer that should only be submitted once |
Courtney Goeltzenleuchter | 3ec3162 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 1308 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Tobin Ehlis | 0cea408 | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1309 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1310 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1311 | FAIL() << "Did not receive Error 'CB (0xaddress) was created w/ VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set...'"; |
| 1312 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 0cea408 | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1313 | } |
| 1314 | } |
| 1315 | |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 1316 | TEST_F(VkLayerTest, BindPipelineNoRenderPass) |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1317 | { |
| 1318 | // Initiate Draw w/o a PSO bound |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1319 | VkResult err; |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1320 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1321 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1322 | "Incorrectly binding graphics pipeline "); |
| 1323 | |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1324 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1325 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1326 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1327 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1328 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1329 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1330 | |
| 1331 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1332 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1333 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 1334 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1335 | ds_pool_ci.poolSizeCount = 1; |
| 1336 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1337 | |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 1338 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1339 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1340 | ASSERT_VK_SUCCESS(err); |
| 1341 | |
| 1342 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1343 | dsl_binding.binding = 0; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1344 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 1345 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1346 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1347 | dsl_binding.pImmutableSamplers = NULL; |
| 1348 | |
| 1349 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1350 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1351 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1352 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1353 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1354 | |
| 1355 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1356 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1357 | ASSERT_VK_SUCCESS(err); |
| 1358 | |
| 1359 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1360 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1361 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1362 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1363 | alloc_info.descriptorPool = ds_pool; |
| 1364 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1365 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1366 | ASSERT_VK_SUCCESS(err); |
| 1367 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 1368 | pipe_ms_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 1369 | pipe_ms_state_ci.pNext = NULL; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1370 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1371 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 1372 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 1373 | pipe_ms_state_ci.pSampleMask = NULL; |
| 1374 | |
| 1375 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 1376 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 1377 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1378 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1379 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 1380 | VkPipelineLayout pipeline_layout; |
| 1381 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1382 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1383 | ASSERT_VK_SUCCESS(err); |
| 1384 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 1385 | VkShaderObj vs(m_device, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 1386 | VkShaderObj fs(m_device, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, this); // TODO - We shouldn't need a fragment shader |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1387 | // but add it to be able to run on more devices |
| 1388 | VkPipelineObj pipe(m_device); |
| 1389 | pipe.AddShader(&vs); |
| 1390 | pipe.AddShader(&fs); |
| 1391 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 1392 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1393 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1394 | // Calls AllocateCommandBuffers |
| 1395 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
| 1396 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
| 1397 | memset(&cmd_buf_info, 0, sizeof(VkCommandBufferBeginInfo)); |
| 1398 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1399 | cmd_buf_info.pNext = NULL; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1400 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1401 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1402 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
| 1403 | vkCmdBindPipeline(commandBuffer.GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1404 | |
| 1405 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1406 | FAIL() << "Did not receive Error 'Incorrectly binding graphics pipeline (0x<handle>) without an active RenderPass'"; |
| 1407 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1408 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1409 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1410 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 1411 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1412 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1413 | } |
| 1414 | |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1415 | TEST_F(VkLayerTest, AllocDescriptorFromEmptyPool) |
| 1416 | { |
| 1417 | // Initiate Draw w/o a PSO bound |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1418 | VkResult err; |
| 1419 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1420 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1421 | "Unable to allocate 1 descriptors of type VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER "); |
| 1422 | |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1423 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1424 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1425 | |
| 1426 | // Create Pool w/ 1 Sampler descriptor, but try to alloc Uniform Buffer descriptor from it |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1427 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1428 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1429 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1430 | |
| 1431 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1432 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1433 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1434 | ds_pool_ci.flags = 0; |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1435 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1436 | ds_pool_ci.poolSizeCount = 1; |
| 1437 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1438 | |
| 1439 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1440 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1441 | ASSERT_VK_SUCCESS(err); |
| 1442 | |
| 1443 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1444 | dsl_binding.binding = 0; |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1445 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 1446 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1447 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1448 | dsl_binding.pImmutableSamplers = NULL; |
| 1449 | |
| 1450 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1451 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1452 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1453 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1454 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1455 | |
| 1456 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1457 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1458 | ASSERT_VK_SUCCESS(err); |
| 1459 | |
| 1460 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1461 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1462 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1463 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1464 | alloc_info.descriptorPool = ds_pool; |
| 1465 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1466 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1467 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1468 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1469 | FAIL() << "Did not receive Error 'Unable to allocate 1 descriptors of type VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER...'"; |
| 1470 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1471 | } |
| 1472 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1473 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1474 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1475 | } |
| 1476 | |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1477 | TEST_F(VkLayerTest, FreeDescriptorFromOneShotPool) |
| 1478 | { |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1479 | VkResult err; |
| 1480 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1481 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1482 | "It is invalid to call vkFreeDescriptorSets() with a pool created without setting VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT."); |
| 1483 | |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1484 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1485 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1486 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1487 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1488 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1489 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1490 | |
| 1491 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1492 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1493 | ds_pool_ci.pNext = NULL; |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1494 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1495 | ds_pool_ci.poolSizeCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1496 | ds_pool_ci.flags = 0; |
| 1497 | // Not specifying VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT means |
| 1498 | // app can only call vkResetDescriptorPool on this pool.; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1499 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1500 | |
| 1501 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1502 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1503 | ASSERT_VK_SUCCESS(err); |
| 1504 | |
| 1505 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1506 | dsl_binding.binding = 0; |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1507 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 1508 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1509 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1510 | dsl_binding.pImmutableSamplers = NULL; |
| 1511 | |
| 1512 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1513 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1514 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1515 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1516 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1517 | |
| 1518 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1519 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1520 | ASSERT_VK_SUCCESS(err); |
| 1521 | |
| 1522 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1523 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1524 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1525 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1526 | alloc_info.descriptorPool = ds_pool; |
| 1527 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1528 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1529 | ASSERT_VK_SUCCESS(err); |
| 1530 | |
| 1531 | err = vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptorSet); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1532 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1533 | FAIL() << "Did not receive Error 'It is invalid to call vkFreeDescriptorSets() with a pool created with...'"; |
| 1534 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1535 | } |
| 1536 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1537 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1538 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1539 | } |
| 1540 | |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1541 | TEST_F(VkLayerTest, InvalidDescriptorPool) |
| 1542 | { |
| 1543 | // TODO : Simple check for bad object should be added to ObjectTracker to catch this case |
| 1544 | // The DS check for this is after driver has been called to validate DS internal data struct |
| 1545 | // Attempt to clear DS Pool with bad object |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1546 | /* |
| 1547 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1548 | "Unable to find pool node for pool 0xbaad6001 specified in vkResetDescriptorPool() call"); |
| 1549 | |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1550 | VkDescriptorPool badPool = (VkDescriptorPool)0xbaad6001; |
| 1551 | vkResetDescriptorPool(device(), badPool); |
| 1552 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1553 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1554 | FAIL() << "Did not receive Error 'Unable to find pool node for pool 0xbaad6001 specified in vkResetDescriptorPool() call'"; |
| 1555 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1556 | }*/ |
| 1557 | } |
| 1558 | |
| 1559 | TEST_F(VkLayerTest, InvalidDescriptorSet) |
| 1560 | { |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1561 | // TODO : Simple check for bad object should be added to ObjectTracker to catch this case |
| 1562 | // The DS check for this is after driver has been called to validate DS internal data struct |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1563 | // Create a valid cmd buffer |
| 1564 | // call vkCmdBindDescriptorSets w/ false DS |
| 1565 | } |
| 1566 | |
| 1567 | TEST_F(VkLayerTest, InvalidDescriptorSetLayout) |
| 1568 | { |
| 1569 | // TODO : Simple check for bad object should be added to ObjectTracker to catch this case |
| 1570 | // The DS check for this is after driver has been called to validate DS internal data struct |
| 1571 | } |
| 1572 | |
| 1573 | TEST_F(VkLayerTest, InvalidPipeline) |
| 1574 | { |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1575 | // TODO : Simple check for bad object should be added to ObjectTracker to catch this case |
| 1576 | // The DS check for this is after driver has been called to validate DS internal data struct |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1577 | // Create a valid cmd buffer |
| 1578 | // call vkCmdBindPipeline w/ false Pipeline |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1579 | // |
| 1580 | // m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1581 | // "Attempt to bind Pipeline "); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 1582 | // |
| 1583 | // ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1584 | // VkCommandBufferObj commandBuffer(m_device); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1585 | // BeginCommandBuffer(); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 1586 | // VkPipeline badPipeline = (VkPipeline)0xbaadb1be; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1587 | // vkCmdBindPipeline(commandBuffer.GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, badPipeline); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1588 | // |
| 1589 | // if (!m_errorMonitor->DesiredMsgFound()) { |
| 1590 | // FAIL() << "Did not receive Error 'Attempt to bind Pipeline 0xbaadb1be that doesn't exist!'"; |
| 1591 | // m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 1592 | // } |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1593 | } |
| 1594 | |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1595 | TEST_F(VkLayerTest, DescriptorSetNotUpdated) |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1596 | { |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1597 | // Create and update CommandBuffer then call QueueSubmit w/o calling End on CommandBuffer |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1598 | VkResult err; |
| 1599 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1600 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_WARN_BIT, |
| 1601 | " bound but it was never updated. "); |
| 1602 | |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1603 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | d72da75 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 1604 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 1605 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1606 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1607 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1608 | ds_type_count.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1609 | |
| 1610 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1611 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1612 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 1613 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1614 | ds_pool_ci.poolSizeCount = 1; |
| 1615 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mike Stroyan | d72da75 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 1616 | |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1617 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1618 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1619 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1620 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1621 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1622 | dsl_binding.binding = 0; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1623 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 1624 | dsl_binding.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1625 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1626 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1627 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1628 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1629 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1630 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1631 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1632 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1633 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1634 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1635 | ASSERT_VK_SUCCESS(err); |
| 1636 | |
| 1637 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1638 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1639 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1640 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1641 | alloc_info.descriptorPool = ds_pool; |
| 1642 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1643 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1644 | ASSERT_VK_SUCCESS(err); |
| 1645 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1646 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 1647 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 1648 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1649 | pipeline_layout_ci.setLayoutCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1650 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1651 | |
| 1652 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1653 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1654 | ASSERT_VK_SUCCESS(err); |
| 1655 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 1656 | VkShaderObj vs(m_device, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1657 | // TODO - We shouldn't need a fragment shader but add it to be able to run on more devices |
| 1658 | VkShaderObj fs(m_device, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1659 | |
Tony Barbour | 4e8d1b1 | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 1660 | VkPipelineObj pipe(m_device); |
| 1661 | pipe.AddShader(&vs); |
Tony Barbour | 3c9e3b1 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 1662 | pipe.AddShader(&fs); |
Tony Barbour | 4e8d1b1 | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 1663 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1664 | |
| 1665 | BeginCommandBuffer(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1666 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 1667 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, 1, &descriptorSet, 0, NULL); |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1668 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1669 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1670 | FAIL() << "Did not recieve Warning 'DS <blah> bound but it was never updated. You may want to either update it or not bind it.'"; |
| 1671 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1672 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1673 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1674 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 1675 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1676 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1677 | } |
| 1678 | |
Tobin Ehlis | 093ef92 | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1679 | TEST_F(VkLayerTest, InvalidBufferViewObject) |
| 1680 | { |
| 1681 | // Create a single TEXEL_BUFFER descriptor and send it an invalid bufferView |
| 1682 | VkResult err; |
| 1683 | |
| 1684 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1685 | "Attempt to update descriptor with invalid bufferView "); |
| 1686 | |
| 1687 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1688 | VkDescriptorPoolSize ds_type_count = {}; |
| 1689 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 1690 | ds_type_count.descriptorCount = 1; |
| 1691 | |
| 1692 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1693 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1694 | ds_pool_ci.pNext = NULL; |
| 1695 | ds_pool_ci.maxSets = 1; |
| 1696 | ds_pool_ci.poolSizeCount = 1; |
| 1697 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 1698 | |
| 1699 | VkDescriptorPool ds_pool; |
| 1700 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 1701 | ASSERT_VK_SUCCESS(err); |
| 1702 | |
| 1703 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 1704 | dsl_binding.binding = 0; |
| 1705 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 1706 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | 093ef92 | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1707 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1708 | dsl_binding.pImmutableSamplers = NULL; |
| 1709 | |
| 1710 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1711 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1712 | ds_layout_ci.pNext = NULL; |
| 1713 | ds_layout_ci.bindingCount = 1; |
| 1714 | ds_layout_ci.pBinding = &dsl_binding; |
| 1715 | VkDescriptorSetLayout ds_layout; |
| 1716 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
| 1717 | ASSERT_VK_SUCCESS(err); |
| 1718 | |
| 1719 | VkDescriptorSet descriptorSet; |
| 1720 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1721 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Tobin Ehlis | 093ef92 | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1722 | alloc_info.setLayoutCount = 1; |
| 1723 | alloc_info.descriptorPool = ds_pool; |
| 1724 | alloc_info.pSetLayouts = &ds_layout; |
| 1725 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
| 1726 | ASSERT_VK_SUCCESS(err); |
| 1727 | |
| 1728 | VkBufferView view = (VkBufferView) 0xbaadbeef; // invalid bufferView object |
Tobin Ehlis | 093ef92 | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1729 | VkWriteDescriptorSet descriptor_write; |
| 1730 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 1731 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 1732 | descriptor_write.dstSet = descriptorSet; |
| 1733 | descriptor_write.dstBinding = 0; |
| 1734 | descriptor_write.descriptorCount = 1; |
| 1735 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 1736 | descriptor_write.pTexelBufferView = &view; |
| 1737 | |
| 1738 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 1739 | |
| 1740 | if (!m_errorMonitor->DesiredMsgFound()) { |
Tobin Ehlis | d949145 | 2015-11-05 10:27:49 -0700 | [diff] [blame] | 1741 | FAIL() << "Did not receive Error 'Attempt to update descriptor with invalid bufferView'"; |
Tobin Ehlis | 093ef92 | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1742 | m_errorMonitor->DumpFailureMsgs(); |
| 1743 | } |
| 1744 | |
| 1745 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1746 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 1747 | } |
| 1748 | |
Tobin Ehlis | e219486 | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1749 | TEST_F(VkLayerTest, InvalidDynamicOffsetCount) |
| 1750 | { |
| 1751 | // Create a descriptorSet w/ some dynamic descriptors and then don't send offsets when binding |
| 1752 | VkResult err; |
| 1753 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1754 | "Attempting to bind 1 descriptorSets with 1 dynamic descriptors, but dynamicOffsetCount is 0. "); |
| 1755 | |
| 1756 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1757 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 1758 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1759 | |
| 1760 | VkDescriptorPoolSize ds_type_count = {}; |
| 1761 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 1762 | ds_type_count.descriptorCount = 1; |
| 1763 | |
| 1764 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1765 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1766 | ds_pool_ci.pNext = NULL; |
| 1767 | ds_pool_ci.maxSets = 1; |
| 1768 | ds_pool_ci.poolSizeCount = 1; |
| 1769 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 1770 | |
| 1771 | VkDescriptorPool ds_pool; |
| 1772 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 1773 | ASSERT_VK_SUCCESS(err); |
| 1774 | |
| 1775 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 1776 | dsl_binding.binding = 0; |
| 1777 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
Jon Ashburn | 96b714a | 2015-11-06 15:31:44 -0700 | [diff] [blame] | 1778 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | e219486 | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1779 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1780 | dsl_binding.pImmutableSamplers = NULL; |
| 1781 | |
| 1782 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1783 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1784 | ds_layout_ci.pNext = NULL; |
| 1785 | ds_layout_ci.bindingCount = 1; |
| 1786 | ds_layout_ci.pBinding = &dsl_binding; |
| 1787 | VkDescriptorSetLayout ds_layout; |
| 1788 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
| 1789 | ASSERT_VK_SUCCESS(err); |
| 1790 | |
| 1791 | VkDescriptorSet descriptorSet; |
| 1792 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1793 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Tobin Ehlis | e219486 | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1794 | alloc_info.setLayoutCount = 1; |
| 1795 | alloc_info.descriptorPool = ds_pool; |
| 1796 | alloc_info.pSetLayouts = &ds_layout; |
| 1797 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
| 1798 | ASSERT_VK_SUCCESS(err); |
| 1799 | |
| 1800 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 1801 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 1802 | pipeline_layout_ci.pNext = NULL; |
| 1803 | pipeline_layout_ci.setLayoutCount = 1; |
| 1804 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 1805 | |
| 1806 | VkPipelineLayout pipeline_layout; |
| 1807 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
| 1808 | ASSERT_VK_SUCCESS(err); |
| 1809 | |
| 1810 | // Create a buffer to update the descriptor with |
| 1811 | uint32_t qfi = 0; |
| 1812 | VkBufferCreateInfo buffCI = {}; |
| 1813 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 1814 | buffCI.size = 1024; |
| 1815 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 1816 | buffCI.queueFamilyIndexCount = 1; |
| 1817 | buffCI.pQueueFamilyIndices = &qfi; |
| 1818 | |
| 1819 | VkBuffer dyub; |
| 1820 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 1821 | ASSERT_VK_SUCCESS(err); |
| 1822 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 1823 | VkDescriptorBufferInfo buffInfo = {}; |
| 1824 | buffInfo.buffer = dyub; |
| 1825 | buffInfo.offset = 0; |
| 1826 | buffInfo.range = 1024; |
| 1827 | |
| 1828 | VkWriteDescriptorSet descriptor_write; |
| 1829 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 1830 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 1831 | descriptor_write.dstSet = descriptorSet; |
| 1832 | descriptor_write.dstBinding = 0; |
| 1833 | descriptor_write.descriptorCount = 1; |
| 1834 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 1835 | descriptor_write.pBufferInfo = &buffInfo; |
| 1836 | |
| 1837 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 1838 | |
| 1839 | BeginCommandBuffer(); |
| 1840 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, 1, &descriptorSet, 0, NULL); |
| 1841 | |
| 1842 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1843 | FAIL() << "Error received was not 'Attempting to bind 1 descriptorSets with 1 dynamic descriptors, but dynamicOffsetCount is 0...'"; |
| 1844 | m_errorMonitor->DumpFailureMsgs(); |
| 1845 | } |
| 1846 | |
| 1847 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 1848 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 1849 | } |
| 1850 | |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1851 | TEST_F(VkLayerTest, DescriptorSetCompatibility) |
| 1852 | { |
| 1853 | // Test various desriptorSet errors with bad binding combinations |
| 1854 | VkResult err; |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1855 | |
| 1856 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1857 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 1858 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1859 | |
| 1860 | static const uint32_t NUM_DESCRIPTOR_TYPES = 5; |
| 1861 | VkDescriptorPoolSize ds_type_count[NUM_DESCRIPTOR_TYPES] = {}; |
| 1862 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1863 | ds_type_count[0].descriptorCount = 10; |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1864 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 1865 | ds_type_count[1].descriptorCount = 2; |
| 1866 | ds_type_count[2].type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 1867 | ds_type_count[2].descriptorCount = 2; |
| 1868 | ds_type_count[3].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 1869 | ds_type_count[3].descriptorCount = 5; |
| 1870 | // TODO : LunarG ILO driver currently asserts in desc.c w/ INPUT_ATTACHMENT type |
| 1871 | //ds_type_count[4].type = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; |
| 1872 | ds_type_count[4].type = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
| 1873 | ds_type_count[4].descriptorCount = 2; |
| 1874 | |
| 1875 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1876 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1877 | ds_pool_ci.pNext = NULL; |
| 1878 | ds_pool_ci.maxSets = 1; |
| 1879 | ds_pool_ci.poolSizeCount = NUM_DESCRIPTOR_TYPES; |
| 1880 | ds_pool_ci.pPoolSizes = ds_type_count; |
| 1881 | |
| 1882 | VkDescriptorPool ds_pool; |
| 1883 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 1884 | ASSERT_VK_SUCCESS(err); |
| 1885 | |
| 1886 | static const uint32_t MAX_DS_TYPES_IN_LAYOUT = 2; |
| 1887 | VkDescriptorSetLayoutBinding dsl_binding[MAX_DS_TYPES_IN_LAYOUT] = {}; |
| 1888 | dsl_binding[0].binding = 0; |
| 1889 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1890 | dsl_binding[0].descriptorCount = 5; |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1891 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 1892 | dsl_binding[0].pImmutableSamplers = NULL; |
| 1893 | |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1894 | // Create layout identical to set0 layout but w/ different stageFlags |
| 1895 | VkDescriptorSetLayoutBinding dsl_fs_stage_only = {}; |
| 1896 | dsl_fs_stage_only.binding = 0; |
| 1897 | dsl_fs_stage_only.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1898 | dsl_fs_stage_only.descriptorCount = 5; |
| 1899 | dsl_fs_stage_only.stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT; // Different stageFlags to cause error at bind time |
| 1900 | dsl_fs_stage_only.pImmutableSamplers = NULL; |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1901 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1902 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1903 | ds_layout_ci.pNext = NULL; |
| 1904 | ds_layout_ci.bindingCount = 1; |
| 1905 | ds_layout_ci.pBinding = dsl_binding; |
| 1906 | static const uint32_t NUM_LAYOUTS = 4; |
| 1907 | VkDescriptorSetLayout ds_layout[NUM_LAYOUTS] = {}; |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1908 | VkDescriptorSetLayout ds_layout_fs_only = {}; |
| 1909 | // Create 4 unique layouts for full pipelineLayout, and 1 special fs-only layout for error case |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1910 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout[0]); |
| 1911 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1912 | ds_layout_ci.pBinding = &dsl_fs_stage_only; |
| 1913 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout_fs_only); |
| 1914 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1915 | dsl_binding[0].binding = 0; |
| 1916 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1917 | dsl_binding[0].descriptorCount = 2; |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1918 | dsl_binding[0].binding = 1; |
| 1919 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1920 | dsl_binding[0].descriptorCount = 2; |
| 1921 | ds_layout_ci.pBinding = dsl_binding; |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1922 | ds_layout_ci.bindingCount = 2; |
| 1923 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout[1]); |
| 1924 | ASSERT_VK_SUCCESS(err); |
| 1925 | dsl_binding[0].binding = 0; |
| 1926 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1927 | dsl_binding[0].descriptorCount = 5; |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1928 | ds_layout_ci.bindingCount = 1; |
| 1929 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout[2]); |
| 1930 | ASSERT_VK_SUCCESS(err); |
| 1931 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1932 | dsl_binding[0].descriptorCount = 2; |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1933 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout[3]); |
| 1934 | ASSERT_VK_SUCCESS(err); |
| 1935 | |
| 1936 | static const uint32_t NUM_SETS = 4; |
| 1937 | VkDescriptorSet descriptorSet[NUM_SETS] = {}; |
| 1938 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1939 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1940 | alloc_info.setLayoutCount = NUM_LAYOUTS; |
| 1941 | alloc_info.descriptorPool = ds_pool; |
| 1942 | alloc_info.pSetLayouts = ds_layout; |
| 1943 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, descriptorSet); |
| 1944 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1945 | VkDescriptorSet ds0_fs_only = {}; |
| 1946 | alloc_info.setLayoutCount = 1; |
| 1947 | alloc_info.pSetLayouts = &ds_layout_fs_only; |
| 1948 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &ds0_fs_only); |
| 1949 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1950 | |
| 1951 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 1952 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 1953 | pipeline_layout_ci.pNext = NULL; |
| 1954 | pipeline_layout_ci.setLayoutCount = NUM_LAYOUTS; |
| 1955 | pipeline_layout_ci.pSetLayouts = ds_layout; |
| 1956 | |
| 1957 | VkPipelineLayout pipeline_layout; |
| 1958 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
| 1959 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 1960 | // Create pipelineLayout with only one setLayout |
| 1961 | pipeline_layout_ci.setLayoutCount = 1; |
| 1962 | VkPipelineLayout single_pipe_layout; |
| 1963 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &single_pipe_layout); |
| 1964 | ASSERT_VK_SUCCESS(err); |
| 1965 | // Create pipelineLayout with 2 descriptor setLayout at index 0 |
| 1966 | pipeline_layout_ci.pSetLayouts = &ds_layout[3]; |
| 1967 | VkPipelineLayout pipe_layout_one_desc; |
| 1968 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipe_layout_one_desc); |
| 1969 | ASSERT_VK_SUCCESS(err); |
| 1970 | // Create pipelineLayout with 5 SAMPLER descriptor setLayout at index 0 |
| 1971 | pipeline_layout_ci.pSetLayouts = &ds_layout[2]; |
| 1972 | VkPipelineLayout pipe_layout_five_samp; |
| 1973 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipe_layout_five_samp); |
| 1974 | ASSERT_VK_SUCCESS(err); |
| 1975 | // Create pipelineLayout with UB type, but stageFlags for FS only |
| 1976 | pipeline_layout_ci.pSetLayouts = &ds_layout_fs_only; |
| 1977 | VkPipelineLayout pipe_layout_fs_only; |
| 1978 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipe_layout_fs_only); |
| 1979 | ASSERT_VK_SUCCESS(err); |
| 1980 | // Create pipelineLayout w/ incompatible set0 layout, but set1 is fine |
| 1981 | VkDescriptorSetLayout pl_bad_s0[2] = {}; |
| 1982 | pl_bad_s0[0] = ds_layout_fs_only; |
| 1983 | pl_bad_s0[1] = ds_layout[1]; |
| 1984 | pipeline_layout_ci.setLayoutCount = 2; |
| 1985 | pipeline_layout_ci.pSetLayouts = pl_bad_s0; |
| 1986 | VkPipelineLayout pipe_layout_bad_set0; |
| 1987 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipe_layout_bad_set0); |
| 1988 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1989 | |
| 1990 | // Create a buffer to update the descriptor with |
| 1991 | uint32_t qfi = 0; |
| 1992 | VkBufferCreateInfo buffCI = {}; |
| 1993 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 1994 | buffCI.size = 1024; |
| 1995 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 1996 | buffCI.queueFamilyIndexCount = 1; |
| 1997 | buffCI.pQueueFamilyIndices = &qfi; |
| 1998 | |
| 1999 | VkBuffer dyub; |
| 2000 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 2001 | ASSERT_VK_SUCCESS(err); |
| 2002 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 2003 | static const uint32_t NUM_BUFFS = 5; |
| 2004 | VkDescriptorBufferInfo buffInfo[NUM_BUFFS] = {}; |
| 2005 | for (uint32_t i=0; i<NUM_BUFFS; ++i) { |
| 2006 | buffInfo[i].buffer = dyub; |
| 2007 | buffInfo[i].offset = 0; |
| 2008 | buffInfo[i].range = 1024; |
| 2009 | } |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2010 | VkImage image; |
| 2011 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2012 | const int32_t tex_width = 32; |
| 2013 | const int32_t tex_height = 32; |
| 2014 | VkImageCreateInfo image_create_info = {}; |
| 2015 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 2016 | image_create_info.pNext = NULL; |
| 2017 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2018 | image_create_info.format = tex_format; |
| 2019 | image_create_info.extent.width = tex_width; |
| 2020 | image_create_info.extent.height = tex_height; |
| 2021 | image_create_info.extent.depth = 1; |
| 2022 | image_create_info.mipLevels = 1; |
| 2023 | image_create_info.arrayLayers = 1; |
| 2024 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
| 2025 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 2026 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 2027 | image_create_info.flags = 0; |
| 2028 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
| 2029 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2030 | |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2031 | VkImageViewCreateInfo image_view_create_info = {}; |
| 2032 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 2033 | image_view_create_info.image = image; |
| 2034 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 2035 | image_view_create_info.format = tex_format; |
| 2036 | image_view_create_info.subresourceRange.layerCount = 1; |
| 2037 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
| 2038 | image_view_create_info.subresourceRange.levelCount = 1; |
| 2039 | image_view_create_info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2040 | |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2041 | VkImageView view; |
| 2042 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, &view); |
| 2043 | ASSERT_VK_SUCCESS(err); |
| 2044 | VkDescriptorImageInfo imageInfo[2] = {}; |
| 2045 | imageInfo[0].imageView = view; |
| 2046 | imageInfo[0].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 2047 | imageInfo[1].imageView = view; |
| 2048 | imageInfo[1].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
| 2049 | |
| 2050 | static const uint32_t NUM_SET_UPDATES = 3; |
| 2051 | VkWriteDescriptorSet descriptor_write[NUM_SET_UPDATES] = {}; |
| 2052 | descriptor_write[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 2053 | descriptor_write[0].dstSet = descriptorSet[0]; |
| 2054 | descriptor_write[0].dstBinding = 0; |
| 2055 | descriptor_write[0].descriptorCount = 5; |
| 2056 | descriptor_write[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2057 | descriptor_write[0].pBufferInfo = buffInfo; |
| 2058 | descriptor_write[1].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 2059 | descriptor_write[1].dstSet = descriptorSet[1]; |
| 2060 | descriptor_write[1].dstBinding = 0; |
| 2061 | descriptor_write[1].descriptorCount = 2; |
| 2062 | descriptor_write[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 2063 | descriptor_write[1].pImageInfo = imageInfo; |
| 2064 | descriptor_write[2].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 2065 | descriptor_write[2].dstSet = descriptorSet[1]; |
| 2066 | descriptor_write[2].dstBinding = 1; |
| 2067 | descriptor_write[2].descriptorCount = 2; |
| 2068 | descriptor_write[2].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 2069 | descriptor_write[2].pImageInfo = imageInfo; |
| 2070 | |
| 2071 | vkUpdateDescriptorSets(m_device->device(), 3, descriptor_write, 0, NULL); |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2072 | |
Tobin Ehlis | d17c28c | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2073 | // Create PSO to be used for draw-time errors below |
| 2074 | char const *vsSource = |
| 2075 | "#version 140\n" |
| 2076 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 2077 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 2078 | "\n" |
| 2079 | "void main(){\n" |
| 2080 | " gl_Position = vec4(1);\n" |
| 2081 | "}\n"; |
| 2082 | char const *fsSource = |
| 2083 | "#version 140\n" |
| 2084 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 2085 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 2086 | "\n" |
| 2087 | "layout(location=0) out vec4 x;\n" |
| 2088 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 2089 | "void main(){\n" |
| 2090 | " x = vec4(bar.y);\n" |
| 2091 | "}\n"; |
| 2092 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 2093 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2094 | VkPipelineObj pipe(m_device); |
| 2095 | pipe.AddShader(&vs); |
| 2096 | pipe.AddShader(&fs); |
Tobin Ehlis | d17c28c | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2097 | pipe.AddColorAttachment(); |
| 2098 | pipe.CreateVKPipeline(pipe_layout_fs_only, renderPass()); |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2099 | |
| 2100 | BeginCommandBuffer(); |
Tobin Ehlis | d17c28c | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2101 | |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2102 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 2103 | // NOTE : I believe LunarG ilo driver has bug (LX#189) that requires binding of PSO |
| 2104 | // here before binding DSs. Otherwise we assert in cmd_copy_dset_data() of cmd_pipeline.c |
| 2105 | // due to the fact that cmd_alloc_dset_data() has not been called in cmd_bind_graphics_pipeline() |
| 2106 | // TODO : Want to cause various binding incompatibility issues here to test DrawState |
| 2107 | // First cause various verify_layout_compatibility() fails |
| 2108 | // Second disturb early and late sets and verify INFO msgs |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2109 | // verify_set_layout_compatibility fail cases: |
| 2110 | // 1. invalid VkPipelineLayout (layout) passed into vkCmdBindDescriptorSets |
| 2111 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, " due to: invalid VkPipelineLayout "); |
| 2112 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, (VkPipelineLayout)0xbaadb1be, 0, 1, &descriptorSet[0], 0, NULL); |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2113 | if (!m_errorMonitor->DesiredMsgFound()) { |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2114 | FAIL() << "Did not receive correct error msg when attempting to bind descriptorSets with invalid VkPipelineLayout."; |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2115 | m_errorMonitor->DumpFailureMsgs(); |
| 2116 | } |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2117 | // 2. layoutIndex exceeds # of layouts in layout |
| 2118 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, " attempting to bind set to index 1"); |
| 2119 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, single_pipe_layout, 0, 2, &descriptorSet[0], 0, NULL); |
| 2120 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2121 | FAIL() << "Did not receive correct error msg when attempting to bind descriptorSet to index 1 when pipelineLayout only has index 0."; |
| 2122 | m_errorMonitor->DumpFailureMsgs(); |
| 2123 | } |
| 2124 | vkDestroyPipelineLayout(m_device->device(), single_pipe_layout, NULL); |
| 2125 | // 3. Pipeline setLayout[0] has 2 descriptors, but set being bound has 5 descriptors |
| 2126 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, ", but corresponding set being bound has 5 descriptors."); |
| 2127 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe_layout_one_desc, 0, 1, &descriptorSet[0], 0, NULL); |
| 2128 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2129 | FAIL() << "Did not receive correct error msg when attempting to bind descriptorSet w/ 5 descriptors to pipelineLayout with only 2 descriptors."; |
| 2130 | m_errorMonitor->DumpFailureMsgs(); |
| 2131 | } |
| 2132 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_one_desc, NULL); |
| 2133 | // 4. same # of descriptors but mismatch in type |
| 2134 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, " descriptor from pipelineLayout is type 'VK_DESCRIPTOR_TYPE_SAMPLER'"); |
| 2135 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe_layout_five_samp, 0, 1, &descriptorSet[0], 0, NULL); |
| 2136 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2137 | FAIL() << "Did not receive correct error msg when attempting to bind UNIFORM_BUFFER descriptorSet to pipelineLayout with overlapping SAMPLER type."; |
| 2138 | m_errorMonitor->DumpFailureMsgs(); |
| 2139 | } |
| 2140 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_five_samp, NULL); |
| 2141 | // 5. same # of descriptors but mismatch in stageFlags |
| 2142 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, " descriptor from pipelineLayout has stageFlags "); |
| 2143 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe_layout_fs_only, 0, 1, &descriptorSet[0], 0, NULL); |
| 2144 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2145 | FAIL() << "Did not receive correct error msg when attempting to bind UNIFORM_BUFFER descriptorSet with ALL stageFlags to pipelineLayout with FS-only stageFlags."; |
| 2146 | m_errorMonitor->DumpFailureMsgs(); |
| 2147 | } |
| 2148 | // Cause INFO messages due to disturbing previously bound Sets |
| 2149 | // First bind sets 0 & 1 |
| 2150 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, 2, &descriptorSet[0], 0, NULL); |
| 2151 | // 1. Disturb bound set0 by re-binding set1 w/ updated pipelineLayout |
| 2152 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_PERF_WARN_BIT, " previously bound as set #0 was disturbed "); |
| 2153 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
| 2154 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2155 | FAIL() << "Did not receive correct info msg when binding Set1 w/ pipelineLayout that should disturb Set0."; |
| 2156 | m_errorMonitor->DumpFailureMsgs(); |
| 2157 | } |
| 2158 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_bad_set0, NULL); |
| 2159 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, 2, &descriptorSet[0], 0, NULL); |
| 2160 | // 2. Disturb set after last bound set |
| 2161 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_PERF_WARN_BIT, " newly bound as set #0 so set #1 and any subsequent sets were disturbed "); |
| 2162 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe_layout_fs_only, 0, 1, &ds0_fs_only, 0, NULL); |
| 2163 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2164 | FAIL() << "Did not receive correct info msg when re-binding Set0 w/ pipelineLayout that should disturb Set1."; |
| 2165 | m_errorMonitor->DumpFailureMsgs(); |
| 2166 | } |
Tobin Ehlis | d17c28c | 2015-12-03 09:40:56 -0700 | [diff] [blame] | 2167 | |
| 2168 | // Cause draw-time errors due to PSO incompatibilities |
| 2169 | // 1. Error due to not binding required set (we actually use same code as above to disturb set0) |
| 2170 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, 2, &descriptorSet[0], 0, NULL); |
| 2171 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe_layout_bad_set0, 1, 1, &descriptorSet[1], 0, NULL); |
| 2172 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, " uses set #0 but that set is not bound."); |
| 2173 | Draw(1, 0, 0, 0); |
| 2174 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2175 | FAIL() << "Did not receive correct error msg when attempting draw requiring Set0 but Set0 is not bound."; |
| 2176 | m_errorMonitor->DumpFailureMsgs(); |
| 2177 | } |
| 2178 | // 2. Error due to bound set not being compatible with PSO's VkPipelineLayout (diff stageFlags in this case) |
| 2179 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, 2, &descriptorSet[0], 0, NULL); |
| 2180 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, " bound as set #0 is not compatible with "); |
| 2181 | Draw(1, 0, 0, 0); |
| 2182 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2183 | FAIL() << "Did not receive correct error msg when attempted draw where bound Set0 layout is not compatible PSO Set0 layout."; |
| 2184 | m_errorMonitor->DumpFailureMsgs(); |
| 2185 | } |
Tobin Ehlis | cb08529 | 2015-12-01 09:57:09 -0700 | [diff] [blame] | 2186 | // Remaining clean-up |
| 2187 | vkDestroyPipelineLayout(m_device->device(), pipe_layout_fs_only, NULL); |
| 2188 | for (uint32_t i=0; i<NUM_LAYOUTS; ++i) { |
| 2189 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout[i], NULL); |
| 2190 | } |
| 2191 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout_fs_only, NULL); |
| 2192 | vkFreeDescriptorSets(m_device->device(), ds_pool, 1, descriptorSet); |
| 2193 | vkDestroyBuffer(m_device->device(), dyub, NULL); |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2194 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2195 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 2196 | } |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 2197 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2198 | TEST_F(VkLayerTest, NoBeginCommandBuffer) |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2199 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2200 | |
| 2201 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2202 | "You must call vkBeginCommandBuffer() before this call to "); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2203 | |
| 2204 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2205 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2206 | // Call EndCommandBuffer() w/o calling BeginCommandBuffer() |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2207 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2208 | |
| 2209 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2210 | FAIL() << "Did not recieve Error 'You must call vkBeginCommandBuffer() before this call to vkEndCommandBuffer()'"; |
| 2211 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2212 | } |
| 2213 | } |
| 2214 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2215 | TEST_F(VkLayerTest, PrimaryCommandBufferFramebufferAndRenderpass) |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2216 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2217 | |
| 2218 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2219 | "may not specify framebuffer or renderpass parameters"); |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2220 | |
| 2221 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2222 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2223 | // Calls AllocateCommandBuffers |
| 2224 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2225 | |
| 2226 | // Force the failure by setting the Renderpass and Framebuffer fields with (fake) data |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2227 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
| 2228 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Cody Northrop | 10d8f98 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 2229 | cmd_buf_info.pNext = NULL; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2230 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
Cody Northrop | 10d8f98 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 2231 | cmd_buf_info.renderPass = (VkRenderPass)0xcadecade; |
| 2232 | cmd_buf_info.framebuffer = (VkFramebuffer)0xcadecade; |
| 2233 | |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2234 | |
| 2235 | // The error should be caught by validation of the BeginCommandBuffer call |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2236 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2237 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2238 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2239 | FAIL() << "Did not receive Error 'vkAllocateCommandBuffers(): Primary Command Buffer may not specify framebuffer or renderpass parameters'"; |
| 2240 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2241 | } |
| 2242 | } |
| 2243 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2244 | TEST_F(VkLayerTest, SecondaryCommandBufferFramebufferAndRenderpass) |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2245 | { |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2246 | VkResult err; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2247 | VkCommandBuffer draw_cmd; |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2248 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2249 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2250 | "must specify framebuffer and renderpass parameters"); |
| 2251 | |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2252 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2253 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2254 | VkCommandBufferAllocateInfo cmd = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2255 | cmd.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
Cody Northrop | 10d8f98 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 2256 | cmd.pNext = NULL; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2257 | cmd.commandPool = m_commandPool; |
| 2258 | cmd.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2259 | cmd.bufferCount = 1; |
Cody Northrop | 10d8f98 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 2260 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2261 | err = vkAllocateCommandBuffers(m_device->device(), &cmd, &draw_cmd); |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2262 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2263 | |
| 2264 | // Force the failure by not setting the Renderpass and Framebuffer fields |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2265 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
| 2266 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Cody Northrop | 10d8f98 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 2267 | cmd_buf_info.pNext = NULL; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2268 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2269 | |
| 2270 | // The error should be caught by validation of the BeginCommandBuffer call |
| 2271 | vkBeginCommandBuffer(draw_cmd, &cmd_buf_info); |
| 2272 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2273 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2274 | FAIL() << "Did not receive Error 'vkAllocateCommandBuffers(): Secondary Command Buffer must specify framebuffer and renderpass parameters'"; |
| 2275 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2276 | } |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2277 | vkFreeCommandBuffers(m_device->device(), m_commandPool, 1, &draw_cmd); |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2278 | } |
| 2279 | |
Tobin Ehlis | 4c8381e | 2015-12-14 13:46:38 -0700 | [diff] [blame] | 2280 | TEST_F(VkLayerTest, CommandBufferResetErrors) |
| 2281 | { |
| 2282 | // Cause error due to Begin while recording CB |
| 2283 | // Then cause 2 errors for attempting to reset CB w/o having |
| 2284 | // VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT set for the pool from |
| 2285 | // which CBs were allocated. Note that this bit is off by default. |
| 2286 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2287 | "Cannot call Begin on CB"); |
| 2288 | |
| 2289 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2290 | |
| 2291 | // Calls AllocateCommandBuffers |
| 2292 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
| 2293 | |
| 2294 | // Force the failure by setting the Renderpass and Framebuffer fields with (fake) data |
| 2295 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
| 2296 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
| 2297 | cmd_buf_info.pNext = NULL; |
| 2298 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
| 2299 | |
| 2300 | // Begin CB to transition to recording state |
| 2301 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
| 2302 | // Can't re-begin. This should trigger error |
| 2303 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
| 2304 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2305 | FAIL() << "Did not receive Error 'Cannot call Begin on CB (0x<ADDR>) in the RECORDING state...'"; |
| 2306 | m_errorMonitor->DumpFailureMsgs(); |
| 2307 | } |
| 2308 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, "Attempt to reset command buffer "); |
| 2309 | VkCommandBufferResetFlags flags = 0; // Don't care about flags for this test |
| 2310 | // Reset attempt will trigger error due to incorrect CommandPool state |
| 2311 | vkResetCommandBuffer(commandBuffer.GetBufferHandle(), flags); |
| 2312 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2313 | FAIL() << "Did not receive Error 'Attempt to reset command buffer (0x<ADDR>) created from command pool...'"; |
| 2314 | m_errorMonitor->DumpFailureMsgs(); |
| 2315 | } |
| 2316 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, " attempts to implicitly reset cmdBuffer created from "); |
| 2317 | // Transition CB to RECORDED state |
| 2318 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
| 2319 | // Now attempting to Begin will implicitly reset, which triggers error |
| 2320 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
| 2321 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2322 | FAIL() << "Did not receive Error 'Call to vkBeginCommandBuffer() on command buffer (0x<ADDR>) attempts to implicitly reset...'"; |
| 2323 | m_errorMonitor->DumpFailureMsgs(); |
| 2324 | } |
| 2325 | } |
| 2326 | |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2327 | TEST_F(VkLayerTest, InvalidPipelineCreateState) |
| 2328 | { |
| 2329 | // Attempt to Create Gfx Pipeline w/o a VS |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2330 | VkResult err; |
| 2331 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2332 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2333 | "Invalid Pipeline CreateInfo State: Vtx Shader required"); |
| 2334 | |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2335 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2336 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 2337 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2338 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2339 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2340 | ds_type_count.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2341 | |
| 2342 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2343 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2344 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 2345 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2346 | ds_pool_ci.poolSizeCount = 1; |
| 2347 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 2348 | |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2349 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2350 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2351 | ASSERT_VK_SUCCESS(err); |
| 2352 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2353 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2354 | dsl_binding.binding = 0; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2355 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 2356 | dsl_binding.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2357 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2358 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2359 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2360 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2361 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2362 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2363 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2364 | ds_layout_ci.pBinding = &dsl_binding; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2365 | |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2366 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2367 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2368 | ASSERT_VK_SUCCESS(err); |
| 2369 | |
| 2370 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2371 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2372 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2373 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2374 | alloc_info.descriptorPool = ds_pool; |
| 2375 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2376 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2377 | ASSERT_VK_SUCCESS(err); |
| 2378 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2379 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 2380 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2381 | pipeline_layout_ci.setLayoutCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2382 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2383 | |
| 2384 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2385 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2386 | ASSERT_VK_SUCCESS(err); |
| 2387 | |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2388 | VkViewport vp = {}; // Just need dummy vp to point to |
| 2389 | VkRect2D sc = {}; // dummy scissor to point to |
| 2390 | |
| 2391 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 2392 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 2393 | vp_state_ci.scissorCount = 1; |
| 2394 | vp_state_ci.pScissors = ≻ |
| 2395 | vp_state_ci.viewportCount = 1; |
| 2396 | vp_state_ci.pViewports = &vp; |
| 2397 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2398 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 2399 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2400 | gp_ci.pViewportState = &vp_state_ci; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2401 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2402 | gp_ci.layout = pipeline_layout; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2403 | gp_ci.renderPass = renderPass(); |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2404 | |
| 2405 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 2406 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Chia-I Wu | 7e47070 | 2015-10-26 17:24:52 +0800 | [diff] [blame] | 2407 | pc_ci.initialDataSize = 0; |
| 2408 | pc_ci.pInitialData = 0; |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2409 | |
| 2410 | VkPipeline pipeline; |
Jon Ashburn | 0d60d27 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 2411 | VkPipelineCache pipelineCache; |
| 2412 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2413 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Jon Ashburn | 0d60d27 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 2414 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2415 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 2416 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2417 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2418 | FAIL() << "Did not receive Error 'Invalid Pipeline CreateInfo State: Vtx Shader required'"; |
| 2419 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2420 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2421 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2422 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2423 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2424 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2425 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2426 | } |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2427 | /*// TODO : This test should be good, but needs Tess support in compiler to run |
| 2428 | TEST_F(VkLayerTest, InvalidPatchControlPoints) |
| 2429 | { |
| 2430 | // Attempt to Create Gfx Pipeline w/o a VS |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2431 | VkResult err; |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2432 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2433 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2434 | "Invalid Pipeline CreateInfo State: VK_PRIMITIVE_TOPOLOGY_PATCH primitive "); |
| 2435 | |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2436 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2437 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2438 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2439 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2440 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2441 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2442 | |
| 2443 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2444 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2445 | ds_pool_ci.pNext = NULL; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2446 | ds_pool_ci.poolSizeCount = 1; |
| 2447 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2448 | |
| 2449 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2450 | err = vkCreateDescriptorPool(m_device->device(), VK_DESCRIPTOR_POOL_USAGE_NON_FREE, 1, &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2451 | ASSERT_VK_SUCCESS(err); |
| 2452 | |
| 2453 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2454 | dsl_binding.binding = 0; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2455 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 2456 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2457 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2458 | dsl_binding.pImmutableSamplers = NULL; |
| 2459 | |
| 2460 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2461 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2462 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2463 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2464 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2465 | |
| 2466 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2467 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2468 | ASSERT_VK_SUCCESS(err); |
| 2469 | |
| 2470 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2471 | err = vkAllocateDescriptorSets(m_device->device(), ds_pool, VK_DESCRIPTOR_SET_USAGE_NON_FREE, 1, &ds_layout, &descriptorSet); |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2472 | ASSERT_VK_SUCCESS(err); |
| 2473 | |
| 2474 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 2475 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 2476 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2477 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2478 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 2479 | |
| 2480 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2481 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2482 | ASSERT_VK_SUCCESS(err); |
| 2483 | |
| 2484 | VkPipelineShaderStageCreateInfo shaderStages[3]; |
| 2485 | memset(&shaderStages, 0, 3 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 2486 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2487 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, this); |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2488 | // Just using VS txt for Tess shaders as we don't care about functionality |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2489 | VkShaderObj tc(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 2490 | VkShaderObj te(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2491 | |
| 2492 | shaderStages[0].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2493 | shaderStages[0].stage = VK_SHADER_STAGE_VERTEX_BIT; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2494 | shaderStages[0].shader = vs.handle(); |
| 2495 | shaderStages[1].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2496 | shaderStages[1].stage = VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2497 | shaderStages[1].shader = tc.handle(); |
| 2498 | shaderStages[2].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2499 | shaderStages[2].stage = VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2500 | shaderStages[2].shader = te.handle(); |
| 2501 | |
| 2502 | VkPipelineInputAssemblyStateCreateInfo iaCI = {}; |
| 2503 | iaCI.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
Chia-I Wu | 99ba2bb | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2504 | iaCI.topology = VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2505 | |
| 2506 | VkPipelineTessellationStateCreateInfo tsCI = {}; |
| 2507 | tsCI.sType = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO; |
| 2508 | tsCI.patchControlPoints = 0; // This will cause an error |
| 2509 | |
| 2510 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 2511 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 2512 | gp_ci.pNext = NULL; |
| 2513 | gp_ci.stageCount = 3; |
| 2514 | gp_ci.pStages = shaderStages; |
| 2515 | gp_ci.pVertexInputState = NULL; |
| 2516 | gp_ci.pInputAssemblyState = &iaCI; |
| 2517 | gp_ci.pTessellationState = &tsCI; |
| 2518 | gp_ci.pViewportState = NULL; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2519 | gp_ci.pRasterizationState = NULL; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2520 | gp_ci.pMultisampleState = NULL; |
| 2521 | gp_ci.pDepthStencilState = NULL; |
| 2522 | gp_ci.pColorBlendState = NULL; |
| 2523 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2524 | gp_ci.layout = pipeline_layout; |
| 2525 | gp_ci.renderPass = renderPass(); |
| 2526 | |
| 2527 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 2528 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 2529 | pc_ci.pNext = NULL; |
| 2530 | pc_ci.initialSize = 0; |
| 2531 | pc_ci.initialData = 0; |
| 2532 | pc_ci.maxSize = 0; |
| 2533 | |
| 2534 | VkPipeline pipeline; |
| 2535 | VkPipelineCache pipelineCache; |
| 2536 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2537 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2538 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2539 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2540 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2541 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2542 | FAIL() << "Did not receive Error 'Invalid Pipeline CreateInfo State: VK_PRIMITIVE_TOPOLOGY_PATCH primitive...'"; |
| 2543 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2544 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2545 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2546 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2547 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2548 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2549 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2550 | } |
| 2551 | */ |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2552 | // Set scissor and viewport counts to different numbers |
| 2553 | TEST_F(VkLayerTest, PSOViewportScissorCountMismatch) |
| 2554 | { |
| 2555 | // Attempt to Create Gfx Pipeline w/o a VS |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2556 | VkResult err; |
| 2557 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2558 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2559 | "Gfx Pipeline viewport count (1) must match scissor count (0)."); |
| 2560 | |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2561 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2562 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2563 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2564 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2565 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2566 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2567 | |
| 2568 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2569 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2570 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2571 | ds_pool_ci.poolSizeCount = 1; |
| 2572 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2573 | |
| 2574 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2575 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2576 | ASSERT_VK_SUCCESS(err); |
| 2577 | |
| 2578 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2579 | dsl_binding.binding = 0; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2580 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 2581 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2582 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2583 | |
| 2584 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2585 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2586 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2587 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2588 | |
| 2589 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2590 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2591 | ASSERT_VK_SUCCESS(err); |
| 2592 | |
| 2593 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2594 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2595 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2596 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2597 | alloc_info.descriptorPool = ds_pool; |
| 2598 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2599 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2600 | ASSERT_VK_SUCCESS(err); |
| 2601 | |
| 2602 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 2603 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2604 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2605 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 2606 | |
| 2607 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2608 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2609 | ASSERT_VK_SUCCESS(err); |
| 2610 | |
| 2611 | VkViewport vp = {}; // Just need dummy vp to point to |
| 2612 | |
| 2613 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 2614 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 2615 | vp_state_ci.scissorCount = 0; |
| 2616 | vp_state_ci.viewportCount = 1; // Count mismatch should cause error |
| 2617 | vp_state_ci.pViewports = &vp; |
| 2618 | |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2619 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 2620 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2621 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2622 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, this); |
| 2623 | VkShaderObj fs(m_device, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, this); // TODO - We shouldn't need a fragment shader |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2624 | // but add it to be able to run on more devices |
Chia-I Wu | 062ad15 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2625 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 2626 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2627 | |
| 2628 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 2629 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2630 | gp_ci.stageCount = 2; |
| 2631 | gp_ci.pStages = shaderStages; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2632 | gp_ci.pViewportState = &vp_state_ci; |
| 2633 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2634 | gp_ci.layout = pipeline_layout; |
| 2635 | gp_ci.renderPass = renderPass(); |
| 2636 | |
| 2637 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 2638 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 2639 | |
| 2640 | VkPipeline pipeline; |
| 2641 | VkPipelineCache pipelineCache; |
| 2642 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2643 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2644 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2645 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2646 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2647 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2648 | FAIL() << "Did not receive Error 'Gfx Pipeline viewport count (1) must match scissor count (0).'"; |
| 2649 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2650 | } |
| 2651 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2652 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2653 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2654 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2655 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2656 | } |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2657 | // Don't set viewport state in PSO. This is an error b/c we always need this state |
| 2658 | // for the counts even if the data is going to be set dynamically. |
| 2659 | TEST_F(VkLayerTest, PSOViewportStateNotSet) |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2660 | { |
| 2661 | // Attempt to Create Gfx Pipeline w/o a VS |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2662 | VkResult err; |
| 2663 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2664 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2665 | "Gfx Pipeline pViewportState is null. Even if "); |
| 2666 | |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2667 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2668 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2669 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2670 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2671 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2672 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2673 | |
| 2674 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2675 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2676 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2677 | ds_pool_ci.poolSizeCount = 1; |
| 2678 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2679 | |
| 2680 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2681 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2682 | ASSERT_VK_SUCCESS(err); |
| 2683 | |
| 2684 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2685 | dsl_binding.binding = 0; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2686 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 2687 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2688 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2689 | |
| 2690 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2691 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2692 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2693 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2694 | |
| 2695 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2696 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2697 | ASSERT_VK_SUCCESS(err); |
| 2698 | |
| 2699 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2700 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2701 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2702 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2703 | alloc_info.descriptorPool = ds_pool; |
| 2704 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2705 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2706 | ASSERT_VK_SUCCESS(err); |
| 2707 | |
| 2708 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 2709 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2710 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2711 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 2712 | |
| 2713 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2714 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2715 | ASSERT_VK_SUCCESS(err); |
| 2716 | |
| 2717 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 2718 | // Set scissor as dynamic to avoid second error |
| 2719 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 2720 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 2721 | dyn_state_ci.dynamicStateCount = 1; |
| 2722 | dyn_state_ci.pDynamicStates = &sc_state; |
| 2723 | |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2724 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 2725 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2726 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2727 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, this); |
| 2728 | VkShaderObj fs(m_device, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, this); // TODO - We shouldn't need a fragment shader |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2729 | // but add it to be able to run on more devices |
Chia-I Wu | 062ad15 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2730 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 2731 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2732 | |
| 2733 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 2734 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2735 | gp_ci.stageCount = 2; |
| 2736 | gp_ci.pStages = shaderStages; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2737 | gp_ci.pViewportState = NULL; // Not setting VP state w/o dynamic vp state should cause validation error |
| 2738 | gp_ci.pDynamicState = &dyn_state_ci; |
| 2739 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2740 | gp_ci.layout = pipeline_layout; |
| 2741 | gp_ci.renderPass = renderPass(); |
| 2742 | |
| 2743 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 2744 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 2745 | |
| 2746 | VkPipeline pipeline; |
| 2747 | VkPipelineCache pipelineCache; |
| 2748 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2749 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2750 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2751 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2752 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2753 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2754 | FAIL() << "Did not receive Error 'Gfx Pipeline pViewportState is null. Even if...'"; |
| 2755 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2756 | } |
| 2757 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2758 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2759 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2760 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2761 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2762 | } |
| 2763 | // Create PSO w/o non-zero viewportCount but no viewport data |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2764 | // Then run second test where dynamic scissor count doesn't match PSO scissor count |
| 2765 | TEST_F(VkLayerTest, PSOViewportCountWithoutDataAndDynScissorMismatch) |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2766 | { |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2767 | VkResult err; |
| 2768 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2769 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2770 | "Gfx Pipeline viewportCount is 1, but pViewports is NULL. "); |
| 2771 | |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2772 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2773 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2774 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2775 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2776 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2777 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2778 | |
| 2779 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2780 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2781 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2782 | ds_pool_ci.poolSizeCount = 1; |
| 2783 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2784 | |
| 2785 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2786 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2787 | ASSERT_VK_SUCCESS(err); |
| 2788 | |
| 2789 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2790 | dsl_binding.binding = 0; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2791 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 2792 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2793 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2794 | |
| 2795 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2796 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2797 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2798 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2799 | |
| 2800 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2801 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2802 | ASSERT_VK_SUCCESS(err); |
| 2803 | |
| 2804 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2805 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2806 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2807 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2808 | alloc_info.descriptorPool = ds_pool; |
| 2809 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2810 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2811 | ASSERT_VK_SUCCESS(err); |
| 2812 | |
| 2813 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 2814 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2815 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2816 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 2817 | |
| 2818 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2819 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2820 | ASSERT_VK_SUCCESS(err); |
| 2821 | |
| 2822 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 2823 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 2824 | vp_state_ci.viewportCount = 1; |
| 2825 | vp_state_ci.pViewports = NULL; // Null vp w/ count of 1 should cause error |
| 2826 | vp_state_ci.scissorCount = 1; |
| 2827 | vp_state_ci.pScissors = NULL; // Scissor is dynamic (below) so this won't cause error |
| 2828 | |
| 2829 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 2830 | // Set scissor as dynamic to avoid that error |
| 2831 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 2832 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 2833 | dyn_state_ci.dynamicStateCount = 1; |
| 2834 | dyn_state_ci.pDynamicStates = &sc_state; |
| 2835 | |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2836 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 2837 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2838 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2839 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, this); |
| 2840 | VkShaderObj fs(m_device, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, this); // TODO - We shouldn't need a fragment shader |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2841 | // but add it to be able to run on more devices |
Chia-I Wu | 062ad15 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2842 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 2843 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2844 | |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2845 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 2846 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 2847 | vi_ci.pNext = nullptr; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2848 | vi_ci.vertexBindingDescriptionCount = 0; |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2849 | vi_ci.pVertexBindingDescriptions = nullptr; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2850 | vi_ci.vertexAttributeDescriptionCount = 0; |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2851 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 2852 | |
| 2853 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 2854 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 2855 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 2856 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2857 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2858 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2859 | rs_ci.pNext = nullptr; |
| 2860 | |
| 2861 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 2862 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 2863 | cb_ci.pNext = nullptr; |
| 2864 | |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2865 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 2866 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2867 | gp_ci.stageCount = 2; |
| 2868 | gp_ci.pStages = shaderStages; |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2869 | gp_ci.pVertexInputState = &vi_ci; |
| 2870 | gp_ci.pInputAssemblyState = &ia_ci; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2871 | gp_ci.pViewportState = &vp_state_ci; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2872 | gp_ci.pRasterizationState = &rs_ci; |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2873 | gp_ci.pColorBlendState = &cb_ci; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2874 | gp_ci.pDynamicState = &dyn_state_ci; |
| 2875 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2876 | gp_ci.layout = pipeline_layout; |
| 2877 | gp_ci.renderPass = renderPass(); |
| 2878 | |
| 2879 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 2880 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 2881 | |
| 2882 | VkPipeline pipeline; |
| 2883 | VkPipelineCache pipelineCache; |
| 2884 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2885 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2886 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2887 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2888 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2889 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2890 | FAIL() << "Did not recieve Error 'Gfx Pipeline viewportCount is 1, but pViewports is NULL...'"; |
| 2891 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2892 | } |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2893 | |
| 2894 | |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2895 | // Now hit second fail case where we set scissor w/ different count than PSO |
| 2896 | // First need to successfully create the PSO from above by setting pViewports |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2897 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2898 | "Dynamic scissorCount from vkCmdSetScissor() is 2, but PSO scissorCount is 1. These counts must match."); |
| 2899 | |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2900 | VkViewport vp = {}; // Just need dummy vp to point to |
| 2901 | vp_state_ci.pViewports = &vp; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2902 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2903 | ASSERT_VK_SUCCESS(err); |
| 2904 | BeginCommandBuffer(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2905 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2906 | VkRect2D scissors[2] = {}; // don't care about data |
| 2907 | // Count of 2 doesn't match PSO count of 1 |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2908 | vkCmdSetScissor(m_commandBuffer->GetBufferHandle(), 2, scissors); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2909 | Draw(1, 0, 0, 0); |
| 2910 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2911 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2912 | FAIL() << "Did not receive Error 'Dynamic scissorCount from vkCmdSetScissor() is 2, but PSO scissorCount is 1...'"; |
| 2913 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2914 | } |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2915 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2916 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2917 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2918 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2919 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2920 | } |
| 2921 | // Create PSO w/o non-zero scissorCount but no scissor data |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2922 | // Then run second test where dynamic viewportCount doesn't match PSO viewportCount |
| 2923 | TEST_F(VkLayerTest, PSOScissorCountWithoutDataAndDynViewportMismatch) |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2924 | { |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2925 | VkResult err; |
| 2926 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2927 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2928 | "Gfx Pipeline scissorCount is 1, but pScissors is NULL. "); |
| 2929 | |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2930 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2931 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2932 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2933 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2934 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2935 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2936 | |
| 2937 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2938 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2939 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2940 | ds_pool_ci.poolSizeCount = 1; |
| 2941 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2942 | |
| 2943 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2944 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2945 | ASSERT_VK_SUCCESS(err); |
| 2946 | |
| 2947 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2948 | dsl_binding.binding = 0; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2949 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 2950 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2951 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2952 | |
| 2953 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2954 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2955 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2956 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2957 | |
| 2958 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2959 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2960 | ASSERT_VK_SUCCESS(err); |
| 2961 | |
| 2962 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2963 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2964 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2965 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2966 | alloc_info.descriptorPool = ds_pool; |
| 2967 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2968 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2969 | ASSERT_VK_SUCCESS(err); |
| 2970 | |
| 2971 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 2972 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2973 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2974 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 2975 | |
| 2976 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2977 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2978 | ASSERT_VK_SUCCESS(err); |
| 2979 | |
| 2980 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 2981 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 2982 | vp_state_ci.scissorCount = 1; |
| 2983 | vp_state_ci.pScissors = NULL; // Null scissor w/ count of 1 should cause error |
| 2984 | vp_state_ci.viewportCount = 1; |
| 2985 | vp_state_ci.pViewports = NULL; // vp is dynamic (below) so this won't cause error |
| 2986 | |
| 2987 | VkDynamicState vp_state = VK_DYNAMIC_STATE_VIEWPORT; |
| 2988 | // Set scissor as dynamic to avoid that error |
| 2989 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 2990 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 2991 | dyn_state_ci.dynamicStateCount = 1; |
| 2992 | dyn_state_ci.pDynamicStates = &vp_state; |
| 2993 | |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2994 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 2995 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2996 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2997 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, this); |
| 2998 | VkShaderObj fs(m_device, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, this); // TODO - We shouldn't need a fragment shader |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2999 | // but add it to be able to run on more devices |
Chia-I Wu | 062ad15 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3000 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 3001 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3002 | |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 3003 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 3004 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 3005 | vi_ci.pNext = nullptr; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3006 | vi_ci.vertexBindingDescriptionCount = 0; |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 3007 | vi_ci.pVertexBindingDescriptions = nullptr; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3008 | vi_ci.vertexAttributeDescriptionCount = 0; |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 3009 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 3010 | |
| 3011 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 3012 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 3013 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 3014 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3015 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3016 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 3017 | rs_ci.pNext = nullptr; |
| 3018 | |
| 3019 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 3020 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 3021 | cb_ci.pNext = nullptr; |
| 3022 | |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3023 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 3024 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 3025 | gp_ci.stageCount = 2; |
| 3026 | gp_ci.pStages = shaderStages; |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 3027 | gp_ci.pVertexInputState = &vi_ci; |
| 3028 | gp_ci.pInputAssemblyState = &ia_ci; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3029 | gp_ci.pViewportState = &vp_state_ci; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3030 | gp_ci.pRasterizationState = &rs_ci; |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 3031 | gp_ci.pColorBlendState = &cb_ci; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3032 | gp_ci.pDynamicState = &dyn_state_ci; |
| 3033 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 3034 | gp_ci.layout = pipeline_layout; |
| 3035 | gp_ci.renderPass = renderPass(); |
| 3036 | |
| 3037 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 3038 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 3039 | |
| 3040 | VkPipeline pipeline; |
| 3041 | VkPipelineCache pipelineCache; |
| 3042 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3043 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3044 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3045 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3046 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3047 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3048 | FAIL() << "Did not recieve Error 'Gfx Pipeline scissorCount is 1, but pScissors is NULL...'"; |
| 3049 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3050 | } |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3051 | |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 3052 | // Now hit second fail case where we set scissor w/ different count than PSO |
| 3053 | // First need to successfully create the PSO from above by setting pViewports |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3054 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3055 | "Dynamic viewportCount from vkCmdSetViewport() is 2, but PSO viewportCount is 1. These counts must match."); |
| 3056 | |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 3057 | VkRect2D sc = {}; // Just need dummy vp to point to |
| 3058 | vp_state_ci.pScissors = ≻ |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3059 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 3060 | ASSERT_VK_SUCCESS(err); |
| 3061 | BeginCommandBuffer(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3062 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 3063 | VkViewport viewports[2] = {}; // don't care about data |
| 3064 | // Count of 2 doesn't match PSO count of 1 |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3065 | vkCmdSetViewport(m_commandBuffer->GetBufferHandle(), 2, viewports); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 3066 | Draw(1, 0, 0, 0); |
| 3067 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3068 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3069 | FAIL() << "Did not receive Error 'Dynamic viewportCount from vkCmdSetViewport() is 2, but PSO viewportCount is 1...'"; |
| 3070 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 3071 | } |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3072 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3073 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 3074 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3075 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3076 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 3077 | } |
| 3078 | |
Tobin Ehlis | b8b06b5 | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 3079 | TEST_F(VkLayerTest, NullRenderPass) |
| 3080 | { |
| 3081 | // Bind a NULL RenderPass |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3082 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3083 | "You cannot use a NULL RenderPass object in vkCmdBeginRenderPass()"); |
Tobin Ehlis | b8b06b5 | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 3084 | |
| 3085 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3086 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | b8b06b5 | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 3087 | |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 3088 | BeginCommandBuffer(); |
Tobin Ehlis | b8b06b5 | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 3089 | // Don't care about RenderPass handle b/c error should be flagged before that |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3090 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), NULL, VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | b8b06b5 | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 3091 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3092 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3093 | FAIL() << "Did not receive Error 'You cannot use a NULL RenderPass object in vkCmdBeginRenderPass()'"; |
| 3094 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | b8b06b5 | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 3095 | } |
| 3096 | } |
| 3097 | |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3098 | TEST_F(VkLayerTest, RenderPassWithinRenderPass) |
| 3099 | { |
| 3100 | // Bind a BeginRenderPass within an active RenderPass |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3101 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3102 | "It is invalid to issue this call inside an active render pass"); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3103 | |
| 3104 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3105 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3106 | |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 3107 | BeginCommandBuffer(); |
Tobin Ehlis | b8b06b5 | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 3108 | // Just create a dummy Renderpass that's non-NULL so we can get to the proper error |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3109 | VkRenderPassBeginInfo rp_begin = {}; |
| 3110 | rp_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; |
| 3111 | rp_begin.pNext = NULL; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 3112 | rp_begin.renderPass = renderPass(); |
| 3113 | rp_begin.framebuffer = framebuffer(); |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3114 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3115 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &rp_begin, VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 3116 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3117 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3118 | FAIL() << "Did not receive Error 'It is invalid to issue this call inside an active render pass...'"; |
| 3119 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3120 | } |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3121 | } |
| 3122 | |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3123 | TEST_F(VkLayerTest, FillBufferWithinRenderPass) |
| 3124 | { |
| 3125 | // Call CmdFillBuffer within an active renderpass |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3126 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3127 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3128 | |
| 3129 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3130 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3131 | |
| 3132 | // Renderpass is started here |
| 3133 | BeginCommandBuffer(); |
| 3134 | |
| 3135 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3136 | vk_testing::Buffer dstBuffer; |
| 3137 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3138 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3139 | m_commandBuffer->FillBuffer(dstBuffer.handle(), 0, 4, 0x11111111); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3140 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3141 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3142 | FAIL() << "Did not receive Error 'It is invalid to issue this call inside an active render pass...'"; |
| 3143 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3144 | } |
| 3145 | } |
| 3146 | |
| 3147 | TEST_F(VkLayerTest, UpdateBufferWithinRenderPass) |
| 3148 | { |
| 3149 | // Call CmdUpdateBuffer within an active renderpass |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3150 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3151 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3152 | |
| 3153 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3154 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3155 | |
| 3156 | // Renderpass is started here |
| 3157 | BeginCommandBuffer(); |
| 3158 | |
| 3159 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3160 | vk_testing::Buffer dstBuffer; |
| 3161 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3162 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3163 | VkDeviceSize dstOffset = 0; |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3164 | VkDeviceSize dataSize = 1024; |
| 3165 | const uint32_t *pData = NULL; |
| 3166 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3167 | vkCmdUpdateBuffer(m_commandBuffer->GetBufferHandle(), dstBuffer.handle(), dstOffset, dataSize, pData); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3168 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3169 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3170 | FAIL() << "Did not receive Error 'It is invalid to issue this call inside an active render pass...'"; |
| 3171 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3172 | } |
| 3173 | } |
| 3174 | |
| 3175 | TEST_F(VkLayerTest, ClearColorImageWithinRenderPass) |
| 3176 | { |
| 3177 | // Call CmdClearColorImage within an active RenderPass |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3178 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3179 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3180 | |
| 3181 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3182 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3183 | |
| 3184 | // Renderpass is started here |
| 3185 | BeginCommandBuffer(); |
| 3186 | |
| 3187 | VkClearColorValue clear_color = {0}; |
| 3188 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 3189 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 3190 | const int32_t tex_width = 32; |
| 3191 | const int32_t tex_height = 32; |
| 3192 | VkImageCreateInfo image_create_info = {}; |
| 3193 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 3194 | image_create_info.pNext = NULL; |
| 3195 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 3196 | image_create_info.format = tex_format; |
| 3197 | image_create_info.extent.width = tex_width; |
| 3198 | image_create_info.extent.height = tex_height; |
| 3199 | image_create_info.extent.depth = 1; |
| 3200 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 3201 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3202 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3203 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 3204 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 3205 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3206 | vk_testing::Image dstImage; |
| 3207 | dstImage.init(*m_device, (const VkImageCreateInfo&)image_create_info, reqs); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3208 | |
| 3209 | const VkImageSubresourceRange range = |
| 3210 | vk_testing::Image::subresource_range(image_create_info, VK_IMAGE_ASPECT_COLOR_BIT); |
| 3211 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3212 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), |
| 3213 | dstImage.handle(), |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3214 | VK_IMAGE_LAYOUT_GENERAL, |
| 3215 | &clear_color, |
| 3216 | 1, |
| 3217 | &range); |
| 3218 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3219 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3220 | FAIL() << "Did not receive Error 'It is invalid to issue this call inside an active render pass...'"; |
| 3221 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3222 | } |
| 3223 | } |
| 3224 | |
| 3225 | TEST_F(VkLayerTest, ClearDepthStencilImageWithinRenderPass) |
| 3226 | { |
| 3227 | // Call CmdClearDepthStencilImage within an active RenderPass |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3228 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3229 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3230 | |
| 3231 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3232 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3233 | |
| 3234 | // Renderpass is started here |
| 3235 | BeginCommandBuffer(); |
| 3236 | |
| 3237 | VkClearDepthStencilValue clear_value = {0}; |
| 3238 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 3239 | VkImageCreateInfo image_create_info = vk_testing::Image::create_info(); |
| 3240 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 3241 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 3242 | image_create_info.extent.width = 64; |
| 3243 | image_create_info.extent.height = 64; |
| 3244 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 3245 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 3246 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3247 | vk_testing::Image dstImage; |
| 3248 | dstImage.init(*m_device, (const VkImageCreateInfo&)image_create_info, reqs); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3249 | |
| 3250 | const VkImageSubresourceRange range = |
| 3251 | vk_testing::Image::subresource_range(image_create_info, VK_IMAGE_ASPECT_DEPTH_BIT); |
| 3252 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3253 | vkCmdClearDepthStencilImage(m_commandBuffer->GetBufferHandle(), |
| 3254 | dstImage.handle(), |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3255 | VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, |
| 3256 | &clear_value, |
| 3257 | 1, |
| 3258 | &range); |
| 3259 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3260 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3261 | FAIL() << "Did not receive Error 'It is invalid to issue this call inside an active render pass...'"; |
| 3262 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3263 | } |
| 3264 | } |
| 3265 | |
| 3266 | TEST_F(VkLayerTest, ClearColorAttachmentsOutsideRenderPass) |
| 3267 | { |
Courtney Goeltzenleuchter | 9feb073 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 3268 | // Call CmdClearAttachmentss outside of an active RenderPass |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3269 | VkResult err; |
| 3270 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3271 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3272 | "vkCmdClearAttachments: This call must be issued inside an active render pass"); |
| 3273 | |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3274 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3275 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3276 | |
| 3277 | // Start no RenderPass |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3278 | err = m_commandBuffer->BeginCommandBuffer(); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3279 | ASSERT_VK_SUCCESS(err); |
| 3280 | |
Courtney Goeltzenleuchter | 9feb073 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 3281 | VkClearAttachment color_attachment; |
| 3282 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 3283 | color_attachment.clearValue.color.float32[0] = 0; |
| 3284 | color_attachment.clearValue.color.float32[1] = 0; |
| 3285 | color_attachment.clearValue.color.float32[2] = 0; |
| 3286 | color_attachment.clearValue.color.float32[3] = 0; |
| 3287 | color_attachment.colorAttachment = 0; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 3288 | VkClearRect clear_rect = { { { 0, 0 }, { 32, 32 } } }; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3289 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), |
Courtney Goeltzenleuchter | 9feb073 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 3290 | 1, &color_attachment, |
| 3291 | 1, &clear_rect); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3292 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3293 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3294 | FAIL() << "Did not receive Error 'vkCmdClearAttachments: This call must be issued inside an active render pass.'"; |
| 3295 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3296 | } |
| 3297 | } |
| 3298 | |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3299 | TEST_F(VkLayerTest, InvalidDynamicStateObject) |
| 3300 | { |
| 3301 | // Create a valid cmd buffer |
| 3302 | // call vkCmdBindDynamicStateObject w/ false DS Obj |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3303 | // TODO : Simple check for bad object should be added to ObjectTracker to catch this case |
| 3304 | // The DS check for this is after driver has been called to validate DS internal data struct |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3305 | } |
Tobin Ehlis | 201b1ba | 2015-05-27 14:55:35 -0600 | [diff] [blame] | 3306 | |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3307 | TEST_F(VkLayerTest, IdxBufferAlignmentError) |
| 3308 | { |
| 3309 | // Bind a BeginRenderPass within an active RenderPass |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3310 | VkResult err; |
| 3311 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3312 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3313 | "vkCmdBindIndexBuffer() offset (0x7) does not fall on "); |
| 3314 | |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3315 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3316 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3317 | uint32_t qfi = 0; |
| 3318 | VkBufferCreateInfo buffCI = {}; |
| 3319 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 3320 | buffCI.size = 1024; |
| 3321 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3322 | buffCI.queueFamilyIndexCount = 1; |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3323 | buffCI.pQueueFamilyIndices = &qfi; |
| 3324 | |
| 3325 | VkBuffer ib; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3326 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3327 | ASSERT_VK_SUCCESS(err); |
| 3328 | |
| 3329 | BeginCommandBuffer(); |
| 3330 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3331 | //vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3332 | // Should error before calling to driver so don't care about actual data |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3333 | vkCmdBindIndexBuffer(m_commandBuffer->GetBufferHandle(), ib, 7, VK_INDEX_TYPE_UINT16); |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3334 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3335 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3336 | FAIL() << "Did not receive Error 'vkCmdBindIndexBuffer() offset (0x7) does not fall on ...'"; |
| 3337 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3338 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3339 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3340 | vkDestroyBuffer(m_device->device(), ib, NULL); |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3341 | } |
| 3342 | |
Tobin Ehlis | 5f728d3 | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 3343 | TEST_F(VkLayerTest, ExecuteCommandsPrimaryCB) |
| 3344 | { |
| 3345 | // Attempt vkCmdExecuteCommands w/ a primary cmd buffer (should only be secondary) |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3346 | |
| 3347 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3348 | "vkCmdExecuteCommands() called w/ Primary Cmd Buffer "); |
Tobin Ehlis | 5f728d3 | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 3349 | |
| 3350 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3351 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 5f728d3 | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 3352 | |
| 3353 | BeginCommandBuffer(); |
| 3354 | //ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3355 | VkCommandBuffer primCB = m_commandBuffer->GetBufferHandle(); |
| 3356 | vkCmdExecuteCommands(m_commandBuffer->GetBufferHandle(), 1, &primCB); |
Tobin Ehlis | 5f728d3 | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 3357 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3358 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3359 | FAIL() << "Did not receive Error 'vkCmdExecuteCommands() called w/ Primary Cmd Buffer '"; |
| 3360 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 5f728d3 | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 3361 | } |
| 3362 | } |
| 3363 | |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3364 | TEST_F(VkLayerTest, DSTypeMismatch) |
| 3365 | { |
| 3366 | // Create DS w/ layout of one type and attempt Update w/ mis-matched type |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3367 | VkResult err; |
| 3368 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3369 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3370 | "Write descriptor update has descriptor type VK_DESCRIPTOR_TYPE_SAMPLER that does not match "); |
| 3371 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3372 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3373 | //VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3374 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3375 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3376 | ds_type_count.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3377 | |
| 3378 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3379 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3380 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3381 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3382 | ds_pool_ci.poolSizeCount = 1; |
| 3383 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3384 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3385 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3386 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3387 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3388 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3389 | dsl_binding.binding = 0; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3390 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 3391 | dsl_binding.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3392 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3393 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3394 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3395 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3396 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3397 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3398 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3399 | ds_layout_ci.pBinding = &dsl_binding; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3400 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3401 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3402 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3403 | ASSERT_VK_SUCCESS(err); |
| 3404 | |
| 3405 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3406 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3407 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3408 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3409 | alloc_info.descriptorPool = ds_pool; |
| 3410 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3411 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3412 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3413 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3414 | VkSamplerCreateInfo sampler_ci = {}; |
| 3415 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3416 | sampler_ci.pNext = NULL; |
Chia-I Wu | 3603b08 | 2015-10-26 16:49:32 +0800 | [diff] [blame] | 3417 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 3418 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 3419 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_BASE; |
Chia-I Wu | ce532f7 | 2015-10-26 17:32:47 +0800 | [diff] [blame] | 3420 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3421 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3422 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3423 | sampler_ci.mipLodBias = 1.0; |
Jon Ashburn | 0717ed5 | 2015-12-14 14:59:20 -0700 | [diff] [blame^] | 3424 | sampler_ci.anisotropyEnable = VK_FALSE; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3425 | sampler_ci.maxAnisotropy = 1; |
| 3426 | sampler_ci.compareEnable = VK_FALSE; |
| 3427 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3428 | sampler_ci.minLod = 1.0; |
| 3429 | sampler_ci.maxLod = 1.0; |
| 3430 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
Mark Lobodzinski | 513acdf | 2015-09-01 15:42:56 -0600 | [diff] [blame] | 3431 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
| 3432 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3433 | VkSampler sampler; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3434 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3435 | ASSERT_VK_SUCCESS(err); |
| 3436 | |
Courtney Goeltzenleuchter | 34aa5c8 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3437 | VkDescriptorImageInfo info = {}; |
| 3438 | info.sampler = sampler; |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3439 | |
| 3440 | VkWriteDescriptorSet descriptor_write; |
| 3441 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3442 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3443 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3444 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3445 | // This is a mismatched type for the layout which expects BUFFER |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3446 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 34aa5c8 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3447 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3448 | |
| 3449 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3450 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3451 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3452 | FAIL() << "Did not receive Error 'Write descriptor update has descriptor type VK_DESCRIPTOR_TYPE_SAMPLER that does not match...'"; |
| 3453 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3454 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3455 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3456 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3457 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3458 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3459 | } |
| 3460 | |
| 3461 | TEST_F(VkLayerTest, DSUpdateOutOfBounds) |
| 3462 | { |
| 3463 | // For overlapping Update, have arrayIndex exceed that of layout |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3464 | VkResult err; |
| 3465 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3466 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3467 | "Descriptor update type of VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET is out of bounds for matching binding"); |
| 3468 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3469 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3470 | //VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3471 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3472 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3473 | ds_type_count.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3474 | |
| 3475 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3476 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3477 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3478 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3479 | ds_pool_ci.poolSizeCount = 1; |
| 3480 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3481 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3482 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3483 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3484 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3485 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3486 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3487 | dsl_binding.binding = 0; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3488 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 3489 | dsl_binding.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3490 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3491 | dsl_binding.pImmutableSamplers = NULL; |
| 3492 | |
| 3493 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3494 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3495 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3496 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3497 | ds_layout_ci.pBinding = &dsl_binding; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3498 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3499 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3500 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3501 | ASSERT_VK_SUCCESS(err); |
| 3502 | |
| 3503 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3504 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3505 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3506 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3507 | alloc_info.descriptorPool = ds_pool; |
| 3508 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3509 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3510 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3511 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3512 | VkSamplerCreateInfo sampler_ci = {}; |
| 3513 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3514 | sampler_ci.pNext = NULL; |
Chia-I Wu | 3603b08 | 2015-10-26 16:49:32 +0800 | [diff] [blame] | 3515 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 3516 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 3517 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_BASE; |
Chia-I Wu | ce532f7 | 2015-10-26 17:32:47 +0800 | [diff] [blame] | 3518 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3519 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3520 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3521 | sampler_ci.mipLodBias = 1.0; |
Jon Ashburn | 0717ed5 | 2015-12-14 14:59:20 -0700 | [diff] [blame^] | 3522 | sampler_ci.anisotropyEnable = VK_FALSE; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3523 | sampler_ci.maxAnisotropy = 1; |
| 3524 | sampler_ci.compareEnable = VK_FALSE; |
| 3525 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3526 | sampler_ci.minLod = 1.0; |
| 3527 | sampler_ci.maxLod = 1.0; |
| 3528 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
Mark Lobodzinski | 513acdf | 2015-09-01 15:42:56 -0600 | [diff] [blame] | 3529 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3530 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3531 | VkSampler sampler; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3532 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3533 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3534 | |
Courtney Goeltzenleuchter | 34aa5c8 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3535 | VkDescriptorImageInfo info = {}; |
| 3536 | info.sampler = sampler; |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3537 | |
| 3538 | VkWriteDescriptorSet descriptor_write; |
| 3539 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3540 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3541 | descriptor_write.dstSet = descriptorSet; |
| 3542 | descriptor_write.dstArrayElement = 1; /* This index out of bounds for the update */ |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3543 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3544 | // This is the wrong type, but out of bounds will be flagged first |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3545 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 34aa5c8 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3546 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3547 | |
| 3548 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3549 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3550 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3551 | FAIL() << "Did not receive Error 'Descriptor update type of VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET is out of bounds for matching binding...'"; |
| 3552 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3553 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3554 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3555 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3556 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3557 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3558 | } |
| 3559 | |
| 3560 | TEST_F(VkLayerTest, InvalidDSUpdateIndex) |
| 3561 | { |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3562 | // Create layout w/ count of 1 and attempt update to that layout w/ binding index 2 |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3563 | VkResult err; |
| 3564 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3565 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3566 | " does not have binding to match update binding "); |
| 3567 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3568 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3569 | //VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3570 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3571 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3572 | ds_type_count.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3573 | |
| 3574 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3575 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3576 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3577 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3578 | ds_pool_ci.poolSizeCount = 1; |
| 3579 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3580 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3581 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3582 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3583 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3584 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3585 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3586 | dsl_binding.binding = 0; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3587 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 3588 | dsl_binding.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3589 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3590 | dsl_binding.pImmutableSamplers = NULL; |
| 3591 | |
| 3592 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3593 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3594 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3595 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3596 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3597 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3598 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3599 | ASSERT_VK_SUCCESS(err); |
| 3600 | |
| 3601 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3602 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3603 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3604 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3605 | alloc_info.descriptorPool = ds_pool; |
| 3606 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3607 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3608 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3609 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3610 | VkSamplerCreateInfo sampler_ci = {}; |
| 3611 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3612 | sampler_ci.pNext = NULL; |
Chia-I Wu | 3603b08 | 2015-10-26 16:49:32 +0800 | [diff] [blame] | 3613 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 3614 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 3615 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_BASE; |
Chia-I Wu | ce532f7 | 2015-10-26 17:32:47 +0800 | [diff] [blame] | 3616 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3617 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3618 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3619 | sampler_ci.mipLodBias = 1.0; |
Jon Ashburn | 0717ed5 | 2015-12-14 14:59:20 -0700 | [diff] [blame^] | 3620 | sampler_ci.anisotropyEnable = VK_FALSE; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3621 | sampler_ci.maxAnisotropy = 1; |
| 3622 | sampler_ci.compareEnable = VK_FALSE; |
| 3623 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3624 | sampler_ci.minLod = 1.0; |
| 3625 | sampler_ci.maxLod = 1.0; |
| 3626 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
Mark Lobodzinski | 513acdf | 2015-09-01 15:42:56 -0600 | [diff] [blame] | 3627 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3628 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3629 | VkSampler sampler; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3630 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3631 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3632 | |
Courtney Goeltzenleuchter | 34aa5c8 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3633 | VkDescriptorImageInfo info = {}; |
| 3634 | info.sampler = sampler; |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3635 | |
| 3636 | VkWriteDescriptorSet descriptor_write; |
| 3637 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3638 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3639 | descriptor_write.dstSet = descriptorSet; |
| 3640 | descriptor_write.dstBinding = 2; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3641 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3642 | // This is the wrong type, but out of bounds will be flagged first |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3643 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 34aa5c8 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3644 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3645 | |
| 3646 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3647 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3648 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3649 | FAIL() << "Did not receive Error 'Descriptor Set <blah> does not have binding to match update binding '"; |
| 3650 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3651 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3652 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3653 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3654 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3655 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3656 | } |
| 3657 | |
| 3658 | TEST_F(VkLayerTest, InvalidDSUpdateStruct) |
| 3659 | { |
| 3660 | // Call UpdateDS w/ struct type other than valid VK_STRUCTUR_TYPE_UPDATE_* types |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3661 | VkResult err; |
| 3662 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3663 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3664 | "Unexpected UPDATE struct of type "); |
| 3665 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3666 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3667 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3668 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3669 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3670 | ds_type_count.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3671 | |
| 3672 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3673 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3674 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3675 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3676 | ds_pool_ci.poolSizeCount = 1; |
| 3677 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3678 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3679 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3680 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3681 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3682 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3683 | dsl_binding.binding = 0; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3684 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 3685 | dsl_binding.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3686 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3687 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3688 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3689 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3690 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3691 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3692 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3693 | ds_layout_ci.pBinding = &dsl_binding; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3694 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3695 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3696 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3697 | ASSERT_VK_SUCCESS(err); |
| 3698 | |
| 3699 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3700 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3701 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3702 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3703 | alloc_info.descriptorPool = ds_pool; |
| 3704 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3705 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3706 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3707 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3708 | VkSamplerCreateInfo sampler_ci = {}; |
| 3709 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3710 | sampler_ci.pNext = NULL; |
Chia-I Wu | 3603b08 | 2015-10-26 16:49:32 +0800 | [diff] [blame] | 3711 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 3712 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 3713 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_BASE; |
Chia-I Wu | ce532f7 | 2015-10-26 17:32:47 +0800 | [diff] [blame] | 3714 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3715 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3716 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3717 | sampler_ci.mipLodBias = 1.0; |
Jon Ashburn | 0717ed5 | 2015-12-14 14:59:20 -0700 | [diff] [blame^] | 3718 | sampler_ci.anisotropyEnable = VK_FALSE; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3719 | sampler_ci.maxAnisotropy = 1; |
| 3720 | sampler_ci.compareEnable = VK_FALSE; |
| 3721 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3722 | sampler_ci.minLod = 1.0; |
| 3723 | sampler_ci.maxLod = 1.0; |
| 3724 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
Mark Lobodzinski | 513acdf | 2015-09-01 15:42:56 -0600 | [diff] [blame] | 3725 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3726 | VkSampler sampler; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3727 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3728 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3729 | |
| 3730 | |
Courtney Goeltzenleuchter | 34aa5c8 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3731 | VkDescriptorImageInfo info = {}; |
| 3732 | info.sampler = sampler; |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3733 | |
| 3734 | VkWriteDescriptorSet descriptor_write; |
| 3735 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3736 | descriptor_write.sType = (VkStructureType)0x99999999; /* Intentionally broken struct type */ |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3737 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3738 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3739 | // This is the wrong type, but out of bounds will be flagged first |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3740 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 34aa5c8 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3741 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3742 | |
| 3743 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3744 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3745 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3746 | FAIL() << "Did not receive Error 'Unexpected UPDATE struct of type '"; |
| 3747 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3748 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3749 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3750 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3751 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3752 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3753 | } |
| 3754 | |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3755 | TEST_F(VkLayerTest, SampleDescriptorUpdateError) |
| 3756 | { |
| 3757 | // Create a single Sampler descriptor and send it an invalid Sampler |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3758 | VkResult err; |
| 3759 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3760 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3761 | "Attempt to update descriptor with invalid sampler 0xbaadbeef"); |
| 3762 | |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3763 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3764 | // TODO : Farm Descriptor setup code to helper function(s) to reduce copied code |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3765 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3766 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3767 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3768 | |
| 3769 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3770 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3771 | ds_pool_ci.pNext = NULL; |
| 3772 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3773 | ds_pool_ci.poolSizeCount = 1; |
| 3774 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3775 | |
| 3776 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3777 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3778 | ASSERT_VK_SUCCESS(err); |
| 3779 | |
| 3780 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3781 | dsl_binding.binding = 0; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3782 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 3783 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3784 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3785 | dsl_binding.pImmutableSamplers = NULL; |
| 3786 | |
| 3787 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3788 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3789 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3790 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3791 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3792 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3793 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3794 | ASSERT_VK_SUCCESS(err); |
| 3795 | |
| 3796 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3797 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3798 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3799 | alloc_info.setLayoutCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3800 | alloc_info.descriptorPool = ds_pool; |
| 3801 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3802 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3803 | ASSERT_VK_SUCCESS(err); |
| 3804 | |
Chia-I Wu | e420a33 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 3805 | VkSampler sampler = (VkSampler) 0xbaadbeef; // Sampler with invalid handle |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3806 | |
| 3807 | VkDescriptorImageInfo descriptor_info; |
| 3808 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 3809 | descriptor_info.sampler = sampler; |
| 3810 | |
| 3811 | VkWriteDescriptorSet descriptor_write; |
| 3812 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3813 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3814 | descriptor_write.dstSet = descriptorSet; |
| 3815 | descriptor_write.dstBinding = 0; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3816 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3817 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 3818 | descriptor_write.pImageInfo = &descriptor_info; |
| 3819 | |
| 3820 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3821 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3822 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3823 | FAIL() << "Did not receive Error 'Attempt to update descriptor with invalid sampler...'"; |
| 3824 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3825 | } |
| 3826 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3827 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3828 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3829 | } |
| 3830 | |
| 3831 | TEST_F(VkLayerTest, ImageViewDescriptorUpdateError) |
| 3832 | { |
| 3833 | // Create a single combined Image/Sampler descriptor and send it an invalid imageView |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3834 | VkResult err; |
| 3835 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3836 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3837 | "Attempt to update descriptor with invalid imageView 0xbaadbeef"); |
| 3838 | |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3839 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3840 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3841 | ds_type_count.type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3842 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3843 | |
| 3844 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3845 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3846 | ds_pool_ci.pNext = NULL; |
| 3847 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3848 | ds_pool_ci.poolSizeCount = 1; |
| 3849 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3850 | |
| 3851 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3852 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3853 | ASSERT_VK_SUCCESS(err); |
| 3854 | |
| 3855 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3856 | dsl_binding.binding = 0; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3857 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 3858 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3859 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3860 | dsl_binding.pImmutableSamplers = NULL; |
| 3861 | |
| 3862 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3863 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3864 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3865 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3866 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3867 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3868 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3869 | ASSERT_VK_SUCCESS(err); |
| 3870 | |
| 3871 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3872 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3873 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3874 | alloc_info.setLayoutCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3875 | alloc_info.descriptorPool = ds_pool; |
| 3876 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3877 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3878 | ASSERT_VK_SUCCESS(err); |
| 3879 | |
| 3880 | VkSamplerCreateInfo sampler_ci = {}; |
| 3881 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3882 | sampler_ci.pNext = NULL; |
Chia-I Wu | 3603b08 | 2015-10-26 16:49:32 +0800 | [diff] [blame] | 3883 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 3884 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 3885 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_BASE; |
Chia-I Wu | ce532f7 | 2015-10-26 17:32:47 +0800 | [diff] [blame] | 3886 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3887 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3888 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3889 | sampler_ci.mipLodBias = 1.0; |
Jon Ashburn | 0717ed5 | 2015-12-14 14:59:20 -0700 | [diff] [blame^] | 3890 | sampler_ci.anisotropyEnable = VK_FALSE; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3891 | sampler_ci.maxAnisotropy = 1; |
| 3892 | sampler_ci.compareEnable = VK_FALSE; |
| 3893 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3894 | sampler_ci.minLod = 1.0; |
| 3895 | sampler_ci.maxLod = 1.0; |
| 3896 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 3897 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
| 3898 | |
| 3899 | VkSampler sampler; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3900 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3901 | ASSERT_VK_SUCCESS(err); |
| 3902 | |
Chia-I Wu | e420a33 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 3903 | VkImageView view = (VkImageView) 0xbaadbeef; // invalid imageView object |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3904 | |
| 3905 | VkDescriptorImageInfo descriptor_info; |
| 3906 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 3907 | descriptor_info.sampler = sampler; |
| 3908 | descriptor_info.imageView = view; |
| 3909 | |
| 3910 | VkWriteDescriptorSet descriptor_write; |
| 3911 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3912 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3913 | descriptor_write.dstSet = descriptorSet; |
| 3914 | descriptor_write.dstBinding = 0; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3915 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3916 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 3917 | descriptor_write.pImageInfo = &descriptor_info; |
| 3918 | |
| 3919 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3920 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3921 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3922 | FAIL() << "Did not receive Error 'Attempt to update descriptor with invalid imageView...'"; |
| 3923 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3924 | } |
| 3925 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3926 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3927 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3928 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3929 | } |
| 3930 | |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3931 | TEST_F(VkLayerTest, CopyDescriptorUpdateErrors) |
| 3932 | { |
| 3933 | // Create DS w/ layout of 2 types, write update 1 and attempt to copy-update into the other |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3934 | VkResult err; |
| 3935 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3936 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3937 | "Copy descriptor update index 0, update count #1, has src update descriptor type VK_DESCRIPTOR_TYPE_SAMPLER "); |
| 3938 | |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3939 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3940 | //VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3941 | VkDescriptorPoolSize ds_type_count[2] = {}; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3942 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3943 | ds_type_count[0].descriptorCount = 1; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3944 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3945 | ds_type_count[1].descriptorCount = 1; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3946 | |
| 3947 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3948 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3949 | ds_pool_ci.pNext = NULL; |
| 3950 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3951 | ds_pool_ci.poolSizeCount = 2; |
| 3952 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3953 | |
| 3954 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3955 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3956 | ASSERT_VK_SUCCESS(err); |
| 3957 | VkDescriptorSetLayoutBinding dsl_binding[2] = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3958 | dsl_binding[0].binding = 0; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3959 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 3960 | dsl_binding[0].descriptorCount = 1; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3961 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 3962 | dsl_binding[0].pImmutableSamplers = NULL; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3963 | dsl_binding[1].binding = 1; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3964 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 3965 | dsl_binding[1].descriptorCount = 1; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3966 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 3967 | dsl_binding[1].pImmutableSamplers = NULL; |
| 3968 | |
| 3969 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3970 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3971 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3972 | ds_layout_ci.bindingCount = 2; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3973 | ds_layout_ci.pBinding = dsl_binding; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3974 | |
| 3975 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3976 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3977 | ASSERT_VK_SUCCESS(err); |
| 3978 | |
| 3979 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3980 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3981 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3982 | alloc_info.setLayoutCount = 1; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3983 | alloc_info.descriptorPool = ds_pool; |
| 3984 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3985 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3986 | ASSERT_VK_SUCCESS(err); |
| 3987 | |
| 3988 | VkSamplerCreateInfo sampler_ci = {}; |
| 3989 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3990 | sampler_ci.pNext = NULL; |
Chia-I Wu | 3603b08 | 2015-10-26 16:49:32 +0800 | [diff] [blame] | 3991 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 3992 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 3993 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_BASE; |
Chia-I Wu | ce532f7 | 2015-10-26 17:32:47 +0800 | [diff] [blame] | 3994 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3995 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3996 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3997 | sampler_ci.mipLodBias = 1.0; |
Jon Ashburn | 0717ed5 | 2015-12-14 14:59:20 -0700 | [diff] [blame^] | 3998 | sampler_ci.anisotropyEnable = VK_FALSE; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3999 | sampler_ci.maxAnisotropy = 1; |
| 4000 | sampler_ci.compareEnable = VK_FALSE; |
| 4001 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 4002 | sampler_ci.minLod = 1.0; |
| 4003 | sampler_ci.maxLod = 1.0; |
| 4004 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 4005 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
| 4006 | |
| 4007 | VkSampler sampler; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4008 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4009 | ASSERT_VK_SUCCESS(err); |
| 4010 | |
| 4011 | VkDescriptorImageInfo info = {}; |
| 4012 | info.sampler = sampler; |
| 4013 | |
| 4014 | VkWriteDescriptorSet descriptor_write; |
| 4015 | memset(&descriptor_write, 0, sizeof(VkWriteDescriptorSet)); |
| 4016 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4017 | descriptor_write.dstSet = descriptorSet; |
| 4018 | descriptor_write.dstBinding = 1; // SAMPLER binding from layout above |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4019 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4020 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 4021 | descriptor_write.pImageInfo = &info; |
| 4022 | // This write update should succeed |
| 4023 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 4024 | // Now perform a copy update that fails due to type mismatch |
| 4025 | VkCopyDescriptorSet copy_ds_update; |
| 4026 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 4027 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 4028 | copy_ds_update.srcSet = descriptorSet; |
| 4029 | copy_ds_update.srcBinding = 1; // copy from SAMPLER binding |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4030 | copy_ds_update.dstSet = descriptorSet; |
| 4031 | copy_ds_update.dstBinding = 0; // ERROR : copy to UNIFORM binding |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4032 | copy_ds_update.descriptorCount = 1; // copy 1 descriptor |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4033 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 4034 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4035 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4036 | FAIL() << "Did not receive Error 'Copy descriptor update index 0, update count #1, has src update descriptor type_DESCRIPTOR_TYPE_SAMPLER'"; |
| 4037 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4038 | } |
| 4039 | // Now perform a copy update that fails due to binding out of bounds |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4040 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4041 | "Copy descriptor update 0 has srcBinding 3 which is out of bounds "); |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4042 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 4043 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 4044 | copy_ds_update.srcSet = descriptorSet; |
| 4045 | copy_ds_update.srcBinding = 3; // ERROR : Invalid binding for matching layout |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4046 | copy_ds_update.dstSet = descriptorSet; |
| 4047 | copy_ds_update.dstBinding = 0; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4048 | copy_ds_update.descriptorCount = 1; // copy 1 descriptor |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4049 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 4050 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4051 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4052 | FAIL() << "Did not receive Error 'Copy descriptor update 0 has srcBinding 3 which is out of bounds...'"; |
| 4053 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4054 | } |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4055 | |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4056 | // Now perform a copy update that fails due to binding out of bounds |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4057 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4058 | "Copy descriptor src update is out of bounds for matching binding 1 "); |
| 4059 | |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4060 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 4061 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 4062 | copy_ds_update.srcSet = descriptorSet; |
| 4063 | copy_ds_update.srcBinding = 1; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4064 | copy_ds_update.dstSet = descriptorSet; |
| 4065 | copy_ds_update.dstBinding = 0; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4066 | copy_ds_update.descriptorCount = 5; // ERROR copy 5 descriptors (out of bounds for layout) |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4067 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 4068 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4069 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4070 | FAIL() << "Did not receive Error 'Copy descriptor src update is out of bounds for matching binding 1...'"; |
| 4071 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4072 | } |
| 4073 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4074 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 4075 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4076 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 4077 | } |
| 4078 | |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4079 | TEST_F(VkLayerTest, NumSamplesMismatch) |
| 4080 | { |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4081 | // Create CommandBuffer where MSAA samples doesn't match RenderPass sampleCount |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4082 | VkResult err; |
| 4083 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4084 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4085 | "Num samples mismatch! "); |
| 4086 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4087 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4088 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4089 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4090 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4091 | ds_type_count.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4092 | |
| 4093 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 4094 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4095 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 4096 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4097 | ds_pool_ci.poolSizeCount = 1; |
| 4098 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 4099 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4100 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4101 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4102 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4103 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4104 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4105 | dsl_binding.binding = 0; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4106 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 4107 | dsl_binding.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4108 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4109 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4110 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4111 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 4112 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4113 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4114 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4115 | ds_layout_ci.pBinding = &dsl_binding; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4116 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4117 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4118 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4119 | ASSERT_VK_SUCCESS(err); |
| 4120 | |
| 4121 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4122 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4123 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4124 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4125 | alloc_info.descriptorPool = ds_pool; |
| 4126 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4127 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4128 | ASSERT_VK_SUCCESS(err); |
| 4129 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4130 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 4131 | pipe_ms_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 4132 | pipe_ms_state_ci.pNext = NULL; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4133 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4134 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 4135 | pipe_ms_state_ci.minSampleShading = 1.0; |
Cody Northrop | e9825b7 | 2015-08-04 14:34:54 -0600 | [diff] [blame] | 4136 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4137 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4138 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 4139 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4140 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4141 | pipeline_layout_ci.setLayoutCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4142 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4143 | |
| 4144 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4145 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4146 | ASSERT_VK_SUCCESS(err); |
| 4147 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4148 | VkShaderObj vs(m_device, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4149 | VkShaderObj fs(m_device, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, this); // TODO - We shouldn't need a fragment shader |
Tony Barbour | 3c9e3b1 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 4150 | // but add it to be able to run on more devices |
Tony Barbour | d7d828b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4151 | VkPipelineObj pipe(m_device); |
| 4152 | pipe.AddShader(&vs); |
Tony Barbour | 3c9e3b1 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 4153 | pipe.AddShader(&fs); |
Tony Barbour | d7d828b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4154 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 4155 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4156 | |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4157 | BeginCommandBuffer(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4158 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4159 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4160 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4161 | FAIL() << "Did not recieve Error 'Num samples mismatch!...'"; |
| 4162 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 4163 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 4164 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4165 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4166 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4167 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 4168 | } |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4169 | |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4170 | TEST_F(VkLayerTest, ClearCmdNoDraw) |
| 4171 | { |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4172 | // Create CommandBuffer where we add ClearCmd for FB Color attachment prior to issuing a Draw |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4173 | VkResult err; |
| 4174 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4175 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_WARN_BIT, |
| 4176 | "vkCmdClearAttachments() issued on CB object "); |
| 4177 | |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4178 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4179 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4180 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4181 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4182 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4183 | ds_type_count.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4184 | |
| 4185 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 4186 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4187 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 4188 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4189 | ds_pool_ci.poolSizeCount = 1; |
| 4190 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4191 | |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4192 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4193 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4194 | ASSERT_VK_SUCCESS(err); |
| 4195 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4196 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4197 | dsl_binding.binding = 0; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4198 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 4199 | dsl_binding.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4200 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4201 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4202 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4203 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 4204 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4205 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4206 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4207 | ds_layout_ci.pBinding = &dsl_binding; |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4208 | |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4209 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4210 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4211 | ASSERT_VK_SUCCESS(err); |
| 4212 | |
| 4213 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4214 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4215 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4216 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4217 | alloc_info.descriptorPool = ds_pool; |
| 4218 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4219 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4220 | ASSERT_VK_SUCCESS(err); |
| 4221 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4222 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 4223 | pipe_ms_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 4224 | pipe_ms_state_ci.pNext = NULL; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4225 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4226 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 4227 | pipe_ms_state_ci.minSampleShading = 1.0; |
Cody Northrop | e9825b7 | 2015-08-04 14:34:54 -0600 | [diff] [blame] | 4228 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4229 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4230 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 4231 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4232 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4233 | pipeline_layout_ci.setLayoutCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4234 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4235 | |
| 4236 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4237 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4238 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4239 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4240 | VkShaderObj vs(m_device, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4241 | // TODO - We shouldn't need a fragment shader but add it to be able to run on more devices |
| 4242 | VkShaderObj fs(m_device, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 4243 | |
Tony Barbour | d7d828b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4244 | VkPipelineObj pipe(m_device); |
| 4245 | pipe.AddShader(&vs); |
Tony Barbour | 3c9e3b1 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 4246 | pipe.AddShader(&fs); |
Tony Barbour | d7d828b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4247 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 4248 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4249 | |
| 4250 | BeginCommandBuffer(); |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4251 | |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4252 | // Main thing we care about for this test is that the VkImage obj we're clearing matches Color Attachment of FB |
| 4253 | // Also pass down other dummy params to keep driver and paramchecker happy |
Courtney Goeltzenleuchter | 9feb073 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 4254 | VkClearAttachment color_attachment; |
| 4255 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 4256 | color_attachment.clearValue.color.float32[0] = 1.0; |
| 4257 | color_attachment.clearValue.color.float32[1] = 1.0; |
| 4258 | color_attachment.clearValue.color.float32[2] = 1.0; |
| 4259 | color_attachment.clearValue.color.float32[3] = 1.0; |
| 4260 | color_attachment.colorAttachment = 0; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 4261 | VkClearRect clear_rect = { { { 0, 0 }, { (int)m_width, (int)m_height } } }; |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4262 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4263 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4264 | |
| 4265 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4266 | FAIL() << "Did not receive Error 'vkCommandClearAttachments() issued on CB object...'"; |
| 4267 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4268 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 4269 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4270 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4271 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4272 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4273 | } |
| 4274 | |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4275 | TEST_F(VkLayerTest, VtxBufferBadIndex) |
| 4276 | { |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4277 | // Create CommandBuffer where MSAA samples doesn't match RenderPass sampleCount |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4278 | VkResult err; |
| 4279 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4280 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4281 | "Vtx Buffer Index 1 was bound, but no vtx buffers are attached to PSO."); |
| 4282 | |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4283 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4284 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4285 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4286 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4287 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4288 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4289 | ds_type_count.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4290 | |
| 4291 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 4292 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4293 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 4294 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4295 | ds_pool_ci.poolSizeCount = 1; |
| 4296 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4297 | |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 4298 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4299 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4300 | ASSERT_VK_SUCCESS(err); |
| 4301 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4302 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4303 | dsl_binding.binding = 0; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4304 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 4305 | dsl_binding.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4306 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4307 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4308 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4309 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 4310 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4311 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4312 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4313 | ds_layout_ci.pBinding = &dsl_binding; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4314 | |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4315 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4316 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4317 | ASSERT_VK_SUCCESS(err); |
| 4318 | |
| 4319 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4320 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4321 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4322 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4323 | alloc_info.descriptorPool = ds_pool; |
| 4324 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4325 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4326 | ASSERT_VK_SUCCESS(err); |
| 4327 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4328 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 4329 | pipe_ms_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 4330 | pipe_ms_state_ci.pNext = NULL; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4331 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4332 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 4333 | pipe_ms_state_ci.minSampleShading = 1.0; |
Cody Northrop | e9825b7 | 2015-08-04 14:34:54 -0600 | [diff] [blame] | 4334 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4335 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4336 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 4337 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4338 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4339 | pipeline_layout_ci.setLayoutCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4340 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 4341 | VkPipelineLayout pipeline_layout; |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4342 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4343 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4344 | ASSERT_VK_SUCCESS(err); |
| 4345 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4346 | VkShaderObj vs(m_device, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4347 | VkShaderObj fs(m_device, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, this); // TODO - We shouldn't need a fragment shader |
Tony Barbour | 3c9e3b1 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 4348 | // but add it to be able to run on more devices |
Tony Barbour | d7d828b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4349 | VkPipelineObj pipe(m_device); |
| 4350 | pipe.AddShader(&vs); |
Tony Barbour | 3c9e3b1 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 4351 | pipe.AddShader(&fs); |
Tony Barbour | d7d828b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4352 | pipe.SetMSAA(&pipe_ms_state_ci); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4353 | pipe.SetViewport(m_viewports); |
| 4354 | pipe.SetScissor(m_scissors); |
Tony Barbour | d7d828b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4355 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4356 | |
| 4357 | BeginCommandBuffer(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4358 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | d28acef | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 4359 | // Don't care about actual data, just need to get to draw to flag error |
| 4360 | static const float vbo_data[3] = {1.f, 0.f, 1.f}; |
| 4361 | VkConstantBufferObj vbo(m_device, sizeof(vbo_data), sizeof(float), (const void*) &vbo_data); |
| 4362 | BindVertexBuffer(&vbo, (VkDeviceSize)0, 1); // VBO idx 1, but no VBO in PSO |
Courtney Goeltzenleuchter | 4ff11cc | 2015-09-23 12:31:50 -0600 | [diff] [blame] | 4363 | Draw(1, 0, 0, 0); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4364 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4365 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4366 | FAIL() << "Did not receive Error 'Vtx Buffer Index 0 was bound, but no vtx buffers are attached to PSO.'"; |
| 4367 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4368 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 4369 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4370 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4371 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4372 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4373 | } |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4374 | #endif // DRAW_STATE_TESTS |
| 4375 | |
Tobin Ehlis | 57e6a61 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 4376 | #if THREADING_TESTS |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4377 | #if GTEST_IS_THREADSAFE |
| 4378 | struct thread_data_struct { |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4379 | VkCommandBuffer commandBuffer; |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4380 | VkEvent event; |
| 4381 | bool bailout; |
| 4382 | }; |
| 4383 | |
| 4384 | extern "C" void *AddToCommandBuffer(void *arg) |
| 4385 | { |
| 4386 | struct thread_data_struct *data = (struct thread_data_struct *) arg; |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4387 | |
| 4388 | for (int i = 0; i<10000; i++) { |
Chia-I Wu | cba6cea | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4389 | vkCmdSetEvent(data->commandBuffer, data->event, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4390 | if (data->bailout) { |
| 4391 | break; |
| 4392 | } |
| 4393 | } |
| 4394 | return NULL; |
| 4395 | } |
| 4396 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4397 | TEST_F(VkLayerTest, ThreadCommandBufferCollision) |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4398 | { |
Mike Stroyan | 7016f4f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 4399 | test_platform_thread thread; |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4400 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4401 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, "THREADING ERROR"); |
| 4402 | |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4403 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4404 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 4405 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4406 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4407 | // Calls AllocateCommandBuffers |
| 4408 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Mark Lobodzinski | a0f061c | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 4409 | |
| 4410 | // Avoid creating RenderPass |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4411 | commandBuffer.BeginCommandBuffer(); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4412 | |
| 4413 | VkEventCreateInfo event_info; |
| 4414 | VkEvent event; |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4415 | VkResult err; |
| 4416 | |
| 4417 | memset(&event_info, 0, sizeof(event_info)); |
| 4418 | event_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 4419 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4420 | err = vkCreateEvent(device(), &event_info, NULL, &event); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4421 | ASSERT_VK_SUCCESS(err); |
| 4422 | |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4423 | err = vkResetEvent(device(), event); |
| 4424 | ASSERT_VK_SUCCESS(err); |
| 4425 | |
| 4426 | struct thread_data_struct data; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4427 | data.commandBuffer = commandBuffer.GetBufferHandle(); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4428 | data.event = event; |
| 4429 | data.bailout = false; |
| 4430 | m_errorMonitor->SetBailout(&data.bailout); |
| 4431 | // Add many entries to command buffer from another thread. |
Mike Stroyan | 7016f4f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 4432 | test_platform_thread_create(&thread, AddToCommandBuffer, (void *)&data); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4433 | // Add many entries to command buffer from this thread at the same time. |
| 4434 | AddToCommandBuffer(&data); |
Mark Lobodzinski | a0f061c | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 4435 | |
Mike Stroyan | 7016f4f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 4436 | test_platform_thread_join(thread, NULL); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4437 | commandBuffer.EndCommandBuffer(); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4438 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4439 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4440 | FAIL() << "Did not receive Error 'THREADING ERROR' from using one VkCommandBufferObj in two threads"; |
| 4441 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4442 | } |
| 4443 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4444 | vkDestroyEvent(device(), event, NULL); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4445 | } |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4446 | #endif // GTEST_IS_THREADSAFE |
| 4447 | #endif // THREADING_TESTS |
| 4448 | |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4449 | #if SHADER_CHECKER_TESTS |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4450 | TEST_F(VkLayerTest, InvalidSPIRVCodeSize) |
| 4451 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4452 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4453 | "Shader is not SPIR-V"); |
| 4454 | |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4455 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4456 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4457 | |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4458 | VkShaderModule module; |
| 4459 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 4460 | struct icd_spv_header spv; |
| 4461 | |
| 4462 | spv.magic = ICD_SPV_MAGIC; |
| 4463 | spv.version = ICD_SPV_VERSION; |
| 4464 | spv.gen_magic = 0; |
| 4465 | |
| 4466 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 4467 | moduleCreateInfo.pNext = NULL; |
Chia-I Wu | 036b161 | 2015-10-26 19:22:06 +0800 | [diff] [blame] | 4468 | moduleCreateInfo.pCode = (const uint32_t *) &spv; |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4469 | moduleCreateInfo.codeSize = 4; |
| 4470 | moduleCreateInfo.flags = 0; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4471 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4472 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4473 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4474 | FAIL() << "Did not recieive Error 'Shader is not SPIR-V'"; |
| 4475 | m_errorMonitor->DumpFailureMsgs(); |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4476 | } |
| 4477 | } |
| 4478 | |
| 4479 | TEST_F(VkLayerTest, InvalidSPIRVMagic) |
| 4480 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4481 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4482 | "Shader is not SPIR-V"); |
| 4483 | |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4484 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4485 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4486 | |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4487 | VkShaderModule module; |
| 4488 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 4489 | struct icd_spv_header spv; |
| 4490 | |
| 4491 | spv.magic = ~ICD_SPV_MAGIC; |
| 4492 | spv.version = ICD_SPV_VERSION; |
| 4493 | spv.gen_magic = 0; |
| 4494 | |
| 4495 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 4496 | moduleCreateInfo.pNext = NULL; |
Chia-I Wu | 036b161 | 2015-10-26 19:22:06 +0800 | [diff] [blame] | 4497 | moduleCreateInfo.pCode = (const uint32_t *) &spv; |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4498 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 4499 | moduleCreateInfo.flags = 0; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4500 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4501 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4502 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4503 | FAIL() << "Did not recieive Error 'Shader is not SPIR-V'"; |
| 4504 | m_errorMonitor->DumpFailureMsgs(); |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4505 | } |
| 4506 | } |
| 4507 | |
| 4508 | TEST_F(VkLayerTest, InvalidSPIRVVersion) |
| 4509 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4510 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4511 | "Shader is not SPIR-V"); |
| 4512 | |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4513 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4514 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4515 | |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4516 | VkShaderModule module; |
| 4517 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 4518 | struct icd_spv_header spv; |
| 4519 | |
| 4520 | spv.magic = ICD_SPV_MAGIC; |
| 4521 | spv.version = ~ICD_SPV_VERSION; |
| 4522 | spv.gen_magic = 0; |
| 4523 | |
| 4524 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 4525 | moduleCreateInfo.pNext = NULL; |
| 4526 | |
Chia-I Wu | 036b161 | 2015-10-26 19:22:06 +0800 | [diff] [blame] | 4527 | moduleCreateInfo.pCode = (const uint32_t *) &spv; |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4528 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 4529 | moduleCreateInfo.flags = 0; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4530 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4531 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4532 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4533 | FAIL() << "Did not recieive Error 'Shader is not SPIR-V'"; |
| 4534 | m_errorMonitor->DumpFailureMsgs(); |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4535 | } |
| 4536 | } |
| 4537 | |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4538 | TEST_F(VkLayerTest, CreatePipelineVertexOutputNotConsumed) |
| 4539 | { |
Tony Barbour | 192f02b | 2015-11-06 14:21:31 -0700 | [diff] [blame] | 4540 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_PERF_WARN_BIT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4541 | "not consumed by fragment shader"); |
| 4542 | |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4543 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4544 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4545 | |
| 4546 | char const *vsSource = |
| 4547 | "#version 140\n" |
| 4548 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4549 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4550 | "\n" |
| 4551 | "layout(location=0) out float x;\n" |
| 4552 | "void main(){\n" |
| 4553 | " gl_Position = vec4(1);\n" |
| 4554 | " x = 0;\n" |
| 4555 | "}\n"; |
| 4556 | char const *fsSource = |
| 4557 | "#version 140\n" |
| 4558 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4559 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4560 | "\n" |
| 4561 | "layout(location=0) out vec4 color;\n" |
| 4562 | "void main(){\n" |
| 4563 | " color = vec4(1);\n" |
| 4564 | "}\n"; |
| 4565 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4566 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4567 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4568 | |
| 4569 | VkPipelineObj pipe(m_device); |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4570 | pipe.AddColorAttachment(); |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4571 | pipe.AddShader(&vs); |
| 4572 | pipe.AddShader(&fs); |
| 4573 | |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4574 | VkDescriptorSetObj descriptorSet(m_device); |
| 4575 | descriptorSet.AppendDummy(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4576 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4577 | |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4578 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4579 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4580 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4581 | FAIL() << "Did not receive Warning 'not consumed by fragment shader'"; |
| 4582 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4583 | } |
| 4584 | } |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4585 | |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4586 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvided) |
| 4587 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4588 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4589 | "not written by vertex shader"); |
| 4590 | |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4591 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4592 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4593 | |
| 4594 | char const *vsSource = |
| 4595 | "#version 140\n" |
| 4596 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4597 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4598 | "\n" |
| 4599 | "void main(){\n" |
| 4600 | " gl_Position = vec4(1);\n" |
| 4601 | "}\n"; |
| 4602 | char const *fsSource = |
| 4603 | "#version 140\n" |
| 4604 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4605 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4606 | "\n" |
| 4607 | "layout(location=0) in float x;\n" |
| 4608 | "layout(location=0) out vec4 color;\n" |
| 4609 | "void main(){\n" |
| 4610 | " color = vec4(x);\n" |
| 4611 | "}\n"; |
| 4612 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4613 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4614 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4615 | |
| 4616 | VkPipelineObj pipe(m_device); |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4617 | pipe.AddColorAttachment(); |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4618 | pipe.AddShader(&vs); |
| 4619 | pipe.AddShader(&fs); |
| 4620 | |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4621 | VkDescriptorSetObj descriptorSet(m_device); |
| 4622 | descriptorSet.AppendDummy(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4623 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4624 | |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4625 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4626 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4627 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4628 | FAIL() << "Did not receive Error 'not written by vertex shader'"; |
| 4629 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4630 | } |
| 4631 | } |
| 4632 | |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4633 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatch) |
| 4634 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4635 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4636 | "Type mismatch on location 0"); |
| 4637 | |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4638 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4639 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4640 | |
| 4641 | char const *vsSource = |
| 4642 | "#version 140\n" |
| 4643 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4644 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4645 | "\n" |
| 4646 | "layout(location=0) out int x;\n" |
| 4647 | "void main(){\n" |
| 4648 | " x = 0;\n" |
| 4649 | " gl_Position = vec4(1);\n" |
| 4650 | "}\n"; |
| 4651 | char const *fsSource = |
| 4652 | "#version 140\n" |
| 4653 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4654 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4655 | "\n" |
| 4656 | "layout(location=0) in float x;\n" /* VS writes int */ |
| 4657 | "layout(location=0) out vec4 color;\n" |
| 4658 | "void main(){\n" |
| 4659 | " color = vec4(x);\n" |
| 4660 | "}\n"; |
| 4661 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4662 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4663 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4664 | |
| 4665 | VkPipelineObj pipe(m_device); |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4666 | pipe.AddColorAttachment(); |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4667 | pipe.AddShader(&vs); |
| 4668 | pipe.AddShader(&fs); |
| 4669 | |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4670 | VkDescriptorSetObj descriptorSet(m_device); |
| 4671 | descriptorSet.AppendDummy(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4672 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4673 | |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4674 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4675 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4676 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4677 | FAIL() << "Did not receive Error 'Type mismatch on location 0'"; |
| 4678 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4679 | } |
| 4680 | } |
| 4681 | |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4682 | TEST_F(VkLayerTest, CreatePipelineAttribNotConsumed) |
| 4683 | { |
Tony Barbour | 192f02b | 2015-11-06 14:21:31 -0700 | [diff] [blame] | 4684 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_PERF_WARN_BIT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4685 | "location 0 not consumed by VS"); |
| 4686 | |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4687 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4688 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4689 | |
| 4690 | VkVertexInputBindingDescription input_binding; |
| 4691 | memset(&input_binding, 0, sizeof(input_binding)); |
| 4692 | |
| 4693 | VkVertexInputAttributeDescription input_attrib; |
| 4694 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 4695 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 4696 | |
| 4697 | char const *vsSource = |
| 4698 | "#version 140\n" |
| 4699 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4700 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4701 | "\n" |
| 4702 | "void main(){\n" |
| 4703 | " gl_Position = vec4(1);\n" |
| 4704 | "}\n"; |
| 4705 | char const *fsSource = |
| 4706 | "#version 140\n" |
| 4707 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4708 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4709 | "\n" |
| 4710 | "layout(location=0) out vec4 color;\n" |
| 4711 | "void main(){\n" |
| 4712 | " color = vec4(1);\n" |
| 4713 | "}\n"; |
| 4714 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4715 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4716 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4717 | |
| 4718 | VkPipelineObj pipe(m_device); |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4719 | pipe.AddColorAttachment(); |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4720 | pipe.AddShader(&vs); |
| 4721 | pipe.AddShader(&fs); |
| 4722 | |
| 4723 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 4724 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 4725 | |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4726 | VkDescriptorSetObj descriptorSet(m_device); |
| 4727 | descriptorSet.AppendDummy(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4728 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4729 | |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4730 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4731 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4732 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4733 | FAIL() << "Did not receive Warning 'location 0 not consumed by VS'"; |
| 4734 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4735 | } |
| 4736 | } |
| 4737 | |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4738 | TEST_F(VkLayerTest, CreatePipelineAttribNotProvided) |
| 4739 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4740 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4741 | "VS consumes input at location 0 but not provided"); |
| 4742 | |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4743 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4744 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4745 | |
| 4746 | char const *vsSource = |
| 4747 | "#version 140\n" |
| 4748 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4749 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4750 | "\n" |
| 4751 | "layout(location=0) in vec4 x;\n" /* not provided */ |
| 4752 | "void main(){\n" |
| 4753 | " gl_Position = x;\n" |
| 4754 | "}\n"; |
| 4755 | char const *fsSource = |
| 4756 | "#version 140\n" |
| 4757 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4758 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4759 | "\n" |
| 4760 | "layout(location=0) out vec4 color;\n" |
| 4761 | "void main(){\n" |
| 4762 | " color = vec4(1);\n" |
| 4763 | "}\n"; |
| 4764 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4765 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4766 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4767 | |
| 4768 | VkPipelineObj pipe(m_device); |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4769 | pipe.AddColorAttachment(); |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4770 | pipe.AddShader(&vs); |
| 4771 | pipe.AddShader(&fs); |
| 4772 | |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4773 | VkDescriptorSetObj descriptorSet(m_device); |
| 4774 | descriptorSet.AppendDummy(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4775 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4776 | |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4777 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4778 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4779 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4780 | FAIL() << "Did not receive Error 'VS consumes input at location 0 but not provided'"; |
| 4781 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4782 | } |
| 4783 | } |
| 4784 | |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4785 | TEST_F(VkLayerTest, CreatePipelineAttribTypeMismatch) |
| 4786 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4787 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4788 | "location 0 does not match VS input type"); |
| 4789 | |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4790 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4791 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4792 | |
| 4793 | VkVertexInputBindingDescription input_binding; |
| 4794 | memset(&input_binding, 0, sizeof(input_binding)); |
| 4795 | |
| 4796 | VkVertexInputAttributeDescription input_attrib; |
| 4797 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 4798 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 4799 | |
| 4800 | char const *vsSource = |
| 4801 | "#version 140\n" |
| 4802 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4803 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4804 | "\n" |
| 4805 | "layout(location=0) in int x;\n" /* attrib provided float */ |
| 4806 | "void main(){\n" |
| 4807 | " gl_Position = vec4(x);\n" |
| 4808 | "}\n"; |
| 4809 | char const *fsSource = |
| 4810 | "#version 140\n" |
| 4811 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4812 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4813 | "\n" |
| 4814 | "layout(location=0) out vec4 color;\n" |
| 4815 | "void main(){\n" |
| 4816 | " color = vec4(1);\n" |
| 4817 | "}\n"; |
| 4818 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4819 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4820 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4821 | |
| 4822 | VkPipelineObj pipe(m_device); |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4823 | pipe.AddColorAttachment(); |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4824 | pipe.AddShader(&vs); |
| 4825 | pipe.AddShader(&fs); |
| 4826 | |
| 4827 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 4828 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 4829 | |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4830 | VkDescriptorSetObj descriptorSet(m_device); |
| 4831 | descriptorSet.AppendDummy(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4832 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4833 | |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4834 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4835 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4836 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4837 | FAIL() << "Did not receive Error 'location 0 does not match VS input type'"; |
| 4838 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4839 | } |
| 4840 | } |
| 4841 | |
Chris Forbes | 03e6d76 | 2015-11-24 11:13:14 +1300 | [diff] [blame] | 4842 | TEST_F(VkLayerTest, CreatePipelineAttribMatrixType) |
| 4843 | { |
| 4844 | m_errorMonitor->SetDesiredFailureMsg(~0u, ""); |
| 4845 | |
| 4846 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4847 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4848 | |
| 4849 | VkVertexInputBindingDescription input_binding; |
| 4850 | memset(&input_binding, 0, sizeof(input_binding)); |
| 4851 | |
| 4852 | VkVertexInputAttributeDescription input_attribs[2]; |
| 4853 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 4854 | |
| 4855 | for (int i = 0; i < 2; i++) { |
| 4856 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 4857 | input_attribs[i].location = i; |
| 4858 | } |
| 4859 | |
| 4860 | char const *vsSource = |
| 4861 | "#version 140\n" |
| 4862 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4863 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4864 | "\n" |
| 4865 | "layout(location=0) in mat2x4 x;\n" |
| 4866 | "void main(){\n" |
| 4867 | " gl_Position = x[0] + x[1];\n" |
| 4868 | "}\n"; |
| 4869 | char const *fsSource = |
| 4870 | "#version 140\n" |
| 4871 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4872 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4873 | "\n" |
| 4874 | "layout(location=0) out vec4 color;\n" |
| 4875 | "void main(){\n" |
| 4876 | " color = vec4(1);\n" |
| 4877 | "}\n"; |
| 4878 | |
| 4879 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4880 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 4881 | |
| 4882 | VkPipelineObj pipe(m_device); |
| 4883 | pipe.AddColorAttachment(); |
| 4884 | pipe.AddShader(&vs); |
| 4885 | pipe.AddShader(&fs); |
| 4886 | |
| 4887 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 4888 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 4889 | |
| 4890 | VkDescriptorSetObj descriptorSet(m_device); |
| 4891 | descriptorSet.AppendDummy(); |
| 4892 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 4893 | |
| 4894 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 4895 | |
| 4896 | /* expect success */ |
| 4897 | if (m_errorMonitor->DesiredMsgFound()) { |
| 4898 | FAIL() << "Expected to succeed but: " << m_errorMonitor->GetFailureMsg(); |
| 4899 | m_errorMonitor->DumpFailureMsgs(); |
| 4900 | } |
| 4901 | } |
| 4902 | |
| 4903 | /* |
| 4904 | * Would work, but not supported by glslang! This is similar to the matrix case above. |
| 4905 | * |
| 4906 | TEST_F(VkLayerTest, CreatePipelineAttribArrayType) |
| 4907 | { |
| 4908 | m_errorMonitor->SetDesiredFailureMsg(~0u, ""); |
| 4909 | |
| 4910 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4911 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4912 | |
| 4913 | VkVertexInputBindingDescription input_binding; |
| 4914 | memset(&input_binding, 0, sizeof(input_binding)); |
| 4915 | |
| 4916 | VkVertexInputAttributeDescription input_attribs[2]; |
| 4917 | memset(input_attribs, 0, sizeof(input_attribs)); |
| 4918 | |
| 4919 | for (int i = 0; i < 2; i++) { |
| 4920 | input_attribs[i].format = VK_FORMAT_R32G32B32A32_SFLOAT; |
| 4921 | input_attribs[i].location = i; |
| 4922 | } |
| 4923 | |
| 4924 | char const *vsSource = |
| 4925 | "#version 140\n" |
| 4926 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4927 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4928 | "\n" |
| 4929 | "layout(location=0) in vec4 x[2];\n" |
| 4930 | "void main(){\n" |
| 4931 | " gl_Position = x[0] + x[1];\n" |
| 4932 | "}\n"; |
| 4933 | char const *fsSource = |
| 4934 | "#version 140\n" |
| 4935 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4936 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4937 | "\n" |
| 4938 | "layout(location=0) out vec4 color;\n" |
| 4939 | "void main(){\n" |
| 4940 | " color = vec4(1);\n" |
| 4941 | "}\n"; |
| 4942 | |
| 4943 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4944 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 4945 | |
| 4946 | VkPipelineObj pipe(m_device); |
| 4947 | pipe.AddColorAttachment(); |
| 4948 | pipe.AddShader(&vs); |
| 4949 | pipe.AddShader(&fs); |
| 4950 | |
| 4951 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 4952 | pipe.AddVertexInputAttribs(input_attribs, 2); |
| 4953 | |
| 4954 | VkDescriptorSetObj descriptorSet(m_device); |
| 4955 | descriptorSet.AppendDummy(); |
| 4956 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
| 4957 | |
| 4958 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 4959 | |
| 4960 | if (m_errorMonitor->DesiredMsgFound()) { |
| 4961 | FAIL() << "Expected to succeed but: " << m_errorMonitor->GetFailureMsg(); |
| 4962 | m_errorMonitor->DumpFailureMsgs(); |
| 4963 | } |
| 4964 | } |
| 4965 | */ |
| 4966 | |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4967 | TEST_F(VkLayerTest, CreatePipelineAttribBindingConflict) |
| 4968 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4969 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4970 | "Duplicate vertex input binding descriptions for binding 0"); |
| 4971 | |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4972 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4973 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4974 | |
| 4975 | /* Two binding descriptions for binding 0 */ |
| 4976 | VkVertexInputBindingDescription input_bindings[2]; |
| 4977 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 4978 | |
| 4979 | VkVertexInputAttributeDescription input_attrib; |
| 4980 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 4981 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 4982 | |
| 4983 | char const *vsSource = |
| 4984 | "#version 140\n" |
| 4985 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4986 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4987 | "\n" |
| 4988 | "layout(location=0) in float x;\n" /* attrib provided float */ |
| 4989 | "void main(){\n" |
| 4990 | " gl_Position = vec4(x);\n" |
| 4991 | "}\n"; |
| 4992 | char const *fsSource = |
| 4993 | "#version 140\n" |
| 4994 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4995 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4996 | "\n" |
| 4997 | "layout(location=0) out vec4 color;\n" |
| 4998 | "void main(){\n" |
| 4999 | " color = vec4(1);\n" |
| 5000 | "}\n"; |
| 5001 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5002 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5003 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5004 | |
| 5005 | VkPipelineObj pipe(m_device); |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 5006 | pipe.AddColorAttachment(); |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5007 | pipe.AddShader(&vs); |
| 5008 | pipe.AddShader(&fs); |
| 5009 | |
| 5010 | pipe.AddVertexInputBindings(input_bindings, 2); |
| 5011 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 5012 | |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5013 | VkDescriptorSetObj descriptorSet(m_device); |
| 5014 | descriptorSet.AppendDummy(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5015 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5016 | |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 5017 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5018 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5019 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5020 | FAIL() << "Did not receive Error 'Duplicate vertex input binding descriptions for binding 0'"; |
| 5021 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 5022 | } |
| 5023 | } |
Chris Forbes | 4c94870 | 2015-05-25 11:13:32 +1200 | [diff] [blame] | 5024 | |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5025 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotWritten) |
| 5026 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5027 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 5028 | "Attachment 0 not written by FS"); |
| 5029 | |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5030 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5031 | |
| 5032 | char const *vsSource = |
| 5033 | "#version 140\n" |
| 5034 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5035 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5036 | "\n" |
| 5037 | "void main(){\n" |
| 5038 | " gl_Position = vec4(1);\n" |
| 5039 | "}\n"; |
| 5040 | char const *fsSource = |
| 5041 | "#version 140\n" |
| 5042 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5043 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5044 | "\n" |
| 5045 | "void main(){\n" |
| 5046 | "}\n"; |
| 5047 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5048 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5049 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5050 | |
| 5051 | VkPipelineObj pipe(m_device); |
| 5052 | pipe.AddShader(&vs); |
| 5053 | pipe.AddShader(&fs); |
| 5054 | |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 5055 | /* set up CB 0, not written */ |
| 5056 | pipe.AddColorAttachment(); |
| 5057 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5058 | |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5059 | VkDescriptorSetObj descriptorSet(m_device); |
| 5060 | descriptorSet.AppendDummy(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5061 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5062 | |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 5063 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5064 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5065 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5066 | FAIL() << "Did not receive Error 'Attachment 0 not written by FS'"; |
| 5067 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 5068 | } |
| 5069 | } |
| 5070 | |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5071 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotConsumed) |
| 5072 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5073 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_WARN_BIT, |
| 5074 | "FS writes to output location 1 with no matching attachment"); |
| 5075 | |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5076 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5077 | |
| 5078 | char const *vsSource = |
| 5079 | "#version 140\n" |
| 5080 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5081 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5082 | "\n" |
| 5083 | "void main(){\n" |
| 5084 | " gl_Position = vec4(1);\n" |
| 5085 | "}\n"; |
| 5086 | char const *fsSource = |
| 5087 | "#version 140\n" |
| 5088 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5089 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5090 | "\n" |
| 5091 | "layout(location=0) out vec4 x;\n" |
| 5092 | "layout(location=1) out vec4 y;\n" /* no matching attachment for this */ |
| 5093 | "void main(){\n" |
| 5094 | " x = vec4(1);\n" |
| 5095 | " y = vec4(1);\n" |
| 5096 | "}\n"; |
| 5097 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5098 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5099 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5100 | |
| 5101 | VkPipelineObj pipe(m_device); |
| 5102 | pipe.AddShader(&vs); |
| 5103 | pipe.AddShader(&fs); |
| 5104 | |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 5105 | /* set up CB 0, not written */ |
| 5106 | pipe.AddColorAttachment(); |
| 5107 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5108 | /* FS writes CB 1, but we don't configure it */ |
| 5109 | |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5110 | VkDescriptorSetObj descriptorSet(m_device); |
| 5111 | descriptorSet.AppendDummy(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5112 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5113 | |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 5114 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5115 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5116 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5117 | FAIL() << "Did not receive Error 'FS writes to output location 1 with no matching attachment'"; |
| 5118 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 5119 | } |
| 5120 | } |
| 5121 | |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5122 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputTypeMismatch) |
| 5123 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5124 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 5125 | "does not match FS output type"); |
| 5126 | |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5127 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5128 | |
| 5129 | char const *vsSource = |
| 5130 | "#version 140\n" |
| 5131 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5132 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5133 | "\n" |
| 5134 | "void main(){\n" |
| 5135 | " gl_Position = vec4(1);\n" |
| 5136 | "}\n"; |
| 5137 | char const *fsSource = |
| 5138 | "#version 140\n" |
| 5139 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5140 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5141 | "\n" |
| 5142 | "layout(location=0) out ivec4 x;\n" /* not UNORM */ |
| 5143 | "void main(){\n" |
| 5144 | " x = ivec4(1);\n" |
| 5145 | "}\n"; |
| 5146 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5147 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5148 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5149 | |
| 5150 | VkPipelineObj pipe(m_device); |
| 5151 | pipe.AddShader(&vs); |
| 5152 | pipe.AddShader(&fs); |
| 5153 | |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 5154 | /* set up CB 0; type is UNORM by default */ |
| 5155 | pipe.AddColorAttachment(); |
| 5156 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5157 | |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5158 | VkDescriptorSetObj descriptorSet(m_device); |
| 5159 | descriptorSet.AppendDummy(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5160 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5161 | |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 5162 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5163 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5164 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5165 | FAIL() << "Did not receive Error 'does not match FS output type'"; |
| 5166 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5167 | } |
| 5168 | } |
Chris Forbes | c205073 | 2015-06-05 14:43:36 +1200 | [diff] [blame] | 5169 | |
Chris Forbes | 76ce788 | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 5170 | TEST_F(VkLayerTest, CreatePipelineUniformBlockNotProvided) |
| 5171 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5172 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 5173 | "not declared in pipeline layout"); |
| 5174 | |
Chris Forbes | 76ce788 | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 5175 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 76ce788 | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 5176 | |
| 5177 | char const *vsSource = |
| 5178 | "#version 140\n" |
| 5179 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5180 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5181 | "\n" |
| 5182 | "void main(){\n" |
| 5183 | " gl_Position = vec4(1);\n" |
| 5184 | "}\n"; |
| 5185 | char const *fsSource = |
| 5186 | "#version 140\n" |
| 5187 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 5188 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 5189 | "\n" |
| 5190 | "layout(location=0) out vec4 x;\n" |
| 5191 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 5192 | "void main(){\n" |
| 5193 | " x = vec4(bar.y);\n" |
| 5194 | "}\n"; |
| 5195 | |
Chris Forbes | 76ce788 | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 5196 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 5197 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 5198 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 76ce788 | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 5199 | |
Chris Forbes | 76ce788 | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 5200 | VkPipelineObj pipe(m_device); |
| 5201 | pipe.AddShader(&vs); |
| 5202 | pipe.AddShader(&fs); |
| 5203 | |
| 5204 | /* set up CB 0; type is UNORM by default */ |
| 5205 | pipe.AddColorAttachment(); |
| 5206 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 5207 | |
| 5208 | VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5209 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 76ce788 | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 5210 | |
| 5211 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 5212 | |
| 5213 | /* should have generated an error -- pipeline layout does not |
| 5214 | * provide a uniform buffer in 0.0 |
| 5215 | */ |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5216 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5217 | FAIL() << "Did not receive Error 'not declared in pipeline layout'"; |
| 5218 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 76ce788 | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 5219 | } |
| 5220 | } |
| 5221 | |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 5222 | #endif // SHADER_CHECKER_TESTS |
| 5223 | |
| 5224 | #if DEVICE_LIMITS_TESTS |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 5225 | TEST_F(VkLayerTest, CreateImageLimitsViolationWidth) |
| 5226 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5227 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 5228 | "CreateImage extents exceed allowable limits for format"); |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 5229 | |
| 5230 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 5231 | |
| 5232 | // Create an image |
| 5233 | VkImage image; |
| 5234 | |
| 5235 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5236 | const int32_t tex_width = 32; |
| 5237 | const int32_t tex_height = 32; |
| 5238 | |
| 5239 | VkImageCreateInfo image_create_info = {}; |
| 5240 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5241 | image_create_info.pNext = NULL; |
| 5242 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5243 | image_create_info.format = tex_format; |
| 5244 | image_create_info.extent.width = tex_width; |
| 5245 | image_create_info.extent.height = tex_height; |
| 5246 | image_create_info.extent.depth = 1; |
| 5247 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 5248 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5249 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 5250 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 5251 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 5252 | image_create_info.flags = 0; |
| 5253 | |
| 5254 | // Introduce error by sending down a bogus width extent |
| 5255 | image_create_info.extent.width = 65536; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5256 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 5257 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5258 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5259 | FAIL() << "Did not receive Error 'CreateImage extents exceed allowable limits for format'"; |
| 5260 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 5261 | } |
| 5262 | } |
| 5263 | |
| 5264 | TEST_F(VkLayerTest, CreateImageResourceSizeViolation) |
| 5265 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5266 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 5267 | "CreateImage resource size exceeds allowable maximum"); |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 5268 | |
| 5269 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 5270 | |
| 5271 | // Create an image |
| 5272 | VkImage image; |
| 5273 | |
| 5274 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5275 | const int32_t tex_width = 32; |
| 5276 | const int32_t tex_height = 32; |
| 5277 | |
| 5278 | VkImageCreateInfo image_create_info = {}; |
| 5279 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5280 | image_create_info.pNext = NULL; |
| 5281 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5282 | image_create_info.format = tex_format; |
| 5283 | image_create_info.extent.width = tex_width; |
| 5284 | image_create_info.extent.height = tex_height; |
| 5285 | image_create_info.extent.depth = 1; |
| 5286 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 5287 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5288 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 5289 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 5290 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 5291 | image_create_info.flags = 0; |
| 5292 | |
| 5293 | // Introduce error by sending down individually allowable values that result in a surface size |
| 5294 | // exceeding the device maximum |
| 5295 | image_create_info.extent.width = 8192; |
| 5296 | image_create_info.extent.height = 8192; |
| 5297 | image_create_info.extent.depth = 16; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 5298 | image_create_info.arrayLayers = 4; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5299 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 5300 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5301 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 5302 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5303 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5304 | FAIL() << "Did not receive Error 'CreateImage resource size exceeds allowable maximum'"; |
| 5305 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 5306 | } |
| 5307 | } |
| 5308 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5309 | TEST_F(VkLayerTest, UpdateBufferAlignment) |
| 5310 | { |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5311 | uint32_t updateData[] = { 1, 2, 3, 4, 5, 6, 7, 8 }; |
| 5312 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5313 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 5314 | "dstOffset, is not a multiple of 4"); |
| 5315 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5316 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5317 | |
| 5318 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 5319 | vk_testing::Buffer buffer; |
| 5320 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 5321 | |
| 5322 | BeginCommandBuffer(); |
| 5323 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5324 | m_commandBuffer->UpdateBuffer(buffer.handle(), 1, 4, updateData); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5325 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5326 | FAIL() << "Did not receive Error 'vkCommandUpdateBuffer parameter, VkDeviceSize dstOffset, is not a multiple of 4'"; |
| 5327 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5328 | } |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5329 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5330 | // Introduce failure by using size that is not multiple of 4 |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5331 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 5332 | "dataSize, is not a multiple of 4"); |
| 5333 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5334 | m_commandBuffer->UpdateBuffer(buffer.handle(), 0, 6, updateData); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5335 | |
| 5336 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5337 | FAIL() << "Did not receive Error 'vkCommandUpdateBuffer parameter, VkDeviceSize dataSize, is not a multiple of 4'"; |
| 5338 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5339 | } |
| 5340 | EndCommandBuffer(); |
| 5341 | } |
| 5342 | |
| 5343 | TEST_F(VkLayerTest, FillBufferAlignment) |
| 5344 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5345 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 5346 | "dstOffset, is not a multiple of 4"); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5347 | |
| 5348 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 5349 | |
| 5350 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 5351 | vk_testing::Buffer buffer; |
| 5352 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 5353 | |
| 5354 | BeginCommandBuffer(); |
| 5355 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5356 | m_commandBuffer->FillBuffer(buffer.handle(), 1, 4, 0x11111111); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5357 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5358 | FAIL() << "Did not receive Error 'vkCommandFillBuffer parameter, VkDeviceSize dstOffset, is not a multiple of 4'"; |
| 5359 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5360 | } |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5361 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5362 | // Introduce failure by using size that is not multiple of 4 |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5363 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 5364 | "size, is not a multiple of 4"); |
| 5365 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5366 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 6, 0x11111111); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5367 | |
| 5368 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5369 | FAIL() << "Did not receive Error 'vkCommandFillBuffer parameter, VkDeviceSize size, is not a multiple of 4'"; |
| 5370 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5371 | } |
| 5372 | EndCommandBuffer(); |
| 5373 | } |
| 5374 | |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 5375 | #endif // DEVICE_LIMITS_TESTS |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5376 | |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 5377 | #if IMAGE_TESTS |
| 5378 | TEST_F(VkLayerTest, InvalidImageView) |
| 5379 | { |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 5380 | VkResult err; |
| 5381 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5382 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 5383 | "vkCreateImageView called with baseMipLevel 10 "); |
| 5384 | |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 5385 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 5386 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5387 | // Create an image and try to create a view with bad baseMipLevel |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 5388 | VkImage image; |
| 5389 | |
| 5390 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5391 | const int32_t tex_width = 32; |
| 5392 | const int32_t tex_height = 32; |
| 5393 | |
| 5394 | VkImageCreateInfo image_create_info = {}; |
| 5395 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5396 | image_create_info.pNext = NULL; |
| 5397 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5398 | image_create_info.format = tex_format; |
| 5399 | image_create_info.extent.width = tex_width; |
| 5400 | image_create_info.extent.height = tex_height; |
| 5401 | image_create_info.extent.depth = 1; |
| 5402 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 5403 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5404 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 5405 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 5406 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 5407 | image_create_info.flags = 0; |
| 5408 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5409 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 5410 | ASSERT_VK_SUCCESS(err); |
| 5411 | |
| 5412 | VkImageViewCreateInfo image_view_create_info = {}; |
| 5413 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5414 | image_view_create_info.image = image; |
| 5415 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 5416 | image_view_create_info.format = tex_format; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5417 | image_view_create_info.subresourceRange.layerCount = 1; |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 5418 | image_view_create_info.subresourceRange.baseMipLevel = 10; // cause an error |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5419 | image_view_create_info.subresourceRange.levelCount = 1; |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 5420 | image_view_create_info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 5421 | |
| 5422 | VkImageView view; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5423 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, &view); |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 5424 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5425 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5426 | FAIL() << "Did not receive Error 'vkCreateImageView called with baseMipLevel 10...'"; |
| 5427 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 5428 | } |
| 5429 | } |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5430 | |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 5431 | TEST_F(VkLayerTest, InvalidImageViewAspect) |
| 5432 | { |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 5433 | VkResult err; |
| 5434 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5435 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 5436 | "vkCreateImageView: Color image formats must have ONLY the VK_IMAGE_ASPECT_COLOR_BIT set"); |
| 5437 | |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 5438 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 5439 | |
| 5440 | // Create an image and try to create a view with an invalid aspectMask |
| 5441 | VkImage image; |
| 5442 | |
| 5443 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5444 | const int32_t tex_width = 32; |
| 5445 | const int32_t tex_height = 32; |
| 5446 | |
| 5447 | VkImageCreateInfo image_create_info = {}; |
| 5448 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5449 | image_create_info.pNext = NULL; |
| 5450 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5451 | image_create_info.format = tex_format; |
| 5452 | image_create_info.extent.width = tex_width; |
| 5453 | image_create_info.extent.height = tex_height; |
| 5454 | image_create_info.extent.depth = 1; |
| 5455 | image_create_info.mipLevels = 1; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5456 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 5457 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 5458 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 5459 | image_create_info.flags = 0; |
| 5460 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5461 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 5462 | ASSERT_VK_SUCCESS(err); |
| 5463 | |
| 5464 | VkImageViewCreateInfo image_view_create_info = {}; |
| 5465 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5466 | image_view_create_info.image = image; |
| 5467 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 5468 | image_view_create_info.format = tex_format; |
| 5469 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5470 | image_view_create_info.subresourceRange.levelCount = 1; |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 5471 | // Cause an error by setting an invalid image aspect |
| 5472 | image_view_create_info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_METADATA_BIT; |
| 5473 | |
| 5474 | VkImageView view; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5475 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, &view); |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 5476 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5477 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5478 | FAIL() << "Did not receive Error 'VkCreateImageView: Color image formats must have ...'"; |
| 5479 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 5480 | } |
| 5481 | } |
| 5482 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5483 | TEST_F(VkLayerTest, CopyImageTypeMismatch) |
| 5484 | { |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5485 | VkResult err; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5486 | bool pass; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5487 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5488 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 5489 | "vkCmdCopyImage called with unmatched source and dest image types"); |
| 5490 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5491 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5492 | |
| 5493 | // Create two images of different types and try to copy between them |
| 5494 | VkImage srcImage; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5495 | VkImage dstImage; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5496 | VkDeviceMemory srcMem; |
| 5497 | VkDeviceMemory destMem; |
| 5498 | VkMemoryRequirements memReqs; |
| 5499 | |
| 5500 | VkImageCreateInfo image_create_info = {}; |
| 5501 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5502 | image_create_info.pNext = NULL; |
| 5503 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5504 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5505 | image_create_info.extent.width = 32; |
| 5506 | image_create_info.extent.height = 32; |
| 5507 | image_create_info.extent.depth = 1; |
| 5508 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 5509 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5510 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5511 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5512 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5513 | image_create_info.flags = 0; |
| 5514 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5515 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5516 | ASSERT_VK_SUCCESS(err); |
| 5517 | |
| 5518 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5519 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5520 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5521 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5522 | ASSERT_VK_SUCCESS(err); |
| 5523 | |
| 5524 | // Allocate memory |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5525 | VkMemoryAllocateInfo memAlloc = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5526 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5527 | memAlloc.pNext = NULL; |
| 5528 | memAlloc.allocationSize = 0; |
| 5529 | memAlloc.memoryTypeIndex = 0; |
| 5530 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 5531 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5532 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5533 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5534 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5535 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5536 | ASSERT_VK_SUCCESS(err); |
| 5537 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5538 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5539 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5540 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5541 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5542 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5543 | ASSERT_VK_SUCCESS(err); |
| 5544 | |
| 5545 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 5546 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5547 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5548 | ASSERT_VK_SUCCESS(err); |
| 5549 | |
| 5550 | BeginCommandBuffer(); |
| 5551 | VkImageCopy copyRegion; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5552 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5553 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 63f0ead | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5554 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5555 | copyRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5556 | copyRegion.srcOffset.x = 0; |
| 5557 | copyRegion.srcOffset.y = 0; |
| 5558 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5559 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5560 | copyRegion.dstSubresource.mipLevel = 0; |
| 5561 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 5562 | copyRegion.dstSubresource.layerCount = 0; |
| 5563 | copyRegion.dstOffset.x = 0; |
| 5564 | copyRegion.dstOffset.y = 0; |
| 5565 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5566 | copyRegion.extent.width = 1; |
| 5567 | copyRegion.extent.height = 1; |
| 5568 | copyRegion.extent.depth = 1; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5569 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5570 | EndCommandBuffer(); |
| 5571 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5572 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5573 | FAIL() << "Did not receive Error 'vkCmdCopyImage called with unmatched source and dest image types'"; |
| 5574 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5575 | } |
| 5576 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5577 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5578 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5579 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 5580 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5581 | } |
| 5582 | |
| 5583 | TEST_F(VkLayerTest, CopyImageFormatSizeMismatch) |
| 5584 | { |
| 5585 | // TODO : Create two images with different format sizes and vkCmdCopyImage between them |
| 5586 | } |
| 5587 | |
| 5588 | TEST_F(VkLayerTest, CopyImageDepthStencilFormatMismatch) |
| 5589 | { |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5590 | VkResult err; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5591 | bool pass; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5592 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5593 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 5594 | "vkCmdCopyImage called with unmatched source and dest image types"); |
| 5595 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5596 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5597 | |
| 5598 | // Create two images of different types and try to copy between them |
| 5599 | VkImage srcImage; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5600 | VkImage dstImage; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5601 | VkDeviceMemory srcMem; |
| 5602 | VkDeviceMemory destMem; |
| 5603 | VkMemoryRequirements memReqs; |
| 5604 | |
| 5605 | VkImageCreateInfo image_create_info = {}; |
| 5606 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5607 | image_create_info.pNext = NULL; |
| 5608 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5609 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5610 | image_create_info.extent.width = 32; |
| 5611 | image_create_info.extent.height = 32; |
| 5612 | image_create_info.extent.depth = 1; |
| 5613 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 5614 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5615 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5616 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5617 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5618 | image_create_info.flags = 0; |
| 5619 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5620 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5621 | ASSERT_VK_SUCCESS(err); |
| 5622 | |
| 5623 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5624 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5625 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5626 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5627 | ASSERT_VK_SUCCESS(err); |
| 5628 | |
| 5629 | // Allocate memory |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5630 | VkMemoryAllocateInfo memAlloc = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5631 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5632 | memAlloc.pNext = NULL; |
| 5633 | memAlloc.allocationSize = 0; |
| 5634 | memAlloc.memoryTypeIndex = 0; |
| 5635 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 5636 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5637 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5638 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5639 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5640 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5641 | ASSERT_VK_SUCCESS(err); |
| 5642 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5643 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5644 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5645 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5646 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5647 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5648 | ASSERT_VK_SUCCESS(err); |
| 5649 | |
| 5650 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 5651 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5652 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5653 | ASSERT_VK_SUCCESS(err); |
| 5654 | |
| 5655 | BeginCommandBuffer(); |
| 5656 | VkImageCopy copyRegion; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5657 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5658 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 63f0ead | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5659 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5660 | copyRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5661 | copyRegion.srcOffset.x = 0; |
| 5662 | copyRegion.srcOffset.y = 0; |
| 5663 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5664 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5665 | copyRegion.dstSubresource.mipLevel = 0; |
| 5666 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 5667 | copyRegion.dstSubresource.layerCount = 0; |
| 5668 | copyRegion.dstOffset.x = 0; |
| 5669 | copyRegion.dstOffset.y = 0; |
| 5670 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5671 | copyRegion.extent.width = 1; |
| 5672 | copyRegion.extent.height = 1; |
| 5673 | copyRegion.extent.depth = 1; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5674 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5675 | EndCommandBuffer(); |
| 5676 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5677 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5678 | FAIL() << "Did not receive Error 'vkCmdCopyImage called with unmatched source and dest image types'"; |
| 5679 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5680 | } |
| 5681 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5682 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5683 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5684 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 5685 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5686 | } |
| 5687 | |
| 5688 | TEST_F(VkLayerTest, ResolveImageLowSampleCount) |
| 5689 | { |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5690 | VkResult err; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5691 | bool pass; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5692 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5693 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 5694 | "vkCmdResolveImage called with source sample count less than 2."); |
| 5695 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5696 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5697 | |
| 5698 | // Create two images of sample count 1 and try to Resolve between them |
| 5699 | VkImage srcImage; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5700 | VkImage dstImage; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5701 | VkDeviceMemory srcMem; |
| 5702 | VkDeviceMemory destMem; |
| 5703 | VkMemoryRequirements memReqs; |
| 5704 | |
| 5705 | VkImageCreateInfo image_create_info = {}; |
| 5706 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5707 | image_create_info.pNext = NULL; |
| 5708 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5709 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5710 | image_create_info.extent.width = 32; |
| 5711 | image_create_info.extent.height = 1; |
| 5712 | image_create_info.extent.depth = 1; |
| 5713 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 5714 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5715 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5716 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5717 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5718 | image_create_info.flags = 0; |
| 5719 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5720 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5721 | ASSERT_VK_SUCCESS(err); |
| 5722 | |
| 5723 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5724 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5725 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5726 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5727 | ASSERT_VK_SUCCESS(err); |
| 5728 | |
| 5729 | // Allocate memory |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5730 | VkMemoryAllocateInfo memAlloc = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5731 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5732 | memAlloc.pNext = NULL; |
| 5733 | memAlloc.allocationSize = 0; |
| 5734 | memAlloc.memoryTypeIndex = 0; |
| 5735 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 5736 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5737 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5738 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5739 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5740 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5741 | ASSERT_VK_SUCCESS(err); |
| 5742 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5743 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5744 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5745 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5746 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5747 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5748 | ASSERT_VK_SUCCESS(err); |
| 5749 | |
| 5750 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 5751 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5752 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5753 | ASSERT_VK_SUCCESS(err); |
| 5754 | |
| 5755 | BeginCommandBuffer(); |
| 5756 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
| 5757 | //VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 5758 | //VK_IMAGE_LAYOUT_GENERAL = 1, |
| 5759 | VkImageResolve resolveRegion; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5760 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5761 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 63f0ead | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5762 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5763 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5764 | resolveRegion.srcOffset.x = 0; |
| 5765 | resolveRegion.srcOffset.y = 0; |
| 5766 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5767 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5768 | resolveRegion.dstSubresource.mipLevel = 0; |
| 5769 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 5770 | resolveRegion.dstSubresource.layerCount = 0; |
| 5771 | resolveRegion.dstOffset.x = 0; |
| 5772 | resolveRegion.dstOffset.y = 0; |
| 5773 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5774 | resolveRegion.extent.width = 1; |
| 5775 | resolveRegion.extent.height = 1; |
| 5776 | resolveRegion.extent.depth = 1; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5777 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5778 | EndCommandBuffer(); |
| 5779 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5780 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5781 | FAIL() << "Did not receive Error 'vkCmdResolveImage called with source sample count less than 2.'"; |
| 5782 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5783 | } |
| 5784 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5785 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5786 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5787 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 5788 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5789 | } |
| 5790 | |
| 5791 | TEST_F(VkLayerTest, ResolveImageHighSampleCount) |
| 5792 | { |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5793 | VkResult err; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5794 | bool pass; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5795 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5796 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 5797 | "vkCmdResolveImage called with dest sample count greater than 1."); |
| 5798 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5799 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5800 | |
| 5801 | // Create two images of sample count 2 and try to Resolve between them |
| 5802 | VkImage srcImage; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5803 | VkImage dstImage; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5804 | VkDeviceMemory srcMem; |
| 5805 | VkDeviceMemory destMem; |
| 5806 | VkMemoryRequirements memReqs; |
| 5807 | |
| 5808 | VkImageCreateInfo image_create_info = {}; |
| 5809 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5810 | image_create_info.pNext = NULL; |
| 5811 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5812 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5813 | image_create_info.extent.width = 32; |
| 5814 | image_create_info.extent.height = 1; |
| 5815 | image_create_info.extent.depth = 1; |
| 5816 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 5817 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5818 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5819 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
Cody Northrop | b3bf94f | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 5820 | // Note: Some implementations expect color attachment usage for any multisample surface |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5821 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5822 | image_create_info.flags = 0; |
| 5823 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5824 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5825 | ASSERT_VK_SUCCESS(err); |
| 5826 | |
| 5827 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
Cody Northrop | b3bf94f | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 5828 | // Note: Some implementations expect color attachment usage for any multisample surface |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5829 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5830 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5831 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5832 | ASSERT_VK_SUCCESS(err); |
| 5833 | |
| 5834 | // Allocate memory |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5835 | VkMemoryAllocateInfo memAlloc = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5836 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5837 | memAlloc.pNext = NULL; |
| 5838 | memAlloc.allocationSize = 0; |
| 5839 | memAlloc.memoryTypeIndex = 0; |
| 5840 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 5841 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5842 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5843 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5844 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5845 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5846 | ASSERT_VK_SUCCESS(err); |
| 5847 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5848 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5849 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5850 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5851 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5852 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5853 | ASSERT_VK_SUCCESS(err); |
| 5854 | |
| 5855 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 5856 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5857 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5858 | ASSERT_VK_SUCCESS(err); |
| 5859 | |
| 5860 | BeginCommandBuffer(); |
| 5861 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
| 5862 | //VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 5863 | //VK_IMAGE_LAYOUT_GENERAL = 1, |
| 5864 | VkImageResolve resolveRegion; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5865 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5866 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 63f0ead | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5867 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5868 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5869 | resolveRegion.srcOffset.x = 0; |
| 5870 | resolveRegion.srcOffset.y = 0; |
| 5871 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5872 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5873 | resolveRegion.dstSubresource.mipLevel = 0; |
| 5874 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 5875 | resolveRegion.dstSubresource.layerCount = 0; |
| 5876 | resolveRegion.dstOffset.x = 0; |
| 5877 | resolveRegion.dstOffset.y = 0; |
| 5878 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5879 | resolveRegion.extent.width = 1; |
| 5880 | resolveRegion.extent.height = 1; |
| 5881 | resolveRegion.extent.depth = 1; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5882 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5883 | EndCommandBuffer(); |
| 5884 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5885 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5886 | FAIL() << "Did not receive Error 'vkCmdResolveImage called with dest sample count greater than 1.'"; |
| 5887 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5888 | } |
| 5889 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5890 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5891 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5892 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 5893 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5894 | } |
| 5895 | |
| 5896 | TEST_F(VkLayerTest, ResolveImageFormatMismatch) |
| 5897 | { |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5898 | VkResult err; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5899 | bool pass; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5900 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5901 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 5902 | "vkCmdResolveImage called with unmatched source and dest formats."); |
| 5903 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5904 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5905 | |
| 5906 | // Create two images of different types and try to copy between them |
| 5907 | VkImage srcImage; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5908 | VkImage dstImage; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5909 | VkDeviceMemory srcMem; |
| 5910 | VkDeviceMemory destMem; |
| 5911 | VkMemoryRequirements memReqs; |
| 5912 | |
| 5913 | VkImageCreateInfo image_create_info = {}; |
| 5914 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5915 | image_create_info.pNext = NULL; |
| 5916 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5917 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5918 | image_create_info.extent.width = 32; |
| 5919 | image_create_info.extent.height = 1; |
| 5920 | image_create_info.extent.depth = 1; |
| 5921 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 5922 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5923 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5924 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
Cody Northrop | b3bf94f | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 5925 | // Note: Some implementations expect color attachment usage for any multisample surface |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5926 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5927 | image_create_info.flags = 0; |
| 5928 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5929 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5930 | ASSERT_VK_SUCCESS(err); |
| 5931 | |
Cody Northrop | b3bf94f | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 5932 | // Set format to something other than source image |
| 5933 | image_create_info.format = VK_FORMAT_R32_SFLOAT; |
| 5934 | // Note: Some implementations expect color attachment usage for any multisample surface |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5935 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5936 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5937 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5938 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5939 | ASSERT_VK_SUCCESS(err); |
| 5940 | |
| 5941 | // Allocate memory |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5942 | VkMemoryAllocateInfo memAlloc = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5943 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5944 | memAlloc.pNext = NULL; |
| 5945 | memAlloc.allocationSize = 0; |
| 5946 | memAlloc.memoryTypeIndex = 0; |
| 5947 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 5948 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5949 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5950 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5951 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5952 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5953 | ASSERT_VK_SUCCESS(err); |
| 5954 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5955 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5956 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5957 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5958 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5959 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5960 | ASSERT_VK_SUCCESS(err); |
| 5961 | |
| 5962 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 5963 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5964 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5965 | ASSERT_VK_SUCCESS(err); |
| 5966 | |
| 5967 | BeginCommandBuffer(); |
| 5968 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
| 5969 | //VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 5970 | //VK_IMAGE_LAYOUT_GENERAL = 1, |
| 5971 | VkImageResolve resolveRegion; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5972 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5973 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 63f0ead | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5974 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5975 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5976 | resolveRegion.srcOffset.x = 0; |
| 5977 | resolveRegion.srcOffset.y = 0; |
| 5978 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5979 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5980 | resolveRegion.dstSubresource.mipLevel = 0; |
| 5981 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 5982 | resolveRegion.dstSubresource.layerCount = 0; |
| 5983 | resolveRegion.dstOffset.x = 0; |
| 5984 | resolveRegion.dstOffset.y = 0; |
| 5985 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5986 | resolveRegion.extent.width = 1; |
| 5987 | resolveRegion.extent.height = 1; |
| 5988 | resolveRegion.extent.depth = 1; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5989 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5990 | EndCommandBuffer(); |
| 5991 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5992 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5993 | FAIL() << "Did not receive Error 'vkCmdResolveImage called with unmatched source and dest formats.'"; |
| 5994 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5995 | } |
| 5996 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5997 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5998 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5999 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 6000 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6001 | } |
| 6002 | |
| 6003 | TEST_F(VkLayerTest, ResolveImageTypeMismatch) |
| 6004 | { |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6005 | VkResult err; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6006 | bool pass; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6007 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6008 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 6009 | "vkCmdResolveImage called with unmatched source and dest image types."); |
| 6010 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6011 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6012 | |
| 6013 | // Create two images of different types and try to copy between them |
| 6014 | VkImage srcImage; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6015 | VkImage dstImage; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6016 | VkDeviceMemory srcMem; |
| 6017 | VkDeviceMemory destMem; |
| 6018 | VkMemoryRequirements memReqs; |
| 6019 | |
| 6020 | VkImageCreateInfo image_create_info = {}; |
| 6021 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6022 | image_create_info.pNext = NULL; |
| 6023 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6024 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 6025 | image_create_info.extent.width = 32; |
| 6026 | image_create_info.extent.height = 1; |
| 6027 | image_create_info.extent.depth = 1; |
| 6028 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 6029 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 6030 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6031 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
Cody Northrop | b3bf94f | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 6032 | // Note: Some implementations expect color attachment usage for any multisample surface |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6033 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6034 | image_create_info.flags = 0; |
| 6035 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6036 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6037 | ASSERT_VK_SUCCESS(err); |
| 6038 | |
| 6039 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
Cody Northrop | b3bf94f | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 6040 | // Note: Some implementations expect color attachment usage for any multisample surface |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6041 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 6042 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6043 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6044 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6045 | ASSERT_VK_SUCCESS(err); |
| 6046 | |
| 6047 | // Allocate memory |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6048 | VkMemoryAllocateInfo memAlloc = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6049 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6050 | memAlloc.pNext = NULL; |
| 6051 | memAlloc.allocationSize = 0; |
| 6052 | memAlloc.memoryTypeIndex = 0; |
| 6053 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 6054 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6055 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6056 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 6057 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6058 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6059 | ASSERT_VK_SUCCESS(err); |
| 6060 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6061 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6062 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 6063 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 6064 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6065 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6066 | ASSERT_VK_SUCCESS(err); |
| 6067 | |
| 6068 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 6069 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6070 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6071 | ASSERT_VK_SUCCESS(err); |
| 6072 | |
| 6073 | BeginCommandBuffer(); |
| 6074 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
| 6075 | //VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 6076 | //VK_IMAGE_LAYOUT_GENERAL = 1, |
| 6077 | VkImageResolve resolveRegion; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6078 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6079 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 63f0ead | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 6080 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6081 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6082 | resolveRegion.srcOffset.x = 0; |
| 6083 | resolveRegion.srcOffset.y = 0; |
| 6084 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 6085 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6086 | resolveRegion.dstSubresource.mipLevel = 0; |
| 6087 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 6088 | resolveRegion.dstSubresource.layerCount = 0; |
| 6089 | resolveRegion.dstOffset.x = 0; |
| 6090 | resolveRegion.dstOffset.y = 0; |
| 6091 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6092 | resolveRegion.extent.width = 1; |
| 6093 | resolveRegion.extent.height = 1; |
| 6094 | resolveRegion.extent.depth = 1; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6095 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6096 | EndCommandBuffer(); |
| 6097 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6098 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 6099 | FAIL() << "Did not receive Error 'vkCmdResolveImage called with unmatched source and dest image types.'"; |
| 6100 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6101 | } |
| 6102 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6103 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6104 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6105 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 6106 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 6107 | } |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6108 | |
| 6109 | TEST_F(VkLayerTest, DepthStencilImageViewWithColorAspectBitError) |
| 6110 | { |
| 6111 | // Create a single Image descriptor and cause it to first hit an error due |
| 6112 | // to using a DS format, then cause it to hit error due to COLOR_BIT not set in aspect |
| 6113 | // The image format check comes 2nd in validation so we trigger it first, |
| 6114 | // then when we cause aspect fail next, bad format check will be preempted |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6115 | VkResult err; |
| 6116 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6117 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 6118 | "Combination depth/stencil image formats can have only the "); |
| 6119 | |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6120 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6121 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6122 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6123 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6124 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6125 | |
| 6126 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 6127 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 6128 | ds_pool_ci.pNext = NULL; |
| 6129 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 6130 | ds_pool_ci.poolSizeCount = 1; |
| 6131 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6132 | |
| 6133 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6134 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6135 | ASSERT_VK_SUCCESS(err); |
| 6136 | |
| 6137 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 6138 | dsl_binding.binding = 0; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6139 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 6140 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6141 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 6142 | dsl_binding.pImmutableSamplers = NULL; |
| 6143 | |
| 6144 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 6145 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 6146 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6147 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 6148 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6149 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6150 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6151 | ASSERT_VK_SUCCESS(err); |
| 6152 | |
| 6153 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6154 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 6155 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 6156 | alloc_info.setLayoutCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6157 | alloc_info.descriptorPool = ds_pool; |
| 6158 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6159 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6160 | ASSERT_VK_SUCCESS(err); |
| 6161 | |
| 6162 | VkImage image_bad; |
| 6163 | VkImage image_good; |
| 6164 | // One bad format and one good format for Color attachment |
| 6165 | const VkFormat tex_format_bad = VK_FORMAT_D32_SFLOAT_S8_UINT; |
| 6166 | const VkFormat tex_format_good = VK_FORMAT_B8G8R8A8_UNORM; |
| 6167 | const int32_t tex_width = 32; |
| 6168 | const int32_t tex_height = 32; |
| 6169 | |
| 6170 | VkImageCreateInfo image_create_info = {}; |
| 6171 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6172 | image_create_info.pNext = NULL; |
| 6173 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 6174 | image_create_info.format = tex_format_bad; |
| 6175 | image_create_info.extent.width = tex_width; |
| 6176 | image_create_info.extent.height = tex_height; |
| 6177 | image_create_info.extent.depth = 1; |
| 6178 | image_create_info.mipLevels = 1; |
| 6179 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 6180 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6181 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 6182 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 6183 | image_create_info.flags = 0; |
| 6184 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6185 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image_bad); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6186 | ASSERT_VK_SUCCESS(err); |
| 6187 | image_create_info.format = tex_format_good; |
| 6188 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6189 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image_good); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6190 | ASSERT_VK_SUCCESS(err); |
| 6191 | |
| 6192 | VkImageViewCreateInfo image_view_create_info = {}; |
| 6193 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 6194 | image_view_create_info.image = image_bad; |
| 6195 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 6196 | image_view_create_info.format = tex_format_bad; |
| 6197 | image_view_create_info.subresourceRange.baseArrayLayer = 0; |
| 6198 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 6199 | image_view_create_info.subresourceRange.layerCount = 1; |
| 6200 | image_view_create_info.subresourceRange.levelCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6201 | image_view_create_info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 6202 | |
| 6203 | VkImageView view; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6204 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, &view); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 6205 | |
| 6206 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 6207 | FAIL() << "Did not receive Error 'Combination depth-stencil image formats can have only the....'"; |
| 6208 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6209 | } |
| 6210 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6211 | vkDestroyImage(m_device->device(), image_bad, NULL); |
| 6212 | vkDestroyImage(m_device->device(), image_good, NULL); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 6213 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 6214 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 6215 | } |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 6216 | #endif // IMAGE_TESTS |
| 6217 | |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 6218 | int main(int argc, char **argv) { |
| 6219 | int result; |
| 6220 | |
| 6221 | ::testing::InitGoogleTest(&argc, argv); |
Tony Barbour | 0199918 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 6222 | VkTestFramework::InitArgs(&argc, argv); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 6223 | |
| 6224 | ::testing::AddGlobalTestEnvironment(new TestEnvironment); |
| 6225 | |
| 6226 | result = RUN_ALL_TESTS(); |
| 6227 | |
Tony Barbour | 0199918 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 6228 | VkTestFramework::Finish(); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 6229 | return result; |
| 6230 | } |