Tony Barbour | d04e8df | 2015-11-17 10:02:56 -0700 | [diff] [blame] | 1 | // |
| 2 | // Copyright (C) 2015 Valve Corporation |
| 3 | // |
| 4 | // Permission is hereby granted, free of charge, to any person obtaining a |
| 5 | // copy of this software and associated documentation files (the "Software"), |
| 6 | // to deal in the Software without restriction, including without limitation |
| 7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 8 | // and/or sell copies of the Software, and to permit persons to whom the |
| 9 | // Software is furnished to do so, subject to the following conditions: |
| 10 | // |
| 11 | // The above copyright notice and this permission notice shall be included |
| 12 | // in all copies or substantial portions of the Software. |
| 13 | // |
| 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 20 | // DEALINGS IN THE SOFTWARE. |
| 21 | // |
| 22 | // Author: Chia-I Wu <olvaffe@gmail.com> |
| 23 | // Author: Chris Forbes <chrisf@ijw.co.nz> |
| 24 | // Author: Courtney Goeltzenleuchter <courtney@LunarG.com> |
| 25 | // Author: Mark Lobodzinski <mark@lunarg.com> |
| 26 | // Author: Mike Stroyan <mike@LunarG.com> |
| 27 | // Author: Tobin Ehlis <tobin@lunarg.com> |
| 28 | // Author: Tony Barbour <tony@LunarG.com> |
| 29 | |
| 30 | |
David Pinedo | 329ca9e | 2015-11-06 12:54:48 -0700 | [diff] [blame] | 31 | #include <vulkan/vulkan.h> |
David Pinedo | a31fe0b | 2015-11-24 09:00:24 -0700 | [diff] [blame] | 32 | #include "vulkan/vk_lunarg_debug_report.h" |
Courtney Goeltzenleuchter | 0abdb66 | 2015-10-07 13:28:58 -0600 | [diff] [blame] | 33 | #include "test_common.h" |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 34 | #include "vkrenderframework.h" |
Tobin Ehlis | 56d204a | 2015-07-03 10:15:26 -0600 | [diff] [blame] | 35 | #include "vk_layer_config.h" |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 36 | #include "../icd/common/icd-spv.h" |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 37 | |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 38 | #define GLM_FORCE_RADIANS |
| 39 | #include "glm/glm.hpp" |
| 40 | #include <glm/gtc/matrix_transform.hpp> |
| 41 | |
Tobin Ehlis | 57e6a61 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 42 | #define MEM_TRACKER_TESTS 1 |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 43 | |
Tobin Ehlis | 57e6a61 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 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 |
Courtney Goeltzenleuchter | f5c6195 | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 261 | instance_layer_names.push_back("Threading"); |
| 262 | instance_layer_names.push_back("ObjectTracker"); |
| 263 | instance_layer_names.push_back("MemTracker"); |
| 264 | instance_layer_names.push_back("DrawState"); |
| 265 | instance_layer_names.push_back("ShaderChecker"); |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 266 | instance_layer_names.push_back("DeviceLimits"); |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 267 | instance_layer_names.push_back("Image"); |
Courtney Goeltzenleuchter | 23b5f8d | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 268 | |
Courtney Goeltzenleuchter | f5c6195 | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 269 | device_layer_names.push_back("Threading"); |
| 270 | device_layer_names.push_back("ObjectTracker"); |
| 271 | device_layer_names.push_back("MemTracker"); |
| 272 | device_layer_names.push_back("DrawState"); |
| 273 | device_layer_names.push_back("ShaderChecker"); |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 274 | device_layer_names.push_back("DeviceLimits"); |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 275 | device_layer_names.push_back("Image"); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 276 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 277 | this->app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 278 | this->app_info.pNext = NULL; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 279 | this->app_info.pApplicationName = "layer_tests"; |
| 280 | this->app_info.applicationVersion = 1; |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 281 | this->app_info.pEngineName = "unittest"; |
| 282 | this->app_info.engineVersion = 1; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 283 | this->app_info.apiVersion = VK_API_VERSION; |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 284 | |
Tony Barbour | 0c1bdc6 | 2015-04-29 17:34:29 -0600 | [diff] [blame] | 285 | m_errorMonitor = new ErrorMonitor; |
Courtney Goeltzenleuchter | f5c6195 | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 286 | InitFramework(instance_layer_names, device_layer_names, |
| 287 | instance_extension_names, device_extension_names, |
| 288 | myDbgFunc, m_errorMonitor); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 289 | } |
| 290 | |
| 291 | virtual void TearDown() { |
| 292 | // Clean up resources before we reset |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 293 | ShutdownFramework(); |
Tony Barbour | 8508b8e | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 294 | delete m_errorMonitor; |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 295 | } |
| 296 | }; |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 297 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 298 | VkResult VkLayerTest::BeginCommandBuffer(VkCommandBufferObj &commandBuffer) |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 299 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 300 | VkResult result; |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 301 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 302 | result = commandBuffer.BeginCommandBuffer(); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 303 | |
| 304 | /* |
| 305 | * For render test all drawing happens in a single render pass |
| 306 | * on a single command buffer. |
| 307 | */ |
Chris Forbes | fe133ef | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 308 | if (VK_SUCCESS == result && renderPass()) { |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 309 | commandBuffer.BeginRenderPass(renderPassBeginInfo()); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 310 | } |
| 311 | |
| 312 | return result; |
| 313 | } |
| 314 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 315 | VkResult VkLayerTest::EndCommandBuffer(VkCommandBufferObj &commandBuffer) |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 316 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 317 | VkResult result; |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 318 | |
Chris Forbes | fe133ef | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 319 | if (renderPass()) { |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 320 | commandBuffer.EndRenderPass(); |
Chris Forbes | fe133ef | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 321 | } |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 322 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 323 | result = commandBuffer.EndCommandBuffer(); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 324 | |
| 325 | return result; |
| 326 | } |
| 327 | |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 328 | void VkLayerTest::VKTriangleTest(const char *vertShaderText, const char *fragShaderText, BsoFailSelect failMask) |
| 329 | { |
| 330 | // Create identity matrix |
| 331 | int i; |
| 332 | struct vktriangle_vs_uniform data; |
| 333 | |
| 334 | glm::mat4 Projection = glm::mat4(1.0f); |
| 335 | glm::mat4 View = glm::mat4(1.0f); |
| 336 | glm::mat4 Model = glm::mat4(1.0f); |
| 337 | glm::mat4 MVP = Projection * View * Model; |
| 338 | const int matrixSize = sizeof(MVP); |
| 339 | const int bufSize = sizeof(vktriangle_vs_uniform) / sizeof(float); |
| 340 | |
| 341 | memcpy(&data.mvp, &MVP[0][0], matrixSize); |
| 342 | |
| 343 | static const Vertex tri_data[] = |
| 344 | { |
| 345 | { XYZ1( -1, -1, 0 ), XYZ1( 1.f, 0.f, 0.f ) }, |
| 346 | { XYZ1( 1, -1, 0 ), XYZ1( 0.f, 1.f, 0.f ) }, |
| 347 | { XYZ1( 0, 1, 0 ), XYZ1( 0.f, 0.f, 1.f ) }, |
| 348 | }; |
| 349 | |
| 350 | for (i=0; i<3; i++) { |
| 351 | data.position[i][0] = tri_data[i].posX; |
| 352 | data.position[i][1] = tri_data[i].posY; |
| 353 | data.position[i][2] = tri_data[i].posZ; |
| 354 | data.position[i][3] = tri_data[i].posW; |
| 355 | data.color[i][0] = tri_data[i].r; |
| 356 | data.color[i][1] = tri_data[i].g; |
| 357 | data.color[i][2] = tri_data[i].b; |
| 358 | data.color[i][3] = tri_data[i].a; |
| 359 | } |
| 360 | |
| 361 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 362 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 363 | |
| 364 | VkConstantBufferObj constantBuffer(m_device, bufSize*2, sizeof(float), (const void*) &data); |
| 365 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 366 | VkShaderObj vs(m_device,vertShaderText,VK_SHADER_STAGE_VERTEX_BIT, this); |
| 367 | VkShaderObj ps(m_device,fragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 368 | |
| 369 | VkPipelineObj pipelineobj(m_device); |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 370 | pipelineobj.AddColorAttachment(); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 371 | pipelineobj.AddShader(&vs); |
| 372 | pipelineobj.AddShader(&ps); |
Courtney Goeltzenleuchter | 2f5deb5 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 373 | if (failMask & BsoFailLineWidth) { |
| 374 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_LINE_WIDTH); |
| 375 | } |
| 376 | if (failMask & BsoFailDepthBias) { |
| 377 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_DEPTH_BIAS); |
| 378 | } |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 379 | // 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] | 380 | if (failMask & BsoFailViewport) { |
| 381 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_VIEWPORT); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 382 | m_viewports.clear(); |
| 383 | m_scissors.clear(); |
Courtney Goeltzenleuchter | 2f5deb5 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 384 | } |
| 385 | if (failMask & BsoFailScissor) { |
| 386 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_SCISSOR); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 387 | m_scissors.clear(); |
| 388 | m_viewports.clear(); |
Courtney Goeltzenleuchter | 2f5deb5 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 389 | } |
| 390 | if (failMask & BsoFailBlend) { |
| 391 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_BLEND_CONSTANTS); |
| 392 | } |
| 393 | if (failMask & BsoFailDepthBounds) { |
| 394 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_DEPTH_BOUNDS); |
| 395 | } |
| 396 | if (failMask & BsoFailStencilReadMask) { |
| 397 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK); |
| 398 | } |
| 399 | if (failMask & BsoFailStencilWriteMask) { |
| 400 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_WRITE_MASK); |
| 401 | } |
| 402 | if (failMask & BsoFailStencilReference) { |
| 403 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_REFERENCE); |
| 404 | } |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 405 | |
| 406 | VkDescriptorSetObj descriptorSet(m_device); |
| 407 | descriptorSet.AppendBuffer(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, constantBuffer); |
| 408 | |
| 409 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 410 | ASSERT_VK_SUCCESS(BeginCommandBuffer()); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 411 | |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 412 | GenericDrawPreparation(pipelineobj, descriptorSet, failMask); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 413 | |
| 414 | // render triangle |
Courtney Goeltzenleuchter | 4ff11cc | 2015-09-23 12:31:50 -0600 | [diff] [blame] | 415 | Draw(3, 1, 0, 0); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 416 | |
| 417 | // finalize recording of the command buffer |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 418 | EndCommandBuffer(); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 419 | |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 420 | QueueCommandBuffer(); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 421 | } |
| 422 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 423 | void VkLayerTest::GenericDrawPreparation(VkCommandBufferObj *commandBuffer, VkPipelineObj &pipelineobj, VkDescriptorSetObj &descriptorSet, BsoFailSelect failMask) |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 424 | { |
| 425 | if (m_depthStencil->Initialized()) { |
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, m_depthStencil); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 427 | } else { |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 428 | 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] | 429 | } |
| 430 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 431 | commandBuffer->PrepareAttachments(); |
Cody Northrop | 2605cb0 | 2015-08-18 15:21:16 -0600 | [diff] [blame] | 432 | // Make sure depthWriteEnable is set so that Depth fail test will work correctly |
| 433 | // 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] | 434 | VkStencilOpState stencil = {}; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 435 | stencil.failOp = VK_STENCIL_OP_KEEP; |
| 436 | stencil.passOp = VK_STENCIL_OP_KEEP; |
| 437 | stencil.depthFailOp = VK_STENCIL_OP_KEEP; |
| 438 | stencil.compareOp = VK_COMPARE_OP_NEVER; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 439 | |
| 440 | VkPipelineDepthStencilStateCreateInfo ds_ci = {}; |
| 441 | ds_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO; |
Courtney Goeltzenleuchter | 2f5deb5 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 442 | ds_ci.pNext = NULL; |
| 443 | ds_ci.depthTestEnable = VK_FALSE; |
| 444 | ds_ci.depthWriteEnable = VK_TRUE; |
| 445 | ds_ci.depthCompareOp = VK_COMPARE_OP_NEVER; |
| 446 | ds_ci.depthBoundsTestEnable = VK_FALSE; |
| 447 | ds_ci.stencilTestEnable = VK_TRUE; |
| 448 | ds_ci.front = stencil; |
| 449 | ds_ci.back = stencil; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 450 | |
Tobin Ehlis | 40e9f52 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 451 | pipelineobj.SetDepthStencil(&ds_ci); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 452 | pipelineobj.SetViewport(m_viewports); |
| 453 | pipelineobj.SetScissor(m_scissors); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 454 | descriptorSet.CreateVKDescriptorSet(commandBuffer); |
Cody Northrop | ccfa96d | 2015-08-27 10:20:35 -0600 | [diff] [blame] | 455 | VkResult err = pipelineobj.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 456 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 457 | commandBuffer->BindPipeline(pipelineobj); |
| 458 | commandBuffer->BindDescriptorSet(descriptorSet); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 459 | } |
| 460 | |
| 461 | // ******************************************************************************************************************** |
| 462 | // ******************************************************************************************************************** |
| 463 | // ******************************************************************************************************************** |
| 464 | // ******************************************************************************************************************** |
Tobin Ehlis | 57e6a61 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 465 | #if MEM_TRACKER_TESTS |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 466 | TEST_F(VkLayerTest, CallResetCommandBufferBeforeCompletion) |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 467 | { |
| 468 | vk_testing::Fence testFence; |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 469 | VkFenceCreateInfo fenceInfo = {}; |
| 470 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 471 | fenceInfo.pNext = NULL; |
| 472 | fenceInfo.flags = 0; |
| 473 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 474 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, "Resetting CB"); |
| 475 | |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 476 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tony Barbour | e389b88 | 2015-07-20 13:00:10 -0600 | [diff] [blame] | 477 | |
| 478 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 479 | vk_testing::Buffer buffer; |
| 480 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 481 | |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 482 | BeginCommandBuffer(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 483 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 4, 0x11111111); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 484 | EndCommandBuffer(); |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 485 | |
| 486 | testFence.init(*m_device, fenceInfo); |
| 487 | |
| 488 | // Bypass framework since it does the waits automatically |
| 489 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 1a748e9 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 490 | VkSubmitInfo submit_info; |
Chia-I Wu | 6ec33a0 | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 491 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 492 | submit_info.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 493 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 1a748e9 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 494 | submit_info.pWaitSemaphores = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 495 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 496 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 497 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 1a748e9 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 498 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 3ec3162 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 499 | |
| 500 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 501 | ASSERT_VK_SUCCESS( err ); |
| 502 | |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 503 | // Introduce failure by calling begin again before checking fence |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 504 | vkResetCommandBuffer(m_commandBuffer->handle(), 0); |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 505 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 506 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 507 | FAIL() << "Did not receive Error 'Resetting CB (0xaddress) before it has completed. You must check CB flag before.'"; |
| 508 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 509 | } |
| 510 | } |
| 511 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 512 | TEST_F(VkLayerTest, CallBeginCommandBufferBeforeCompletion) |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 513 | { |
| 514 | vk_testing::Fence testFence; |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 515 | VkFenceCreateInfo fenceInfo = {}; |
| 516 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 517 | fenceInfo.pNext = NULL; |
| 518 | fenceInfo.flags = 0; |
| 519 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 520 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, "Calling vkBeginCommandBuffer() on active CB"); |
| 521 | |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 522 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 523 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 524 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 525 | |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 526 | BeginCommandBuffer(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 527 | 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] | 528 | EndCommandBuffer(); |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 529 | |
| 530 | testFence.init(*m_device, fenceInfo); |
| 531 | |
| 532 | // Bypass framework since it does the waits automatically |
| 533 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 1a748e9 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 534 | VkSubmitInfo submit_info; |
Chia-I Wu | 6ec33a0 | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 535 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 536 | submit_info.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 537 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 1a748e9 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 538 | submit_info.pWaitSemaphores = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 539 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 540 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 541 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 1a748e9 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 542 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 3ec3162 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 543 | |
| 544 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 545 | ASSERT_VK_SUCCESS( err ); |
| 546 | |
Mark Lobodzinski | 87db501 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 547 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 548 | VkCommandBufferBeginInfo info = {}; |
| 549 | info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
| 550 | info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Mark Lobodzinski | 87db501 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 551 | info.renderPass = VK_NULL_HANDLE; |
| 552 | info.subpass = 0; |
| 553 | info.framebuffer = VK_NULL_HANDLE; |
Chia-I Wu | fdc1cd0 | 2015-11-11 10:18:12 +0800 | [diff] [blame] | 554 | info.occlusionQueryEnable = VK_FALSE; |
| 555 | info.queryFlags = 0; |
| 556 | info.pipelineStatistics = 0; |
Mark Lobodzinski | 87db501 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 557 | |
| 558 | // Introduce failure by calling BCB again before checking fence |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 559 | vkBeginCommandBuffer(m_commandBuffer->handle(), &info); |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 560 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 561 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 562 | FAIL() << "Did not receive Error 'Calling vkBeginCommandBuffer() on an active CB (0xaddress) before it has completed'"; |
| 563 | m_errorMonitor->DumpFailureMsgs(); |
| 564 | |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 565 | } |
| 566 | } |
| 567 | |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 568 | TEST_F(VkLayerTest, MapMemWithoutHostVisibleBit) |
| 569 | { |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 570 | VkResult err; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 571 | bool pass; |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 572 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 573 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 574 | "Mapping Memory without VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT"); |
| 575 | |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 576 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 577 | |
| 578 | // Create an image, allocate memory, free it, and then try to bind it |
| 579 | VkImage image; |
Mark Lobodzinski | 2318261 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 580 | VkDeviceMemory mem; |
| 581 | VkMemoryRequirements mem_reqs; |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 582 | |
| 583 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 584 | const int32_t tex_width = 32; |
| 585 | const int32_t tex_height = 32; |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 586 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 587 | VkImageCreateInfo image_create_info = {}; |
| 588 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 589 | image_create_info.pNext = NULL; |
| 590 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 591 | image_create_info.format = tex_format; |
| 592 | image_create_info.extent.width = tex_width; |
| 593 | image_create_info.extent.height = tex_height; |
| 594 | image_create_info.extent.depth = 1; |
| 595 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 596 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 597 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 598 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 599 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 600 | image_create_info.flags = 0; |
Mark Lobodzinski | 87db501 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 601 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 602 | VkMemoryAllocateInfo mem_alloc = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 603 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 604 | mem_alloc.pNext = NULL; |
| 605 | mem_alloc.allocationSize = 0; |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 606 | // 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] | 607 | mem_alloc.memoryTypeIndex = 1; |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 608 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 609 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 610 | ASSERT_VK_SUCCESS(err); |
| 611 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 612 | vkGetImageMemoryRequirements(m_device->device(), |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 613 | image, |
Mark Lobodzinski | 2318261 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 614 | &mem_reqs); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 615 | |
Mark Lobodzinski | 2318261 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 616 | mem_alloc.allocationSize = mem_reqs.size; |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 617 | |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 618 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 619 | 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] | 620 | vkDestroyImage(m_device->device(), image, NULL); |
Tony Barbour | 49a3b65 | 2015-08-04 16:13:01 -0600 | [diff] [blame] | 621 | return; |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 622 | } |
Mike Stroyan | d72da75 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 623 | |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 624 | // allocate memory |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 625 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 626 | ASSERT_VK_SUCCESS(err); |
| 627 | |
| 628 | // Try to bind free memory that has been freed |
Tony Barbour | e84a8d6 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 629 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 630 | ASSERT_VK_SUCCESS(err); |
| 631 | |
| 632 | // Map memory as if to initialize the image |
| 633 | void *mappedAddress = NULL; |
Mark Lobodzinski | 2318261 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 634 | err = vkMapMemory(m_device->device(), mem, 0, 0, 0, &mappedAddress); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 635 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 636 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 637 | FAIL() << "Did not receive Error 'Error received did not match expected error message from vkMapMemory in MemTracker'"; |
| 638 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 639 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 640 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 641 | vkDestroyImage(m_device->device(), image, NULL); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 642 | } |
| 643 | |
Tobin Ehlis | 33ce8fd | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 644 | // TODO : Is this test still valid. Not sure it is with updates to memory binding model |
| 645 | // Verify and delete the test of fix the check |
| 646 | //TEST_F(VkLayerTest, FreeBoundMemory) |
| 647 | //{ |
Tobin Ehlis | 33ce8fd | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 648 | // VkResult err; |
| 649 | // |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 650 | // m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_WARN_BIT, |
| 651 | // "Freeing memory object while it still has references"); |
Tobin Ehlis | 33ce8fd | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 652 | // |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 653 | // ASSERT_NO_FATAL_FAILURE(InitState()); |
| 654 | |
Tobin Ehlis | 33ce8fd | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 655 | // // Create an image, allocate memory, free it, and then try to bind it |
| 656 | // VkImage image; |
| 657 | // VkDeviceMemory mem; |
| 658 | // VkMemoryRequirements mem_reqs; |
| 659 | // |
| 660 | // const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 661 | // const int32_t tex_width = 32; |
| 662 | // const int32_t tex_height = 32; |
| 663 | // |
| 664 | // const VkImageCreateInfo image_create_info = { |
| 665 | // .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, |
| 666 | // .pNext = NULL, |
| 667 | // .imageType = VK_IMAGE_TYPE_2D, |
| 668 | // .format = tex_format, |
| 669 | // .extent = { tex_width, tex_height, 1 }, |
| 670 | // .mipLevels = 1, |
| 671 | // .arraySize = 1, |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 672 | // .samples = VK_SAMPLE_COUNT_1_BIT, |
Tobin Ehlis | 33ce8fd | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 673 | // .tiling = VK_IMAGE_TILING_LINEAR, |
| 674 | // .usage = VK_IMAGE_USAGE_SAMPLED_BIT, |
| 675 | // .flags = 0, |
| 676 | // }; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 677 | // VkMemoryAllocateInfo mem_alloc = { |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 678 | // .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO, |
Tobin Ehlis | 33ce8fd | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 679 | // .pNext = NULL, |
| 680 | // .allocationSize = 0, |
| 681 | // .memoryTypeIndex = 0, |
| 682 | // }; |
| 683 | // |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 684 | // err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | 33ce8fd | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 685 | // ASSERT_VK_SUCCESS(err); |
| 686 | // |
| 687 | // err = vkGetImageMemoryRequirements(m_device->device(), |
| 688 | // image, |
| 689 | // &mem_reqs); |
| 690 | // ASSERT_VK_SUCCESS(err); |
| 691 | // |
| 692 | // mem_alloc.allocationSize = mem_reqs.size; |
| 693 | // |
| 694 | // err = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
| 695 | // ASSERT_VK_SUCCESS(err); |
| 696 | // |
| 697 | // // allocate memory |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 698 | // err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | 33ce8fd | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 699 | // ASSERT_VK_SUCCESS(err); |
| 700 | // |
| 701 | // // Bind memory to Image object |
| 702 | // err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 703 | // ASSERT_VK_SUCCESS(err); |
| 704 | // |
| 705 | // // Introduce validation failure, free memory while still bound to object |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 706 | // vkFreeMemory(m_device->device(), mem, NULL); |
Courtney Goeltzenleuchter | 0d6857f | 2015-09-04 13:52:24 -0600 | [diff] [blame] | 707 | // |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 708 | // if (!m_errorMonitor->DesiredMsgFound()) { |
| 709 | // FAIL() << "Did not receive Warning 'Freeing memory object while it still has references'"); |
| 710 | // m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 33ce8fd | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 711 | // } |
| 712 | //} |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 713 | |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 714 | TEST_F(VkLayerTest, RebindMemory) |
| 715 | { |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 716 | VkResult err; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 717 | bool pass; |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 718 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 719 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 720 | "which has already been bound to mem object"); |
| 721 | |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 722 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 723 | |
| 724 | // Create an image, allocate memory, free it, and then try to bind it |
| 725 | VkImage image; |
| 726 | VkDeviceMemory mem1; |
| 727 | VkDeviceMemory mem2; |
| 728 | VkMemoryRequirements mem_reqs; |
| 729 | |
| 730 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 731 | const int32_t tex_width = 32; |
| 732 | const int32_t tex_height = 32; |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 733 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 734 | VkImageCreateInfo image_create_info = {}; |
| 735 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 736 | image_create_info.pNext = NULL; |
| 737 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 738 | image_create_info.format = tex_format; |
| 739 | image_create_info.extent.width = tex_width; |
| 740 | image_create_info.extent.height = tex_height; |
| 741 | image_create_info.extent.depth = 1; |
| 742 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 743 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 744 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 745 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 746 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 747 | image_create_info.flags = 0; |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 748 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 749 | VkMemoryAllocateInfo mem_alloc = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 750 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 751 | mem_alloc.pNext = NULL; |
| 752 | mem_alloc.allocationSize = 0; |
| 753 | mem_alloc.memoryTypeIndex = 0; |
| 754 | |
| 755 | // Introduce failure, do NOT set memProps to VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
| 756 | mem_alloc.memoryTypeIndex = 1; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 757 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 758 | ASSERT_VK_SUCCESS(err); |
| 759 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 760 | vkGetImageMemoryRequirements(m_device->device(), |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 761 | image, |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 762 | &mem_reqs); |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 763 | |
| 764 | mem_alloc.allocationSize = mem_reqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 765 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
| 766 | ASSERT_TRUE(pass); |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 767 | |
| 768 | // allocate 2 memory objects |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 769 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem1); |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 770 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 771 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem2); |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 772 | ASSERT_VK_SUCCESS(err); |
| 773 | |
| 774 | // Bind first memory object to Image object |
Tony Barbour | e84a8d6 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 775 | err = vkBindImageMemory(m_device->device(), image, mem1, 0); |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 776 | ASSERT_VK_SUCCESS(err); |
| 777 | |
| 778 | // 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] | 779 | err = vkBindImageMemory(m_device->device(), image, mem2, 0); |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 780 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 781 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 782 | FAIL() << "Did not receive Error when rebinding memory to an object"; |
| 783 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 784 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 785 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 786 | vkDestroyImage(m_device->device(), image, NULL); |
| 787 | vkFreeMemory(m_device->device(), mem1, NULL); |
| 788 | vkFreeMemory(m_device->device(), mem2, NULL); |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 789 | } |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 790 | |
Tony Barbour | 8508b8e | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 791 | TEST_F(VkLayerTest, SubmitSignaledFence) |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 792 | { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 793 | vk_testing::Fence testFence; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 794 | |
| 795 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 796 | "submitted in SIGNALED state. Fences must be reset before being submitted"); |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 797 | |
| 798 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 8508b8e | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 799 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 800 | fenceInfo.pNext = NULL; |
| 801 | fenceInfo.flags = VK_FENCE_CREATE_SIGNALED_BIT; |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 802 | |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 803 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 804 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 805 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 806 | |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 807 | BeginCommandBuffer(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 808 | 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] | 809 | EndCommandBuffer(); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 810 | |
| 811 | testFence.init(*m_device, fenceInfo); |
Mark Lobodzinski | 87db501 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 812 | |
Courtney Goeltzenleuchter | 1a748e9 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 813 | VkSubmitInfo submit_info; |
Chia-I Wu | 6ec33a0 | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 814 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 815 | submit_info.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 816 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 1a748e9 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 817 | submit_info.pWaitSemaphores = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 818 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 819 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 820 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 1a748e9 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 821 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 3ec3162 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 822 | |
| 823 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
Mark Lobodzinski | 87db501 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 824 | vkQueueWaitIdle(m_device->m_queue ); |
Mark Lobodzinski | 87db501 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 825 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 826 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 827 | FAIL() << "Did not receive Error 'VkQueueSubmit with fence in SIGNALED_STATE'"; |
| 828 | m_errorMonitor->DumpFailureMsgs(); |
Tony Barbour | 8508b8e | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 829 | } |
Tony Barbour | 8508b8e | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 830 | } |
| 831 | |
| 832 | TEST_F(VkLayerTest, ResetUnsignaledFence) |
| 833 | { |
| 834 | vk_testing::Fence testFence; |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 835 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 8508b8e | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 836 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 837 | fenceInfo.pNext = NULL; |
| 838 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 839 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_WARN_BIT, |
| 840 | "submitted to VkResetFences in UNSIGNALED STATE"); |
| 841 | |
Tony Barbour | 8508b8e | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 842 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 843 | testFence.init(*m_device, fenceInfo); |
Chia-I Wu | a499234 | 2015-07-03 11:45:55 +0800 | [diff] [blame] | 844 | VkFence fences[1] = {testFence.handle()}; |
Tony Barbour | 8508b8e | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 845 | vkResetFences(m_device->device(), 1, fences); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 846 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 847 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 848 | FAIL() << "Did not receive Error 'VkResetFences with fence in UNSIGNALED_STATE'"; |
| 849 | m_errorMonitor->DumpFailureMsgs(); |
| 850 | } |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 851 | } |
Tobin Ehlis | d94ba72 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 852 | |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 853 | /* TODO: Update for changes due to bug-14075 tiling across render passes */ |
| 854 | #if 0 |
Tobin Ehlis | d94ba72 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 855 | TEST_F(VkLayerTest, InvalidUsageBits) |
| 856 | { |
| 857 | // Initiate Draw w/o a PSO bound |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 858 | |
| 859 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 860 | "Invalid usage flag for image "); |
Tobin Ehlis | d94ba72 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 861 | |
| 862 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 863 | VkCommandBufferObj commandBuffer(m_device); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 864 | BeginCommandBuffer(); |
Tobin Ehlis | d94ba72 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 865 | |
| 866 | const VkExtent3D e3d = { |
| 867 | .width = 128, |
| 868 | .height = 128, |
| 869 | .depth = 1, |
| 870 | }; |
| 871 | const VkImageCreateInfo ici = { |
| 872 | .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, |
| 873 | .pNext = NULL, |
| 874 | .imageType = VK_IMAGE_TYPE_2D, |
| 875 | .format = VK_FORMAT_D32_SFLOAT_S8_UINT, |
| 876 | .extent = e3d, |
| 877 | .mipLevels = 1, |
| 878 | .arraySize = 1, |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 879 | .samples = VK_SAMPLE_COUNT_1_BIT, |
Tobin Ehlis | d94ba72 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 880 | .tiling = VK_IMAGE_TILING_LINEAR, |
Courtney Goeltzenleuchter | c3b8eea | 2015-09-10 14:14:11 -0600 | [diff] [blame] | 881 | .usage = 0, // Not setting VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
Tobin Ehlis | d94ba72 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 882 | .flags = 0, |
| 883 | }; |
| 884 | |
| 885 | VkImage dsi; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 886 | vkCreateImage(m_device->device(), &ici, NULL, &dsi); |
Tobin Ehlis | d94ba72 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 887 | VkDepthStencilView dsv; |
| 888 | const VkDepthStencilViewCreateInfo dsvci = { |
| 889 | .sType = VK_STRUCTURE_TYPE_DEPTH_STENCIL_VIEW_CREATE_INFO, |
| 890 | .pNext = NULL, |
| 891 | .image = dsi, |
| 892 | .mipLevel = 0, |
Courtney Goeltzenleuchter | 3dee808 | 2015-09-10 16:38:41 -0600 | [diff] [blame] | 893 | .baseArrayLayer = 0, |
Tobin Ehlis | d94ba72 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 894 | .arraySize = 1, |
| 895 | .flags = 0, |
| 896 | }; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 897 | vkCreateDepthStencilView(m_device->device(), &dsvci, NULL, &dsv); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 898 | |
| 899 | if (!m_errorMonitor->DesiredMsgFound()) { |
Tobin Ehlis | d94ba72 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 900 | FAIL() << "Error received was not 'Invalid usage flag for image...'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 901 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | d94ba72 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 902 | } |
| 903 | } |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 904 | #endif // 0 |
| 905 | #endif // MEM_TRACKER_TESTS |
| 906 | |
Tobin Ehlis | 40e9f52 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 907 | #if OBJ_TRACKER_TESTS |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 908 | TEST_F(VkLayerTest, PipelineNotBound) |
| 909 | { |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 910 | VkResult err; |
| 911 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 912 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 913 | "Invalid VkPipeline Object "); |
| 914 | |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 915 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 916 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 917 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 918 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 919 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 920 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 921 | |
| 922 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 923 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 924 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 925 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 926 | ds_pool_ci.poolSizeCount = 1; |
| 927 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 928 | |
| 929 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 930 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 931 | ASSERT_VK_SUCCESS(err); |
| 932 | |
| 933 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 934 | dsl_binding.binding = 0; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 935 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 936 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 937 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 938 | dsl_binding.pImmutableSamplers = NULL; |
| 939 | |
| 940 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 941 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 942 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 943 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 944 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 945 | |
| 946 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 947 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 948 | ASSERT_VK_SUCCESS(err); |
| 949 | |
| 950 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 951 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 952 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 953 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 954 | alloc_info.descriptorPool = ds_pool; |
| 955 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 956 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 957 | ASSERT_VK_SUCCESS(err); |
| 958 | |
| 959 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 960 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 961 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 962 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 963 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 964 | |
| 965 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 966 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 967 | ASSERT_VK_SUCCESS(err); |
| 968 | |
| 969 | VkPipeline badPipeline = (VkPipeline)0xbaadb1be; |
| 970 | |
| 971 | BeginCommandBuffer(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 972 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, badPipeline); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 973 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 974 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 975 | FAIL() << "Error received was not 'Invalid VkPipeline Object 0xbaadb1be'" << endl; |
| 976 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 977 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 978 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 979 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 980 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 981 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 982 | } |
| 983 | |
| 984 | TEST_F(VkLayerTest, BindInvalidMemory) |
| 985 | { |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 986 | VkResult err; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 987 | bool pass; |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 988 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 989 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 990 | "Invalid VkDeviceMemory Object "); |
| 991 | |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 992 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 993 | |
| 994 | // Create an image, allocate memory, free it, and then try to bind it |
| 995 | VkImage image; |
| 996 | VkDeviceMemory mem; |
| 997 | VkMemoryRequirements mem_reqs; |
| 998 | |
| 999 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 1000 | const int32_t tex_width = 32; |
| 1001 | const int32_t tex_height = 32; |
| 1002 | |
| 1003 | VkImageCreateInfo image_create_info = {}; |
| 1004 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1005 | image_create_info.pNext = NULL; |
| 1006 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1007 | image_create_info.format = tex_format; |
| 1008 | image_create_info.extent.width = tex_width; |
| 1009 | image_create_info.extent.height = tex_height; |
| 1010 | image_create_info.extent.depth = 1; |
| 1011 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 1012 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1013 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1014 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1015 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 1016 | image_create_info.flags = 0; |
| 1017 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1018 | VkMemoryAllocateInfo mem_alloc = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1019 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1020 | mem_alloc.pNext = NULL; |
| 1021 | mem_alloc.allocationSize = 0; |
| 1022 | mem_alloc.memoryTypeIndex = 0; |
| 1023 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1024 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1025 | ASSERT_VK_SUCCESS(err); |
| 1026 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 1027 | vkGetImageMemoryRequirements(m_device->device(), |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1028 | image, |
| 1029 | &mem_reqs); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1030 | |
| 1031 | mem_alloc.allocationSize = mem_reqs.size; |
| 1032 | |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 1033 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
| 1034 | ASSERT_TRUE(pass); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1035 | |
| 1036 | // allocate memory |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1037 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1038 | ASSERT_VK_SUCCESS(err); |
| 1039 | |
| 1040 | // Introduce validation failure, free memory before binding |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1041 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1042 | |
| 1043 | // Try to bind free memory that has been freed |
| 1044 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 1045 | // This may very well return an error. |
| 1046 | (void)err; |
| 1047 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1048 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1049 | FAIL() << "Did not receive Error 'Invalid VkDeviceMemory Object 0x<handle>'"; |
| 1050 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1051 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1052 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1053 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1054 | } |
| 1055 | |
| 1056 | TEST_F(VkLayerTest, BindMemoryToDestroyedObject) |
| 1057 | { |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1058 | VkResult err; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 1059 | bool pass; |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1060 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1061 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, "Invalid VkImage Object "); |
| 1062 | |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1063 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1064 | |
| 1065 | // Create an image object, allocate memory, destroy the object and then try to bind it |
| 1066 | VkImage image; |
| 1067 | VkDeviceMemory mem; |
| 1068 | VkMemoryRequirements mem_reqs; |
| 1069 | |
| 1070 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 1071 | const int32_t tex_width = 32; |
| 1072 | const int32_t tex_height = 32; |
| 1073 | |
| 1074 | VkImageCreateInfo image_create_info = {}; |
| 1075 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1076 | image_create_info.pNext = NULL; |
| 1077 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1078 | image_create_info.format = tex_format; |
| 1079 | image_create_info.extent.width = tex_width; |
| 1080 | image_create_info.extent.height = tex_height; |
| 1081 | image_create_info.extent.depth = 1; |
| 1082 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 1083 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1084 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1085 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1086 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 1087 | image_create_info.flags = 0; |
| 1088 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1089 | VkMemoryAllocateInfo mem_alloc = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1090 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1091 | mem_alloc.pNext = NULL; |
| 1092 | mem_alloc.allocationSize = 0; |
| 1093 | mem_alloc.memoryTypeIndex = 0; |
| 1094 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1095 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1096 | ASSERT_VK_SUCCESS(err); |
| 1097 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 1098 | vkGetImageMemoryRequirements(m_device->device(), |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1099 | image, |
| 1100 | &mem_reqs); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1101 | |
| 1102 | mem_alloc.allocationSize = mem_reqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 1103 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
| 1104 | ASSERT_TRUE(pass); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1105 | |
| 1106 | // Allocate memory |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1107 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1108 | ASSERT_VK_SUCCESS(err); |
| 1109 | |
| 1110 | // Introduce validation failure, destroy Image object before binding |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1111 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1112 | ASSERT_VK_SUCCESS(err); |
| 1113 | |
| 1114 | // Now Try to bind memory to this destroyed object |
| 1115 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 1116 | // This may very well return an error. |
| 1117 | (void) err; |
| 1118 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1119 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1120 | FAIL() << "Did not receive Error 'Invalid VkImage Object 0x<handle>'"; |
| 1121 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1122 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1123 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1124 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1125 | } |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1126 | |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 1127 | #endif // OBJ_TRACKER_TESTS |
| 1128 | |
Tobin Ehlis | 57e6a61 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 1129 | #if DRAW_STATE_TESTS |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1130 | TEST_F(VkLayerTest, LineWidthStateNotBound) |
| 1131 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1132 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1133 | "Dynamic line width state not set for this command buffer"); |
| 1134 | |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1135 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a line width state object is not bound beforehand"); |
| 1136 | |
| 1137 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailLineWidth); |
| 1138 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1139 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1140 | FAIL() << "Did not receive Error 'Dynamic line width state not set for this command buffer'"; |
| 1141 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1142 | } |
| 1143 | } |
| 1144 | |
| 1145 | TEST_F(VkLayerTest, DepthBiasStateNotBound) |
| 1146 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1147 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1148 | "Dynamic depth bias state not set for this command buffer"); |
| 1149 | |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1150 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a depth bias state object is not bound beforehand"); |
| 1151 | |
| 1152 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailDepthBias); |
| 1153 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1154 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1155 | FAIL() << "Did not receive Error 'Dynamic depth bias state not set for this command buffer'"; |
| 1156 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1157 | } |
| 1158 | } |
| 1159 | |
Cody Northrop | bca3bcd | 2015-10-27 16:54:28 -0600 | [diff] [blame] | 1160 | // 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] | 1161 | TEST_F(VkLayerTest, ViewportStateNotBound) |
| 1162 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1163 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1164 | "Dynamic viewport state not set for this command buffer"); |
| 1165 | |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1166 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a viewport state object is not bound beforehand"); |
| 1167 | |
| 1168 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailViewport); |
| 1169 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1170 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1171 | FAIL() << "Did not recieve Error 'Dynamic scissor state not set for this command buffer'"; |
| 1172 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1173 | } |
| 1174 | } |
| 1175 | |
| 1176 | TEST_F(VkLayerTest, ScissorStateNotBound) |
| 1177 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1178 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1179 | "Dynamic scissor state not set for this command buffer"); |
| 1180 | |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1181 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a viewport state object is not bound beforehand"); |
| 1182 | |
| 1183 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailScissor); |
| 1184 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1185 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1186 | FAIL() << "Did not recieve Error ' Expected: 'Dynamic scissor state not set for this command buffer'"; |
| 1187 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1188 | } |
| 1189 | } |
| 1190 | |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1191 | TEST_F(VkLayerTest, BlendStateNotBound) |
| 1192 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1193 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1194 | "Dynamic blend object state not set for this command buffer"); |
| 1195 | |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1196 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a blend state object is not bound beforehand"); |
| 1197 | |
| 1198 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailBlend); |
| 1199 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1200 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1201 | FAIL() << "Did not recieve Error 'Dynamic blend object state not set for this command buffer'"; |
| 1202 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1203 | } |
| 1204 | } |
| 1205 | |
| 1206 | TEST_F(VkLayerTest, DepthBoundsStateNotBound) |
| 1207 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1208 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1209 | "Dynamic depth bounds state not set for this command buffer"); |
| 1210 | |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1211 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a depth bounds state object is not bound beforehand"); |
| 1212 | |
| 1213 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailDepthBounds); |
| 1214 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1215 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1216 | FAIL() << "Did not receive Error 'Dynamic depth bounds state not set for this command buffer'"; |
| 1217 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1218 | } |
| 1219 | } |
| 1220 | |
| 1221 | TEST_F(VkLayerTest, StencilReadMaskNotSet) |
| 1222 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1223 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1224 | "Dynamic stencil read mask state not set for this command buffer"); |
| 1225 | |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1226 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1227 | |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1228 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a stencil read mask is not set beforehand"); |
| 1229 | |
| 1230 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailStencilReadMask); |
| 1231 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1232 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1233 | FAIL() << "Did not receive Error 'Dynamic stencil read mask state not set for this command buffer'"; |
| 1234 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1235 | } |
| 1236 | } |
| 1237 | |
| 1238 | TEST_F(VkLayerTest, StencilWriteMaskNotSet) |
| 1239 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1240 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1241 | "Dynamic stencil write mask state not set for this command buffer"); |
| 1242 | |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1243 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1244 | |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1245 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a stencil write mask is not set beforehand"); |
| 1246 | |
| 1247 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailStencilWriteMask); |
| 1248 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1249 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1250 | FAIL() << "Did not receive Error 'Dynamic stencil write mask state not set for this command buffer'"; |
| 1251 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1252 | } |
| 1253 | } |
| 1254 | |
| 1255 | TEST_F(VkLayerTest, StencilReferenceNotSet) |
| 1256 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1257 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1258 | "Dynamic stencil reference state not set for this command buffer"); |
| 1259 | |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1260 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a stencil reference is not set beforehand"); |
| 1261 | |
| 1262 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailStencilReference); |
| 1263 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1264 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1265 | FAIL() << "Did not receive Error 'Dynamic stencil reference state not set for this command buffer'"; |
| 1266 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1267 | } |
| 1268 | } |
| 1269 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1270 | TEST_F(VkLayerTest, CommandBufferTwoSubmits) |
Tobin Ehlis | 0cea408 | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1271 | { |
| 1272 | vk_testing::Fence testFence; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1273 | |
| 1274 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1275 | "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] | 1276 | |
| 1277 | VkFenceCreateInfo fenceInfo = {}; |
| 1278 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 1279 | fenceInfo.pNext = NULL; |
| 1280 | fenceInfo.flags = 0; |
| 1281 | |
| 1282 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1283 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 1284 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1285 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1286 | // 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] | 1287 | BeginCommandBuffer(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1288 | 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] | 1289 | EndCommandBuffer(); |
| 1290 | |
| 1291 | testFence.init(*m_device, fenceInfo); |
| 1292 | |
| 1293 | // Bypass framework since it does the waits automatically |
| 1294 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 1a748e9 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1295 | VkSubmitInfo submit_info; |
Chia-I Wu | 6ec33a0 | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 1296 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1297 | submit_info.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1298 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 1a748e9 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1299 | submit_info.pWaitSemaphores = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1300 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1301 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1302 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 1a748e9 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1303 | submit_info.pSignalSemaphores = NULL; |
| 1304 | |
Courtney Goeltzenleuchter | 3ec3162 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 1305 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Tobin Ehlis | 0cea408 | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1306 | ASSERT_VK_SUCCESS( err ); |
| 1307 | |
Tobin Ehlis | 0cea408 | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1308 | // 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] | 1309 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Tobin Ehlis | 0cea408 | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1310 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1311 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1312 | FAIL() << "Did not receive Error 'CB (0xaddress) was created w/ VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set...'"; |
| 1313 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 0cea408 | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1314 | } |
| 1315 | } |
| 1316 | |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 1317 | TEST_F(VkLayerTest, BindPipelineNoRenderPass) |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1318 | { |
| 1319 | // Initiate Draw w/o a PSO bound |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1320 | VkResult err; |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1321 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1322 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1323 | "Incorrectly binding graphics pipeline "); |
| 1324 | |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1325 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1326 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1327 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1328 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1329 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1330 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1331 | |
| 1332 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1333 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1334 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 1335 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1336 | ds_pool_ci.poolSizeCount = 1; |
| 1337 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1338 | |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 1339 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1340 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1341 | ASSERT_VK_SUCCESS(err); |
| 1342 | |
| 1343 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1344 | dsl_binding.binding = 0; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1345 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 1346 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1347 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1348 | dsl_binding.pImmutableSamplers = NULL; |
| 1349 | |
| 1350 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1351 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1352 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1353 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1354 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1355 | |
| 1356 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1357 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1358 | ASSERT_VK_SUCCESS(err); |
| 1359 | |
| 1360 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1361 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1362 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1363 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1364 | alloc_info.descriptorPool = ds_pool; |
| 1365 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1366 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1367 | ASSERT_VK_SUCCESS(err); |
| 1368 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 1369 | pipe_ms_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 1370 | pipe_ms_state_ci.pNext = NULL; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1371 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1372 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 1373 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 1374 | pipe_ms_state_ci.pSampleMask = NULL; |
| 1375 | |
| 1376 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 1377 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 1378 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1379 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1380 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 1381 | VkPipelineLayout pipeline_layout; |
| 1382 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1383 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1384 | ASSERT_VK_SUCCESS(err); |
| 1385 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 1386 | VkShaderObj vs(m_device, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 1387 | 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] | 1388 | // but add it to be able to run on more devices |
| 1389 | VkPipelineObj pipe(m_device); |
| 1390 | pipe.AddShader(&vs); |
| 1391 | pipe.AddShader(&fs); |
| 1392 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 1393 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1394 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1395 | // Calls AllocateCommandBuffers |
| 1396 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
| 1397 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
| 1398 | memset(&cmd_buf_info, 0, sizeof(VkCommandBufferBeginInfo)); |
| 1399 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1400 | cmd_buf_info.pNext = NULL; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1401 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1402 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1403 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
| 1404 | vkCmdBindPipeline(commandBuffer.GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1405 | |
| 1406 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1407 | FAIL() << "Did not receive Error 'Incorrectly binding graphics pipeline (0x<handle>) without an active RenderPass'"; |
| 1408 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1409 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1410 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1411 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 1412 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1413 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1414 | } |
| 1415 | |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1416 | TEST_F(VkLayerTest, AllocDescriptorFromEmptyPool) |
| 1417 | { |
| 1418 | // Initiate Draw w/o a PSO bound |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1419 | VkResult err; |
| 1420 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1421 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1422 | "Unable to allocate 1 descriptors of type VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER "); |
| 1423 | |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1424 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1425 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1426 | |
| 1427 | // 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] | 1428 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1429 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1430 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1431 | |
| 1432 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1433 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1434 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1435 | ds_pool_ci.flags = 0; |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1436 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1437 | ds_pool_ci.poolSizeCount = 1; |
| 1438 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1439 | |
| 1440 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1441 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1442 | ASSERT_VK_SUCCESS(err); |
| 1443 | |
| 1444 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1445 | dsl_binding.binding = 0; |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1446 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 1447 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1448 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1449 | dsl_binding.pImmutableSamplers = NULL; |
| 1450 | |
| 1451 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1452 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1453 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1454 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1455 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1456 | |
| 1457 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1458 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1459 | ASSERT_VK_SUCCESS(err); |
| 1460 | |
| 1461 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1462 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1463 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1464 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1465 | alloc_info.descriptorPool = ds_pool; |
| 1466 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1467 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1468 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1469 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1470 | FAIL() << "Did not receive Error 'Unable to allocate 1 descriptors of type VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER...'"; |
| 1471 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1472 | } |
| 1473 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1474 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1475 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1476 | } |
| 1477 | |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1478 | TEST_F(VkLayerTest, FreeDescriptorFromOneShotPool) |
| 1479 | { |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1480 | VkResult err; |
| 1481 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1482 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1483 | "It is invalid to call vkFreeDescriptorSets() with a pool created without setting VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT."); |
| 1484 | |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1485 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1486 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1487 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1488 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1489 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1490 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1491 | |
| 1492 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1493 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1494 | ds_pool_ci.pNext = NULL; |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1495 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1496 | ds_pool_ci.poolSizeCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1497 | ds_pool_ci.flags = 0; |
| 1498 | // Not specifying VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT means |
| 1499 | // app can only call vkResetDescriptorPool on this pool.; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1500 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1501 | |
| 1502 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1503 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1504 | ASSERT_VK_SUCCESS(err); |
| 1505 | |
| 1506 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1507 | dsl_binding.binding = 0; |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1508 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 1509 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1510 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1511 | dsl_binding.pImmutableSamplers = NULL; |
| 1512 | |
| 1513 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1514 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1515 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1516 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1517 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1518 | |
| 1519 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1520 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1521 | ASSERT_VK_SUCCESS(err); |
| 1522 | |
| 1523 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1524 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1525 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1526 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1527 | alloc_info.descriptorPool = ds_pool; |
| 1528 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1529 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1530 | ASSERT_VK_SUCCESS(err); |
| 1531 | |
| 1532 | err = vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptorSet); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1533 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1534 | FAIL() << "Did not receive Error 'It is invalid to call vkFreeDescriptorSets() with a pool created with...'"; |
| 1535 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1536 | } |
| 1537 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1538 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1539 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1540 | } |
| 1541 | |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1542 | TEST_F(VkLayerTest, InvalidDescriptorPool) |
| 1543 | { |
| 1544 | // TODO : Simple check for bad object should be added to ObjectTracker to catch this case |
| 1545 | // The DS check for this is after driver has been called to validate DS internal data struct |
| 1546 | // Attempt to clear DS Pool with bad object |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1547 | /* |
| 1548 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1549 | "Unable to find pool node for pool 0xbaad6001 specified in vkResetDescriptorPool() call"); |
| 1550 | |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1551 | VkDescriptorPool badPool = (VkDescriptorPool)0xbaad6001; |
| 1552 | vkResetDescriptorPool(device(), badPool); |
| 1553 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1554 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1555 | FAIL() << "Did not receive Error 'Unable to find pool node for pool 0xbaad6001 specified in vkResetDescriptorPool() call'"; |
| 1556 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1557 | }*/ |
| 1558 | } |
| 1559 | |
| 1560 | TEST_F(VkLayerTest, InvalidDescriptorSet) |
| 1561 | { |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1562 | // TODO : Simple check for bad object should be added to ObjectTracker to catch this case |
| 1563 | // 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] | 1564 | // Create a valid cmd buffer |
| 1565 | // call vkCmdBindDescriptorSets w/ false DS |
| 1566 | } |
| 1567 | |
| 1568 | TEST_F(VkLayerTest, InvalidDescriptorSetLayout) |
| 1569 | { |
| 1570 | // TODO : Simple check for bad object should be added to ObjectTracker to catch this case |
| 1571 | // The DS check for this is after driver has been called to validate DS internal data struct |
| 1572 | } |
| 1573 | |
| 1574 | TEST_F(VkLayerTest, InvalidPipeline) |
| 1575 | { |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1576 | // TODO : Simple check for bad object should be added to ObjectTracker to catch this case |
| 1577 | // 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] | 1578 | // Create a valid cmd buffer |
| 1579 | // call vkCmdBindPipeline w/ false Pipeline |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1580 | // |
| 1581 | // m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1582 | // "Attempt to bind Pipeline "); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 1583 | // |
| 1584 | // ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1585 | // VkCommandBufferObj commandBuffer(m_device); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1586 | // BeginCommandBuffer(); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 1587 | // VkPipeline badPipeline = (VkPipeline)0xbaadb1be; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1588 | // vkCmdBindPipeline(commandBuffer.GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, badPipeline); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1589 | // |
| 1590 | // if (!m_errorMonitor->DesiredMsgFound()) { |
| 1591 | // FAIL() << "Did not receive Error 'Attempt to bind Pipeline 0xbaadb1be that doesn't exist!'"; |
| 1592 | // m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 1593 | // } |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1594 | } |
| 1595 | |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1596 | TEST_F(VkLayerTest, DescriptorSetNotUpdated) |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1597 | { |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1598 | // 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] | 1599 | VkResult err; |
| 1600 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1601 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_WARN_BIT, |
| 1602 | " bound but it was never updated. "); |
| 1603 | |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1604 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | d72da75 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 1605 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 1606 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1607 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1608 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1609 | ds_type_count.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1610 | |
| 1611 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1612 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1613 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 1614 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1615 | ds_pool_ci.poolSizeCount = 1; |
| 1616 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mike Stroyan | d72da75 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 1617 | |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1618 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1619 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1620 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1621 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1622 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1623 | dsl_binding.binding = 0; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1624 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 1625 | dsl_binding.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1626 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1627 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1628 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1629 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1630 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1631 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1632 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1633 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1634 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1635 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1636 | ASSERT_VK_SUCCESS(err); |
| 1637 | |
| 1638 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1639 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1640 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1641 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1642 | alloc_info.descriptorPool = ds_pool; |
| 1643 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1644 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1645 | ASSERT_VK_SUCCESS(err); |
| 1646 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1647 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 1648 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 1649 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1650 | pipeline_layout_ci.setLayoutCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1651 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1652 | |
| 1653 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1654 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1655 | ASSERT_VK_SUCCESS(err); |
| 1656 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 1657 | VkShaderObj vs(m_device, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1658 | // TODO - We shouldn't need a fragment shader but add it to be able to run on more devices |
| 1659 | VkShaderObj fs(m_device, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1660 | |
Tony Barbour | 4e8d1b1 | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 1661 | VkPipelineObj pipe(m_device); |
| 1662 | pipe.AddShader(&vs); |
Tony Barbour | 3c9e3b1 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 1663 | pipe.AddShader(&fs); |
Tony Barbour | 4e8d1b1 | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 1664 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1665 | |
| 1666 | BeginCommandBuffer(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1667 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 1668 | 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] | 1669 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1670 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1671 | FAIL() << "Did not recieve Warning 'DS <blah> bound but it was never updated. You may want to either update it or not bind it.'"; |
| 1672 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1673 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1674 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1675 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 1676 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1677 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1678 | } |
| 1679 | |
Tobin Ehlis | 093ef92 | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1680 | TEST_F(VkLayerTest, InvalidBufferViewObject) |
| 1681 | { |
| 1682 | // Create a single TEXEL_BUFFER descriptor and send it an invalid bufferView |
| 1683 | VkResult err; |
| 1684 | |
| 1685 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1686 | "Attempt to update descriptor with invalid bufferView "); |
| 1687 | |
| 1688 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1689 | VkDescriptorPoolSize ds_type_count = {}; |
| 1690 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 1691 | ds_type_count.descriptorCount = 1; |
| 1692 | |
| 1693 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1694 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1695 | ds_pool_ci.pNext = NULL; |
| 1696 | ds_pool_ci.maxSets = 1; |
| 1697 | ds_pool_ci.poolSizeCount = 1; |
| 1698 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 1699 | |
| 1700 | VkDescriptorPool ds_pool; |
| 1701 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 1702 | ASSERT_VK_SUCCESS(err); |
| 1703 | |
| 1704 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 1705 | dsl_binding.binding = 0; |
| 1706 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 1707 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | 093ef92 | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1708 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1709 | dsl_binding.pImmutableSamplers = NULL; |
| 1710 | |
| 1711 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1712 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1713 | ds_layout_ci.pNext = NULL; |
| 1714 | ds_layout_ci.bindingCount = 1; |
| 1715 | ds_layout_ci.pBinding = &dsl_binding; |
| 1716 | VkDescriptorSetLayout ds_layout; |
| 1717 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
| 1718 | ASSERT_VK_SUCCESS(err); |
| 1719 | |
| 1720 | VkDescriptorSet descriptorSet; |
| 1721 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1722 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Tobin Ehlis | 093ef92 | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1723 | alloc_info.setLayoutCount = 1; |
| 1724 | alloc_info.descriptorPool = ds_pool; |
| 1725 | alloc_info.pSetLayouts = &ds_layout; |
| 1726 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
| 1727 | ASSERT_VK_SUCCESS(err); |
| 1728 | |
| 1729 | VkBufferView view = (VkBufferView) 0xbaadbeef; // invalid bufferView object |
Tobin Ehlis | 093ef92 | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1730 | VkWriteDescriptorSet descriptor_write; |
| 1731 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 1732 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 1733 | descriptor_write.dstSet = descriptorSet; |
| 1734 | descriptor_write.dstBinding = 0; |
| 1735 | descriptor_write.descriptorCount = 1; |
| 1736 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 1737 | descriptor_write.pTexelBufferView = &view; |
| 1738 | |
| 1739 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 1740 | |
| 1741 | if (!m_errorMonitor->DesiredMsgFound()) { |
Tobin Ehlis | d949145 | 2015-11-05 10:27:49 -0700 | [diff] [blame] | 1742 | FAIL() << "Did not receive Error 'Attempt to update descriptor with invalid bufferView'"; |
Tobin Ehlis | 093ef92 | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1743 | m_errorMonitor->DumpFailureMsgs(); |
| 1744 | } |
| 1745 | |
| 1746 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1747 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 1748 | } |
| 1749 | |
Tobin Ehlis | e219486 | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1750 | TEST_F(VkLayerTest, InvalidDynamicOffsetCount) |
| 1751 | { |
| 1752 | // Create a descriptorSet w/ some dynamic descriptors and then don't send offsets when binding |
| 1753 | VkResult err; |
| 1754 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1755 | "Attempting to bind 1 descriptorSets with 1 dynamic descriptors, but dynamicOffsetCount is 0. "); |
| 1756 | |
| 1757 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1758 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 1759 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1760 | |
| 1761 | VkDescriptorPoolSize ds_type_count = {}; |
| 1762 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 1763 | ds_type_count.descriptorCount = 1; |
| 1764 | |
| 1765 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1766 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1767 | ds_pool_ci.pNext = NULL; |
| 1768 | ds_pool_ci.maxSets = 1; |
| 1769 | ds_pool_ci.poolSizeCount = 1; |
| 1770 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 1771 | |
| 1772 | VkDescriptorPool ds_pool; |
| 1773 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 1774 | ASSERT_VK_SUCCESS(err); |
| 1775 | |
| 1776 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 1777 | dsl_binding.binding = 0; |
| 1778 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
Jon Ashburn | 96b714a | 2015-11-06 15:31:44 -0700 | [diff] [blame] | 1779 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | e219486 | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1780 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1781 | dsl_binding.pImmutableSamplers = NULL; |
| 1782 | |
| 1783 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1784 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1785 | ds_layout_ci.pNext = NULL; |
| 1786 | ds_layout_ci.bindingCount = 1; |
| 1787 | ds_layout_ci.pBinding = &dsl_binding; |
| 1788 | VkDescriptorSetLayout ds_layout; |
| 1789 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
| 1790 | ASSERT_VK_SUCCESS(err); |
| 1791 | |
| 1792 | VkDescriptorSet descriptorSet; |
| 1793 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 1794 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Tobin Ehlis | e219486 | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1795 | alloc_info.setLayoutCount = 1; |
| 1796 | alloc_info.descriptorPool = ds_pool; |
| 1797 | alloc_info.pSetLayouts = &ds_layout; |
| 1798 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
| 1799 | ASSERT_VK_SUCCESS(err); |
| 1800 | |
| 1801 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 1802 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 1803 | pipeline_layout_ci.pNext = NULL; |
| 1804 | pipeline_layout_ci.setLayoutCount = 1; |
| 1805 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 1806 | |
| 1807 | VkPipelineLayout pipeline_layout; |
| 1808 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
| 1809 | ASSERT_VK_SUCCESS(err); |
| 1810 | |
| 1811 | // Create a buffer to update the descriptor with |
| 1812 | uint32_t qfi = 0; |
| 1813 | VkBufferCreateInfo buffCI = {}; |
| 1814 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 1815 | buffCI.size = 1024; |
| 1816 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 1817 | buffCI.queueFamilyIndexCount = 1; |
| 1818 | buffCI.pQueueFamilyIndices = &qfi; |
| 1819 | |
| 1820 | VkBuffer dyub; |
| 1821 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 1822 | ASSERT_VK_SUCCESS(err); |
| 1823 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 1824 | VkDescriptorBufferInfo buffInfo = {}; |
| 1825 | buffInfo.buffer = dyub; |
| 1826 | buffInfo.offset = 0; |
| 1827 | buffInfo.range = 1024; |
| 1828 | |
| 1829 | VkWriteDescriptorSet descriptor_write; |
| 1830 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 1831 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 1832 | descriptor_write.dstSet = descriptorSet; |
| 1833 | descriptor_write.dstBinding = 0; |
| 1834 | descriptor_write.descriptorCount = 1; |
| 1835 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 1836 | descriptor_write.pBufferInfo = &buffInfo; |
| 1837 | |
| 1838 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 1839 | |
| 1840 | BeginCommandBuffer(); |
| 1841 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, 1, &descriptorSet, 0, NULL); |
| 1842 | |
| 1843 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1844 | FAIL() << "Error received was not 'Attempting to bind 1 descriptorSets with 1 dynamic descriptors, but dynamicOffsetCount is 0...'"; |
| 1845 | m_errorMonitor->DumpFailureMsgs(); |
| 1846 | } |
| 1847 | |
| 1848 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 1849 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 1850 | } |
| 1851 | |
Tobin Ehlis | 982099b | 2015-11-05 09:52:49 -0700 | [diff] [blame] | 1852 | /* WIP for Tobin's follow-on descriptor set validation efforts |
| 1853 | TEST_F(VkLayerTest, DescriptorSetCompatibility) |
| 1854 | { |
| 1855 | // Test various desriptorSet errors with bad binding combinations |
| 1856 | VkResult err; |
| 1857 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1858 | "Attempting to bind 1 descriptorSets with 1 dynamic descriptors, but dynamicOffsetCount is 0. "); |
| 1859 | |
| 1860 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1861 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 1862 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1863 | |
| 1864 | static const uint32_t NUM_DESCRIPTOR_TYPES = 5; |
| 1865 | VkDescriptorPoolSize ds_type_count[NUM_DESCRIPTOR_TYPES] = {}; |
| 1866 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1867 | ds_type_count[0].descriptorCount = 5; |
| 1868 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 1869 | ds_type_count[1].descriptorCount = 2; |
| 1870 | ds_type_count[2].type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 1871 | ds_type_count[2].descriptorCount = 2; |
| 1872 | ds_type_count[3].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 1873 | ds_type_count[3].descriptorCount = 5; |
| 1874 | // TODO : LunarG ILO driver currently asserts in desc.c w/ INPUT_ATTACHMENT type |
| 1875 | //ds_type_count[4].type = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; |
| 1876 | ds_type_count[4].type = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
| 1877 | ds_type_count[4].descriptorCount = 2; |
| 1878 | |
| 1879 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1880 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1881 | ds_pool_ci.pNext = NULL; |
| 1882 | ds_pool_ci.maxSets = 1; |
| 1883 | ds_pool_ci.poolSizeCount = NUM_DESCRIPTOR_TYPES; |
| 1884 | ds_pool_ci.pPoolSizes = ds_type_count; |
| 1885 | |
| 1886 | VkDescriptorPool ds_pool; |
| 1887 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 1888 | ASSERT_VK_SUCCESS(err); |
| 1889 | |
| 1890 | static const uint32_t MAX_DS_TYPES_IN_LAYOUT = 2; |
| 1891 | VkDescriptorSetLayoutBinding dsl_binding[MAX_DS_TYPES_IN_LAYOUT] = {}; |
| 1892 | dsl_binding[0].binding = 0; |
| 1893 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1894 | dsl_binding[0].arraySize = 5; |
| 1895 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 1896 | dsl_binding[0].pImmutableSamplers = NULL; |
| 1897 | |
| 1898 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1899 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1900 | ds_layout_ci.pNext = NULL; |
| 1901 | ds_layout_ci.bindingCount = 1; |
| 1902 | ds_layout_ci.pBinding = dsl_binding; |
| 1903 | static const uint32_t NUM_LAYOUTS = 4; |
| 1904 | VkDescriptorSetLayout ds_layout[NUM_LAYOUTS] = {}; |
| 1905 | // Create 4 unique layouts |
| 1906 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout[0]); |
| 1907 | ASSERT_VK_SUCCESS(err); |
| 1908 | dsl_binding[0].binding = 0; |
| 1909 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 1910 | dsl_binding[0].arraySize = 2; |
| 1911 | dsl_binding[0].binding = 1; |
| 1912 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; |
| 1913 | dsl_binding[0].arraySize = 2; |
| 1914 | ds_layout_ci.bindingCount = 2; |
| 1915 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout[1]); |
| 1916 | ASSERT_VK_SUCCESS(err); |
| 1917 | dsl_binding[0].binding = 0; |
| 1918 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 1919 | dsl_binding[0].arraySize = 5; |
| 1920 | ds_layout_ci.bindingCount = 1; |
| 1921 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout[2]); |
| 1922 | ASSERT_VK_SUCCESS(err); |
| 1923 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER; |
| 1924 | dsl_binding[0].arraySize = 2; |
| 1925 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout[3]); |
| 1926 | ASSERT_VK_SUCCESS(err); |
| 1927 | |
| 1928 | static const uint32_t NUM_SETS = 4; |
| 1929 | VkDescriptorSet descriptorSet[NUM_SETS] = {}; |
| 1930 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 1931 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
| 1932 | alloc_info.setLayoutCount = NUM_LAYOUTS; |
| 1933 | alloc_info.descriptorPool = ds_pool; |
| 1934 | alloc_info.pSetLayouts = ds_layout; |
| 1935 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, descriptorSet); |
| 1936 | ASSERT_VK_SUCCESS(err); |
| 1937 | |
| 1938 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 1939 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 1940 | pipeline_layout_ci.pNext = NULL; |
| 1941 | pipeline_layout_ci.setLayoutCount = NUM_LAYOUTS; |
| 1942 | pipeline_layout_ci.pSetLayouts = ds_layout; |
| 1943 | |
| 1944 | VkPipelineLayout pipeline_layout; |
| 1945 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
| 1946 | ASSERT_VK_SUCCESS(err); |
| 1947 | |
| 1948 | // Create a buffer to update the descriptor with |
| 1949 | uint32_t qfi = 0; |
| 1950 | VkBufferCreateInfo buffCI = {}; |
| 1951 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 1952 | buffCI.size = 1024; |
| 1953 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 1954 | buffCI.queueFamilyIndexCount = 1; |
| 1955 | buffCI.pQueueFamilyIndices = &qfi; |
| 1956 | |
| 1957 | VkBuffer dyub; |
| 1958 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 1959 | ASSERT_VK_SUCCESS(err); |
| 1960 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 1961 | static const uint32_t NUM_BUFFS = 5; |
| 1962 | VkDescriptorBufferInfo buffInfo[NUM_BUFFS] = {}; |
| 1963 | for (uint32_t i=0; i<NUM_BUFFS; ++i) { |
| 1964 | buffInfo[i].buffer = dyub; |
| 1965 | buffInfo[i].offset = 0; |
| 1966 | buffInfo[i].range = 1024; |
| 1967 | } |
| 1968 | |
| 1969 | VkWriteDescriptorSet descriptor_write; |
| 1970 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 1971 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 1972 | descriptor_write.dstSet = descriptorSet[0]; |
| 1973 | descriptor_write.dstBinding = 0; |
| 1974 | descriptor_write.descriptorCount = 5; |
| 1975 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1976 | descriptor_write.pBufferInfo = buffInfo; |
| 1977 | |
| 1978 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 1979 | |
| 1980 | VkShaderObj vs(m_device, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 1981 | VkShaderObj fs(m_device, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, this); // TODO - We shouldn't need a fragment shader |
| 1982 | // but add it to be able to run on more devices |
| 1983 | VkPipelineObj pipe(m_device); |
| 1984 | pipe.AddShader(&vs); |
| 1985 | pipe.AddShader(&fs); |
| 1986 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
| 1987 | |
| 1988 | BeginCommandBuffer(); |
| 1989 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 1990 | // NOTE : I believe LunarG ilo driver has bug (LX#189) that requires binding of PSO |
| 1991 | // here before binding DSs. Otherwise we assert in cmd_copy_dset_data() of cmd_pipeline.c |
| 1992 | // due to the fact that cmd_alloc_dset_data() has not been called in cmd_bind_graphics_pipeline() |
| 1993 | // TODO : Want to cause various binding incompatibility issues here to test DrawState |
| 1994 | // First cause various verify_layout_compatibility() fails |
| 1995 | // Second disturb early and late sets and verify INFO msgs |
| 1996 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, 1, &descriptorSet[0], 0, NULL); |
| 1997 | |
| 1998 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1999 | FAIL() << "Error received was not 'Attempting to bind 1 descriptorSets with 1 dynamic descriptors, but dynamicOffsetCount is 0...'"; |
| 2000 | m_errorMonitor->DumpFailureMsgs(); |
| 2001 | } |
| 2002 | |
| 2003 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2004 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 2005 | } |
| 2006 | */ |
| 2007 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2008 | TEST_F(VkLayerTest, NoBeginCommandBuffer) |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2009 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2010 | |
| 2011 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2012 | "You must call vkBeginCommandBuffer() before this call to "); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2013 | |
| 2014 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2015 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2016 | // Call EndCommandBuffer() w/o calling BeginCommandBuffer() |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2017 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2018 | |
| 2019 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2020 | FAIL() << "Did not recieve Error 'You must call vkBeginCommandBuffer() before this call to vkEndCommandBuffer()'"; |
| 2021 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2022 | } |
| 2023 | } |
| 2024 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2025 | TEST_F(VkLayerTest, PrimaryCommandBufferFramebufferAndRenderpass) |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2026 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2027 | |
| 2028 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2029 | "may not specify framebuffer or renderpass parameters"); |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2030 | |
| 2031 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2032 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2033 | // Calls AllocateCommandBuffers |
| 2034 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2035 | |
| 2036 | // 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] | 2037 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
| 2038 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Cody Northrop | 10d8f98 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 2039 | cmd_buf_info.pNext = NULL; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2040 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
Cody Northrop | 10d8f98 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 2041 | cmd_buf_info.renderPass = (VkRenderPass)0xcadecade; |
| 2042 | cmd_buf_info.framebuffer = (VkFramebuffer)0xcadecade; |
| 2043 | |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2044 | |
| 2045 | // The error should be caught by validation of the BeginCommandBuffer call |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2046 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2047 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2048 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2049 | FAIL() << "Did not receive Error 'vkAllocateCommandBuffers(): Primary Command Buffer may not specify framebuffer or renderpass parameters'"; |
| 2050 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2051 | } |
| 2052 | } |
| 2053 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2054 | TEST_F(VkLayerTest, SecondaryCommandBufferFramebufferAndRenderpass) |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2055 | { |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2056 | VkResult err; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2057 | VkCommandBuffer draw_cmd; |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2058 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2059 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2060 | "must specify framebuffer and renderpass parameters"); |
| 2061 | |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2062 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2063 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2064 | VkCommandBufferAllocateInfo cmd = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2065 | cmd.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; |
Cody Northrop | 10d8f98 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 2066 | cmd.pNext = NULL; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2067 | cmd.commandPool = m_commandPool; |
| 2068 | cmd.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2069 | cmd.bufferCount = 1; |
Cody Northrop | 10d8f98 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 2070 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2071 | err = vkAllocateCommandBuffers(m_device->device(), &cmd, &draw_cmd); |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2072 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2073 | |
| 2074 | // Force the failure by not setting the Renderpass and Framebuffer fields |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2075 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
| 2076 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Cody Northrop | 10d8f98 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 2077 | cmd_buf_info.pNext = NULL; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2078 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2079 | |
| 2080 | // The error should be caught by validation of the BeginCommandBuffer call |
| 2081 | vkBeginCommandBuffer(draw_cmd, &cmd_buf_info); |
| 2082 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2083 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2084 | FAIL() << "Did not receive Error 'vkAllocateCommandBuffers(): Secondary Command Buffer must specify framebuffer and renderpass parameters'"; |
| 2085 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2086 | } |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2087 | vkFreeCommandBuffers(m_device->device(), m_commandPool, 1, &draw_cmd); |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 2088 | } |
| 2089 | |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2090 | TEST_F(VkLayerTest, InvalidPipelineCreateState) |
| 2091 | { |
| 2092 | // Attempt to Create Gfx Pipeline w/o a VS |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2093 | VkResult err; |
| 2094 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2095 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2096 | "Invalid Pipeline CreateInfo State: Vtx Shader required"); |
| 2097 | |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2098 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2099 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 2100 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2101 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2102 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2103 | ds_type_count.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2104 | |
| 2105 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2106 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2107 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 2108 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2109 | ds_pool_ci.poolSizeCount = 1; |
| 2110 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 2111 | |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2112 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2113 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2114 | ASSERT_VK_SUCCESS(err); |
| 2115 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2116 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2117 | dsl_binding.binding = 0; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2118 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 2119 | dsl_binding.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2120 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2121 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2122 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2123 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2124 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2125 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2126 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2127 | ds_layout_ci.pBinding = &dsl_binding; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2128 | |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2129 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2130 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2131 | ASSERT_VK_SUCCESS(err); |
| 2132 | |
| 2133 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2134 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2135 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2136 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2137 | alloc_info.descriptorPool = ds_pool; |
| 2138 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2139 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2140 | ASSERT_VK_SUCCESS(err); |
| 2141 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2142 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 2143 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2144 | pipeline_layout_ci.setLayoutCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2145 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2146 | |
| 2147 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2148 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2149 | ASSERT_VK_SUCCESS(err); |
| 2150 | |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2151 | VkViewport vp = {}; // Just need dummy vp to point to |
| 2152 | VkRect2D sc = {}; // dummy scissor to point to |
| 2153 | |
| 2154 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 2155 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 2156 | vp_state_ci.scissorCount = 1; |
| 2157 | vp_state_ci.pScissors = ≻ |
| 2158 | vp_state_ci.viewportCount = 1; |
| 2159 | vp_state_ci.pViewports = &vp; |
| 2160 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2161 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 2162 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2163 | gp_ci.pViewportState = &vp_state_ci; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2164 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2165 | gp_ci.layout = pipeline_layout; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2166 | gp_ci.renderPass = renderPass(); |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2167 | |
| 2168 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 2169 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Chia-I Wu | 7e47070 | 2015-10-26 17:24:52 +0800 | [diff] [blame] | 2170 | pc_ci.initialDataSize = 0; |
| 2171 | pc_ci.pInitialData = 0; |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2172 | |
| 2173 | VkPipeline pipeline; |
Jon Ashburn | 0d60d27 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 2174 | VkPipelineCache pipelineCache; |
| 2175 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2176 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Jon Ashburn | 0d60d27 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 2177 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2178 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 2179 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2180 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2181 | FAIL() << "Did not receive Error 'Invalid Pipeline CreateInfo State: Vtx Shader required'"; |
| 2182 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2183 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2184 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2185 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2186 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2187 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2188 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2189 | } |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2190 | /*// TODO : This test should be good, but needs Tess support in compiler to run |
| 2191 | TEST_F(VkLayerTest, InvalidPatchControlPoints) |
| 2192 | { |
| 2193 | // Attempt to Create Gfx Pipeline w/o a VS |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2194 | VkResult err; |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2195 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2196 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2197 | "Invalid Pipeline CreateInfo State: VK_PRIMITIVE_TOPOLOGY_PATCH primitive "); |
| 2198 | |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2199 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2200 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2201 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2202 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2203 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2204 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2205 | |
| 2206 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2207 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2208 | ds_pool_ci.pNext = NULL; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2209 | ds_pool_ci.poolSizeCount = 1; |
| 2210 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2211 | |
| 2212 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2213 | 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] | 2214 | ASSERT_VK_SUCCESS(err); |
| 2215 | |
| 2216 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2217 | dsl_binding.binding = 0; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2218 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 2219 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2220 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2221 | dsl_binding.pImmutableSamplers = NULL; |
| 2222 | |
| 2223 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2224 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2225 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2226 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2227 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2228 | |
| 2229 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2230 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2231 | ASSERT_VK_SUCCESS(err); |
| 2232 | |
| 2233 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2234 | 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] | 2235 | ASSERT_VK_SUCCESS(err); |
| 2236 | |
| 2237 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 2238 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 2239 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2240 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2241 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 2242 | |
| 2243 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2244 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2245 | ASSERT_VK_SUCCESS(err); |
| 2246 | |
| 2247 | VkPipelineShaderStageCreateInfo shaderStages[3]; |
| 2248 | memset(&shaderStages, 0, 3 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 2249 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2250 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, this); |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2251 | // 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] | 2252 | VkShaderObj tc(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 2253 | VkShaderObj te(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2254 | |
| 2255 | shaderStages[0].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2256 | shaderStages[0].stage = VK_SHADER_STAGE_VERTEX_BIT; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2257 | shaderStages[0].shader = vs.handle(); |
| 2258 | shaderStages[1].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2259 | shaderStages[1].stage = VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2260 | shaderStages[1].shader = tc.handle(); |
| 2261 | shaderStages[2].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2262 | shaderStages[2].stage = VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2263 | shaderStages[2].shader = te.handle(); |
| 2264 | |
| 2265 | VkPipelineInputAssemblyStateCreateInfo iaCI = {}; |
| 2266 | iaCI.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
Chia-I Wu | 99ba2bb | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2267 | iaCI.topology = VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2268 | |
| 2269 | VkPipelineTessellationStateCreateInfo tsCI = {}; |
| 2270 | tsCI.sType = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO; |
| 2271 | tsCI.patchControlPoints = 0; // This will cause an error |
| 2272 | |
| 2273 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 2274 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 2275 | gp_ci.pNext = NULL; |
| 2276 | gp_ci.stageCount = 3; |
| 2277 | gp_ci.pStages = shaderStages; |
| 2278 | gp_ci.pVertexInputState = NULL; |
| 2279 | gp_ci.pInputAssemblyState = &iaCI; |
| 2280 | gp_ci.pTessellationState = &tsCI; |
| 2281 | gp_ci.pViewportState = NULL; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2282 | gp_ci.pRasterizationState = NULL; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2283 | gp_ci.pMultisampleState = NULL; |
| 2284 | gp_ci.pDepthStencilState = NULL; |
| 2285 | gp_ci.pColorBlendState = NULL; |
| 2286 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2287 | gp_ci.layout = pipeline_layout; |
| 2288 | gp_ci.renderPass = renderPass(); |
| 2289 | |
| 2290 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 2291 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 2292 | pc_ci.pNext = NULL; |
| 2293 | pc_ci.initialSize = 0; |
| 2294 | pc_ci.initialData = 0; |
| 2295 | pc_ci.maxSize = 0; |
| 2296 | |
| 2297 | VkPipeline pipeline; |
| 2298 | VkPipelineCache pipelineCache; |
| 2299 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2300 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2301 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2302 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2303 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2304 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2305 | FAIL() << "Did not receive Error 'Invalid Pipeline CreateInfo State: VK_PRIMITIVE_TOPOLOGY_PATCH primitive...'"; |
| 2306 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2307 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2308 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2309 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2310 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2311 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2312 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2313 | } |
| 2314 | */ |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2315 | // Set scissor and viewport counts to different numbers |
| 2316 | TEST_F(VkLayerTest, PSOViewportScissorCountMismatch) |
| 2317 | { |
| 2318 | // Attempt to Create Gfx Pipeline w/o a VS |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2319 | VkResult err; |
| 2320 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2321 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2322 | "Gfx Pipeline viewport count (1) must match scissor count (0)."); |
| 2323 | |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2324 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2325 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2326 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2327 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2328 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2329 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2330 | |
| 2331 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2332 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2333 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2334 | ds_pool_ci.poolSizeCount = 1; |
| 2335 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2336 | |
| 2337 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2338 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2339 | ASSERT_VK_SUCCESS(err); |
| 2340 | |
| 2341 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2342 | dsl_binding.binding = 0; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2343 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 2344 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2345 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2346 | |
| 2347 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2348 | 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] | 2349 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2350 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2351 | |
| 2352 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2353 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2354 | ASSERT_VK_SUCCESS(err); |
| 2355 | |
| 2356 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2357 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2358 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2359 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2360 | alloc_info.descriptorPool = ds_pool; |
| 2361 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2362 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2363 | ASSERT_VK_SUCCESS(err); |
| 2364 | |
| 2365 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 2366 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2367 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2368 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 2369 | |
| 2370 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2371 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2372 | ASSERT_VK_SUCCESS(err); |
| 2373 | |
| 2374 | VkViewport vp = {}; // Just need dummy vp to point to |
| 2375 | |
| 2376 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 2377 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 2378 | vp_state_ci.scissorCount = 0; |
| 2379 | vp_state_ci.viewportCount = 1; // Count mismatch should cause error |
| 2380 | vp_state_ci.pViewports = &vp; |
| 2381 | |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2382 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 2383 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2384 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2385 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, this); |
| 2386 | 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] | 2387 | // but add it to be able to run on more devices |
Chia-I Wu | 062ad15 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2388 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 2389 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2390 | |
| 2391 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 2392 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2393 | gp_ci.stageCount = 2; |
| 2394 | gp_ci.pStages = shaderStages; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2395 | gp_ci.pViewportState = &vp_state_ci; |
| 2396 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2397 | gp_ci.layout = pipeline_layout; |
| 2398 | gp_ci.renderPass = renderPass(); |
| 2399 | |
| 2400 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 2401 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 2402 | |
| 2403 | VkPipeline pipeline; |
| 2404 | VkPipelineCache pipelineCache; |
| 2405 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2406 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2407 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2408 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2409 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2410 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2411 | FAIL() << "Did not receive Error 'Gfx Pipeline viewport count (1) must match scissor count (0).'"; |
| 2412 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2413 | } |
| 2414 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2415 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2416 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2417 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2418 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2419 | } |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2420 | // Don't set viewport state in PSO. This is an error b/c we always need this state |
| 2421 | // for the counts even if the data is going to be set dynamically. |
| 2422 | TEST_F(VkLayerTest, PSOViewportStateNotSet) |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2423 | { |
| 2424 | // Attempt to Create Gfx Pipeline w/o a VS |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2425 | VkResult err; |
| 2426 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2427 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2428 | "Gfx Pipeline pViewportState is null. Even if "); |
| 2429 | |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2430 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2431 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2432 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2433 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2434 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2435 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2436 | |
| 2437 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2438 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2439 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2440 | ds_pool_ci.poolSizeCount = 1; |
| 2441 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2442 | |
| 2443 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2444 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2445 | ASSERT_VK_SUCCESS(err); |
| 2446 | |
| 2447 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2448 | dsl_binding.binding = 0; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2449 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 2450 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2451 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2452 | |
| 2453 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2454 | 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] | 2455 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2456 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2457 | |
| 2458 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2459 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2460 | ASSERT_VK_SUCCESS(err); |
| 2461 | |
| 2462 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2463 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2464 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2465 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2466 | alloc_info.descriptorPool = ds_pool; |
| 2467 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2468 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2469 | ASSERT_VK_SUCCESS(err); |
| 2470 | |
| 2471 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 2472 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2473 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2474 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 2475 | |
| 2476 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2477 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2478 | ASSERT_VK_SUCCESS(err); |
| 2479 | |
| 2480 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 2481 | // Set scissor as dynamic to avoid second error |
| 2482 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 2483 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 2484 | dyn_state_ci.dynamicStateCount = 1; |
| 2485 | dyn_state_ci.pDynamicStates = &sc_state; |
| 2486 | |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2487 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 2488 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2489 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2490 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, this); |
| 2491 | 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] | 2492 | // but add it to be able to run on more devices |
Chia-I Wu | 062ad15 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2493 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 2494 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2495 | |
| 2496 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 2497 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2498 | gp_ci.stageCount = 2; |
| 2499 | gp_ci.pStages = shaderStages; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2500 | gp_ci.pViewportState = NULL; // Not setting VP state w/o dynamic vp state should cause validation error |
| 2501 | gp_ci.pDynamicState = &dyn_state_ci; |
| 2502 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2503 | gp_ci.layout = pipeline_layout; |
| 2504 | gp_ci.renderPass = renderPass(); |
| 2505 | |
| 2506 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 2507 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 2508 | |
| 2509 | VkPipeline pipeline; |
| 2510 | VkPipelineCache pipelineCache; |
| 2511 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2512 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2513 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2514 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2515 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2516 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2517 | FAIL() << "Did not receive Error 'Gfx Pipeline pViewportState is null. Even if...'"; |
| 2518 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2519 | } |
| 2520 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2521 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2522 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2523 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2524 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2525 | } |
| 2526 | // Create PSO w/o non-zero viewportCount but no viewport data |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2527 | // Then run second test where dynamic scissor count doesn't match PSO scissor count |
| 2528 | TEST_F(VkLayerTest, PSOViewportCountWithoutDataAndDynScissorMismatch) |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2529 | { |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2530 | VkResult err; |
| 2531 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2532 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2533 | "Gfx Pipeline viewportCount is 1, but pViewports is NULL. "); |
| 2534 | |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2535 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2536 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2537 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2538 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2539 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2540 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2541 | |
| 2542 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2543 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2544 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2545 | ds_pool_ci.poolSizeCount = 1; |
| 2546 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2547 | |
| 2548 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2549 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2550 | ASSERT_VK_SUCCESS(err); |
| 2551 | |
| 2552 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2553 | dsl_binding.binding = 0; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2554 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 2555 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2556 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2557 | |
| 2558 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2559 | 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] | 2560 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2561 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2562 | |
| 2563 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2564 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2565 | ASSERT_VK_SUCCESS(err); |
| 2566 | |
| 2567 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2568 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2569 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2570 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2571 | alloc_info.descriptorPool = ds_pool; |
| 2572 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2573 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2574 | ASSERT_VK_SUCCESS(err); |
| 2575 | |
| 2576 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 2577 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2578 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2579 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 2580 | |
| 2581 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2582 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2583 | ASSERT_VK_SUCCESS(err); |
| 2584 | |
| 2585 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 2586 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 2587 | vp_state_ci.viewportCount = 1; |
| 2588 | vp_state_ci.pViewports = NULL; // Null vp w/ count of 1 should cause error |
| 2589 | vp_state_ci.scissorCount = 1; |
| 2590 | vp_state_ci.pScissors = NULL; // Scissor is dynamic (below) so this won't cause error |
| 2591 | |
| 2592 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 2593 | // Set scissor as dynamic to avoid that error |
| 2594 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 2595 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 2596 | dyn_state_ci.dynamicStateCount = 1; |
| 2597 | dyn_state_ci.pDynamicStates = &sc_state; |
| 2598 | |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2599 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 2600 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2601 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2602 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, this); |
| 2603 | 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] | 2604 | // but add it to be able to run on more devices |
Chia-I Wu | 062ad15 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2605 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 2606 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2607 | |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2608 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 2609 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 2610 | vi_ci.pNext = nullptr; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2611 | vi_ci.vertexBindingDescriptionCount = 0; |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2612 | vi_ci.pVertexBindingDescriptions = nullptr; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2613 | vi_ci.vertexAttributeDescriptionCount = 0; |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2614 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 2615 | |
| 2616 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 2617 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 2618 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 2619 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2620 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2621 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2622 | rs_ci.pNext = nullptr; |
| 2623 | |
| 2624 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 2625 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 2626 | cb_ci.pNext = nullptr; |
| 2627 | |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 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; |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2632 | gp_ci.pVertexInputState = &vi_ci; |
| 2633 | gp_ci.pInputAssemblyState = &ia_ci; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2634 | gp_ci.pViewportState = &vp_state_ci; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2635 | gp_ci.pRasterizationState = &rs_ci; |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2636 | gp_ci.pColorBlendState = &cb_ci; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2637 | gp_ci.pDynamicState = &dyn_state_ci; |
| 2638 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2639 | gp_ci.layout = pipeline_layout; |
| 2640 | gp_ci.renderPass = renderPass(); |
| 2641 | |
| 2642 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 2643 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 2644 | |
| 2645 | VkPipeline pipeline; |
| 2646 | VkPipelineCache pipelineCache; |
| 2647 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2648 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2649 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2650 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2651 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2652 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2653 | FAIL() << "Did not recieve Error 'Gfx Pipeline viewportCount is 1, but pViewports is NULL...'"; |
| 2654 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2655 | } |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2656 | |
| 2657 | |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2658 | // Now hit second fail case where we set scissor w/ different count than PSO |
| 2659 | // First need to successfully create the PSO from above by setting pViewports |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2660 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2661 | "Dynamic scissorCount from vkCmdSetScissor() is 2, but PSO scissorCount is 1. These counts must match."); |
| 2662 | |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2663 | VkViewport vp = {}; // Just need dummy vp to point to |
| 2664 | vp_state_ci.pViewports = &vp; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2665 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2666 | ASSERT_VK_SUCCESS(err); |
| 2667 | BeginCommandBuffer(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2668 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2669 | VkRect2D scissors[2] = {}; // don't care about data |
| 2670 | // Count of 2 doesn't match PSO count of 1 |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2671 | vkCmdSetScissor(m_commandBuffer->GetBufferHandle(), 2, scissors); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2672 | Draw(1, 0, 0, 0); |
| 2673 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2674 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2675 | FAIL() << "Did not receive Error 'Dynamic scissorCount from vkCmdSetScissor() is 2, but PSO scissorCount is 1...'"; |
| 2676 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2677 | } |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2678 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2679 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2680 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2681 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2682 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2683 | } |
| 2684 | // Create PSO w/o non-zero scissorCount but no scissor data |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2685 | // Then run second test where dynamic viewportCount doesn't match PSO viewportCount |
| 2686 | TEST_F(VkLayerTest, PSOScissorCountWithoutDataAndDynViewportMismatch) |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2687 | { |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2688 | VkResult err; |
| 2689 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2690 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2691 | "Gfx Pipeline scissorCount is 1, but pScissors is NULL. "); |
| 2692 | |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2693 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2694 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2695 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2696 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2697 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2698 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2699 | |
| 2700 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2701 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2702 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2703 | ds_pool_ci.poolSizeCount = 1; |
| 2704 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2705 | |
| 2706 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2707 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2708 | ASSERT_VK_SUCCESS(err); |
| 2709 | |
| 2710 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2711 | dsl_binding.binding = 0; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2712 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 2713 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2714 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2715 | |
| 2716 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2717 | 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] | 2718 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2719 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2720 | |
| 2721 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2722 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2723 | ASSERT_VK_SUCCESS(err); |
| 2724 | |
| 2725 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2726 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 2727 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2728 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2729 | alloc_info.descriptorPool = ds_pool; |
| 2730 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2731 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2732 | ASSERT_VK_SUCCESS(err); |
| 2733 | |
| 2734 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 2735 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2736 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2737 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 2738 | |
| 2739 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2740 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2741 | ASSERT_VK_SUCCESS(err); |
| 2742 | |
| 2743 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 2744 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 2745 | vp_state_ci.scissorCount = 1; |
| 2746 | vp_state_ci.pScissors = NULL; // Null scissor w/ count of 1 should cause error |
| 2747 | vp_state_ci.viewportCount = 1; |
| 2748 | vp_state_ci.pViewports = NULL; // vp is dynamic (below) so this won't cause error |
| 2749 | |
| 2750 | VkDynamicState vp_state = VK_DYNAMIC_STATE_VIEWPORT; |
| 2751 | // Set scissor as dynamic to avoid that error |
| 2752 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 2753 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 2754 | dyn_state_ci.dynamicStateCount = 1; |
| 2755 | dyn_state_ci.pDynamicStates = &vp_state; |
| 2756 | |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2757 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 2758 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2759 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2760 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, this); |
| 2761 | 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] | 2762 | // but add it to be able to run on more devices |
Chia-I Wu | 062ad15 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2763 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 2764 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2765 | |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2766 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 2767 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 2768 | vi_ci.pNext = nullptr; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2769 | vi_ci.vertexBindingDescriptionCount = 0; |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2770 | vi_ci.pVertexBindingDescriptions = nullptr; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2771 | vi_ci.vertexAttributeDescriptionCount = 0; |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2772 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 2773 | |
| 2774 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 2775 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 2776 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 2777 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2778 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2779 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2780 | rs_ci.pNext = nullptr; |
| 2781 | |
| 2782 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 2783 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 2784 | cb_ci.pNext = nullptr; |
| 2785 | |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2786 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 2787 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2788 | gp_ci.stageCount = 2; |
| 2789 | gp_ci.pStages = shaderStages; |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2790 | gp_ci.pVertexInputState = &vi_ci; |
| 2791 | gp_ci.pInputAssemblyState = &ia_ci; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2792 | gp_ci.pViewportState = &vp_state_ci; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2793 | gp_ci.pRasterizationState = &rs_ci; |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2794 | gp_ci.pColorBlendState = &cb_ci; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2795 | gp_ci.pDynamicState = &dyn_state_ci; |
| 2796 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2797 | gp_ci.layout = pipeline_layout; |
| 2798 | gp_ci.renderPass = renderPass(); |
| 2799 | |
| 2800 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 2801 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 2802 | |
| 2803 | VkPipeline pipeline; |
| 2804 | VkPipelineCache pipelineCache; |
| 2805 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2806 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2807 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2808 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2809 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2810 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2811 | FAIL() << "Did not recieve Error 'Gfx Pipeline scissorCount is 1, but pScissors is NULL...'"; |
| 2812 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2813 | } |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2814 | |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2815 | // Now hit second fail case where we set scissor w/ different count than PSO |
| 2816 | // First need to successfully create the PSO from above by setting pViewports |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2817 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2818 | "Dynamic viewportCount from vkCmdSetViewport() is 2, but PSO viewportCount is 1. These counts must match."); |
| 2819 | |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2820 | VkRect2D sc = {}; // Just need dummy vp to point to |
| 2821 | vp_state_ci.pScissors = ≻ |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2822 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2823 | ASSERT_VK_SUCCESS(err); |
| 2824 | BeginCommandBuffer(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2825 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2826 | VkViewport viewports[2] = {}; // don't care about data |
| 2827 | // Count of 2 doesn't match PSO count of 1 |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2828 | vkCmdSetViewport(m_commandBuffer->GetBufferHandle(), 2, viewports); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2829 | Draw(1, 0, 0, 0); |
| 2830 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2831 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2832 | FAIL() << "Did not receive Error 'Dynamic viewportCount from vkCmdSetViewport() is 2, but PSO viewportCount is 1...'"; |
| 2833 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2834 | } |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2835 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2836 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2837 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2838 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2839 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2840 | } |
| 2841 | |
Tobin Ehlis | b8b06b5 | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 2842 | TEST_F(VkLayerTest, NullRenderPass) |
| 2843 | { |
| 2844 | // Bind a NULL RenderPass |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2845 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2846 | "You cannot use a NULL RenderPass object in vkCmdBeginRenderPass()"); |
Tobin Ehlis | b8b06b5 | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 2847 | |
| 2848 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2849 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | b8b06b5 | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 2850 | |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 2851 | BeginCommandBuffer(); |
Tobin Ehlis | b8b06b5 | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 2852 | // 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] | 2853 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), NULL, VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | b8b06b5 | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 2854 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2855 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2856 | FAIL() << "Did not receive Error 'You cannot use a NULL RenderPass object in vkCmdBeginRenderPass()'"; |
| 2857 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | b8b06b5 | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 2858 | } |
| 2859 | } |
| 2860 | |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2861 | TEST_F(VkLayerTest, RenderPassWithinRenderPass) |
| 2862 | { |
| 2863 | // Bind a BeginRenderPass within an active RenderPass |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2864 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2865 | "It is invalid to issue this call inside an active render pass"); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2866 | |
| 2867 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2868 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2869 | |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 2870 | BeginCommandBuffer(); |
Tobin Ehlis | b8b06b5 | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 2871 | // 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] | 2872 | VkRenderPassBeginInfo rp_begin = {}; |
| 2873 | rp_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; |
| 2874 | rp_begin.pNext = NULL; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2875 | rp_begin.renderPass = renderPass(); |
| 2876 | rp_begin.framebuffer = framebuffer(); |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 2877 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2878 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &rp_begin, VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2879 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2880 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2881 | FAIL() << "Did not receive Error 'It is invalid to issue this call inside an active render pass...'"; |
| 2882 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 2883 | } |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2884 | } |
| 2885 | |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2886 | TEST_F(VkLayerTest, FillBufferWithinRenderPass) |
| 2887 | { |
| 2888 | // Call CmdFillBuffer within an active renderpass |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2889 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2890 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2891 | |
| 2892 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2893 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2894 | |
| 2895 | // Renderpass is started here |
| 2896 | BeginCommandBuffer(); |
| 2897 | |
| 2898 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2899 | vk_testing::Buffer dstBuffer; |
| 2900 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2901 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2902 | m_commandBuffer->FillBuffer(dstBuffer.handle(), 0, 4, 0x11111111); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2903 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2904 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2905 | FAIL() << "Did not receive Error 'It is invalid to issue this call inside an active render pass...'"; |
| 2906 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2907 | } |
| 2908 | } |
| 2909 | |
| 2910 | TEST_F(VkLayerTest, UpdateBufferWithinRenderPass) |
| 2911 | { |
| 2912 | // Call CmdUpdateBuffer within an active renderpass |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2913 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2914 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2915 | |
| 2916 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2917 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2918 | |
| 2919 | // Renderpass is started here |
| 2920 | BeginCommandBuffer(); |
| 2921 | |
| 2922 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2923 | vk_testing::Buffer dstBuffer; |
| 2924 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2925 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2926 | VkDeviceSize dstOffset = 0; |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2927 | VkDeviceSize dataSize = 1024; |
| 2928 | const uint32_t *pData = NULL; |
| 2929 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2930 | vkCmdUpdateBuffer(m_commandBuffer->GetBufferHandle(), dstBuffer.handle(), dstOffset, dataSize, pData); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2931 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2932 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2933 | FAIL() << "Did not receive Error 'It is invalid to issue this call inside an active render pass...'"; |
| 2934 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2935 | } |
| 2936 | } |
| 2937 | |
| 2938 | TEST_F(VkLayerTest, ClearColorImageWithinRenderPass) |
| 2939 | { |
| 2940 | // Call CmdClearColorImage within an active RenderPass |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2941 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2942 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2943 | |
| 2944 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2945 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2946 | |
| 2947 | // Renderpass is started here |
| 2948 | BeginCommandBuffer(); |
| 2949 | |
| 2950 | VkClearColorValue clear_color = {0}; |
| 2951 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 2952 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2953 | const int32_t tex_width = 32; |
| 2954 | const int32_t tex_height = 32; |
| 2955 | VkImageCreateInfo image_create_info = {}; |
| 2956 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 2957 | image_create_info.pNext = NULL; |
| 2958 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2959 | image_create_info.format = tex_format; |
| 2960 | image_create_info.extent.width = tex_width; |
| 2961 | image_create_info.extent.height = tex_height; |
| 2962 | image_create_info.extent.depth = 1; |
| 2963 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 2964 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2965 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2966 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 2967 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 2968 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2969 | vk_testing::Image dstImage; |
| 2970 | dstImage.init(*m_device, (const VkImageCreateInfo&)image_create_info, reqs); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2971 | |
| 2972 | const VkImageSubresourceRange range = |
| 2973 | vk_testing::Image::subresource_range(image_create_info, VK_IMAGE_ASPECT_COLOR_BIT); |
| 2974 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2975 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), |
| 2976 | dstImage.handle(), |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2977 | VK_IMAGE_LAYOUT_GENERAL, |
| 2978 | &clear_color, |
| 2979 | 1, |
| 2980 | &range); |
| 2981 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2982 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2983 | FAIL() << "Did not receive Error 'It is invalid to issue this call inside an active render pass...'"; |
| 2984 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2985 | } |
| 2986 | } |
| 2987 | |
| 2988 | TEST_F(VkLayerTest, ClearDepthStencilImageWithinRenderPass) |
| 2989 | { |
| 2990 | // Call CmdClearDepthStencilImage within an active RenderPass |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2991 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2992 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2993 | |
| 2994 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2995 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2996 | |
| 2997 | // Renderpass is started here |
| 2998 | BeginCommandBuffer(); |
| 2999 | |
| 3000 | VkClearDepthStencilValue clear_value = {0}; |
| 3001 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 3002 | VkImageCreateInfo image_create_info = vk_testing::Image::create_info(); |
| 3003 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 3004 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 3005 | image_create_info.extent.width = 64; |
| 3006 | image_create_info.extent.height = 64; |
| 3007 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 3008 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 3009 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3010 | vk_testing::Image dstImage; |
| 3011 | dstImage.init(*m_device, (const VkImageCreateInfo&)image_create_info, reqs); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3012 | |
| 3013 | const VkImageSubresourceRange range = |
| 3014 | vk_testing::Image::subresource_range(image_create_info, VK_IMAGE_ASPECT_DEPTH_BIT); |
| 3015 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3016 | vkCmdClearDepthStencilImage(m_commandBuffer->GetBufferHandle(), |
| 3017 | dstImage.handle(), |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3018 | VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, |
| 3019 | &clear_value, |
| 3020 | 1, |
| 3021 | &range); |
| 3022 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3023 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3024 | FAIL() << "Did not receive Error 'It is invalid to issue this call inside an active render pass...'"; |
| 3025 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3026 | } |
| 3027 | } |
| 3028 | |
| 3029 | TEST_F(VkLayerTest, ClearColorAttachmentsOutsideRenderPass) |
| 3030 | { |
Courtney Goeltzenleuchter | 9feb073 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 3031 | // Call CmdClearAttachmentss outside of an active RenderPass |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3032 | VkResult err; |
| 3033 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3034 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3035 | "vkCmdClearAttachments: This call must be issued inside an active render pass"); |
| 3036 | |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3037 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3038 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3039 | |
| 3040 | // Start no RenderPass |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3041 | err = m_commandBuffer->BeginCommandBuffer(); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3042 | ASSERT_VK_SUCCESS(err); |
| 3043 | |
Courtney Goeltzenleuchter | 9feb073 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 3044 | VkClearAttachment color_attachment; |
| 3045 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 3046 | color_attachment.clearValue.color.float32[0] = 0; |
| 3047 | color_attachment.clearValue.color.float32[1] = 0; |
| 3048 | color_attachment.clearValue.color.float32[2] = 0; |
| 3049 | color_attachment.clearValue.color.float32[3] = 0; |
| 3050 | color_attachment.colorAttachment = 0; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 3051 | VkClearRect clear_rect = { { { 0, 0 }, { 32, 32 } } }; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3052 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), |
Courtney Goeltzenleuchter | 9feb073 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 3053 | 1, &color_attachment, |
| 3054 | 1, &clear_rect); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3055 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3056 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3057 | FAIL() << "Did not receive Error 'vkCmdClearAttachments: This call must be issued inside an active render pass.'"; |
| 3058 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 3059 | } |
| 3060 | } |
| 3061 | |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3062 | TEST_F(VkLayerTest, InvalidDynamicStateObject) |
| 3063 | { |
| 3064 | // Create a valid cmd buffer |
| 3065 | // call vkCmdBindDynamicStateObject w/ false DS Obj |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 3066 | // TODO : Simple check for bad object should be added to ObjectTracker to catch this case |
| 3067 | // 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] | 3068 | } |
Tobin Ehlis | 201b1ba | 2015-05-27 14:55:35 -0600 | [diff] [blame] | 3069 | |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3070 | TEST_F(VkLayerTest, IdxBufferAlignmentError) |
| 3071 | { |
| 3072 | // Bind a BeginRenderPass within an active RenderPass |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3073 | VkResult err; |
| 3074 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3075 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3076 | "vkCmdBindIndexBuffer() offset (0x7) does not fall on "); |
| 3077 | |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3078 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3079 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3080 | uint32_t qfi = 0; |
| 3081 | VkBufferCreateInfo buffCI = {}; |
| 3082 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 3083 | buffCI.size = 1024; |
| 3084 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3085 | buffCI.queueFamilyIndexCount = 1; |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3086 | buffCI.pQueueFamilyIndices = &qfi; |
| 3087 | |
| 3088 | VkBuffer ib; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3089 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3090 | ASSERT_VK_SUCCESS(err); |
| 3091 | |
| 3092 | BeginCommandBuffer(); |
| 3093 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3094 | //vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3095 | // 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] | 3096 | vkCmdBindIndexBuffer(m_commandBuffer->GetBufferHandle(), ib, 7, VK_INDEX_TYPE_UINT16); |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3097 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3098 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3099 | FAIL() << "Did not receive Error 'vkCmdBindIndexBuffer() offset (0x7) does not fall on ...'"; |
| 3100 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3101 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3102 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3103 | vkDestroyBuffer(m_device->device(), ib, NULL); |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 3104 | } |
| 3105 | |
Tobin Ehlis | 5f728d3 | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 3106 | TEST_F(VkLayerTest, ExecuteCommandsPrimaryCB) |
| 3107 | { |
| 3108 | // Attempt vkCmdExecuteCommands w/ a primary cmd buffer (should only be secondary) |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3109 | |
| 3110 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3111 | "vkCmdExecuteCommands() called w/ Primary Cmd Buffer "); |
Tobin Ehlis | 5f728d3 | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 3112 | |
| 3113 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3114 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 5f728d3 | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 3115 | |
| 3116 | BeginCommandBuffer(); |
| 3117 | //ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3118 | VkCommandBuffer primCB = m_commandBuffer->GetBufferHandle(); |
| 3119 | vkCmdExecuteCommands(m_commandBuffer->GetBufferHandle(), 1, &primCB); |
Tobin Ehlis | 5f728d3 | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 3120 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3121 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3122 | FAIL() << "Did not receive Error 'vkCmdExecuteCommands() called w/ Primary Cmd Buffer '"; |
| 3123 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 5f728d3 | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 3124 | } |
| 3125 | } |
| 3126 | |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3127 | TEST_F(VkLayerTest, DSTypeMismatch) |
| 3128 | { |
| 3129 | // 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] | 3130 | VkResult err; |
| 3131 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3132 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3133 | "Write descriptor update has descriptor type VK_DESCRIPTOR_TYPE_SAMPLER that does not match "); |
| 3134 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3135 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3136 | //VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3137 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3138 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3139 | ds_type_count.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3140 | |
| 3141 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3142 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3143 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3144 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3145 | ds_pool_ci.poolSizeCount = 1; |
| 3146 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3147 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3148 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3149 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3150 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3151 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3152 | dsl_binding.binding = 0; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3153 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 3154 | dsl_binding.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3155 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3156 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3157 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3158 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3159 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3160 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3161 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3162 | ds_layout_ci.pBinding = &dsl_binding; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3163 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3164 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3165 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3166 | ASSERT_VK_SUCCESS(err); |
| 3167 | |
| 3168 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3169 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3170 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3171 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3172 | alloc_info.descriptorPool = ds_pool; |
| 3173 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3174 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3175 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3176 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3177 | VkSamplerCreateInfo sampler_ci = {}; |
| 3178 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3179 | sampler_ci.pNext = NULL; |
Chia-I Wu | 3603b08 | 2015-10-26 16:49:32 +0800 | [diff] [blame] | 3180 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 3181 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 3182 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_BASE; |
Chia-I Wu | ce532f7 | 2015-10-26 17:32:47 +0800 | [diff] [blame] | 3183 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3184 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3185 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3186 | sampler_ci.mipLodBias = 1.0; |
| 3187 | sampler_ci.maxAnisotropy = 1; |
| 3188 | sampler_ci.compareEnable = VK_FALSE; |
| 3189 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3190 | sampler_ci.minLod = 1.0; |
| 3191 | sampler_ci.maxLod = 1.0; |
| 3192 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
Mark Lobodzinski | 513acdf | 2015-09-01 15:42:56 -0600 | [diff] [blame] | 3193 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
| 3194 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3195 | VkSampler sampler; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3196 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3197 | ASSERT_VK_SUCCESS(err); |
| 3198 | |
Courtney Goeltzenleuchter | 34aa5c8 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3199 | VkDescriptorImageInfo info = {}; |
| 3200 | info.sampler = sampler; |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3201 | |
| 3202 | VkWriteDescriptorSet descriptor_write; |
| 3203 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3204 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3205 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3206 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3207 | // This is a mismatched type for the layout which expects BUFFER |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3208 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 34aa5c8 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3209 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3210 | |
| 3211 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3212 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3213 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3214 | FAIL() << "Did not receive Error 'Write descriptor update has descriptor type VK_DESCRIPTOR_TYPE_SAMPLER that does not match...'"; |
| 3215 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3216 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3217 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3218 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3219 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3220 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3221 | } |
| 3222 | |
| 3223 | TEST_F(VkLayerTest, DSUpdateOutOfBounds) |
| 3224 | { |
| 3225 | // For overlapping Update, have arrayIndex exceed that of layout |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3226 | VkResult err; |
| 3227 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3228 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3229 | "Descriptor update type of VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET is out of bounds for matching binding"); |
| 3230 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3231 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3232 | //VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3233 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3234 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3235 | ds_type_count.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3236 | |
| 3237 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3238 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3239 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3240 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3241 | ds_pool_ci.poolSizeCount = 1; |
| 3242 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3243 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3244 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3245 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3246 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3247 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3248 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3249 | dsl_binding.binding = 0; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3250 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 3251 | dsl_binding.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3252 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3253 | dsl_binding.pImmutableSamplers = NULL; |
| 3254 | |
| 3255 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3256 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3257 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3258 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3259 | ds_layout_ci.pBinding = &dsl_binding; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3260 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3261 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3262 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3263 | ASSERT_VK_SUCCESS(err); |
| 3264 | |
| 3265 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3266 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3267 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3268 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3269 | alloc_info.descriptorPool = ds_pool; |
| 3270 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3271 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3272 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3273 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3274 | VkSamplerCreateInfo sampler_ci = {}; |
| 3275 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3276 | sampler_ci.pNext = NULL; |
Chia-I Wu | 3603b08 | 2015-10-26 16:49:32 +0800 | [diff] [blame] | 3277 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 3278 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 3279 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_BASE; |
Chia-I Wu | ce532f7 | 2015-10-26 17:32:47 +0800 | [diff] [blame] | 3280 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3281 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3282 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3283 | sampler_ci.mipLodBias = 1.0; |
| 3284 | sampler_ci.maxAnisotropy = 1; |
| 3285 | sampler_ci.compareEnable = VK_FALSE; |
| 3286 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3287 | sampler_ci.minLod = 1.0; |
| 3288 | sampler_ci.maxLod = 1.0; |
| 3289 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
Mark Lobodzinski | 513acdf | 2015-09-01 15:42:56 -0600 | [diff] [blame] | 3290 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3291 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3292 | VkSampler sampler; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3293 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3294 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3295 | |
Courtney Goeltzenleuchter | 34aa5c8 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3296 | VkDescriptorImageInfo info = {}; |
| 3297 | info.sampler = sampler; |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3298 | |
| 3299 | VkWriteDescriptorSet descriptor_write; |
| 3300 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3301 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3302 | descriptor_write.dstSet = descriptorSet; |
| 3303 | 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] | 3304 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3305 | // 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] | 3306 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 34aa5c8 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3307 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3308 | |
| 3309 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3310 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3311 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3312 | FAIL() << "Did not receive Error 'Descriptor update type of VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET is out of bounds for matching binding...'"; |
| 3313 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3314 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3315 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3316 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3317 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3318 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3319 | } |
| 3320 | |
| 3321 | TEST_F(VkLayerTest, InvalidDSUpdateIndex) |
| 3322 | { |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3323 | // 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] | 3324 | VkResult err; |
| 3325 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3326 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3327 | " does not have binding to match update binding "); |
| 3328 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3329 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3330 | //VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3331 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3332 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3333 | ds_type_count.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3334 | |
| 3335 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3336 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3337 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3338 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3339 | ds_pool_ci.poolSizeCount = 1; |
| 3340 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3341 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3342 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3343 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3344 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3345 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3346 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3347 | dsl_binding.binding = 0; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3348 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 3349 | dsl_binding.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3350 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3351 | dsl_binding.pImmutableSamplers = NULL; |
| 3352 | |
| 3353 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3354 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3355 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3356 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3357 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3358 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3359 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3360 | ASSERT_VK_SUCCESS(err); |
| 3361 | |
| 3362 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3363 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3364 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3365 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3366 | alloc_info.descriptorPool = ds_pool; |
| 3367 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3368 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3369 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3370 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3371 | VkSamplerCreateInfo sampler_ci = {}; |
| 3372 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3373 | sampler_ci.pNext = NULL; |
Chia-I Wu | 3603b08 | 2015-10-26 16:49:32 +0800 | [diff] [blame] | 3374 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 3375 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 3376 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_BASE; |
Chia-I Wu | ce532f7 | 2015-10-26 17:32:47 +0800 | [diff] [blame] | 3377 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3378 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3379 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3380 | sampler_ci.mipLodBias = 1.0; |
| 3381 | sampler_ci.maxAnisotropy = 1; |
| 3382 | sampler_ci.compareEnable = VK_FALSE; |
| 3383 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3384 | sampler_ci.minLod = 1.0; |
| 3385 | sampler_ci.maxLod = 1.0; |
| 3386 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
Mark Lobodzinski | 513acdf | 2015-09-01 15:42:56 -0600 | [diff] [blame] | 3387 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3388 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3389 | VkSampler sampler; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3390 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3391 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3392 | |
Courtney Goeltzenleuchter | 34aa5c8 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3393 | VkDescriptorImageInfo info = {}; |
| 3394 | info.sampler = sampler; |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3395 | |
| 3396 | VkWriteDescriptorSet descriptor_write; |
| 3397 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3398 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3399 | descriptor_write.dstSet = descriptorSet; |
| 3400 | descriptor_write.dstBinding = 2; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3401 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3402 | // 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] | 3403 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 34aa5c8 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3404 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3405 | |
| 3406 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3407 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3408 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3409 | FAIL() << "Did not receive Error 'Descriptor Set <blah> does not have binding to match update binding '"; |
| 3410 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3411 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3412 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3413 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3414 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3415 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3416 | } |
| 3417 | |
| 3418 | TEST_F(VkLayerTest, InvalidDSUpdateStruct) |
| 3419 | { |
| 3420 | // 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] | 3421 | VkResult err; |
| 3422 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3423 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3424 | "Unexpected UPDATE struct of type "); |
| 3425 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3426 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3427 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3428 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3429 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3430 | ds_type_count.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3431 | |
| 3432 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3433 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3434 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3435 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3436 | ds_pool_ci.poolSizeCount = 1; |
| 3437 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3438 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3439 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3440 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3441 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3442 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3443 | dsl_binding.binding = 0; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3444 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 3445 | dsl_binding.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3446 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3447 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3448 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3449 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3450 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3451 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3452 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3453 | ds_layout_ci.pBinding = &dsl_binding; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3454 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3455 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3456 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3457 | ASSERT_VK_SUCCESS(err); |
| 3458 | |
| 3459 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3460 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3461 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3462 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3463 | alloc_info.descriptorPool = ds_pool; |
| 3464 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3465 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3466 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3467 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3468 | VkSamplerCreateInfo sampler_ci = {}; |
| 3469 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3470 | sampler_ci.pNext = NULL; |
Chia-I Wu | 3603b08 | 2015-10-26 16:49:32 +0800 | [diff] [blame] | 3471 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 3472 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 3473 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_BASE; |
Chia-I Wu | ce532f7 | 2015-10-26 17:32:47 +0800 | [diff] [blame] | 3474 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3475 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3476 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3477 | sampler_ci.mipLodBias = 1.0; |
| 3478 | sampler_ci.maxAnisotropy = 1; |
| 3479 | sampler_ci.compareEnable = VK_FALSE; |
| 3480 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3481 | sampler_ci.minLod = 1.0; |
| 3482 | sampler_ci.maxLod = 1.0; |
| 3483 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
Mark Lobodzinski | 513acdf | 2015-09-01 15:42:56 -0600 | [diff] [blame] | 3484 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3485 | VkSampler sampler; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3486 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3487 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3488 | |
| 3489 | |
Courtney Goeltzenleuchter | 34aa5c8 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3490 | VkDescriptorImageInfo info = {}; |
| 3491 | info.sampler = sampler; |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3492 | |
| 3493 | VkWriteDescriptorSet descriptor_write; |
| 3494 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3495 | descriptor_write.sType = (VkStructureType)0x99999999; /* Intentionally broken struct type */ |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3496 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3497 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3498 | // 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] | 3499 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 34aa5c8 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3500 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3501 | |
| 3502 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3503 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3504 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3505 | FAIL() << "Did not receive Error 'Unexpected UPDATE struct of type '"; |
| 3506 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3507 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3508 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3509 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3510 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3511 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3512 | } |
| 3513 | |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3514 | TEST_F(VkLayerTest, SampleDescriptorUpdateError) |
| 3515 | { |
| 3516 | // Create a single Sampler descriptor and send it an invalid Sampler |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3517 | VkResult err; |
| 3518 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3519 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3520 | "Attempt to update descriptor with invalid sampler 0xbaadbeef"); |
| 3521 | |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3522 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3523 | // 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] | 3524 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3525 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3526 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3527 | |
| 3528 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3529 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3530 | ds_pool_ci.pNext = NULL; |
| 3531 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3532 | ds_pool_ci.poolSizeCount = 1; |
| 3533 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3534 | |
| 3535 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3536 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3537 | ASSERT_VK_SUCCESS(err); |
| 3538 | |
| 3539 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3540 | dsl_binding.binding = 0; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3541 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 3542 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3543 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3544 | dsl_binding.pImmutableSamplers = NULL; |
| 3545 | |
| 3546 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3547 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3548 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3549 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3550 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3551 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3552 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3553 | ASSERT_VK_SUCCESS(err); |
| 3554 | |
| 3555 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3556 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3557 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3558 | alloc_info.setLayoutCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3559 | alloc_info.descriptorPool = ds_pool; |
| 3560 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3561 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3562 | ASSERT_VK_SUCCESS(err); |
| 3563 | |
Chia-I Wu | e420a33 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 3564 | VkSampler sampler = (VkSampler) 0xbaadbeef; // Sampler with invalid handle |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3565 | |
| 3566 | VkDescriptorImageInfo descriptor_info; |
| 3567 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 3568 | descriptor_info.sampler = sampler; |
| 3569 | |
| 3570 | VkWriteDescriptorSet descriptor_write; |
| 3571 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3572 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3573 | descriptor_write.dstSet = descriptorSet; |
| 3574 | descriptor_write.dstBinding = 0; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3575 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3576 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 3577 | descriptor_write.pImageInfo = &descriptor_info; |
| 3578 | |
| 3579 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3580 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3581 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3582 | FAIL() << "Did not receive Error 'Attempt to update descriptor with invalid sampler...'"; |
| 3583 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3584 | } |
| 3585 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3586 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3587 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3588 | } |
| 3589 | |
| 3590 | TEST_F(VkLayerTest, ImageViewDescriptorUpdateError) |
| 3591 | { |
| 3592 | // 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] | 3593 | VkResult err; |
| 3594 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3595 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3596 | "Attempt to update descriptor with invalid imageView 0xbaadbeef"); |
| 3597 | |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3598 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3599 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3600 | ds_type_count.type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3601 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3602 | |
| 3603 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3604 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3605 | ds_pool_ci.pNext = NULL; |
| 3606 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3607 | ds_pool_ci.poolSizeCount = 1; |
| 3608 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3609 | |
| 3610 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3611 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3612 | ASSERT_VK_SUCCESS(err); |
| 3613 | |
| 3614 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3615 | dsl_binding.binding = 0; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3616 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 3617 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3618 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3619 | dsl_binding.pImmutableSamplers = NULL; |
| 3620 | |
| 3621 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3622 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3623 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3624 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3625 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3626 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3627 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3628 | ASSERT_VK_SUCCESS(err); |
| 3629 | |
| 3630 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3631 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3632 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3633 | alloc_info.setLayoutCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3634 | alloc_info.descriptorPool = ds_pool; |
| 3635 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3636 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3637 | ASSERT_VK_SUCCESS(err); |
| 3638 | |
| 3639 | VkSamplerCreateInfo sampler_ci = {}; |
| 3640 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3641 | sampler_ci.pNext = NULL; |
Chia-I Wu | 3603b08 | 2015-10-26 16:49:32 +0800 | [diff] [blame] | 3642 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 3643 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 3644 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_BASE; |
Chia-I Wu | ce532f7 | 2015-10-26 17:32:47 +0800 | [diff] [blame] | 3645 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3646 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3647 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3648 | sampler_ci.mipLodBias = 1.0; |
| 3649 | sampler_ci.maxAnisotropy = 1; |
| 3650 | sampler_ci.compareEnable = VK_FALSE; |
| 3651 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3652 | sampler_ci.minLod = 1.0; |
| 3653 | sampler_ci.maxLod = 1.0; |
| 3654 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 3655 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
| 3656 | |
| 3657 | VkSampler sampler; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3658 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3659 | ASSERT_VK_SUCCESS(err); |
| 3660 | |
Chia-I Wu | e420a33 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 3661 | VkImageView view = (VkImageView) 0xbaadbeef; // invalid imageView object |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3662 | |
| 3663 | VkDescriptorImageInfo descriptor_info; |
| 3664 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 3665 | descriptor_info.sampler = sampler; |
| 3666 | descriptor_info.imageView = view; |
| 3667 | |
| 3668 | VkWriteDescriptorSet descriptor_write; |
| 3669 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3670 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3671 | descriptor_write.dstSet = descriptorSet; |
| 3672 | descriptor_write.dstBinding = 0; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3673 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3674 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 3675 | descriptor_write.pImageInfo = &descriptor_info; |
| 3676 | |
| 3677 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3678 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3679 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3680 | FAIL() << "Did not receive Error 'Attempt to update descriptor with invalid imageView...'"; |
| 3681 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3682 | } |
| 3683 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3684 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3685 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3686 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3687 | } |
| 3688 | |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3689 | TEST_F(VkLayerTest, CopyDescriptorUpdateErrors) |
| 3690 | { |
| 3691 | // 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] | 3692 | VkResult err; |
| 3693 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3694 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3695 | "Copy descriptor update index 0, update count #1, has src update descriptor type VK_DESCRIPTOR_TYPE_SAMPLER "); |
| 3696 | |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3697 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3698 | //VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3699 | VkDescriptorPoolSize ds_type_count[2] = {}; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3700 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3701 | ds_type_count[0].descriptorCount = 1; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3702 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3703 | ds_type_count[1].descriptorCount = 1; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3704 | |
| 3705 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3706 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3707 | ds_pool_ci.pNext = NULL; |
| 3708 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3709 | ds_pool_ci.poolSizeCount = 2; |
| 3710 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3711 | |
| 3712 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3713 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3714 | ASSERT_VK_SUCCESS(err); |
| 3715 | VkDescriptorSetLayoutBinding dsl_binding[2] = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3716 | dsl_binding[0].binding = 0; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3717 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 3718 | dsl_binding[0].descriptorCount = 1; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3719 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 3720 | dsl_binding[0].pImmutableSamplers = NULL; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3721 | dsl_binding[1].binding = 1; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3722 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 3723 | dsl_binding[1].descriptorCount = 1; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3724 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 3725 | dsl_binding[1].pImmutableSamplers = NULL; |
| 3726 | |
| 3727 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3728 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3729 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3730 | ds_layout_ci.bindingCount = 2; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3731 | ds_layout_ci.pBinding = dsl_binding; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3732 | |
| 3733 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3734 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3735 | ASSERT_VK_SUCCESS(err); |
| 3736 | |
| 3737 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3738 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3739 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3740 | alloc_info.setLayoutCount = 1; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3741 | alloc_info.descriptorPool = ds_pool; |
| 3742 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3743 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3744 | ASSERT_VK_SUCCESS(err); |
| 3745 | |
| 3746 | VkSamplerCreateInfo sampler_ci = {}; |
| 3747 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3748 | sampler_ci.pNext = NULL; |
Chia-I Wu | 3603b08 | 2015-10-26 16:49:32 +0800 | [diff] [blame] | 3749 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 3750 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 3751 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_BASE; |
Chia-I Wu | ce532f7 | 2015-10-26 17:32:47 +0800 | [diff] [blame] | 3752 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3753 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3754 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3755 | sampler_ci.mipLodBias = 1.0; |
| 3756 | sampler_ci.maxAnisotropy = 1; |
| 3757 | sampler_ci.compareEnable = VK_FALSE; |
| 3758 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3759 | sampler_ci.minLod = 1.0; |
| 3760 | sampler_ci.maxLod = 1.0; |
| 3761 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 3762 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
| 3763 | |
| 3764 | VkSampler sampler; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3765 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3766 | ASSERT_VK_SUCCESS(err); |
| 3767 | |
| 3768 | VkDescriptorImageInfo info = {}; |
| 3769 | info.sampler = sampler; |
| 3770 | |
| 3771 | VkWriteDescriptorSet descriptor_write; |
| 3772 | memset(&descriptor_write, 0, sizeof(VkWriteDescriptorSet)); |
| 3773 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3774 | descriptor_write.dstSet = descriptorSet; |
| 3775 | descriptor_write.dstBinding = 1; // SAMPLER binding from layout above |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3776 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3777 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 3778 | descriptor_write.pImageInfo = &info; |
| 3779 | // This write update should succeed |
| 3780 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3781 | // Now perform a copy update that fails due to type mismatch |
| 3782 | VkCopyDescriptorSet copy_ds_update; |
| 3783 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 3784 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 3785 | copy_ds_update.srcSet = descriptorSet; |
| 3786 | copy_ds_update.srcBinding = 1; // copy from SAMPLER binding |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3787 | copy_ds_update.dstSet = descriptorSet; |
| 3788 | copy_ds_update.dstBinding = 0; // ERROR : copy to UNIFORM binding |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3789 | copy_ds_update.descriptorCount = 1; // copy 1 descriptor |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3790 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 3791 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3792 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3793 | FAIL() << "Did not receive Error 'Copy descriptor update index 0, update count #1, has src update descriptor type_DESCRIPTOR_TYPE_SAMPLER'"; |
| 3794 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3795 | } |
| 3796 | // 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] | 3797 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3798 | "Copy descriptor update 0 has srcBinding 3 which is out of bounds "); |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3799 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 3800 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 3801 | copy_ds_update.srcSet = descriptorSet; |
| 3802 | copy_ds_update.srcBinding = 3; // ERROR : Invalid binding for matching layout |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3803 | copy_ds_update.dstSet = descriptorSet; |
| 3804 | copy_ds_update.dstBinding = 0; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3805 | copy_ds_update.descriptorCount = 1; // copy 1 descriptor |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3806 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 3807 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3808 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3809 | FAIL() << "Did not receive Error 'Copy descriptor update 0 has srcBinding 3 which is out of bounds...'"; |
| 3810 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3811 | } |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3812 | |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3813 | // 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] | 3814 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3815 | "Copy descriptor src update is out of bounds for matching binding 1 "); |
| 3816 | |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3817 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 3818 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 3819 | copy_ds_update.srcSet = descriptorSet; |
| 3820 | copy_ds_update.srcBinding = 1; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3821 | copy_ds_update.dstSet = descriptorSet; |
| 3822 | copy_ds_update.dstBinding = 0; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3823 | 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] | 3824 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 3825 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3826 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3827 | FAIL() << "Did not receive Error 'Copy descriptor src update is out of bounds for matching binding 1...'"; |
| 3828 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3829 | } |
| 3830 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3831 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3832 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3833 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3834 | } |
| 3835 | |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3836 | TEST_F(VkLayerTest, NumSamplesMismatch) |
| 3837 | { |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3838 | // Create CommandBuffer where MSAA samples doesn't match RenderPass sampleCount |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3839 | VkResult err; |
| 3840 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3841 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3842 | "Num samples mismatch! "); |
| 3843 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3844 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3845 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3846 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3847 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3848 | ds_type_count.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3849 | |
| 3850 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3851 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3852 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3853 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3854 | ds_pool_ci.poolSizeCount = 1; |
| 3855 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3856 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3857 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3858 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3859 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3860 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3861 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3862 | dsl_binding.binding = 0; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3863 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 3864 | dsl_binding.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3865 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3866 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3867 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3868 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3869 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3870 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3871 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3872 | ds_layout_ci.pBinding = &dsl_binding; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3873 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3874 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3875 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3876 | ASSERT_VK_SUCCESS(err); |
| 3877 | |
| 3878 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3879 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3880 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3881 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3882 | alloc_info.descriptorPool = ds_pool; |
| 3883 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3884 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3885 | ASSERT_VK_SUCCESS(err); |
| 3886 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3887 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 3888 | pipe_ms_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 3889 | pipe_ms_state_ci.pNext = NULL; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3890 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3891 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 3892 | pipe_ms_state_ci.minSampleShading = 1.0; |
Cody Northrop | e9825b7 | 2015-08-04 14:34:54 -0600 | [diff] [blame] | 3893 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3894 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3895 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 3896 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3897 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3898 | pipeline_layout_ci.setLayoutCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3899 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3900 | |
| 3901 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3902 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3903 | ASSERT_VK_SUCCESS(err); |
| 3904 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 3905 | VkShaderObj vs(m_device, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 3906 | 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] | 3907 | // but add it to be able to run on more devices |
Tony Barbour | d7d828b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 3908 | VkPipelineObj pipe(m_device); |
| 3909 | pipe.AddShader(&vs); |
Tony Barbour | 3c9e3b1 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 3910 | pipe.AddShader(&fs); |
Tony Barbour | d7d828b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 3911 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 3912 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3913 | |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 3914 | BeginCommandBuffer(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3915 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3916 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3917 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3918 | FAIL() << "Did not recieve Error 'Num samples mismatch!...'"; |
| 3919 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3920 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3921 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3922 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3923 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3924 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3925 | } |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3926 | |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3927 | TEST_F(VkLayerTest, ClearCmdNoDraw) |
| 3928 | { |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3929 | // 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] | 3930 | VkResult err; |
| 3931 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3932 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_WARN_BIT, |
| 3933 | "vkCmdClearAttachments() issued on CB object "); |
| 3934 | |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3935 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3936 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3937 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3938 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3939 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3940 | ds_type_count.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3941 | |
| 3942 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3943 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3944 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3945 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3946 | ds_pool_ci.poolSizeCount = 1; |
| 3947 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3948 | |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3949 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3950 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3951 | ASSERT_VK_SUCCESS(err); |
| 3952 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3953 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3954 | dsl_binding.binding = 0; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3955 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 3956 | dsl_binding.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3957 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3958 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3959 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3960 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3961 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3962 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3963 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3964 | ds_layout_ci.pBinding = &dsl_binding; |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3965 | |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3966 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3967 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3968 | ASSERT_VK_SUCCESS(err); |
| 3969 | |
| 3970 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3971 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 3972 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3973 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3974 | alloc_info.descriptorPool = ds_pool; |
| 3975 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3976 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3977 | ASSERT_VK_SUCCESS(err); |
| 3978 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3979 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 3980 | pipe_ms_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 3981 | pipe_ms_state_ci.pNext = NULL; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3982 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3983 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 3984 | pipe_ms_state_ci.minSampleShading = 1.0; |
Cody Northrop | e9825b7 | 2015-08-04 14:34:54 -0600 | [diff] [blame] | 3985 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3986 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3987 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 3988 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3989 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3990 | pipeline_layout_ci.setLayoutCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3991 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3992 | |
| 3993 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3994 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3995 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3996 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 3997 | VkShaderObj vs(m_device, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3998 | // TODO - We shouldn't need a fragment shader but add it to be able to run on more devices |
| 3999 | VkShaderObj fs(m_device, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 4000 | |
Tony Barbour | d7d828b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4001 | VkPipelineObj pipe(m_device); |
| 4002 | pipe.AddShader(&vs); |
Tony Barbour | 3c9e3b1 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 4003 | pipe.AddShader(&fs); |
Tony Barbour | d7d828b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4004 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 4005 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4006 | |
| 4007 | BeginCommandBuffer(); |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4008 | |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4009 | // Main thing we care about for this test is that the VkImage obj we're clearing matches Color Attachment of FB |
| 4010 | // Also pass down other dummy params to keep driver and paramchecker happy |
Courtney Goeltzenleuchter | 9feb073 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 4011 | VkClearAttachment color_attachment; |
| 4012 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 4013 | color_attachment.clearValue.color.float32[0] = 1.0; |
| 4014 | color_attachment.clearValue.color.float32[1] = 1.0; |
| 4015 | color_attachment.clearValue.color.float32[2] = 1.0; |
| 4016 | color_attachment.clearValue.color.float32[3] = 1.0; |
| 4017 | color_attachment.colorAttachment = 0; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 4018 | VkClearRect clear_rect = { { { 0, 0 }, { (int)m_width, (int)m_height } } }; |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4019 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4020 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4021 | |
| 4022 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4023 | FAIL() << "Did not receive Error 'vkCommandClearAttachments() issued on CB object...'"; |
| 4024 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4025 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 4026 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4027 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4028 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4029 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 4030 | } |
| 4031 | |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4032 | TEST_F(VkLayerTest, VtxBufferBadIndex) |
| 4033 | { |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4034 | // Create CommandBuffer where MSAA samples doesn't match RenderPass sampleCount |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4035 | VkResult err; |
| 4036 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4037 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4038 | "Vtx Buffer Index 1 was bound, but no vtx buffers are attached to PSO."); |
| 4039 | |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4040 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4041 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4042 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4043 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4044 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4045 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4046 | ds_type_count.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4047 | |
| 4048 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 4049 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 4050 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 4051 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 4052 | ds_pool_ci.poolSizeCount = 1; |
| 4053 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4054 | |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 4055 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4056 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4057 | ASSERT_VK_SUCCESS(err); |
| 4058 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4059 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4060 | dsl_binding.binding = 0; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4061 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 4062 | dsl_binding.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4063 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 4064 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4065 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4066 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 4067 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 4068 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4069 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4070 | ds_layout_ci.pBinding = &dsl_binding; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4071 | |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4072 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4073 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4074 | ASSERT_VK_SUCCESS(err); |
| 4075 | |
| 4076 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4077 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 4078 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4079 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 4080 | alloc_info.descriptorPool = ds_pool; |
| 4081 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4082 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4083 | ASSERT_VK_SUCCESS(err); |
| 4084 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4085 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 4086 | pipe_ms_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 4087 | pipe_ms_state_ci.pNext = NULL; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4088 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4089 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 4090 | pipe_ms_state_ci.minSampleShading = 1.0; |
Cody Northrop | e9825b7 | 2015-08-04 14:34:54 -0600 | [diff] [blame] | 4091 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4092 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4093 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 4094 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 4095 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 4096 | pipeline_layout_ci.setLayoutCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 4097 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 4098 | VkPipelineLayout pipeline_layout; |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4099 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4100 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4101 | ASSERT_VK_SUCCESS(err); |
| 4102 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4103 | VkShaderObj vs(m_device, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4104 | 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] | 4105 | // but add it to be able to run on more devices |
Tony Barbour | d7d828b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4106 | VkPipelineObj pipe(m_device); |
| 4107 | pipe.AddShader(&vs); |
Tony Barbour | 3c9e3b1 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 4108 | pipe.AddShader(&fs); |
Tony Barbour | d7d828b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4109 | pipe.SetMSAA(&pipe_ms_state_ci); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 4110 | pipe.SetViewport(m_viewports); |
| 4111 | pipe.SetScissor(m_scissors); |
Tony Barbour | d7d828b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 4112 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 4113 | |
| 4114 | BeginCommandBuffer(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4115 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | d28acef | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 4116 | // Don't care about actual data, just need to get to draw to flag error |
| 4117 | static const float vbo_data[3] = {1.f, 0.f, 1.f}; |
| 4118 | VkConstantBufferObj vbo(m_device, sizeof(vbo_data), sizeof(float), (const void*) &vbo_data); |
| 4119 | 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] | 4120 | Draw(1, 0, 0, 0); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4121 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4122 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4123 | FAIL() << "Did not receive Error 'Vtx Buffer Index 0 was bound, but no vtx buffers are attached to PSO.'"; |
| 4124 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4125 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 4126 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4127 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 4128 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 4129 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 4130 | } |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4131 | #endif // DRAW_STATE_TESTS |
| 4132 | |
Tobin Ehlis | 57e6a61 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 4133 | #if THREADING_TESTS |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4134 | #if GTEST_IS_THREADSAFE |
| 4135 | struct thread_data_struct { |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4136 | VkCommandBuffer commandBuffer; |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4137 | VkEvent event; |
| 4138 | bool bailout; |
| 4139 | }; |
| 4140 | |
| 4141 | extern "C" void *AddToCommandBuffer(void *arg) |
| 4142 | { |
| 4143 | struct thread_data_struct *data = (struct thread_data_struct *) arg; |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4144 | |
| 4145 | for (int i = 0; i<10000; i++) { |
Chia-I Wu | cba6cea | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4146 | vkCmdSetEvent(data->commandBuffer, data->event, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4147 | if (data->bailout) { |
| 4148 | break; |
| 4149 | } |
| 4150 | } |
| 4151 | return NULL; |
| 4152 | } |
| 4153 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4154 | TEST_F(VkLayerTest, ThreadCommandBufferCollision) |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4155 | { |
Mike Stroyan | 7016f4f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 4156 | test_platform_thread thread; |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4157 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4158 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, "THREADING ERROR"); |
| 4159 | |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4160 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4161 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 4162 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4163 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4164 | // Calls AllocateCommandBuffers |
| 4165 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Mark Lobodzinski | a0f061c | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 4166 | |
| 4167 | // Avoid creating RenderPass |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4168 | commandBuffer.BeginCommandBuffer(); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4169 | |
| 4170 | VkEventCreateInfo event_info; |
| 4171 | VkEvent event; |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4172 | VkResult err; |
| 4173 | |
| 4174 | memset(&event_info, 0, sizeof(event_info)); |
| 4175 | event_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 4176 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4177 | err = vkCreateEvent(device(), &event_info, NULL, &event); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4178 | ASSERT_VK_SUCCESS(err); |
| 4179 | |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4180 | err = vkResetEvent(device(), event); |
| 4181 | ASSERT_VK_SUCCESS(err); |
| 4182 | |
| 4183 | struct thread_data_struct data; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4184 | data.commandBuffer = commandBuffer.GetBufferHandle(); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4185 | data.event = event; |
| 4186 | data.bailout = false; |
| 4187 | m_errorMonitor->SetBailout(&data.bailout); |
| 4188 | // Add many entries to command buffer from another thread. |
Mike Stroyan | 7016f4f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 4189 | test_platform_thread_create(&thread, AddToCommandBuffer, (void *)&data); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4190 | // Add many entries to command buffer from this thread at the same time. |
| 4191 | AddToCommandBuffer(&data); |
Mark Lobodzinski | a0f061c | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 4192 | |
Mike Stroyan | 7016f4f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 4193 | test_platform_thread_join(thread, NULL); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4194 | commandBuffer.EndCommandBuffer(); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4195 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4196 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4197 | FAIL() << "Did not receive Error 'THREADING ERROR' from using one VkCommandBufferObj in two threads"; |
| 4198 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4199 | } |
| 4200 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4201 | vkDestroyEvent(device(), event, NULL); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4202 | } |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4203 | #endif // GTEST_IS_THREADSAFE |
| 4204 | #endif // THREADING_TESTS |
| 4205 | |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4206 | #if SHADER_CHECKER_TESTS |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4207 | TEST_F(VkLayerTest, InvalidSPIRVCodeSize) |
| 4208 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4209 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4210 | "Shader is not SPIR-V"); |
| 4211 | |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4212 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4213 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4214 | |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4215 | VkShaderModule module; |
| 4216 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 4217 | struct icd_spv_header spv; |
| 4218 | |
| 4219 | spv.magic = ICD_SPV_MAGIC; |
| 4220 | spv.version = ICD_SPV_VERSION; |
| 4221 | spv.gen_magic = 0; |
| 4222 | |
| 4223 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 4224 | moduleCreateInfo.pNext = NULL; |
Chia-I Wu | 036b161 | 2015-10-26 19:22:06 +0800 | [diff] [blame] | 4225 | moduleCreateInfo.pCode = (const uint32_t *) &spv; |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4226 | moduleCreateInfo.codeSize = 4; |
| 4227 | moduleCreateInfo.flags = 0; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4228 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4229 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4230 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4231 | FAIL() << "Did not recieive Error 'Shader is not SPIR-V'"; |
| 4232 | m_errorMonitor->DumpFailureMsgs(); |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4233 | } |
| 4234 | } |
| 4235 | |
| 4236 | TEST_F(VkLayerTest, InvalidSPIRVMagic) |
| 4237 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4238 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4239 | "Shader is not SPIR-V"); |
| 4240 | |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4241 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4242 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4243 | |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4244 | VkShaderModule module; |
| 4245 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 4246 | struct icd_spv_header spv; |
| 4247 | |
| 4248 | spv.magic = ~ICD_SPV_MAGIC; |
| 4249 | spv.version = ICD_SPV_VERSION; |
| 4250 | spv.gen_magic = 0; |
| 4251 | |
| 4252 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 4253 | moduleCreateInfo.pNext = NULL; |
Chia-I Wu | 036b161 | 2015-10-26 19:22:06 +0800 | [diff] [blame] | 4254 | moduleCreateInfo.pCode = (const uint32_t *) &spv; |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4255 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 4256 | moduleCreateInfo.flags = 0; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4257 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4258 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4259 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4260 | FAIL() << "Did not recieive Error 'Shader is not SPIR-V'"; |
| 4261 | m_errorMonitor->DumpFailureMsgs(); |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4262 | } |
| 4263 | } |
| 4264 | |
| 4265 | TEST_F(VkLayerTest, InvalidSPIRVVersion) |
| 4266 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4267 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4268 | "Shader is not SPIR-V"); |
| 4269 | |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4270 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4271 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4272 | |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4273 | VkShaderModule module; |
| 4274 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 4275 | struct icd_spv_header spv; |
| 4276 | |
| 4277 | spv.magic = ICD_SPV_MAGIC; |
| 4278 | spv.version = ~ICD_SPV_VERSION; |
| 4279 | spv.gen_magic = 0; |
| 4280 | |
| 4281 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 4282 | moduleCreateInfo.pNext = NULL; |
| 4283 | |
Chia-I Wu | 036b161 | 2015-10-26 19:22:06 +0800 | [diff] [blame] | 4284 | moduleCreateInfo.pCode = (const uint32_t *) &spv; |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4285 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 4286 | moduleCreateInfo.flags = 0; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4287 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4288 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4289 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4290 | FAIL() << "Did not recieive Error 'Shader is not SPIR-V'"; |
| 4291 | m_errorMonitor->DumpFailureMsgs(); |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4292 | } |
| 4293 | } |
| 4294 | |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4295 | TEST_F(VkLayerTest, CreatePipelineVertexOutputNotConsumed) |
| 4296 | { |
Tony Barbour | 192f02b | 2015-11-06 14:21:31 -0700 | [diff] [blame] | 4297 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_PERF_WARN_BIT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4298 | "not consumed by fragment shader"); |
| 4299 | |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4300 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4301 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4302 | |
| 4303 | char const *vsSource = |
| 4304 | "#version 140\n" |
| 4305 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4306 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4307 | "\n" |
| 4308 | "layout(location=0) out float x;\n" |
| 4309 | "void main(){\n" |
| 4310 | " gl_Position = vec4(1);\n" |
| 4311 | " x = 0;\n" |
| 4312 | "}\n"; |
| 4313 | char const *fsSource = |
| 4314 | "#version 140\n" |
| 4315 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4316 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4317 | "\n" |
| 4318 | "layout(location=0) out vec4 color;\n" |
| 4319 | "void main(){\n" |
| 4320 | " color = vec4(1);\n" |
| 4321 | "}\n"; |
| 4322 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4323 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4324 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4325 | |
| 4326 | VkPipelineObj pipe(m_device); |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4327 | pipe.AddColorAttachment(); |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4328 | pipe.AddShader(&vs); |
| 4329 | pipe.AddShader(&fs); |
| 4330 | |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4331 | VkDescriptorSetObj descriptorSet(m_device); |
| 4332 | descriptorSet.AppendDummy(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4333 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4334 | |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4335 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4336 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4337 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4338 | FAIL() << "Did not receive Warning 'not consumed by fragment shader'"; |
| 4339 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4340 | } |
| 4341 | } |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4342 | |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4343 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvided) |
| 4344 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4345 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4346 | "not written by vertex shader"); |
| 4347 | |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4348 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4349 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4350 | |
| 4351 | char const *vsSource = |
| 4352 | "#version 140\n" |
| 4353 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4354 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4355 | "\n" |
| 4356 | "void main(){\n" |
| 4357 | " gl_Position = vec4(1);\n" |
| 4358 | "}\n"; |
| 4359 | char const *fsSource = |
| 4360 | "#version 140\n" |
| 4361 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4362 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4363 | "\n" |
| 4364 | "layout(location=0) in float x;\n" |
| 4365 | "layout(location=0) out vec4 color;\n" |
| 4366 | "void main(){\n" |
| 4367 | " color = vec4(x);\n" |
| 4368 | "}\n"; |
| 4369 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4370 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4371 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4372 | |
| 4373 | VkPipelineObj pipe(m_device); |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4374 | pipe.AddColorAttachment(); |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4375 | pipe.AddShader(&vs); |
| 4376 | pipe.AddShader(&fs); |
| 4377 | |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4378 | VkDescriptorSetObj descriptorSet(m_device); |
| 4379 | descriptorSet.AppendDummy(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4380 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4381 | |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4382 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4383 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4384 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4385 | FAIL() << "Did not receive Error 'not written by vertex shader'"; |
| 4386 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4387 | } |
| 4388 | } |
| 4389 | |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4390 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatch) |
| 4391 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4392 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4393 | "Type mismatch on location 0"); |
| 4394 | |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4395 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4396 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4397 | |
| 4398 | char const *vsSource = |
| 4399 | "#version 140\n" |
| 4400 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4401 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4402 | "\n" |
| 4403 | "layout(location=0) out int x;\n" |
| 4404 | "void main(){\n" |
| 4405 | " x = 0;\n" |
| 4406 | " gl_Position = vec4(1);\n" |
| 4407 | "}\n"; |
| 4408 | char const *fsSource = |
| 4409 | "#version 140\n" |
| 4410 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4411 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4412 | "\n" |
| 4413 | "layout(location=0) in float x;\n" /* VS writes int */ |
| 4414 | "layout(location=0) out vec4 color;\n" |
| 4415 | "void main(){\n" |
| 4416 | " color = vec4(x);\n" |
| 4417 | "}\n"; |
| 4418 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4419 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4420 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4421 | |
| 4422 | VkPipelineObj pipe(m_device); |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4423 | pipe.AddColorAttachment(); |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4424 | pipe.AddShader(&vs); |
| 4425 | pipe.AddShader(&fs); |
| 4426 | |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4427 | VkDescriptorSetObj descriptorSet(m_device); |
| 4428 | descriptorSet.AppendDummy(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4429 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4430 | |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4431 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4432 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4433 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4434 | FAIL() << "Did not receive Error 'Type mismatch on location 0'"; |
| 4435 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4436 | } |
| 4437 | } |
| 4438 | |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4439 | TEST_F(VkLayerTest, CreatePipelineAttribNotConsumed) |
| 4440 | { |
Tony Barbour | 192f02b | 2015-11-06 14:21:31 -0700 | [diff] [blame] | 4441 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_PERF_WARN_BIT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4442 | "location 0 not consumed by VS"); |
| 4443 | |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4444 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4445 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4446 | |
| 4447 | VkVertexInputBindingDescription input_binding; |
| 4448 | memset(&input_binding, 0, sizeof(input_binding)); |
| 4449 | |
| 4450 | VkVertexInputAttributeDescription input_attrib; |
| 4451 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 4452 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 4453 | |
| 4454 | char const *vsSource = |
| 4455 | "#version 140\n" |
| 4456 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4457 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4458 | "\n" |
| 4459 | "void main(){\n" |
| 4460 | " gl_Position = vec4(1);\n" |
| 4461 | "}\n"; |
| 4462 | char const *fsSource = |
| 4463 | "#version 140\n" |
| 4464 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4465 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4466 | "\n" |
| 4467 | "layout(location=0) out vec4 color;\n" |
| 4468 | "void main(){\n" |
| 4469 | " color = vec4(1);\n" |
| 4470 | "}\n"; |
| 4471 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4472 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4473 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4474 | |
| 4475 | VkPipelineObj pipe(m_device); |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4476 | pipe.AddColorAttachment(); |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4477 | pipe.AddShader(&vs); |
| 4478 | pipe.AddShader(&fs); |
| 4479 | |
| 4480 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 4481 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 4482 | |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4483 | VkDescriptorSetObj descriptorSet(m_device); |
| 4484 | descriptorSet.AppendDummy(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4485 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4486 | |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4487 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4488 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4489 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4490 | FAIL() << "Did not receive Warning 'location 0 not consumed by VS'"; |
| 4491 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4492 | } |
| 4493 | } |
| 4494 | |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4495 | TEST_F(VkLayerTest, CreatePipelineAttribNotProvided) |
| 4496 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4497 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4498 | "VS consumes input at location 0 but not provided"); |
| 4499 | |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4500 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4501 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4502 | |
| 4503 | char const *vsSource = |
| 4504 | "#version 140\n" |
| 4505 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4506 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4507 | "\n" |
| 4508 | "layout(location=0) in vec4 x;\n" /* not provided */ |
| 4509 | "void main(){\n" |
| 4510 | " gl_Position = x;\n" |
| 4511 | "}\n"; |
| 4512 | char const *fsSource = |
| 4513 | "#version 140\n" |
| 4514 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4515 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4516 | "\n" |
| 4517 | "layout(location=0) out vec4 color;\n" |
| 4518 | "void main(){\n" |
| 4519 | " color = vec4(1);\n" |
| 4520 | "}\n"; |
| 4521 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4522 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4523 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4524 | |
| 4525 | VkPipelineObj pipe(m_device); |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4526 | pipe.AddColorAttachment(); |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4527 | pipe.AddShader(&vs); |
| 4528 | pipe.AddShader(&fs); |
| 4529 | |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4530 | VkDescriptorSetObj descriptorSet(m_device); |
| 4531 | descriptorSet.AppendDummy(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4532 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4533 | |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4534 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4535 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4536 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4537 | FAIL() << "Did not receive Error 'VS consumes input at location 0 but not provided'"; |
| 4538 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4539 | } |
| 4540 | } |
| 4541 | |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4542 | TEST_F(VkLayerTest, CreatePipelineAttribTypeMismatch) |
| 4543 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4544 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4545 | "location 0 does not match VS input type"); |
| 4546 | |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4547 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4548 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4549 | |
| 4550 | VkVertexInputBindingDescription input_binding; |
| 4551 | memset(&input_binding, 0, sizeof(input_binding)); |
| 4552 | |
| 4553 | VkVertexInputAttributeDescription input_attrib; |
| 4554 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 4555 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 4556 | |
| 4557 | char const *vsSource = |
| 4558 | "#version 140\n" |
| 4559 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4560 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4561 | "\n" |
| 4562 | "layout(location=0) in int x;\n" /* attrib provided float */ |
| 4563 | "void main(){\n" |
| 4564 | " gl_Position = vec4(x);\n" |
| 4565 | "}\n"; |
| 4566 | char const *fsSource = |
| 4567 | "#version 140\n" |
| 4568 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4569 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4570 | "\n" |
| 4571 | "layout(location=0) out vec4 color;\n" |
| 4572 | "void main(){\n" |
| 4573 | " color = vec4(1);\n" |
| 4574 | "}\n"; |
| 4575 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4576 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4577 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4578 | |
| 4579 | VkPipelineObj pipe(m_device); |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4580 | pipe.AddColorAttachment(); |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4581 | pipe.AddShader(&vs); |
| 4582 | pipe.AddShader(&fs); |
| 4583 | |
| 4584 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 4585 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 4586 | |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4587 | VkDescriptorSetObj descriptorSet(m_device); |
| 4588 | descriptorSet.AppendDummy(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4589 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4590 | |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4591 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4592 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4593 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4594 | FAIL() << "Did not receive Error 'location 0 does not match VS input type'"; |
| 4595 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4596 | } |
| 4597 | } |
| 4598 | |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4599 | TEST_F(VkLayerTest, CreatePipelineAttribBindingConflict) |
| 4600 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4601 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4602 | "Duplicate vertex input binding descriptions for binding 0"); |
| 4603 | |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4604 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4605 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4606 | |
| 4607 | /* Two binding descriptions for binding 0 */ |
| 4608 | VkVertexInputBindingDescription input_bindings[2]; |
| 4609 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 4610 | |
| 4611 | VkVertexInputAttributeDescription input_attrib; |
| 4612 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 4613 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 4614 | |
| 4615 | char const *vsSource = |
| 4616 | "#version 140\n" |
| 4617 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4618 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4619 | "\n" |
| 4620 | "layout(location=0) in float x;\n" /* attrib provided float */ |
| 4621 | "void main(){\n" |
| 4622 | " gl_Position = vec4(x);\n" |
| 4623 | "}\n"; |
| 4624 | char const *fsSource = |
| 4625 | "#version 140\n" |
| 4626 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4627 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4628 | "\n" |
| 4629 | "layout(location=0) out vec4 color;\n" |
| 4630 | "void main(){\n" |
| 4631 | " color = vec4(1);\n" |
| 4632 | "}\n"; |
| 4633 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4634 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4635 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4636 | |
| 4637 | VkPipelineObj pipe(m_device); |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4638 | pipe.AddColorAttachment(); |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4639 | pipe.AddShader(&vs); |
| 4640 | pipe.AddShader(&fs); |
| 4641 | |
| 4642 | pipe.AddVertexInputBindings(input_bindings, 2); |
| 4643 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 4644 | |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4645 | VkDescriptorSetObj descriptorSet(m_device); |
| 4646 | descriptorSet.AppendDummy(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4647 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4648 | |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4649 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4650 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4651 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4652 | FAIL() << "Did not receive Error 'Duplicate vertex input binding descriptions for binding 0'"; |
| 4653 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4654 | } |
| 4655 | } |
Chris Forbes | 4c94870 | 2015-05-25 11:13:32 +1200 | [diff] [blame] | 4656 | |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4657 | /* TODO: would be nice to test the mixed broadcast & custom case, but the GLSL->SPV compiler |
| 4658 | * rejects it. */ |
| 4659 | |
| 4660 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotWritten) |
| 4661 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4662 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4663 | "Attachment 0 not written by FS"); |
| 4664 | |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4665 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4666 | |
| 4667 | char const *vsSource = |
| 4668 | "#version 140\n" |
| 4669 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4670 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4671 | "\n" |
| 4672 | "void main(){\n" |
| 4673 | " gl_Position = vec4(1);\n" |
| 4674 | "}\n"; |
| 4675 | char const *fsSource = |
| 4676 | "#version 140\n" |
| 4677 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4678 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4679 | "\n" |
| 4680 | "void main(){\n" |
| 4681 | "}\n"; |
| 4682 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4683 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4684 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4685 | |
| 4686 | VkPipelineObj pipe(m_device); |
| 4687 | pipe.AddShader(&vs); |
| 4688 | pipe.AddShader(&fs); |
| 4689 | |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4690 | /* set up CB 0, not written */ |
| 4691 | pipe.AddColorAttachment(); |
| 4692 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4693 | |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4694 | VkDescriptorSetObj descriptorSet(m_device); |
| 4695 | descriptorSet.AppendDummy(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4696 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4697 | |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4698 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4699 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4700 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4701 | FAIL() << "Did not receive Error 'Attachment 0 not written by FS'"; |
| 4702 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4703 | } |
| 4704 | } |
| 4705 | |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4706 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotConsumed) |
| 4707 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4708 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_WARN_BIT, |
| 4709 | "FS writes to output location 1 with no matching attachment"); |
| 4710 | |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4711 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4712 | |
| 4713 | char const *vsSource = |
| 4714 | "#version 140\n" |
| 4715 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4716 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4717 | "\n" |
| 4718 | "void main(){\n" |
| 4719 | " gl_Position = vec4(1);\n" |
| 4720 | "}\n"; |
| 4721 | char const *fsSource = |
| 4722 | "#version 140\n" |
| 4723 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4724 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4725 | "\n" |
| 4726 | "layout(location=0) out vec4 x;\n" |
| 4727 | "layout(location=1) out vec4 y;\n" /* no matching attachment for this */ |
| 4728 | "void main(){\n" |
| 4729 | " x = vec4(1);\n" |
| 4730 | " y = vec4(1);\n" |
| 4731 | "}\n"; |
| 4732 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4733 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4734 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4735 | |
| 4736 | VkPipelineObj pipe(m_device); |
| 4737 | pipe.AddShader(&vs); |
| 4738 | pipe.AddShader(&fs); |
| 4739 | |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4740 | /* set up CB 0, not written */ |
| 4741 | pipe.AddColorAttachment(); |
| 4742 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4743 | /* FS writes CB 1, but we don't configure it */ |
| 4744 | |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4745 | VkDescriptorSetObj descriptorSet(m_device); |
| 4746 | descriptorSet.AppendDummy(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4747 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4748 | |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4749 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4750 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4751 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4752 | FAIL() << "Did not receive Error 'FS writes to output location 1 with no matching attachment'"; |
| 4753 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4754 | } |
| 4755 | } |
| 4756 | |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4757 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputTypeMismatch) |
| 4758 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4759 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4760 | "does not match FS output type"); |
| 4761 | |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4762 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4763 | |
| 4764 | char const *vsSource = |
| 4765 | "#version 140\n" |
| 4766 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4767 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4768 | "\n" |
| 4769 | "void main(){\n" |
| 4770 | " gl_Position = vec4(1);\n" |
| 4771 | "}\n"; |
| 4772 | char const *fsSource = |
| 4773 | "#version 140\n" |
| 4774 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4775 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4776 | "\n" |
| 4777 | "layout(location=0) out ivec4 x;\n" /* not UNORM */ |
| 4778 | "void main(){\n" |
| 4779 | " x = ivec4(1);\n" |
| 4780 | "}\n"; |
| 4781 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4782 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4783 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4784 | |
| 4785 | VkPipelineObj pipe(m_device); |
| 4786 | pipe.AddShader(&vs); |
| 4787 | pipe.AddShader(&fs); |
| 4788 | |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4789 | /* set up CB 0; type is UNORM by default */ |
| 4790 | pipe.AddColorAttachment(); |
| 4791 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4792 | |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4793 | VkDescriptorSetObj descriptorSet(m_device); |
| 4794 | descriptorSet.AppendDummy(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4795 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4796 | |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4797 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4798 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4799 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4800 | FAIL() << "Did not receive Error 'does not match FS output type'"; |
| 4801 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4802 | } |
| 4803 | } |
Chris Forbes | c205073 | 2015-06-05 14:43:36 +1200 | [diff] [blame] | 4804 | |
Chris Forbes | 76ce788 | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 4805 | TEST_F(VkLayerTest, CreatePipelineUniformBlockNotProvided) |
| 4806 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4807 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4808 | "not declared in pipeline layout"); |
| 4809 | |
Chris Forbes | 76ce788 | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 4810 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 76ce788 | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 4811 | |
| 4812 | char const *vsSource = |
| 4813 | "#version 140\n" |
| 4814 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4815 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4816 | "\n" |
| 4817 | "void main(){\n" |
| 4818 | " gl_Position = vec4(1);\n" |
| 4819 | "}\n"; |
| 4820 | char const *fsSource = |
| 4821 | "#version 140\n" |
| 4822 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4823 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4824 | "\n" |
| 4825 | "layout(location=0) out vec4 x;\n" |
| 4826 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 4827 | "void main(){\n" |
| 4828 | " x = vec4(bar.y);\n" |
| 4829 | "}\n"; |
| 4830 | |
Chris Forbes | 76ce788 | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 4831 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4832 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4833 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 76ce788 | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 4834 | |
Chris Forbes | 76ce788 | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 4835 | VkPipelineObj pipe(m_device); |
| 4836 | pipe.AddShader(&vs); |
| 4837 | pipe.AddShader(&fs); |
| 4838 | |
| 4839 | /* set up CB 0; type is UNORM by default */ |
| 4840 | pipe.AddColorAttachment(); |
| 4841 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4842 | |
| 4843 | VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4844 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 76ce788 | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 4845 | |
| 4846 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 4847 | |
| 4848 | /* should have generated an error -- pipeline layout does not |
| 4849 | * provide a uniform buffer in 0.0 |
| 4850 | */ |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4851 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4852 | FAIL() << "Did not receive Error 'not declared in pipeline layout'"; |
| 4853 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 76ce788 | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 4854 | } |
| 4855 | } |
| 4856 | |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4857 | #endif // SHADER_CHECKER_TESTS |
| 4858 | |
| 4859 | #if DEVICE_LIMITS_TESTS |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4860 | TEST_F(VkLayerTest, CreateImageLimitsViolationWidth) |
| 4861 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4862 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4863 | "CreateImage extents exceed allowable limits for format"); |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4864 | |
| 4865 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4866 | |
| 4867 | // Create an image |
| 4868 | VkImage image; |
| 4869 | |
| 4870 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 4871 | const int32_t tex_width = 32; |
| 4872 | const int32_t tex_height = 32; |
| 4873 | |
| 4874 | VkImageCreateInfo image_create_info = {}; |
| 4875 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4876 | image_create_info.pNext = NULL; |
| 4877 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4878 | image_create_info.format = tex_format; |
| 4879 | image_create_info.extent.width = tex_width; |
| 4880 | image_create_info.extent.height = tex_height; |
| 4881 | image_create_info.extent.depth = 1; |
| 4882 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 4883 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4884 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4885 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 4886 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 4887 | image_create_info.flags = 0; |
| 4888 | |
| 4889 | // Introduce error by sending down a bogus width extent |
| 4890 | image_create_info.extent.width = 65536; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4891 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4892 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4893 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4894 | FAIL() << "Did not receive Error 'CreateImage extents exceed allowable limits for format'"; |
| 4895 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4896 | } |
| 4897 | } |
| 4898 | |
| 4899 | TEST_F(VkLayerTest, CreateImageResourceSizeViolation) |
| 4900 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4901 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4902 | "CreateImage resource size exceeds allowable maximum"); |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4903 | |
| 4904 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4905 | |
| 4906 | // Create an image |
| 4907 | VkImage image; |
| 4908 | |
| 4909 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 4910 | const int32_t tex_width = 32; |
| 4911 | const int32_t tex_height = 32; |
| 4912 | |
| 4913 | VkImageCreateInfo image_create_info = {}; |
| 4914 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4915 | image_create_info.pNext = NULL; |
| 4916 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4917 | image_create_info.format = tex_format; |
| 4918 | image_create_info.extent.width = tex_width; |
| 4919 | image_create_info.extent.height = tex_height; |
| 4920 | image_create_info.extent.depth = 1; |
| 4921 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 4922 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4923 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4924 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 4925 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 4926 | image_create_info.flags = 0; |
| 4927 | |
| 4928 | // Introduce error by sending down individually allowable values that result in a surface size |
| 4929 | // exceeding the device maximum |
| 4930 | image_create_info.extent.width = 8192; |
| 4931 | image_create_info.extent.height = 8192; |
| 4932 | image_create_info.extent.depth = 16; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 4933 | image_create_info.arrayLayers = 4; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4934 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4935 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4936 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4937 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4938 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4939 | FAIL() << "Did not receive Error 'CreateImage resource size exceeds allowable maximum'"; |
| 4940 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4941 | } |
| 4942 | } |
| 4943 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4944 | TEST_F(VkLayerTest, UpdateBufferAlignment) |
| 4945 | { |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4946 | uint32_t updateData[] = { 1, 2, 3, 4, 5, 6, 7, 8 }; |
| 4947 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4948 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4949 | "dstOffset, is not a multiple of 4"); |
| 4950 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4951 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4952 | |
| 4953 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 4954 | vk_testing::Buffer buffer; |
| 4955 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 4956 | |
| 4957 | BeginCommandBuffer(); |
| 4958 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4959 | m_commandBuffer->UpdateBuffer(buffer.handle(), 1, 4, updateData); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4960 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4961 | FAIL() << "Did not receive Error 'vkCommandUpdateBuffer parameter, VkDeviceSize dstOffset, is not a multiple of 4'"; |
| 4962 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4963 | } |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4964 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4965 | // Introduce failure by using size that is not multiple of 4 |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4966 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4967 | "dataSize, is not a multiple of 4"); |
| 4968 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4969 | m_commandBuffer->UpdateBuffer(buffer.handle(), 0, 6, updateData); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4970 | |
| 4971 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4972 | FAIL() << "Did not receive Error 'vkCommandUpdateBuffer parameter, VkDeviceSize dataSize, is not a multiple of 4'"; |
| 4973 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4974 | } |
| 4975 | EndCommandBuffer(); |
| 4976 | } |
| 4977 | |
| 4978 | TEST_F(VkLayerTest, FillBufferAlignment) |
| 4979 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4980 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4981 | "dstOffset, is not a multiple of 4"); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4982 | |
| 4983 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4984 | |
| 4985 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 4986 | vk_testing::Buffer buffer; |
| 4987 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 4988 | |
| 4989 | BeginCommandBuffer(); |
| 4990 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4991 | m_commandBuffer->FillBuffer(buffer.handle(), 1, 4, 0x11111111); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4992 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4993 | FAIL() << "Did not receive Error 'vkCommandFillBuffer parameter, VkDeviceSize dstOffset, is not a multiple of 4'"; |
| 4994 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4995 | } |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4996 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4997 | // Introduce failure by using size that is not multiple of 4 |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4998 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4999 | "size, is not a multiple of 4"); |
| 5000 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5001 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 6, 0x11111111); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5002 | |
| 5003 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5004 | FAIL() << "Did not receive Error 'vkCommandFillBuffer parameter, VkDeviceSize size, is not a multiple of 4'"; |
| 5005 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5006 | } |
| 5007 | EndCommandBuffer(); |
| 5008 | } |
| 5009 | |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 5010 | #endif // DEVICE_LIMITS_TESTS |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 5011 | |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 5012 | #if IMAGE_TESTS |
| 5013 | TEST_F(VkLayerTest, InvalidImageView) |
| 5014 | { |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 5015 | VkResult err; |
| 5016 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5017 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 5018 | "vkCreateImageView called with baseMipLevel 10 "); |
| 5019 | |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 5020 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 5021 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5022 | // Create an image and try to create a view with bad baseMipLevel |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 5023 | VkImage image; |
| 5024 | |
| 5025 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5026 | const int32_t tex_width = 32; |
| 5027 | const int32_t tex_height = 32; |
| 5028 | |
| 5029 | VkImageCreateInfo image_create_info = {}; |
| 5030 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5031 | image_create_info.pNext = NULL; |
| 5032 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5033 | image_create_info.format = tex_format; |
| 5034 | image_create_info.extent.width = tex_width; |
| 5035 | image_create_info.extent.height = tex_height; |
| 5036 | image_create_info.extent.depth = 1; |
| 5037 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 5038 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5039 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 5040 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 5041 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 5042 | image_create_info.flags = 0; |
| 5043 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5044 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 5045 | ASSERT_VK_SUCCESS(err); |
| 5046 | |
| 5047 | VkImageViewCreateInfo image_view_create_info = {}; |
| 5048 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5049 | image_view_create_info.image = image; |
| 5050 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 5051 | image_view_create_info.format = tex_format; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5052 | image_view_create_info.subresourceRange.layerCount = 1; |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 5053 | image_view_create_info.subresourceRange.baseMipLevel = 10; // cause an error |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5054 | image_view_create_info.subresourceRange.levelCount = 1; |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 5055 | image_view_create_info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 5056 | |
| 5057 | VkImageView view; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5058 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, &view); |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 5059 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5060 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5061 | FAIL() << "Did not receive Error 'vkCreateImageView called with baseMipLevel 10...'"; |
| 5062 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 5063 | } |
| 5064 | } |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5065 | |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 5066 | TEST_F(VkLayerTest, InvalidImageViewAspect) |
| 5067 | { |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 5068 | VkResult err; |
| 5069 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5070 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 5071 | "vkCreateImageView: Color image formats must have ONLY the VK_IMAGE_ASPECT_COLOR_BIT set"); |
| 5072 | |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 5073 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 5074 | |
| 5075 | // Create an image and try to create a view with an invalid aspectMask |
| 5076 | VkImage image; |
| 5077 | |
| 5078 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5079 | const int32_t tex_width = 32; |
| 5080 | const int32_t tex_height = 32; |
| 5081 | |
| 5082 | VkImageCreateInfo image_create_info = {}; |
| 5083 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5084 | image_create_info.pNext = NULL; |
| 5085 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5086 | image_create_info.format = tex_format; |
| 5087 | image_create_info.extent.width = tex_width; |
| 5088 | image_create_info.extent.height = tex_height; |
| 5089 | image_create_info.extent.depth = 1; |
| 5090 | image_create_info.mipLevels = 1; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5091 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 5092 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 5093 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 5094 | image_create_info.flags = 0; |
| 5095 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5096 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 5097 | ASSERT_VK_SUCCESS(err); |
| 5098 | |
| 5099 | VkImageViewCreateInfo image_view_create_info = {}; |
| 5100 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5101 | image_view_create_info.image = image; |
| 5102 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 5103 | image_view_create_info.format = tex_format; |
| 5104 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5105 | image_view_create_info.subresourceRange.levelCount = 1; |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 5106 | // Cause an error by setting an invalid image aspect |
| 5107 | image_view_create_info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_METADATA_BIT; |
| 5108 | |
| 5109 | VkImageView view; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5110 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, &view); |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 5111 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5112 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5113 | FAIL() << "Did not receive Error 'VkCreateImageView: Color image formats must have ...'"; |
| 5114 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 5115 | } |
| 5116 | } |
| 5117 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5118 | TEST_F(VkLayerTest, CopyImageTypeMismatch) |
| 5119 | { |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5120 | VkResult err; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5121 | bool pass; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5122 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5123 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 5124 | "vkCmdCopyImage called with unmatched source and dest image types"); |
| 5125 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5126 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5127 | |
| 5128 | // Create two images of different types and try to copy between them |
| 5129 | VkImage srcImage; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5130 | VkImage dstImage; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5131 | VkDeviceMemory srcMem; |
| 5132 | VkDeviceMemory destMem; |
| 5133 | VkMemoryRequirements memReqs; |
| 5134 | |
| 5135 | VkImageCreateInfo image_create_info = {}; |
| 5136 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5137 | image_create_info.pNext = NULL; |
| 5138 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5139 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5140 | image_create_info.extent.width = 32; |
| 5141 | image_create_info.extent.height = 32; |
| 5142 | image_create_info.extent.depth = 1; |
| 5143 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 5144 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5145 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5146 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5147 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5148 | image_create_info.flags = 0; |
| 5149 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5150 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5151 | ASSERT_VK_SUCCESS(err); |
| 5152 | |
| 5153 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5154 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5155 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5156 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5157 | ASSERT_VK_SUCCESS(err); |
| 5158 | |
| 5159 | // Allocate memory |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5160 | VkMemoryAllocateInfo memAlloc = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5161 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5162 | memAlloc.pNext = NULL; |
| 5163 | memAlloc.allocationSize = 0; |
| 5164 | memAlloc.memoryTypeIndex = 0; |
| 5165 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 5166 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5167 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5168 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5169 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5170 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5171 | ASSERT_VK_SUCCESS(err); |
| 5172 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5173 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5174 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5175 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5176 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5177 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5178 | ASSERT_VK_SUCCESS(err); |
| 5179 | |
| 5180 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 5181 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5182 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5183 | ASSERT_VK_SUCCESS(err); |
| 5184 | |
| 5185 | BeginCommandBuffer(); |
| 5186 | VkImageCopy copyRegion; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5187 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5188 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 63f0ead | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5189 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5190 | copyRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5191 | copyRegion.srcOffset.x = 0; |
| 5192 | copyRegion.srcOffset.y = 0; |
| 5193 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5194 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5195 | copyRegion.dstSubresource.mipLevel = 0; |
| 5196 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 5197 | copyRegion.dstSubresource.layerCount = 0; |
| 5198 | copyRegion.dstOffset.x = 0; |
| 5199 | copyRegion.dstOffset.y = 0; |
| 5200 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5201 | copyRegion.extent.width = 1; |
| 5202 | copyRegion.extent.height = 1; |
| 5203 | copyRegion.extent.depth = 1; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5204 | 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] | 5205 | EndCommandBuffer(); |
| 5206 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5207 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5208 | FAIL() << "Did not receive Error 'vkCmdCopyImage called with unmatched source and dest image types'"; |
| 5209 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5210 | } |
| 5211 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5212 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5213 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5214 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 5215 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5216 | } |
| 5217 | |
| 5218 | TEST_F(VkLayerTest, CopyImageFormatSizeMismatch) |
| 5219 | { |
| 5220 | // TODO : Create two images with different format sizes and vkCmdCopyImage between them |
| 5221 | } |
| 5222 | |
| 5223 | TEST_F(VkLayerTest, CopyImageDepthStencilFormatMismatch) |
| 5224 | { |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5225 | VkResult err; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5226 | bool pass; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5227 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5228 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 5229 | "vkCmdCopyImage called with unmatched source and dest image types"); |
| 5230 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5231 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5232 | |
| 5233 | // Create two images of different types and try to copy between them |
| 5234 | VkImage srcImage; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5235 | VkImage dstImage; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5236 | VkDeviceMemory srcMem; |
| 5237 | VkDeviceMemory destMem; |
| 5238 | VkMemoryRequirements memReqs; |
| 5239 | |
| 5240 | VkImageCreateInfo image_create_info = {}; |
| 5241 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5242 | image_create_info.pNext = NULL; |
| 5243 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5244 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5245 | image_create_info.extent.width = 32; |
| 5246 | image_create_info.extent.height = 32; |
| 5247 | image_create_info.extent.depth = 1; |
| 5248 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 5249 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5250 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5251 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5252 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5253 | image_create_info.flags = 0; |
| 5254 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5255 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5256 | ASSERT_VK_SUCCESS(err); |
| 5257 | |
| 5258 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5259 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5260 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5261 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5262 | ASSERT_VK_SUCCESS(err); |
| 5263 | |
| 5264 | // Allocate memory |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5265 | VkMemoryAllocateInfo memAlloc = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5266 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5267 | memAlloc.pNext = NULL; |
| 5268 | memAlloc.allocationSize = 0; |
| 5269 | memAlloc.memoryTypeIndex = 0; |
| 5270 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 5271 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5272 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5273 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5274 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5275 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5276 | ASSERT_VK_SUCCESS(err); |
| 5277 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5278 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5279 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5280 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5281 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5282 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5283 | ASSERT_VK_SUCCESS(err); |
| 5284 | |
| 5285 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 5286 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5287 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5288 | ASSERT_VK_SUCCESS(err); |
| 5289 | |
| 5290 | BeginCommandBuffer(); |
| 5291 | VkImageCopy copyRegion; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5292 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5293 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 63f0ead | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5294 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5295 | copyRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5296 | copyRegion.srcOffset.x = 0; |
| 5297 | copyRegion.srcOffset.y = 0; |
| 5298 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5299 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5300 | copyRegion.dstSubresource.mipLevel = 0; |
| 5301 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 5302 | copyRegion.dstSubresource.layerCount = 0; |
| 5303 | copyRegion.dstOffset.x = 0; |
| 5304 | copyRegion.dstOffset.y = 0; |
| 5305 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5306 | copyRegion.extent.width = 1; |
| 5307 | copyRegion.extent.height = 1; |
| 5308 | copyRegion.extent.depth = 1; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5309 | 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] | 5310 | EndCommandBuffer(); |
| 5311 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5312 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5313 | FAIL() << "Did not receive Error 'vkCmdCopyImage called with unmatched source and dest image types'"; |
| 5314 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5315 | } |
| 5316 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5317 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5318 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5319 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 5320 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5321 | } |
| 5322 | |
| 5323 | TEST_F(VkLayerTest, ResolveImageLowSampleCount) |
| 5324 | { |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5325 | VkResult err; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5326 | bool pass; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5327 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5328 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 5329 | "vkCmdResolveImage called with source sample count less than 2."); |
| 5330 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5331 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5332 | |
| 5333 | // Create two images of sample count 1 and try to Resolve between them |
| 5334 | VkImage srcImage; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5335 | VkImage dstImage; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5336 | VkDeviceMemory srcMem; |
| 5337 | VkDeviceMemory destMem; |
| 5338 | VkMemoryRequirements memReqs; |
| 5339 | |
| 5340 | VkImageCreateInfo image_create_info = {}; |
| 5341 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5342 | image_create_info.pNext = NULL; |
| 5343 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5344 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5345 | image_create_info.extent.width = 32; |
| 5346 | image_create_info.extent.height = 1; |
| 5347 | image_create_info.extent.depth = 1; |
| 5348 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 5349 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5350 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5351 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5352 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5353 | image_create_info.flags = 0; |
| 5354 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5355 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5356 | ASSERT_VK_SUCCESS(err); |
| 5357 | |
| 5358 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5359 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5360 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5361 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5362 | ASSERT_VK_SUCCESS(err); |
| 5363 | |
| 5364 | // Allocate memory |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5365 | VkMemoryAllocateInfo memAlloc = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5366 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5367 | memAlloc.pNext = NULL; |
| 5368 | memAlloc.allocationSize = 0; |
| 5369 | memAlloc.memoryTypeIndex = 0; |
| 5370 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 5371 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5372 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5373 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5374 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5375 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5376 | ASSERT_VK_SUCCESS(err); |
| 5377 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5378 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5379 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5380 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5381 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5382 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5383 | ASSERT_VK_SUCCESS(err); |
| 5384 | |
| 5385 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 5386 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5387 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5388 | ASSERT_VK_SUCCESS(err); |
| 5389 | |
| 5390 | BeginCommandBuffer(); |
| 5391 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
| 5392 | //VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 5393 | //VK_IMAGE_LAYOUT_GENERAL = 1, |
| 5394 | VkImageResolve resolveRegion; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5395 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5396 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 63f0ead | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5397 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5398 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5399 | resolveRegion.srcOffset.x = 0; |
| 5400 | resolveRegion.srcOffset.y = 0; |
| 5401 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5402 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5403 | resolveRegion.dstSubresource.mipLevel = 0; |
| 5404 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 5405 | resolveRegion.dstSubresource.layerCount = 0; |
| 5406 | resolveRegion.dstOffset.x = 0; |
| 5407 | resolveRegion.dstOffset.y = 0; |
| 5408 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5409 | resolveRegion.extent.width = 1; |
| 5410 | resolveRegion.extent.height = 1; |
| 5411 | resolveRegion.extent.depth = 1; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5412 | 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] | 5413 | EndCommandBuffer(); |
| 5414 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5415 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5416 | FAIL() << "Did not receive Error 'vkCmdResolveImage called with source sample count less than 2.'"; |
| 5417 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5418 | } |
| 5419 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5420 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5421 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5422 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 5423 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5424 | } |
| 5425 | |
| 5426 | TEST_F(VkLayerTest, ResolveImageHighSampleCount) |
| 5427 | { |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5428 | VkResult err; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5429 | bool pass; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5430 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5431 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 5432 | "vkCmdResolveImage called with dest sample count greater than 1."); |
| 5433 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5434 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5435 | |
| 5436 | // Create two images of sample count 2 and try to Resolve between them |
| 5437 | VkImage srcImage; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5438 | VkImage dstImage; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5439 | VkDeviceMemory srcMem; |
| 5440 | VkDeviceMemory destMem; |
| 5441 | VkMemoryRequirements memReqs; |
| 5442 | |
| 5443 | VkImageCreateInfo image_create_info = {}; |
| 5444 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5445 | image_create_info.pNext = NULL; |
| 5446 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5447 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5448 | image_create_info.extent.width = 32; |
| 5449 | image_create_info.extent.height = 1; |
| 5450 | image_create_info.extent.depth = 1; |
| 5451 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 5452 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5453 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5454 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
Cody Northrop | b3bf94f | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 5455 | // Note: Some implementations expect color attachment usage for any multisample surface |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5456 | 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] | 5457 | image_create_info.flags = 0; |
| 5458 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5459 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5460 | ASSERT_VK_SUCCESS(err); |
| 5461 | |
| 5462 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
Cody Northrop | b3bf94f | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 5463 | // Note: Some implementations expect color attachment usage for any multisample surface |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5464 | 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] | 5465 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5466 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5467 | ASSERT_VK_SUCCESS(err); |
| 5468 | |
| 5469 | // Allocate memory |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5470 | VkMemoryAllocateInfo memAlloc = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5471 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5472 | memAlloc.pNext = NULL; |
| 5473 | memAlloc.allocationSize = 0; |
| 5474 | memAlloc.memoryTypeIndex = 0; |
| 5475 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 5476 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5477 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5478 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5479 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5480 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5481 | ASSERT_VK_SUCCESS(err); |
| 5482 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5483 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5484 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5485 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5486 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5487 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5488 | ASSERT_VK_SUCCESS(err); |
| 5489 | |
| 5490 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 5491 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5492 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5493 | ASSERT_VK_SUCCESS(err); |
| 5494 | |
| 5495 | BeginCommandBuffer(); |
| 5496 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
| 5497 | //VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 5498 | //VK_IMAGE_LAYOUT_GENERAL = 1, |
| 5499 | VkImageResolve resolveRegion; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5500 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5501 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 63f0ead | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5502 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5503 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5504 | resolveRegion.srcOffset.x = 0; |
| 5505 | resolveRegion.srcOffset.y = 0; |
| 5506 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5507 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5508 | resolveRegion.dstSubresource.mipLevel = 0; |
| 5509 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 5510 | resolveRegion.dstSubresource.layerCount = 0; |
| 5511 | resolveRegion.dstOffset.x = 0; |
| 5512 | resolveRegion.dstOffset.y = 0; |
| 5513 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5514 | resolveRegion.extent.width = 1; |
| 5515 | resolveRegion.extent.height = 1; |
| 5516 | resolveRegion.extent.depth = 1; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5517 | 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] | 5518 | EndCommandBuffer(); |
| 5519 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5520 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5521 | FAIL() << "Did not receive Error 'vkCmdResolveImage called with dest sample count greater than 1.'"; |
| 5522 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5523 | } |
| 5524 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5525 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5526 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5527 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 5528 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5529 | } |
| 5530 | |
| 5531 | TEST_F(VkLayerTest, ResolveImageFormatMismatch) |
| 5532 | { |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5533 | VkResult err; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5534 | bool pass; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5535 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5536 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 5537 | "vkCmdResolveImage called with unmatched source and dest formats."); |
| 5538 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5539 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5540 | |
| 5541 | // Create two images of different types and try to copy between them |
| 5542 | VkImage srcImage; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5543 | VkImage dstImage; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5544 | VkDeviceMemory srcMem; |
| 5545 | VkDeviceMemory destMem; |
| 5546 | VkMemoryRequirements memReqs; |
| 5547 | |
| 5548 | VkImageCreateInfo image_create_info = {}; |
| 5549 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5550 | image_create_info.pNext = NULL; |
| 5551 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5552 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5553 | image_create_info.extent.width = 32; |
| 5554 | image_create_info.extent.height = 1; |
| 5555 | image_create_info.extent.depth = 1; |
| 5556 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 5557 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5558 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5559 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
Cody Northrop | b3bf94f | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 5560 | // Note: Some implementations expect color attachment usage for any multisample surface |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5561 | 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] | 5562 | image_create_info.flags = 0; |
| 5563 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5564 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5565 | ASSERT_VK_SUCCESS(err); |
| 5566 | |
Cody Northrop | b3bf94f | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 5567 | // Set format to something other than source image |
| 5568 | image_create_info.format = VK_FORMAT_R32_SFLOAT; |
| 5569 | // Note: Some implementations expect color attachment usage for any multisample surface |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5570 | 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] | 5571 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5572 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5573 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5574 | ASSERT_VK_SUCCESS(err); |
| 5575 | |
| 5576 | // Allocate memory |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5577 | VkMemoryAllocateInfo memAlloc = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5578 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5579 | memAlloc.pNext = NULL; |
| 5580 | memAlloc.allocationSize = 0; |
| 5581 | memAlloc.memoryTypeIndex = 0; |
| 5582 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 5583 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5584 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5585 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5586 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5587 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5588 | ASSERT_VK_SUCCESS(err); |
| 5589 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5590 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5591 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5592 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5593 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5594 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5595 | ASSERT_VK_SUCCESS(err); |
| 5596 | |
| 5597 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 5598 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5599 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5600 | ASSERT_VK_SUCCESS(err); |
| 5601 | |
| 5602 | BeginCommandBuffer(); |
| 5603 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
| 5604 | //VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 5605 | //VK_IMAGE_LAYOUT_GENERAL = 1, |
| 5606 | VkImageResolve resolveRegion; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5607 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5608 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 63f0ead | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5609 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5610 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5611 | resolveRegion.srcOffset.x = 0; |
| 5612 | resolveRegion.srcOffset.y = 0; |
| 5613 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5614 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5615 | resolveRegion.dstSubresource.mipLevel = 0; |
| 5616 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 5617 | resolveRegion.dstSubresource.layerCount = 0; |
| 5618 | resolveRegion.dstOffset.x = 0; |
| 5619 | resolveRegion.dstOffset.y = 0; |
| 5620 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5621 | resolveRegion.extent.width = 1; |
| 5622 | resolveRegion.extent.height = 1; |
| 5623 | resolveRegion.extent.depth = 1; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5624 | 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] | 5625 | EndCommandBuffer(); |
| 5626 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5627 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5628 | FAIL() << "Did not receive Error 'vkCmdResolveImage called with unmatched source and dest formats.'"; |
| 5629 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5630 | } |
| 5631 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5632 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5633 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5634 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 5635 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5636 | } |
| 5637 | |
| 5638 | TEST_F(VkLayerTest, ResolveImageTypeMismatch) |
| 5639 | { |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5640 | VkResult err; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5641 | bool pass; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5642 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5643 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 5644 | "vkCmdResolveImage called with unmatched source and dest image types."); |
| 5645 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5646 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5647 | |
| 5648 | // Create two images of different types and try to copy between them |
| 5649 | VkImage srcImage; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5650 | VkImage dstImage; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5651 | VkDeviceMemory srcMem; |
| 5652 | VkDeviceMemory destMem; |
| 5653 | VkMemoryRequirements memReqs; |
| 5654 | |
| 5655 | VkImageCreateInfo image_create_info = {}; |
| 5656 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5657 | image_create_info.pNext = NULL; |
| 5658 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5659 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5660 | image_create_info.extent.width = 32; |
| 5661 | image_create_info.extent.height = 1; |
| 5662 | image_create_info.extent.depth = 1; |
| 5663 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 5664 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5665 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5666 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
Cody Northrop | b3bf94f | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 5667 | // Note: Some implementations expect color attachment usage for any multisample surface |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5668 | 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] | 5669 | image_create_info.flags = 0; |
| 5670 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5671 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5672 | ASSERT_VK_SUCCESS(err); |
| 5673 | |
| 5674 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
Cody Northrop | b3bf94f | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 5675 | // Note: Some implementations expect color attachment usage for any multisample surface |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5676 | 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] | 5677 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5678 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5679 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5680 | ASSERT_VK_SUCCESS(err); |
| 5681 | |
| 5682 | // Allocate memory |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5683 | VkMemoryAllocateInfo memAlloc = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5684 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5685 | memAlloc.pNext = NULL; |
| 5686 | memAlloc.allocationSize = 0; |
| 5687 | memAlloc.memoryTypeIndex = 0; |
| 5688 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 5689 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5690 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5691 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5692 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5693 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5694 | ASSERT_VK_SUCCESS(err); |
| 5695 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5696 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5697 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5698 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5699 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5700 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5701 | ASSERT_VK_SUCCESS(err); |
| 5702 | |
| 5703 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 5704 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5705 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5706 | ASSERT_VK_SUCCESS(err); |
| 5707 | |
| 5708 | BeginCommandBuffer(); |
| 5709 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
| 5710 | //VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 5711 | //VK_IMAGE_LAYOUT_GENERAL = 1, |
| 5712 | VkImageResolve resolveRegion; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5713 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5714 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 63f0ead | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5715 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5716 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5717 | resolveRegion.srcOffset.x = 0; |
| 5718 | resolveRegion.srcOffset.y = 0; |
| 5719 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5720 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5721 | resolveRegion.dstSubresource.mipLevel = 0; |
| 5722 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 5723 | resolveRegion.dstSubresource.layerCount = 0; |
| 5724 | resolveRegion.dstOffset.x = 0; |
| 5725 | resolveRegion.dstOffset.y = 0; |
| 5726 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5727 | resolveRegion.extent.width = 1; |
| 5728 | resolveRegion.extent.height = 1; |
| 5729 | resolveRegion.extent.depth = 1; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5730 | 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] | 5731 | EndCommandBuffer(); |
| 5732 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5733 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5734 | FAIL() << "Did not receive Error 'vkCmdResolveImage called with unmatched source and dest image types.'"; |
| 5735 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5736 | } |
| 5737 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5738 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5739 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5740 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 5741 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5742 | } |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5743 | |
| 5744 | TEST_F(VkLayerTest, DepthStencilImageViewWithColorAspectBitError) |
| 5745 | { |
| 5746 | // Create a single Image descriptor and cause it to first hit an error due |
| 5747 | // to using a DS format, then cause it to hit error due to COLOR_BIT not set in aspect |
| 5748 | // The image format check comes 2nd in validation so we trigger it first, |
| 5749 | // 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] | 5750 | VkResult err; |
| 5751 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5752 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 5753 | "Combination depth/stencil image formats can have only the "); |
| 5754 | |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5755 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5756 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5757 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5758 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5759 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5760 | |
| 5761 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 5762 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5763 | ds_pool_ci.pNext = NULL; |
| 5764 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5765 | ds_pool_ci.poolSizeCount = 1; |
| 5766 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5767 | |
| 5768 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5769 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5770 | ASSERT_VK_SUCCESS(err); |
| 5771 | |
| 5772 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5773 | dsl_binding.binding = 0; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5774 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 5775 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5776 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5777 | dsl_binding.pImmutableSamplers = NULL; |
| 5778 | |
| 5779 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 5780 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5781 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5782 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5783 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5784 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5785 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5786 | ASSERT_VK_SUCCESS(err); |
| 5787 | |
| 5788 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5789 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Chia-I Wu | c1f5e40 | 2015-11-10 16:21:09 +0800 | [diff] [blame] | 5790 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5791 | alloc_info.setLayoutCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5792 | alloc_info.descriptorPool = ds_pool; |
| 5793 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5794 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5795 | ASSERT_VK_SUCCESS(err); |
| 5796 | |
| 5797 | VkImage image_bad; |
| 5798 | VkImage image_good; |
| 5799 | // One bad format and one good format for Color attachment |
| 5800 | const VkFormat tex_format_bad = VK_FORMAT_D32_SFLOAT_S8_UINT; |
| 5801 | const VkFormat tex_format_good = VK_FORMAT_B8G8R8A8_UNORM; |
| 5802 | const int32_t tex_width = 32; |
| 5803 | const int32_t tex_height = 32; |
| 5804 | |
| 5805 | VkImageCreateInfo image_create_info = {}; |
| 5806 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5807 | image_create_info.pNext = NULL; |
| 5808 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5809 | image_create_info.format = tex_format_bad; |
| 5810 | image_create_info.extent.width = tex_width; |
| 5811 | image_create_info.extent.height = tex_height; |
| 5812 | image_create_info.extent.depth = 1; |
| 5813 | image_create_info.mipLevels = 1; |
| 5814 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5815 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5816 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 5817 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 5818 | image_create_info.flags = 0; |
| 5819 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5820 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image_bad); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5821 | ASSERT_VK_SUCCESS(err); |
| 5822 | image_create_info.format = tex_format_good; |
| 5823 | 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] | 5824 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image_good); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5825 | ASSERT_VK_SUCCESS(err); |
| 5826 | |
| 5827 | VkImageViewCreateInfo image_view_create_info = {}; |
| 5828 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5829 | image_view_create_info.image = image_bad; |
| 5830 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 5831 | image_view_create_info.format = tex_format_bad; |
| 5832 | image_view_create_info.subresourceRange.baseArrayLayer = 0; |
| 5833 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5834 | image_view_create_info.subresourceRange.layerCount = 1; |
| 5835 | image_view_create_info.subresourceRange.levelCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5836 | image_view_create_info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 5837 | |
| 5838 | VkImageView view; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5839 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, &view); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5840 | |
| 5841 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5842 | FAIL() << "Did not receive Error 'Combination depth-stencil image formats can have only the....'"; |
| 5843 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5844 | } |
| 5845 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5846 | vkDestroyImage(m_device->device(), image_bad, NULL); |
| 5847 | vkDestroyImage(m_device->device(), image_good, NULL); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5848 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5849 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5850 | } |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 5851 | #endif // IMAGE_TESTS |
| 5852 | |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 5853 | int main(int argc, char **argv) { |
| 5854 | int result; |
| 5855 | |
| 5856 | ::testing::InitGoogleTest(&argc, argv); |
Tony Barbour | 0199918 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 5857 | VkTestFramework::InitArgs(&argc, argv); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 5858 | |
| 5859 | ::testing::AddGlobalTestEnvironment(new TestEnvironment); |
| 5860 | |
| 5861 | result = RUN_ALL_TESTS(); |
| 5862 | |
Tony Barbour | 0199918 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 5863 | VkTestFramework::Finish(); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 5864 | return result; |
| 5865 | } |