Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1 | #include <vulkan.h> |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 2 | #include "vk_debug_report_lunarg.h" |
Courtney Goeltzenleuchter | 0abdb66 | 2015-10-07 13:28:58 -0600 | [diff] [blame] | 3 | #include "test_common.h" |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 4 | #include "vkrenderframework.h" |
Tobin Ehlis | 56d204a | 2015-07-03 10:15:26 -0600 | [diff] [blame] | 5 | #include "vk_layer_config.h" |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6 | #include "../icd/common/icd-spv.h" |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 7 | |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 8 | #define GLM_FORCE_RADIANS |
| 9 | #include "glm/glm.hpp" |
| 10 | #include <glm/gtc/matrix_transform.hpp> |
| 11 | |
Tobin Ehlis | 57e6a61 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 12 | #define MEM_TRACKER_TESTS 1 |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 13 | |
Tobin Ehlis | 57e6a61 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 14 | #define OBJ_TRACKER_TESTS 1 |
| 15 | #define DRAW_STATE_TESTS 1 |
| 16 | #define THREADING_TESTS 1 |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 17 | #define SHADER_CHECKER_TESTS 1 |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 18 | #define DEVICE_LIMITS_TESTS 1 |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 19 | #define IMAGE_TESTS 1 |
Tobin Ehlis | 57e6a61 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 20 | |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 21 | //-------------------------------------------------------------------------------------- |
| 22 | // Mesh and VertexFormat Data |
| 23 | //-------------------------------------------------------------------------------------- |
| 24 | struct Vertex |
| 25 | { |
| 26 | float posX, posY, posZ, posW; // Position data |
| 27 | float r, g, b, a; // Color |
| 28 | }; |
| 29 | |
| 30 | #define XYZ1(_x_, _y_, _z_) (_x_), (_y_), (_z_), 1.f |
| 31 | |
| 32 | typedef enum _BsoFailSelect { |
| 33 | BsoFailNone = 0x00000000, |
Cody Northrop | e4bc694 | 2015-08-26 10:01:32 -0600 | [diff] [blame] | 34 | BsoFailLineWidth = 0x00000001, |
| 35 | BsoFailDepthBias = 0x00000002, |
Cody Northrop | f5bd225 | 2015-08-17 11:10:49 -0600 | [diff] [blame] | 36 | BsoFailViewport = 0x00000004, |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 37 | BsoFailScissor = 0x00000008, |
| 38 | BsoFailBlend = 0x00000010, |
| 39 | BsoFailDepthBounds = 0x00000020, |
| 40 | BsoFailStencilReadMask = 0x00000040, |
| 41 | BsoFailStencilWriteMask = 0x00000080, |
| 42 | BsoFailStencilReference = 0x00000100, |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 43 | } BsoFailSelect; |
| 44 | |
| 45 | struct vktriangle_vs_uniform { |
| 46 | // Must start with MVP |
| 47 | float mvp[4][4]; |
| 48 | float position[3][4]; |
| 49 | float color[3][4]; |
| 50 | }; |
| 51 | |
Mark Lobodzinski | 6bbdff1 | 2015-06-02 09:41:30 -0500 | [diff] [blame] | 52 | static const char bindStateVertShaderText[] = |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 53 | "#version 130\n" |
| 54 | "vec2 vertices[3];\n" |
| 55 | "void main() {\n" |
| 56 | " vertices[0] = vec2(-1.0, -1.0);\n" |
| 57 | " vertices[1] = vec2( 1.0, -1.0);\n" |
| 58 | " vertices[2] = vec2( 0.0, 1.0);\n" |
| 59 | " gl_Position = vec4(vertices[gl_VertexID % 3], 0.0, 1.0);\n" |
| 60 | "}\n"; |
| 61 | |
Mark Lobodzinski | 6bbdff1 | 2015-06-02 09:41:30 -0500 | [diff] [blame] | 62 | static const char bindStateFragShaderText[] = |
Cody Northrop | 74a2d2c | 2015-06-16 17:32:04 -0600 | [diff] [blame] | 63 | "#version 140\n" |
| 64 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 65 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 66 | "\n" |
| 67 | "layout(location = 0) out vec4 uFragColor;\n" |
| 68 | "void main(){\n" |
| 69 | " uFragColor = vec4(0,1,0,1);\n" |
| 70 | "}\n"; |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 71 | |
Courtney Goeltzenleuchter | 0d6857f | 2015-09-04 13:52:24 -0600 | [diff] [blame] | 72 | static VkBool32 myDbgFunc( |
Tony Barbour | e84a8d6 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 73 | VkFlags msgFlags, |
| 74 | VkDbgObjectType objType, |
| 75 | uint64_t srcObject, |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 76 | size_t location, |
| 77 | int32_t msgCode, |
| 78 | const char* pLayerPrefix, |
| 79 | const char* pMsg, |
| 80 | void* pUserData); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 81 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 82 | // ******************************************************** |
| 83 | // ErrorMonitor Usage: |
| 84 | // |
| 85 | // Call SetDesiredFailureMsg with a string to be compared against all |
| 86 | // encountered log messages. Passing NULL will match all log messages. |
| 87 | // logMsg will return true for skipCall only if msg is matched or NULL. |
| 88 | // |
| 89 | // Call DesiredMsgFound to determine if the desired failure message |
| 90 | // was encountered. |
| 91 | |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 92 | class ErrorMonitor { |
| 93 | public: |
Tony Barbour | 0c1bdc6 | 2015-04-29 17:34:29 -0600 | [diff] [blame] | 94 | ErrorMonitor() |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 95 | { |
Mike Stroyan | 7016f4f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 96 | test_platform_thread_create_mutex(&m_mutex); |
| 97 | test_platform_thread_lock_mutex(&m_mutex); |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 98 | m_msgFlags = VK_DBG_REPORT_INFO_BIT; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 99 | m_bailout = NULL; |
Mike Stroyan | 7016f4f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 100 | test_platform_thread_unlock_mutex(&m_mutex); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 101 | } |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 102 | |
| 103 | void SetDesiredFailureMsg(VkFlags msgFlags, const char *msgString) |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 104 | { |
Mike Stroyan | 7016f4f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 105 | test_platform_thread_lock_mutex(&m_mutex); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 106 | m_desiredMsg.clear(); |
| 107 | m_failureMsg.clear(); |
| 108 | m_otherMsgs.clear(); |
| 109 | m_desiredMsg = msgString; |
| 110 | m_msgFound = VK_FALSE; |
| 111 | m_msgFlags = msgFlags; |
Mike Stroyan | 7016f4f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 112 | test_platform_thread_unlock_mutex(&m_mutex); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 113 | } |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 114 | |
| 115 | VkBool32 CheckForDesiredMsg(VkFlags msgFlags, const char *msgString) |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 116 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 117 | VkBool32 result = VK_FALSE; |
Mike Stroyan | 7016f4f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 118 | test_platform_thread_lock_mutex(&m_mutex); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 119 | if (m_bailout != NULL) { |
| 120 | *m_bailout = true; |
| 121 | } |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 122 | string errorString(msgString); |
| 123 | if (msgFlags & m_msgFlags) { |
| 124 | if (errorString.find(m_desiredMsg) != string::npos) { |
| 125 | m_failureMsg = errorString; |
| 126 | m_msgFound = VK_TRUE; |
| 127 | result = VK_TRUE; |
| 128 | } else { |
| 129 | m_otherMsgs.push_back(errorString); |
| 130 | } |
| 131 | } |
Mike Stroyan | 7016f4f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 132 | test_platform_thread_unlock_mutex(&m_mutex); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 133 | return result; |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 134 | } |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 135 | |
| 136 | vector<string> GetOtherFailureMsgs(void) |
| 137 | { |
| 138 | return m_otherMsgs; |
| 139 | } |
| 140 | |
| 141 | string GetFailureMsg(void) |
| 142 | { |
| 143 | return m_failureMsg; |
| 144 | } |
| 145 | |
| 146 | VkBool32 DesiredMsgFound(void) |
| 147 | { |
| 148 | return m_msgFound; |
| 149 | } |
| 150 | |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 151 | void SetBailout(bool *bailout) |
| 152 | { |
| 153 | m_bailout = bailout; |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 154 | } |
| 155 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 156 | void DumpFailureMsgs(void) |
| 157 | { |
| 158 | vector<string> otherMsgs = GetOtherFailureMsgs(); |
| 159 | cout << "Other error messages logged for this test were:" << endl; |
| 160 | for (auto iter = otherMsgs.begin(); iter != otherMsgs.end(); iter++) { |
| 161 | cout << " " << *iter << endl; |
| 162 | } |
| 163 | } |
| 164 | |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 165 | private: |
Mike Stroyan | 7016f4f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 166 | VkFlags m_msgFlags; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 167 | string m_desiredMsg; |
| 168 | string m_failureMsg; |
| 169 | vector<string> m_otherMsgs; |
Mike Stroyan | 7016f4f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 170 | test_platform_thread_mutex m_mutex; |
| 171 | bool* m_bailout; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 172 | VkBool32 m_msgFound; |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 173 | }; |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 174 | |
Courtney Goeltzenleuchter | 0d6857f | 2015-09-04 13:52:24 -0600 | [diff] [blame] | 175 | static VkBool32 myDbgFunc( |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 176 | VkFlags msgFlags, |
Tony Barbour | e84a8d6 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 177 | VkDbgObjectType objType, |
| 178 | uint64_t srcObject, |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 179 | size_t location, |
| 180 | int32_t msgCode, |
| 181 | const char* pLayerPrefix, |
| 182 | const char* pMsg, |
| 183 | void* pUserData) |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 184 | { |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 185 | if (msgFlags & (VK_DBG_REPORT_WARN_BIT | VK_DBG_REPORT_ERROR_BIT)) { |
Tony Barbour | 8508b8e | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 186 | ErrorMonitor *errMonitor = (ErrorMonitor *)pUserData; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 187 | return errMonitor->CheckForDesiredMsg(msgFlags, pMsg); |
Tony Barbour | 8508b8e | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 188 | } |
Courtney Goeltzenleuchter | 0d6857f | 2015-09-04 13:52:24 -0600 | [diff] [blame] | 189 | return false; |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 190 | } |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 191 | |
Tony Barbour | 0199918 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 192 | class VkLayerTest : public VkRenderFramework |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 193 | { |
| 194 | public: |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 195 | VkResult BeginCommandBuffer(VkCommandBufferObj &commandBuffer); |
| 196 | VkResult EndCommandBuffer(VkCommandBufferObj &commandBuffer); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 197 | void VKTriangleTest(const char *vertShaderText, const char *fragShaderText, BsoFailSelect failMask); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 198 | void GenericDrawPreparation(VkCommandBufferObj *commandBuffer, VkPipelineObj &pipelineobj, VkDescriptorSetObj &descriptorSet, BsoFailSelect failMask); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 199 | void GenericDrawPreparation(VkPipelineObj &pipelineobj, VkDescriptorSetObj &descriptorSet, BsoFailSelect failMask) |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 200 | { GenericDrawPreparation(m_commandBuffer, pipelineobj, descriptorSet, failMask); } |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 201 | |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 202 | /* Convenience functions that use built-in command buffer */ |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 203 | VkResult BeginCommandBuffer() { return BeginCommandBuffer(*m_commandBuffer); } |
| 204 | VkResult EndCommandBuffer() { return EndCommandBuffer(*m_commandBuffer); } |
Courtney Goeltzenleuchter | 4ff11cc | 2015-09-23 12:31:50 -0600 | [diff] [blame] | 205 | 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] | 206 | { m_commandBuffer->Draw(vertexCount, instanceCount, firstVertex, firstInstance); } |
Courtney Goeltzenleuchter | 4ff11cc | 2015-09-23 12:31:50 -0600 | [diff] [blame] | 207 | 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] | 208 | { m_commandBuffer->DrawIndexed(indexCount, instanceCount, firstIndex, vertexOffset, firstInstance); } |
| 209 | void QueueCommandBuffer() { m_commandBuffer->QueueCommandBuffer(); } |
| 210 | void QueueCommandBuffer(const VkFence& fence) { m_commandBuffer->QueueCommandBuffer(fence); } |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 211 | void BindVertexBuffer(VkConstantBufferObj *vertexBuffer, VkDeviceSize offset, uint32_t binding) |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 212 | { m_commandBuffer->BindVertexBuffer(vertexBuffer, offset, binding); } |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 213 | void BindIndexBuffer(VkIndexBufferObj *indexBuffer, VkDeviceSize offset) |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 214 | { m_commandBuffer->BindIndexBuffer(indexBuffer, offset); } |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 215 | protected: |
Tony Barbour | 0199918 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 216 | ErrorMonitor *m_errorMonitor; |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 217 | |
| 218 | virtual void SetUp() { |
Courtney Goeltzenleuchter | f5c6195 | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 219 | std::vector<const char *> instance_layer_names; |
| 220 | std::vector<const char *> device_layer_names; |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 221 | std::vector<const char *> instance_extension_names; |
| 222 | std::vector<const char *> device_extension_names; |
Tony Barbour | 950ebc0 | 2015-04-23 12:55:36 -0600 | [diff] [blame] | 223 | |
Courtney Goeltzenleuchter | 846298c | 2015-07-30 11:32:46 -0600 | [diff] [blame] | 224 | instance_extension_names.push_back(VK_DEBUG_REPORT_EXTENSION_NAME); |
Courtney Goeltzenleuchter | de53c5b | 2015-06-16 15:59:11 -0600 | [diff] [blame] | 225 | /* |
| 226 | * Since CreateDbgMsgCallback is an instance level extension call |
| 227 | * any extension / layer that utilizes that feature also needs |
| 228 | * to be enabled at create instance time. |
| 229 | */ |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 230 | // Use Threading layer first to protect others from ThreadCommandBufferCollision test |
Courtney Goeltzenleuchter | f5c6195 | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 231 | instance_layer_names.push_back("Threading"); |
| 232 | instance_layer_names.push_back("ObjectTracker"); |
| 233 | instance_layer_names.push_back("MemTracker"); |
| 234 | instance_layer_names.push_back("DrawState"); |
| 235 | instance_layer_names.push_back("ShaderChecker"); |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 236 | instance_layer_names.push_back("DeviceLimits"); |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 237 | instance_layer_names.push_back("Image"); |
Courtney Goeltzenleuchter | 23b5f8d | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 238 | |
Courtney Goeltzenleuchter | f5c6195 | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 239 | device_layer_names.push_back("Threading"); |
| 240 | device_layer_names.push_back("ObjectTracker"); |
| 241 | device_layer_names.push_back("MemTracker"); |
| 242 | device_layer_names.push_back("DrawState"); |
| 243 | device_layer_names.push_back("ShaderChecker"); |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 244 | device_layer_names.push_back("DeviceLimits"); |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 245 | device_layer_names.push_back("Image"); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 246 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 247 | this->app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 248 | this->app_info.pNext = NULL; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 249 | this->app_info.pApplicationName = "layer_tests"; |
| 250 | this->app_info.applicationVersion = 1; |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 251 | this->app_info.pEngineName = "unittest"; |
| 252 | this->app_info.engineVersion = 1; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 253 | this->app_info.apiVersion = VK_API_VERSION; |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 254 | |
Tony Barbour | 0c1bdc6 | 2015-04-29 17:34:29 -0600 | [diff] [blame] | 255 | m_errorMonitor = new ErrorMonitor; |
Courtney Goeltzenleuchter | f5c6195 | 2015-07-06 09:10:47 -0600 | [diff] [blame] | 256 | InitFramework(instance_layer_names, device_layer_names, |
| 257 | instance_extension_names, device_extension_names, |
| 258 | myDbgFunc, m_errorMonitor); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 259 | } |
| 260 | |
| 261 | virtual void TearDown() { |
| 262 | // Clean up resources before we reset |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 263 | ShutdownFramework(); |
Tony Barbour | 8508b8e | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 264 | delete m_errorMonitor; |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 265 | } |
| 266 | }; |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 267 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 268 | VkResult VkLayerTest::BeginCommandBuffer(VkCommandBufferObj &commandBuffer) |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 269 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 270 | VkResult result; |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 271 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 272 | result = commandBuffer.BeginCommandBuffer(); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 273 | |
| 274 | /* |
| 275 | * For render test all drawing happens in a single render pass |
| 276 | * on a single command buffer. |
| 277 | */ |
Chris Forbes | fe133ef | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 278 | if (VK_SUCCESS == result && renderPass()) { |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 279 | commandBuffer.BeginRenderPass(renderPassBeginInfo()); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 280 | } |
| 281 | |
| 282 | return result; |
| 283 | } |
| 284 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 285 | VkResult VkLayerTest::EndCommandBuffer(VkCommandBufferObj &commandBuffer) |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 286 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 287 | VkResult result; |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 288 | |
Chris Forbes | fe133ef | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 289 | if (renderPass()) { |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 290 | commandBuffer.EndRenderPass(); |
Chris Forbes | fe133ef | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 291 | } |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 292 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 293 | result = commandBuffer.EndCommandBuffer(); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 294 | |
| 295 | return result; |
| 296 | } |
| 297 | |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 298 | void VkLayerTest::VKTriangleTest(const char *vertShaderText, const char *fragShaderText, BsoFailSelect failMask) |
| 299 | { |
| 300 | // Create identity matrix |
| 301 | int i; |
| 302 | struct vktriangle_vs_uniform data; |
| 303 | |
| 304 | glm::mat4 Projection = glm::mat4(1.0f); |
| 305 | glm::mat4 View = glm::mat4(1.0f); |
| 306 | glm::mat4 Model = glm::mat4(1.0f); |
| 307 | glm::mat4 MVP = Projection * View * Model; |
| 308 | const int matrixSize = sizeof(MVP); |
| 309 | const int bufSize = sizeof(vktriangle_vs_uniform) / sizeof(float); |
| 310 | |
| 311 | memcpy(&data.mvp, &MVP[0][0], matrixSize); |
| 312 | |
| 313 | static const Vertex tri_data[] = |
| 314 | { |
| 315 | { XYZ1( -1, -1, 0 ), XYZ1( 1.f, 0.f, 0.f ) }, |
| 316 | { XYZ1( 1, -1, 0 ), XYZ1( 0.f, 1.f, 0.f ) }, |
| 317 | { XYZ1( 0, 1, 0 ), XYZ1( 0.f, 0.f, 1.f ) }, |
| 318 | }; |
| 319 | |
| 320 | for (i=0; i<3; i++) { |
| 321 | data.position[i][0] = tri_data[i].posX; |
| 322 | data.position[i][1] = tri_data[i].posY; |
| 323 | data.position[i][2] = tri_data[i].posZ; |
| 324 | data.position[i][3] = tri_data[i].posW; |
| 325 | data.color[i][0] = tri_data[i].r; |
| 326 | data.color[i][1] = tri_data[i].g; |
| 327 | data.color[i][2] = tri_data[i].b; |
| 328 | data.color[i][3] = tri_data[i].a; |
| 329 | } |
| 330 | |
| 331 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 332 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 333 | |
| 334 | VkConstantBufferObj constantBuffer(m_device, bufSize*2, sizeof(float), (const void*) &data); |
| 335 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 336 | VkShaderObj vs(m_device,vertShaderText,VK_SHADER_STAGE_VERTEX_BIT, this); |
| 337 | VkShaderObj ps(m_device,fragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 338 | |
| 339 | VkPipelineObj pipelineobj(m_device); |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 340 | pipelineobj.AddColorAttachment(); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 341 | pipelineobj.AddShader(&vs); |
| 342 | pipelineobj.AddShader(&ps); |
Courtney Goeltzenleuchter | 2f5deb5 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 343 | if (failMask & BsoFailLineWidth) { |
| 344 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_LINE_WIDTH); |
| 345 | } |
| 346 | if (failMask & BsoFailDepthBias) { |
| 347 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_DEPTH_BIAS); |
| 348 | } |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 349 | // 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] | 350 | if (failMask & BsoFailViewport) { |
| 351 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_VIEWPORT); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 352 | m_viewports.clear(); |
| 353 | m_scissors.clear(); |
Courtney Goeltzenleuchter | 2f5deb5 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 354 | } |
| 355 | if (failMask & BsoFailScissor) { |
| 356 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_SCISSOR); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 357 | m_scissors.clear(); |
| 358 | m_viewports.clear(); |
Courtney Goeltzenleuchter | 2f5deb5 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 359 | } |
| 360 | if (failMask & BsoFailBlend) { |
| 361 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_BLEND_CONSTANTS); |
| 362 | } |
| 363 | if (failMask & BsoFailDepthBounds) { |
| 364 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_DEPTH_BOUNDS); |
| 365 | } |
| 366 | if (failMask & BsoFailStencilReadMask) { |
| 367 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK); |
| 368 | } |
| 369 | if (failMask & BsoFailStencilWriteMask) { |
| 370 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_WRITE_MASK); |
| 371 | } |
| 372 | if (failMask & BsoFailStencilReference) { |
| 373 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_STENCIL_REFERENCE); |
| 374 | } |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 375 | |
| 376 | VkDescriptorSetObj descriptorSet(m_device); |
| 377 | descriptorSet.AppendBuffer(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, constantBuffer); |
| 378 | |
| 379 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 380 | ASSERT_VK_SUCCESS(BeginCommandBuffer()); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 381 | |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 382 | GenericDrawPreparation(pipelineobj, descriptorSet, failMask); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 383 | |
| 384 | // render triangle |
Courtney Goeltzenleuchter | 4ff11cc | 2015-09-23 12:31:50 -0600 | [diff] [blame] | 385 | Draw(3, 1, 0, 0); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 386 | |
| 387 | // finalize recording of the command buffer |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 388 | EndCommandBuffer(); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 389 | |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 390 | QueueCommandBuffer(); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 391 | } |
| 392 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 393 | void VkLayerTest::GenericDrawPreparation(VkCommandBufferObj *commandBuffer, VkPipelineObj &pipelineobj, VkDescriptorSetObj &descriptorSet, BsoFailSelect failMask) |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 394 | { |
| 395 | if (m_depthStencil->Initialized()) { |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 396 | 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] | 397 | } else { |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 398 | 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] | 399 | } |
| 400 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 401 | commandBuffer->PrepareAttachments(); |
Cody Northrop | 2605cb0 | 2015-08-18 15:21:16 -0600 | [diff] [blame] | 402 | // Make sure depthWriteEnable is set so that Depth fail test will work correctly |
| 403 | // 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] | 404 | VkStencilOpState stencil = {}; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 405 | stencil.failOp = VK_STENCIL_OP_KEEP; |
| 406 | stencil.passOp = VK_STENCIL_OP_KEEP; |
| 407 | stencil.depthFailOp = VK_STENCIL_OP_KEEP; |
| 408 | stencil.compareOp = VK_COMPARE_OP_NEVER; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 409 | |
| 410 | VkPipelineDepthStencilStateCreateInfo ds_ci = {}; |
| 411 | ds_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO; |
Courtney Goeltzenleuchter | 2f5deb5 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 412 | ds_ci.pNext = NULL; |
| 413 | ds_ci.depthTestEnable = VK_FALSE; |
| 414 | ds_ci.depthWriteEnable = VK_TRUE; |
| 415 | ds_ci.depthCompareOp = VK_COMPARE_OP_NEVER; |
| 416 | ds_ci.depthBoundsTestEnable = VK_FALSE; |
| 417 | ds_ci.stencilTestEnable = VK_TRUE; |
| 418 | ds_ci.front = stencil; |
| 419 | ds_ci.back = stencil; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 420 | |
Tobin Ehlis | 40e9f52 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 421 | pipelineobj.SetDepthStencil(&ds_ci); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 422 | pipelineobj.SetViewport(m_viewports); |
| 423 | pipelineobj.SetScissor(m_scissors); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 424 | descriptorSet.CreateVKDescriptorSet(commandBuffer); |
Cody Northrop | ccfa96d | 2015-08-27 10:20:35 -0600 | [diff] [blame] | 425 | VkResult err = pipelineobj.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 426 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 427 | commandBuffer->BindPipeline(pipelineobj); |
| 428 | commandBuffer->BindDescriptorSet(descriptorSet); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 429 | } |
| 430 | |
| 431 | // ******************************************************************************************************************** |
| 432 | // ******************************************************************************************************************** |
| 433 | // ******************************************************************************************************************** |
| 434 | // ******************************************************************************************************************** |
Tobin Ehlis | 57e6a61 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 435 | #if MEM_TRACKER_TESTS |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 436 | TEST_F(VkLayerTest, CallResetCommandBufferBeforeCompletion) |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 437 | { |
| 438 | vk_testing::Fence testFence; |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 439 | VkFenceCreateInfo fenceInfo = {}; |
| 440 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 441 | fenceInfo.pNext = NULL; |
| 442 | fenceInfo.flags = 0; |
| 443 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 444 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, "Resetting CB"); |
| 445 | |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 446 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tony Barbour | e389b88 | 2015-07-20 13:00:10 -0600 | [diff] [blame] | 447 | |
| 448 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 449 | vk_testing::Buffer buffer; |
| 450 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 451 | |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 452 | BeginCommandBuffer(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 453 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 4, 0x11111111); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 454 | EndCommandBuffer(); |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 455 | |
| 456 | testFence.init(*m_device, fenceInfo); |
| 457 | |
| 458 | // Bypass framework since it does the waits automatically |
| 459 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 1a748e9 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 460 | VkSubmitInfo submit_info; |
Chia-I Wu | 6ec33a0 | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 461 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 462 | submit_info.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 463 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 1a748e9 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 464 | submit_info.pWaitSemaphores = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 465 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 466 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 467 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 1a748e9 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 468 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 3ec3162 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 469 | |
| 470 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 471 | ASSERT_VK_SUCCESS( err ); |
| 472 | |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 473 | // Introduce failure by calling begin again before checking fence |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 474 | vkResetCommandBuffer(m_commandBuffer->handle(), 0); |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 475 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 476 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 477 | FAIL() << "Did not receive Error 'Resetting CB (0xaddress) before it has completed. You must check CB flag before.'"; |
| 478 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 479 | } |
| 480 | } |
| 481 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 482 | TEST_F(VkLayerTest, CallBeginCommandBufferBeforeCompletion) |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 483 | { |
| 484 | vk_testing::Fence testFence; |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 485 | VkFenceCreateInfo fenceInfo = {}; |
| 486 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 487 | fenceInfo.pNext = NULL; |
| 488 | fenceInfo.flags = 0; |
| 489 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 490 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, "Calling vkBeginCommandBuffer() on active CB"); |
| 491 | |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 492 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 493 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 494 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 495 | |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 496 | BeginCommandBuffer(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 497 | 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] | 498 | EndCommandBuffer(); |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 499 | |
| 500 | testFence.init(*m_device, fenceInfo); |
| 501 | |
| 502 | // Bypass framework since it does the waits automatically |
| 503 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 1a748e9 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 504 | VkSubmitInfo submit_info; |
Chia-I Wu | 6ec33a0 | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 505 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 506 | submit_info.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 507 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 1a748e9 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 508 | submit_info.pWaitSemaphores = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 509 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 510 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 511 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 1a748e9 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 512 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 3ec3162 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 513 | |
| 514 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 515 | ASSERT_VK_SUCCESS( err ); |
| 516 | |
Mark Lobodzinski | 87db501 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 517 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 518 | VkCommandBufferBeginInfo info = {}; |
| 519 | info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
| 520 | info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Mark Lobodzinski | 87db501 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 521 | info.renderPass = VK_NULL_HANDLE; |
| 522 | info.subpass = 0; |
| 523 | info.framebuffer = VK_NULL_HANDLE; |
| 524 | |
| 525 | // Introduce failure by calling BCB again before checking fence |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 526 | vkBeginCommandBuffer(m_commandBuffer->handle(), &info); |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 527 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 528 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 529 | FAIL() << "Did not receive Error 'Calling vkBeginCommandBuffer() on an active CB (0xaddress) before it has completed'"; |
| 530 | m_errorMonitor->DumpFailureMsgs(); |
| 531 | |
Mark Lobodzinski | 8107819 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 532 | } |
| 533 | } |
| 534 | |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 535 | TEST_F(VkLayerTest, MapMemWithoutHostVisibleBit) |
| 536 | { |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 537 | VkResult err; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 538 | bool pass; |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 539 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 540 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 541 | "Mapping Memory without VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT"); |
| 542 | |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 543 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 544 | |
| 545 | // Create an image, allocate memory, free it, and then try to bind it |
| 546 | VkImage image; |
Mark Lobodzinski | 2318261 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 547 | VkDeviceMemory mem; |
| 548 | VkMemoryRequirements mem_reqs; |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 549 | |
| 550 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 551 | const int32_t tex_width = 32; |
| 552 | const int32_t tex_height = 32; |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 553 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 554 | VkImageCreateInfo image_create_info = {}; |
| 555 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 556 | image_create_info.pNext = NULL; |
| 557 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 558 | image_create_info.format = tex_format; |
| 559 | image_create_info.extent.width = tex_width; |
| 560 | image_create_info.extent.height = tex_height; |
| 561 | image_create_info.extent.depth = 1; |
| 562 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 563 | image_create_info.arrayLayers = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 564 | image_create_info.samples = 1; |
| 565 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 566 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 567 | image_create_info.flags = 0; |
Mark Lobodzinski | 87db501 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 568 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 569 | VkMemoryAllocateInfo mem_alloc = {}; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 570 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 571 | mem_alloc.pNext = NULL; |
| 572 | mem_alloc.allocationSize = 0; |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 573 | // 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] | 574 | mem_alloc.memoryTypeIndex = 1; |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 575 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 576 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 577 | ASSERT_VK_SUCCESS(err); |
| 578 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 579 | vkGetImageMemoryRequirements(m_device->device(), |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 580 | image, |
Mark Lobodzinski | 2318261 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 581 | &mem_reqs); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 582 | |
Mark Lobodzinski | 2318261 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 583 | mem_alloc.allocationSize = mem_reqs.size; |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 584 | |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 585 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 586 | 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] | 587 | vkDestroyImage(m_device->device(), image, NULL); |
Tony Barbour | 49a3b65 | 2015-08-04 16:13:01 -0600 | [diff] [blame] | 588 | return; |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 589 | } |
Mike Stroyan | d72da75 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 590 | |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 591 | // allocate memory |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 592 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 593 | ASSERT_VK_SUCCESS(err); |
| 594 | |
| 595 | // Try to bind free memory that has been freed |
Tony Barbour | e84a8d6 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 596 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 597 | ASSERT_VK_SUCCESS(err); |
| 598 | |
| 599 | // Map memory as if to initialize the image |
| 600 | void *mappedAddress = NULL; |
Mark Lobodzinski | 2318261 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 601 | err = vkMapMemory(m_device->device(), mem, 0, 0, 0, &mappedAddress); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 602 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 603 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 604 | FAIL() << "Did not receive Error 'Error received did not match expected error message from vkMapMemory in MemTracker'"; |
| 605 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 606 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 607 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 608 | vkDestroyImage(m_device->device(), image, NULL); |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 609 | } |
| 610 | |
Tobin Ehlis | 33ce8fd | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 611 | // TODO : Is this test still valid. Not sure it is with updates to memory binding model |
| 612 | // Verify and delete the test of fix the check |
| 613 | //TEST_F(VkLayerTest, FreeBoundMemory) |
| 614 | //{ |
Tobin Ehlis | 33ce8fd | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 615 | // VkResult err; |
| 616 | // |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 617 | // m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_WARN_BIT, |
| 618 | // "Freeing memory object while it still has references"); |
Tobin Ehlis | 33ce8fd | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 619 | // |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 620 | // ASSERT_NO_FATAL_FAILURE(InitState()); |
| 621 | |
Tobin Ehlis | 33ce8fd | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 622 | // // Create an image, allocate memory, free it, and then try to bind it |
| 623 | // VkImage image; |
| 624 | // VkDeviceMemory mem; |
| 625 | // VkMemoryRequirements mem_reqs; |
| 626 | // |
| 627 | // const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 628 | // const int32_t tex_width = 32; |
| 629 | // const int32_t tex_height = 32; |
| 630 | // |
| 631 | // const VkImageCreateInfo image_create_info = { |
| 632 | // .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, |
| 633 | // .pNext = NULL, |
| 634 | // .imageType = VK_IMAGE_TYPE_2D, |
| 635 | // .format = tex_format, |
| 636 | // .extent = { tex_width, tex_height, 1 }, |
| 637 | // .mipLevels = 1, |
| 638 | // .arraySize = 1, |
| 639 | // .samples = 1, |
| 640 | // .tiling = VK_IMAGE_TILING_LINEAR, |
| 641 | // .usage = VK_IMAGE_USAGE_SAMPLED_BIT, |
| 642 | // .flags = 0, |
| 643 | // }; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 644 | // VkMemoryAllocateInfo mem_alloc = { |
Tobin Ehlis | 33ce8fd | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 645 | // .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO, |
| 646 | // .pNext = NULL, |
| 647 | // .allocationSize = 0, |
| 648 | // .memoryTypeIndex = 0, |
| 649 | // }; |
| 650 | // |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 651 | // err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | 33ce8fd | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 652 | // ASSERT_VK_SUCCESS(err); |
| 653 | // |
| 654 | // err = vkGetImageMemoryRequirements(m_device->device(), |
| 655 | // image, |
| 656 | // &mem_reqs); |
| 657 | // ASSERT_VK_SUCCESS(err); |
| 658 | // |
| 659 | // mem_alloc.allocationSize = mem_reqs.size; |
| 660 | // |
| 661 | // err = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
| 662 | // ASSERT_VK_SUCCESS(err); |
| 663 | // |
| 664 | // // allocate memory |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 665 | // err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | 33ce8fd | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 666 | // ASSERT_VK_SUCCESS(err); |
| 667 | // |
| 668 | // // Bind memory to Image object |
| 669 | // err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 670 | // ASSERT_VK_SUCCESS(err); |
| 671 | // |
| 672 | // // Introduce validation failure, free memory while still bound to object |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 673 | // vkFreeMemory(m_device->device(), mem, NULL); |
Courtney Goeltzenleuchter | 0d6857f | 2015-09-04 13:52:24 -0600 | [diff] [blame] | 674 | // |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 675 | // if (!m_errorMonitor->DesiredMsgFound()) { |
| 676 | // FAIL() << "Did not receive Warning 'Freeing memory object while it still has references'"); |
| 677 | // m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 33ce8fd | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 678 | // } |
| 679 | //} |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 680 | |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 681 | TEST_F(VkLayerTest, RebindMemory) |
| 682 | { |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 683 | VkResult err; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 684 | bool pass; |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 685 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 686 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 687 | "which has already been bound to mem object"); |
| 688 | |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 689 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 690 | |
| 691 | // Create an image, allocate memory, free it, and then try to bind it |
| 692 | VkImage image; |
| 693 | VkDeviceMemory mem1; |
| 694 | VkDeviceMemory mem2; |
| 695 | VkMemoryRequirements mem_reqs; |
| 696 | |
| 697 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 698 | const int32_t tex_width = 32; |
| 699 | const int32_t tex_height = 32; |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 700 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 701 | VkImageCreateInfo image_create_info = {}; |
| 702 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 703 | image_create_info.pNext = NULL; |
| 704 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 705 | image_create_info.format = tex_format; |
| 706 | image_create_info.extent.width = tex_width; |
| 707 | image_create_info.extent.height = tex_height; |
| 708 | image_create_info.extent.depth = 1; |
| 709 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 710 | image_create_info.arrayLayers = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 711 | image_create_info.samples = 1; |
| 712 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 713 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 714 | image_create_info.flags = 0; |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 715 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 716 | VkMemoryAllocateInfo mem_alloc = {}; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 717 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 718 | mem_alloc.pNext = NULL; |
| 719 | mem_alloc.allocationSize = 0; |
| 720 | mem_alloc.memoryTypeIndex = 0; |
| 721 | |
| 722 | // Introduce failure, do NOT set memProps to VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
| 723 | mem_alloc.memoryTypeIndex = 1; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 724 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 725 | ASSERT_VK_SUCCESS(err); |
| 726 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 727 | vkGetImageMemoryRequirements(m_device->device(), |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 728 | image, |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 729 | &mem_reqs); |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 730 | |
| 731 | mem_alloc.allocationSize = mem_reqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 732 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
| 733 | ASSERT_TRUE(pass); |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 734 | |
| 735 | // allocate 2 memory objects |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 736 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem1); |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 737 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 738 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem2); |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 739 | ASSERT_VK_SUCCESS(err); |
| 740 | |
| 741 | // Bind first memory object to Image object |
Tony Barbour | e84a8d6 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 742 | err = vkBindImageMemory(m_device->device(), image, mem1, 0); |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 743 | ASSERT_VK_SUCCESS(err); |
| 744 | |
| 745 | // 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] | 746 | err = vkBindImageMemory(m_device->device(), image, mem2, 0); |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 747 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 748 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 749 | FAIL() << "Did not receive Error when rebinding memory to an object"; |
| 750 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 751 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 752 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 753 | vkDestroyImage(m_device->device(), image, NULL); |
| 754 | vkFreeMemory(m_device->device(), mem1, NULL); |
| 755 | vkFreeMemory(m_device->device(), mem2, NULL); |
Mark Lobodzinski | c66c671 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 756 | } |
Mark Lobodzinski | 5f25be4 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 757 | |
Tony Barbour | 8508b8e | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 758 | TEST_F(VkLayerTest, SubmitSignaledFence) |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 759 | { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 760 | vk_testing::Fence testFence; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 761 | |
| 762 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 763 | "submitted in SIGNALED state. Fences must be reset before being submitted"); |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 764 | |
| 765 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 8508b8e | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 766 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 767 | fenceInfo.pNext = NULL; |
| 768 | fenceInfo.flags = VK_FENCE_CREATE_SIGNALED_BIT; |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 769 | |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 770 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 771 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 772 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 773 | |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 774 | BeginCommandBuffer(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 775 | 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] | 776 | EndCommandBuffer(); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 777 | |
| 778 | testFence.init(*m_device, fenceInfo); |
Mark Lobodzinski | 87db501 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 779 | |
Courtney Goeltzenleuchter | 1a748e9 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 780 | VkSubmitInfo submit_info; |
Chia-I Wu | 6ec33a0 | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 781 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 782 | submit_info.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 783 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 1a748e9 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 784 | submit_info.pWaitSemaphores = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 785 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 786 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 787 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 1a748e9 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 788 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 3ec3162 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 789 | |
| 790 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
Mark Lobodzinski | 87db501 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 791 | vkQueueWaitIdle(m_device->m_queue ); |
Mark Lobodzinski | 87db501 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 792 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 793 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 794 | FAIL() << "Did not receive Error 'VkQueueSubmit with fence in SIGNALED_STATE'"; |
| 795 | m_errorMonitor->DumpFailureMsgs(); |
Tony Barbour | 8508b8e | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 796 | } |
Tony Barbour | 8508b8e | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 797 | } |
| 798 | |
| 799 | TEST_F(VkLayerTest, ResetUnsignaledFence) |
| 800 | { |
| 801 | vk_testing::Fence testFence; |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 802 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 8508b8e | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 803 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 804 | fenceInfo.pNext = NULL; |
| 805 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 806 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_WARN_BIT, |
| 807 | "submitted to VkResetFences in UNSIGNALED STATE"); |
| 808 | |
Tony Barbour | 8508b8e | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 809 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 810 | testFence.init(*m_device, fenceInfo); |
Chia-I Wu | a499234 | 2015-07-03 11:45:55 +0800 | [diff] [blame] | 811 | VkFence fences[1] = {testFence.handle()}; |
Tony Barbour | 8508b8e | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 812 | vkResetFences(m_device->device(), 1, fences); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 813 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 814 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 815 | FAIL() << "Did not receive Error 'VkResetFences with fence in UNSIGNALED_STATE'"; |
| 816 | m_errorMonitor->DumpFailureMsgs(); |
| 817 | } |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 818 | } |
Tobin Ehlis | d94ba72 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 819 | |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 820 | /* TODO: Update for changes due to bug-14075 tiling across render passes */ |
| 821 | #if 0 |
Tobin Ehlis | d94ba72 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 822 | TEST_F(VkLayerTest, InvalidUsageBits) |
| 823 | { |
| 824 | // Initiate Draw w/o a PSO bound |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 825 | |
| 826 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 827 | "Invalid usage flag for image "); |
Tobin Ehlis | d94ba72 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 828 | |
| 829 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 830 | VkCommandBufferObj commandBuffer(m_device); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 831 | BeginCommandBuffer(); |
Tobin Ehlis | d94ba72 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 832 | |
| 833 | const VkExtent3D e3d = { |
| 834 | .width = 128, |
| 835 | .height = 128, |
| 836 | .depth = 1, |
| 837 | }; |
| 838 | const VkImageCreateInfo ici = { |
| 839 | .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, |
| 840 | .pNext = NULL, |
| 841 | .imageType = VK_IMAGE_TYPE_2D, |
| 842 | .format = VK_FORMAT_D32_SFLOAT_S8_UINT, |
| 843 | .extent = e3d, |
| 844 | .mipLevels = 1, |
| 845 | .arraySize = 1, |
| 846 | .samples = 1, |
| 847 | .tiling = VK_IMAGE_TILING_LINEAR, |
Courtney Goeltzenleuchter | c3b8eea | 2015-09-10 14:14:11 -0600 | [diff] [blame] | 848 | .usage = 0, // Not setting VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
Tobin Ehlis | d94ba72 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 849 | .flags = 0, |
| 850 | }; |
| 851 | |
| 852 | VkImage dsi; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 853 | vkCreateImage(m_device->device(), &ici, NULL, &dsi); |
Tobin Ehlis | d94ba72 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 854 | VkDepthStencilView dsv; |
| 855 | const VkDepthStencilViewCreateInfo dsvci = { |
| 856 | .sType = VK_STRUCTURE_TYPE_DEPTH_STENCIL_VIEW_CREATE_INFO, |
| 857 | .pNext = NULL, |
| 858 | .image = dsi, |
| 859 | .mipLevel = 0, |
Courtney Goeltzenleuchter | 3dee808 | 2015-09-10 16:38:41 -0600 | [diff] [blame] | 860 | .baseArrayLayer = 0, |
Tobin Ehlis | d94ba72 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 861 | .arraySize = 1, |
| 862 | .flags = 0, |
| 863 | }; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 864 | vkCreateDepthStencilView(m_device->device(), &dsvci, NULL, &dsv); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 865 | |
| 866 | if (!m_errorMonitor->DesiredMsgFound()) { |
Tobin Ehlis | d94ba72 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 867 | FAIL() << "Error received was not 'Invalid usage flag for image...'"; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 868 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | d94ba72 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 869 | } |
| 870 | } |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 871 | #endif // 0 |
| 872 | #endif // MEM_TRACKER_TESTS |
| 873 | |
Tobin Ehlis | 40e9f52 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 874 | #if OBJ_TRACKER_TESTS |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 875 | TEST_F(VkLayerTest, PipelineNotBound) |
| 876 | { |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 877 | VkResult err; |
| 878 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 879 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 880 | "Invalid VkPipeline Object "); |
| 881 | |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 882 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 883 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 884 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 885 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 886 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 887 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 888 | |
| 889 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 890 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 891 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 892 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 893 | ds_pool_ci.poolSizeCount = 1; |
| 894 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 895 | |
| 896 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 897 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 898 | ASSERT_VK_SUCCESS(err); |
| 899 | |
| 900 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 901 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 902 | dsl_binding.arraySize = 1; |
| 903 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 904 | dsl_binding.pImmutableSamplers = NULL; |
| 905 | |
| 906 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 907 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 908 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 909 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame^] | 910 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 911 | |
| 912 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 913 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 914 | ASSERT_VK_SUCCESS(err); |
| 915 | |
| 916 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 917 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 918 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 919 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 920 | alloc_info.descriptorPool = ds_pool; |
| 921 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 922 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 923 | ASSERT_VK_SUCCESS(err); |
| 924 | |
| 925 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 926 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 927 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 928 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 929 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 930 | |
| 931 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 932 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 933 | ASSERT_VK_SUCCESS(err); |
| 934 | |
| 935 | VkPipeline badPipeline = (VkPipeline)0xbaadb1be; |
| 936 | |
| 937 | BeginCommandBuffer(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 938 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, badPipeline); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 939 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 940 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 941 | FAIL() << "Error received was not 'Invalid VkPipeline Object 0xbaadb1be'" << endl; |
| 942 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 943 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 944 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 945 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 946 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 947 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 948 | } |
| 949 | |
| 950 | TEST_F(VkLayerTest, BindInvalidMemory) |
| 951 | { |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 952 | VkResult err; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 953 | bool pass; |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 954 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 955 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 956 | "Invalid VkDeviceMemory Object "); |
| 957 | |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 958 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 959 | |
| 960 | // Create an image, allocate memory, free it, and then try to bind it |
| 961 | VkImage image; |
| 962 | VkDeviceMemory mem; |
| 963 | VkMemoryRequirements mem_reqs; |
| 964 | |
| 965 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 966 | const int32_t tex_width = 32; |
| 967 | const int32_t tex_height = 32; |
| 968 | |
| 969 | VkImageCreateInfo image_create_info = {}; |
| 970 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 971 | image_create_info.pNext = NULL; |
| 972 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 973 | image_create_info.format = tex_format; |
| 974 | image_create_info.extent.width = tex_width; |
| 975 | image_create_info.extent.height = tex_height; |
| 976 | image_create_info.extent.depth = 1; |
| 977 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 978 | image_create_info.arrayLayers = 1; |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 979 | image_create_info.samples = 1; |
| 980 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 981 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 982 | image_create_info.flags = 0; |
| 983 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 984 | VkMemoryAllocateInfo mem_alloc = {}; |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 985 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 986 | mem_alloc.pNext = NULL; |
| 987 | mem_alloc.allocationSize = 0; |
| 988 | mem_alloc.memoryTypeIndex = 0; |
| 989 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 990 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 991 | ASSERT_VK_SUCCESS(err); |
| 992 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 993 | vkGetImageMemoryRequirements(m_device->device(), |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 994 | image, |
| 995 | &mem_reqs); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 996 | |
| 997 | mem_alloc.allocationSize = mem_reqs.size; |
| 998 | |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 999 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
| 1000 | ASSERT_TRUE(pass); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1001 | |
| 1002 | // allocate memory |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1003 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1004 | ASSERT_VK_SUCCESS(err); |
| 1005 | |
| 1006 | // Introduce validation failure, free memory before binding |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1007 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1008 | |
| 1009 | // Try to bind free memory that has been freed |
| 1010 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 1011 | // This may very well return an error. |
| 1012 | (void)err; |
| 1013 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1014 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1015 | FAIL() << "Did not receive Error 'Invalid VkDeviceMemory Object 0x<handle>'"; |
| 1016 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1017 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1018 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1019 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1020 | } |
| 1021 | |
| 1022 | TEST_F(VkLayerTest, BindMemoryToDestroyedObject) |
| 1023 | { |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1024 | VkResult err; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 1025 | bool pass; |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1026 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1027 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, "Invalid VkImage Object "); |
| 1028 | |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1029 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1030 | |
| 1031 | // Create an image object, allocate memory, destroy the object and then try to bind it |
| 1032 | VkImage image; |
| 1033 | VkDeviceMemory mem; |
| 1034 | VkMemoryRequirements mem_reqs; |
| 1035 | |
| 1036 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 1037 | const int32_t tex_width = 32; |
| 1038 | const int32_t tex_height = 32; |
| 1039 | |
| 1040 | VkImageCreateInfo image_create_info = {}; |
| 1041 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1042 | image_create_info.pNext = NULL; |
| 1043 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1044 | image_create_info.format = tex_format; |
| 1045 | image_create_info.extent.width = tex_width; |
| 1046 | image_create_info.extent.height = tex_height; |
| 1047 | image_create_info.extent.depth = 1; |
| 1048 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 1049 | image_create_info.arrayLayers = 1; |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1050 | image_create_info.samples = 1; |
| 1051 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1052 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 1053 | image_create_info.flags = 0; |
| 1054 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1055 | VkMemoryAllocateInfo mem_alloc = {}; |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1056 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 1057 | mem_alloc.pNext = NULL; |
| 1058 | mem_alloc.allocationSize = 0; |
| 1059 | mem_alloc.memoryTypeIndex = 0; |
| 1060 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1061 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1062 | ASSERT_VK_SUCCESS(err); |
| 1063 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 1064 | vkGetImageMemoryRequirements(m_device->device(), |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1065 | image, |
| 1066 | &mem_reqs); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1067 | |
| 1068 | mem_alloc.allocationSize = mem_reqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 1069 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
| 1070 | ASSERT_TRUE(pass); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1071 | |
| 1072 | // Allocate memory |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1073 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1074 | ASSERT_VK_SUCCESS(err); |
| 1075 | |
| 1076 | // Introduce validation failure, destroy Image object before binding |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1077 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1078 | ASSERT_VK_SUCCESS(err); |
| 1079 | |
| 1080 | // Now Try to bind memory to this destroyed object |
| 1081 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 1082 | // This may very well return an error. |
| 1083 | (void) err; |
| 1084 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1085 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1086 | FAIL() << "Did not receive Error 'Invalid VkImage Object 0x<handle>'"; |
| 1087 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1088 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1089 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1090 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1091 | } |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1092 | |
| 1093 | TEST_F(VkLayerTest, InvalidBufferViewObject) |
| 1094 | { |
| 1095 | // Create a single TEXEL_BUFFER descriptor and send it an invalid bufferView |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1096 | VkResult err; |
| 1097 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1098 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1099 | "Invalid VkBufferView Object 0xbaadbeef"); |
| 1100 | |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1101 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1102 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1103 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1104 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1105 | |
| 1106 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1107 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1108 | ds_pool_ci.pNext = NULL; |
| 1109 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1110 | ds_pool_ci.poolSizeCount = 1; |
| 1111 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1112 | |
| 1113 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1114 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1115 | ASSERT_VK_SUCCESS(err); |
| 1116 | |
| 1117 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 1118 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 1119 | dsl_binding.arraySize = 1; |
| 1120 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1121 | dsl_binding.pImmutableSamplers = NULL; |
| 1122 | |
| 1123 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1124 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1125 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1126 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame^] | 1127 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1128 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1129 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1130 | ASSERT_VK_SUCCESS(err); |
| 1131 | |
| 1132 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1133 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1134 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1135 | alloc_info.setLayoutCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1136 | alloc_info.descriptorPool = ds_pool; |
| 1137 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1138 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1139 | ASSERT_VK_SUCCESS(err); |
| 1140 | |
Chia-I Wu | e420a33 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 1141 | VkBufferView view = (VkBufferView) 0xbaadbeef; // invalid bufferView object |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1142 | |
| 1143 | VkWriteDescriptorSet descriptor_write; |
| 1144 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 1145 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1146 | descriptor_write.dstSet = descriptorSet; |
| 1147 | descriptor_write.dstBinding = 0; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1148 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1149 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 1150 | descriptor_write.pTexelBufferView = &view; |
| 1151 | |
| 1152 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 1153 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1154 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1155 | FAIL() << "Did nto receive Error 'Invalid VkBufferView Object 0xbaadbeef'"; |
| 1156 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1157 | } |
| 1158 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1159 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1160 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1161 | } |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 1162 | #endif // OBJ_TRACKER_TESTS |
| 1163 | |
Tobin Ehlis | 57e6a61 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 1164 | #if DRAW_STATE_TESTS |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1165 | TEST_F(VkLayerTest, LineWidthStateNotBound) |
| 1166 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1167 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1168 | "Dynamic line width state not set for this command buffer"); |
| 1169 | |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1170 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a line width state object is not bound beforehand"); |
| 1171 | |
| 1172 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailLineWidth); |
| 1173 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1174 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1175 | FAIL() << "Did not receive Error 'Dynamic line width state not set for this command buffer'"; |
| 1176 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1177 | } |
| 1178 | } |
| 1179 | |
| 1180 | TEST_F(VkLayerTest, DepthBiasStateNotBound) |
| 1181 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1182 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1183 | "Dynamic depth bias state not set for this command buffer"); |
| 1184 | |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1185 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a depth bias state object is not bound beforehand"); |
| 1186 | |
| 1187 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailDepthBias); |
| 1188 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1189 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1190 | FAIL() << "Did not receive Error 'Dynamic depth bias state not set for this command buffer'"; |
| 1191 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1192 | } |
| 1193 | } |
| 1194 | |
Cody Northrop | bca3bcd | 2015-10-27 16:54:28 -0600 | [diff] [blame] | 1195 | // 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] | 1196 | TEST_F(VkLayerTest, ViewportStateNotBound) |
| 1197 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1198 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1199 | "Dynamic viewport state not set for this command buffer"); |
| 1200 | |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1201 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a viewport state object is not bound beforehand"); |
| 1202 | |
| 1203 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailViewport); |
| 1204 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1205 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1206 | FAIL() << "Did not recieve Error 'Dynamic scissor state not set for this command buffer'"; |
| 1207 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1208 | } |
| 1209 | } |
| 1210 | |
| 1211 | TEST_F(VkLayerTest, ScissorStateNotBound) |
| 1212 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1213 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1214 | "Dynamic scissor state not set for this command buffer"); |
| 1215 | |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1216 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a viewport state object is not bound beforehand"); |
| 1217 | |
| 1218 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailScissor); |
| 1219 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1220 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1221 | FAIL() << "Did not recieve Error ' Expected: 'Dynamic scissor state not set for this command buffer'"; |
| 1222 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1223 | } |
| 1224 | } |
| 1225 | |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1226 | TEST_F(VkLayerTest, BlendStateNotBound) |
| 1227 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1228 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1229 | "Dynamic blend object state not set for this command buffer"); |
| 1230 | |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1231 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a blend state object is not bound beforehand"); |
| 1232 | |
| 1233 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailBlend); |
| 1234 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1235 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1236 | FAIL() << "Did not recieve Error 'Dynamic blend object state not set for this command buffer'"; |
| 1237 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1238 | } |
| 1239 | } |
| 1240 | |
| 1241 | TEST_F(VkLayerTest, DepthBoundsStateNotBound) |
| 1242 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1243 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1244 | "Dynamic depth bounds state not set for this command buffer"); |
| 1245 | |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1246 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a depth bounds state object is not bound beforehand"); |
| 1247 | |
| 1248 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailDepthBounds); |
| 1249 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1250 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1251 | FAIL() << "Did not receive Error 'Dynamic depth bounds state not set for this command buffer'"; |
| 1252 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1253 | } |
| 1254 | } |
| 1255 | |
| 1256 | TEST_F(VkLayerTest, StencilReadMaskNotSet) |
| 1257 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1258 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1259 | "Dynamic stencil read mask state not set for this command buffer"); |
| 1260 | |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1261 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1262 | |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1263 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a stencil read mask is not set beforehand"); |
| 1264 | |
| 1265 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailStencilReadMask); |
| 1266 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1267 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1268 | FAIL() << "Did not receive Error 'Dynamic stencil read mask state not set for this command buffer'"; |
| 1269 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1270 | } |
| 1271 | } |
| 1272 | |
| 1273 | TEST_F(VkLayerTest, StencilWriteMaskNotSet) |
| 1274 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1275 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1276 | "Dynamic stencil write mask state not set for this command buffer"); |
| 1277 | |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1278 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1279 | |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1280 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a stencil write mask is not set beforehand"); |
| 1281 | |
| 1282 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailStencilWriteMask); |
| 1283 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1284 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1285 | FAIL() << "Did not receive Error 'Dynamic stencil write mask state not set for this command buffer'"; |
| 1286 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1287 | } |
| 1288 | } |
| 1289 | |
| 1290 | TEST_F(VkLayerTest, StencilReferenceNotSet) |
| 1291 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1292 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1293 | "Dynamic stencil reference state not set for this command buffer"); |
| 1294 | |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1295 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a stencil reference is not set beforehand"); |
| 1296 | |
| 1297 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailStencilReference); |
| 1298 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1299 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1300 | FAIL() << "Did not receive Error 'Dynamic stencil reference state not set for this command buffer'"; |
| 1301 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1302 | } |
| 1303 | } |
| 1304 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1305 | TEST_F(VkLayerTest, CommandBufferTwoSubmits) |
Tobin Ehlis | 0cea408 | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1306 | { |
| 1307 | vk_testing::Fence testFence; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1308 | |
| 1309 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1310 | "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] | 1311 | |
| 1312 | VkFenceCreateInfo fenceInfo = {}; |
| 1313 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 1314 | fenceInfo.pNext = NULL; |
| 1315 | fenceInfo.flags = 0; |
| 1316 | |
| 1317 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1318 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 1319 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1320 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1321 | // 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] | 1322 | BeginCommandBuffer(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1323 | 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] | 1324 | EndCommandBuffer(); |
| 1325 | |
| 1326 | testFence.init(*m_device, fenceInfo); |
| 1327 | |
| 1328 | // Bypass framework since it does the waits automatically |
| 1329 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 1a748e9 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1330 | VkSubmitInfo submit_info; |
Chia-I Wu | 6ec33a0 | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 1331 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1332 | submit_info.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1333 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 1a748e9 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1334 | submit_info.pWaitSemaphores = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1335 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1336 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1337 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 1a748e9 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1338 | submit_info.pSignalSemaphores = NULL; |
| 1339 | |
Courtney Goeltzenleuchter | 3ec3162 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 1340 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Tobin Ehlis | 0cea408 | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1341 | ASSERT_VK_SUCCESS( err ); |
| 1342 | |
Tobin Ehlis | 0cea408 | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1343 | // 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] | 1344 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Tobin Ehlis | 0cea408 | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1345 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1346 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1347 | FAIL() << "Did not receive Error 'CB (0xaddress) was created w/ VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set...'"; |
| 1348 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 0cea408 | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1349 | } |
| 1350 | } |
| 1351 | |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 1352 | TEST_F(VkLayerTest, BindPipelineNoRenderPass) |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1353 | { |
| 1354 | // Initiate Draw w/o a PSO bound |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1355 | VkResult err; |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1356 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1357 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1358 | "Incorrectly binding graphics pipeline "); |
| 1359 | |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1360 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1361 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1362 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1363 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1364 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1365 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1366 | |
| 1367 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1368 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1369 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 1370 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1371 | ds_pool_ci.poolSizeCount = 1; |
| 1372 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1373 | |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 1374 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1375 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1376 | ASSERT_VK_SUCCESS(err); |
| 1377 | |
| 1378 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 1379 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1380 | dsl_binding.arraySize = 1; |
| 1381 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1382 | dsl_binding.pImmutableSamplers = NULL; |
| 1383 | |
| 1384 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1385 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1386 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1387 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame^] | 1388 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1389 | |
| 1390 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1391 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1392 | ASSERT_VK_SUCCESS(err); |
| 1393 | |
| 1394 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1395 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1396 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1397 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1398 | alloc_info.descriptorPool = ds_pool; |
| 1399 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1400 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1401 | ASSERT_VK_SUCCESS(err); |
| 1402 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 1403 | pipe_ms_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 1404 | pipe_ms_state_ci.pNext = NULL; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1405 | pipe_ms_state_ci.rasterizationSamples = 1; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1406 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 1407 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 1408 | pipe_ms_state_ci.pSampleMask = NULL; |
| 1409 | |
| 1410 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 1411 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 1412 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1413 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1414 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 1415 | VkPipelineLayout pipeline_layout; |
| 1416 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1417 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1418 | ASSERT_VK_SUCCESS(err); |
| 1419 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 1420 | VkShaderObj vs(m_device, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 1421 | 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] | 1422 | // but add it to be able to run on more devices |
| 1423 | VkPipelineObj pipe(m_device); |
| 1424 | pipe.AddShader(&vs); |
| 1425 | pipe.AddShader(&fs); |
| 1426 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 1427 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1428 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1429 | // Calls AllocateCommandBuffers |
| 1430 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
| 1431 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
| 1432 | memset(&cmd_buf_info, 0, sizeof(VkCommandBufferBeginInfo)); |
| 1433 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1434 | cmd_buf_info.pNext = NULL; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1435 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1436 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1437 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
| 1438 | vkCmdBindPipeline(commandBuffer.GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1439 | |
| 1440 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1441 | FAIL() << "Did not receive Error 'Incorrectly binding graphics pipeline (0x<handle>) without an active RenderPass'"; |
| 1442 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1443 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1444 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1445 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 1446 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1447 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1448 | } |
| 1449 | |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1450 | TEST_F(VkLayerTest, AllocDescriptorFromEmptyPool) |
| 1451 | { |
| 1452 | // Initiate Draw w/o a PSO bound |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1453 | VkResult err; |
| 1454 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1455 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1456 | "Unable to allocate 1 descriptors of type VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER "); |
| 1457 | |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1458 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1459 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1460 | |
| 1461 | // 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] | 1462 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1463 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1464 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1465 | |
| 1466 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1467 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1468 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1469 | ds_pool_ci.flags = 0; |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1470 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1471 | ds_pool_ci.poolSizeCount = 1; |
| 1472 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1473 | |
| 1474 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1475 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1476 | ASSERT_VK_SUCCESS(err); |
| 1477 | |
| 1478 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 1479 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1480 | dsl_binding.arraySize = 1; |
| 1481 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1482 | dsl_binding.pImmutableSamplers = NULL; |
| 1483 | |
| 1484 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1485 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1486 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1487 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame^] | 1488 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1489 | |
| 1490 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1491 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1492 | ASSERT_VK_SUCCESS(err); |
| 1493 | |
| 1494 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1495 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1496 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1497 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1498 | alloc_info.descriptorPool = ds_pool; |
| 1499 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1500 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1501 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1502 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1503 | FAIL() << "Did not receive Error 'Unable to allocate 1 descriptors of type VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER...'"; |
| 1504 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1505 | } |
| 1506 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1507 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1508 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1509 | } |
| 1510 | |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1511 | TEST_F(VkLayerTest, FreeDescriptorFromOneShotPool) |
| 1512 | { |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1513 | VkResult err; |
| 1514 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1515 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1516 | "It is invalid to call vkFreeDescriptorSets() with a pool created without setting VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT."); |
| 1517 | |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1518 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1519 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1520 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1521 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1522 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1523 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1524 | |
| 1525 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1526 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1527 | ds_pool_ci.pNext = NULL; |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1528 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1529 | ds_pool_ci.poolSizeCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1530 | ds_pool_ci.flags = 0; |
| 1531 | // Not specifying VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT means |
| 1532 | // app can only call vkResetDescriptorPool on this pool.; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1533 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1534 | |
| 1535 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1536 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1537 | ASSERT_VK_SUCCESS(err); |
| 1538 | |
| 1539 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 1540 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1541 | dsl_binding.arraySize = 1; |
| 1542 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1543 | dsl_binding.pImmutableSamplers = NULL; |
| 1544 | |
| 1545 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1546 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1547 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1548 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame^] | 1549 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1550 | |
| 1551 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1552 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1553 | ASSERT_VK_SUCCESS(err); |
| 1554 | |
| 1555 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1556 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1557 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1558 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1559 | alloc_info.descriptorPool = ds_pool; |
| 1560 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1561 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1562 | ASSERT_VK_SUCCESS(err); |
| 1563 | |
| 1564 | err = vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptorSet); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1565 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1566 | FAIL() << "Did not receive Error 'It is invalid to call vkFreeDescriptorSets() with a pool created with...'"; |
| 1567 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1568 | } |
| 1569 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1570 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1571 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1572 | } |
| 1573 | |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1574 | TEST_F(VkLayerTest, InvalidDescriptorPool) |
| 1575 | { |
| 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 |
| 1578 | // Attempt to clear DS Pool with bad object |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1579 | /* |
| 1580 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1581 | "Unable to find pool node for pool 0xbaad6001 specified in vkResetDescriptorPool() call"); |
| 1582 | |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1583 | VkDescriptorPool badPool = (VkDescriptorPool)0xbaad6001; |
| 1584 | vkResetDescriptorPool(device(), badPool); |
| 1585 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1586 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1587 | FAIL() << "Did not receive Error 'Unable to find pool node for pool 0xbaad6001 specified in vkResetDescriptorPool() call'"; |
| 1588 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1589 | }*/ |
| 1590 | } |
| 1591 | |
| 1592 | TEST_F(VkLayerTest, InvalidDescriptorSet) |
| 1593 | { |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1594 | // TODO : Simple check for bad object should be added to ObjectTracker to catch this case |
| 1595 | // 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] | 1596 | // Create a valid cmd buffer |
| 1597 | // call vkCmdBindDescriptorSets w/ false DS |
| 1598 | } |
| 1599 | |
| 1600 | TEST_F(VkLayerTest, InvalidDescriptorSetLayout) |
| 1601 | { |
| 1602 | // TODO : Simple check for bad object should be added to ObjectTracker to catch this case |
| 1603 | // The DS check for this is after driver has been called to validate DS internal data struct |
| 1604 | } |
| 1605 | |
| 1606 | TEST_F(VkLayerTest, InvalidPipeline) |
| 1607 | { |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1608 | // TODO : Simple check for bad object should be added to ObjectTracker to catch this case |
| 1609 | // 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] | 1610 | // Create a valid cmd buffer |
| 1611 | // call vkCmdBindPipeline w/ false Pipeline |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1612 | // |
| 1613 | // m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1614 | // "Attempt to bind Pipeline "); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 1615 | // |
| 1616 | // ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1617 | // VkCommandBufferObj commandBuffer(m_device); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1618 | // BeginCommandBuffer(); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 1619 | // VkPipeline badPipeline = (VkPipeline)0xbaadb1be; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1620 | // vkCmdBindPipeline(commandBuffer.GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, badPipeline); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1621 | // |
| 1622 | // if (!m_errorMonitor->DesiredMsgFound()) { |
| 1623 | // FAIL() << "Did not receive Error 'Attempt to bind Pipeline 0xbaadb1be that doesn't exist!'"; |
| 1624 | // m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 1625 | // } |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1626 | } |
| 1627 | |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1628 | TEST_F(VkLayerTest, DescriptorSetNotUpdated) |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1629 | { |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1630 | // 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] | 1631 | VkResult err; |
| 1632 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1633 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_WARN_BIT, |
| 1634 | " bound but it was never updated. "); |
| 1635 | |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1636 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | d72da75 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 1637 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 1638 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1639 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1640 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1641 | ds_type_count.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1642 | |
| 1643 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1644 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1645 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 1646 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1647 | ds_pool_ci.poolSizeCount = 1; |
| 1648 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mike Stroyan | d72da75 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 1649 | |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1650 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1651 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1652 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1653 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1654 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 1655 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1656 | dsl_binding.arraySize = 1; |
| 1657 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1658 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1659 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1660 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1661 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1662 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1663 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame^] | 1664 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1665 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1666 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1667 | ASSERT_VK_SUCCESS(err); |
| 1668 | |
| 1669 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1670 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1671 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1672 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1673 | alloc_info.descriptorPool = ds_pool; |
| 1674 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1675 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1676 | ASSERT_VK_SUCCESS(err); |
| 1677 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1678 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 1679 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 1680 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1681 | pipeline_layout_ci.setLayoutCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1682 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1683 | |
| 1684 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1685 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1686 | ASSERT_VK_SUCCESS(err); |
| 1687 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 1688 | VkShaderObj vs(m_device, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1689 | // TODO - We shouldn't need a fragment shader but add it to be able to run on more devices |
| 1690 | VkShaderObj fs(m_device, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1691 | |
Tony Barbour | 4e8d1b1 | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 1692 | VkPipelineObj pipe(m_device); |
| 1693 | pipe.AddShader(&vs); |
Tony Barbour | 3c9e3b1 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 1694 | pipe.AddShader(&fs); |
Tony Barbour | 4e8d1b1 | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 1695 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1696 | |
| 1697 | BeginCommandBuffer(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1698 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 1699 | 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] | 1700 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1701 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1702 | FAIL() << "Did not recieve Warning 'DS <blah> bound but it was never updated. You may want to either update it or not bind it.'"; |
| 1703 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1704 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1705 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1706 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 1707 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1708 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1709 | } |
| 1710 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1711 | TEST_F(VkLayerTest, NoBeginCommandBuffer) |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1712 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1713 | |
| 1714 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1715 | "You must call vkBeginCommandBuffer() before this call to "); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1716 | |
| 1717 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1718 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1719 | // Call EndCommandBuffer() w/o calling BeginCommandBuffer() |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1720 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1721 | |
| 1722 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1723 | FAIL() << "Did not recieve Error 'You must call vkBeginCommandBuffer() before this call to vkEndCommandBuffer()'"; |
| 1724 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1725 | } |
| 1726 | } |
| 1727 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1728 | TEST_F(VkLayerTest, PrimaryCommandBufferFramebufferAndRenderpass) |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1729 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1730 | |
| 1731 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1732 | "may not specify framebuffer or renderpass parameters"); |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1733 | |
| 1734 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1735 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1736 | // Calls AllocateCommandBuffers |
| 1737 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1738 | |
| 1739 | // 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] | 1740 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
| 1741 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Cody Northrop | 10d8f98 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 1742 | cmd_buf_info.pNext = NULL; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1743 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
Cody Northrop | 10d8f98 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 1744 | cmd_buf_info.renderPass = (VkRenderPass)0xcadecade; |
| 1745 | cmd_buf_info.framebuffer = (VkFramebuffer)0xcadecade; |
| 1746 | |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1747 | |
| 1748 | // The error should be caught by validation of the BeginCommandBuffer call |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1749 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1750 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1751 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1752 | FAIL() << "Did not receive Error 'vkAllocateCommandBuffers(): Primary Command Buffer may not specify framebuffer or renderpass parameters'"; |
| 1753 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1754 | } |
| 1755 | } |
| 1756 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1757 | TEST_F(VkLayerTest, SecondaryCommandBufferFramebufferAndRenderpass) |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1758 | { |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1759 | VkResult err; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1760 | VkCommandBuffer draw_cmd; |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1761 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1762 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1763 | "must specify framebuffer and renderpass parameters"); |
| 1764 | |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1765 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1766 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1767 | VkCommandBufferAllocateInfo cmd = {}; |
| 1768 | cmd.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOC_INFO; |
Cody Northrop | 10d8f98 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 1769 | cmd.pNext = NULL; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1770 | cmd.commandPool = m_commandPool; |
| 1771 | cmd.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1772 | cmd.bufferCount = 1; |
Cody Northrop | 10d8f98 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 1773 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1774 | err = vkAllocateCommandBuffers(m_device->device(), &cmd, &draw_cmd); |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1775 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1776 | |
| 1777 | // Force the failure by not setting the Renderpass and Framebuffer fields |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1778 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
| 1779 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Cody Northrop | 10d8f98 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 1780 | cmd_buf_info.pNext = NULL; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1781 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1782 | |
| 1783 | // The error should be caught by validation of the BeginCommandBuffer call |
| 1784 | vkBeginCommandBuffer(draw_cmd, &cmd_buf_info); |
| 1785 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1786 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1787 | FAIL() << "Did not receive Error 'vkAllocateCommandBuffers(): Secondary Command Buffer must specify framebuffer and renderpass parameters'"; |
| 1788 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1789 | } |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1790 | vkFreeCommandBuffers(m_device->device(), m_commandPool, 1, &draw_cmd); |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1791 | } |
| 1792 | |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1793 | TEST_F(VkLayerTest, InvalidPipelineCreateState) |
| 1794 | { |
| 1795 | // Attempt to Create Gfx Pipeline w/o a VS |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1796 | VkResult err; |
| 1797 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1798 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1799 | "Invalid Pipeline CreateInfo State: Vtx Shader required"); |
| 1800 | |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1801 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1802 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 1803 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1804 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1805 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1806 | ds_type_count.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1807 | |
| 1808 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1809 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1810 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 1811 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1812 | ds_pool_ci.poolSizeCount = 1; |
| 1813 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 1814 | |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1815 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1816 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1817 | ASSERT_VK_SUCCESS(err); |
| 1818 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1819 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 1820 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1821 | dsl_binding.arraySize = 1; |
| 1822 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1823 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1824 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1825 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1826 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1827 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1828 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame^] | 1829 | ds_layout_ci.pBinding = &dsl_binding; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1830 | |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1831 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1832 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1833 | ASSERT_VK_SUCCESS(err); |
| 1834 | |
| 1835 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1836 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1837 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1838 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1839 | alloc_info.descriptorPool = ds_pool; |
| 1840 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1841 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1842 | ASSERT_VK_SUCCESS(err); |
| 1843 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1844 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 1845 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1846 | pipeline_layout_ci.setLayoutCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1847 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1848 | |
| 1849 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1850 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1851 | ASSERT_VK_SUCCESS(err); |
| 1852 | |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 1853 | VkViewport vp = {}; // Just need dummy vp to point to |
| 1854 | VkRect2D sc = {}; // dummy scissor to point to |
| 1855 | |
| 1856 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 1857 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 1858 | vp_state_ci.scissorCount = 1; |
| 1859 | vp_state_ci.pScissors = ≻ |
| 1860 | vp_state_ci.viewportCount = 1; |
| 1861 | vp_state_ci.pViewports = &vp; |
| 1862 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1863 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 1864 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 1865 | gp_ci.pViewportState = &vp_state_ci; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1866 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 1867 | gp_ci.layout = pipeline_layout; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1868 | gp_ci.renderPass = renderPass(); |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1869 | |
| 1870 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 1871 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Chia-I Wu | 7e47070 | 2015-10-26 17:24:52 +0800 | [diff] [blame] | 1872 | pc_ci.initialDataSize = 0; |
| 1873 | pc_ci.pInitialData = 0; |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1874 | |
| 1875 | VkPipeline pipeline; |
Jon Ashburn | 0d60d27 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 1876 | VkPipelineCache pipelineCache; |
| 1877 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1878 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Jon Ashburn | 0d60d27 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 1879 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1880 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1881 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1882 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1883 | FAIL() << "Did not receive Error 'Invalid Pipeline CreateInfo State: Vtx Shader required'"; |
| 1884 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1885 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1886 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1887 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 1888 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 1889 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1890 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1891 | } |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1892 | /*// TODO : This test should be good, but needs Tess support in compiler to run |
| 1893 | TEST_F(VkLayerTest, InvalidPatchControlPoints) |
| 1894 | { |
| 1895 | // Attempt to Create Gfx Pipeline w/o a VS |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1896 | VkResult err; |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1897 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1898 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1899 | "Invalid Pipeline CreateInfo State: VK_PRIMITIVE_TOPOLOGY_PATCH primitive "); |
| 1900 | |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1901 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1902 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1903 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1904 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1905 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1906 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1907 | |
| 1908 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1909 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1910 | ds_pool_ci.pNext = NULL; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1911 | ds_pool_ci.poolSizeCount = 1; |
| 1912 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1913 | |
| 1914 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1915 | 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] | 1916 | ASSERT_VK_SUCCESS(err); |
| 1917 | |
| 1918 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 1919 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1920 | dsl_binding.arraySize = 1; |
| 1921 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1922 | dsl_binding.pImmutableSamplers = NULL; |
| 1923 | |
| 1924 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1925 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1926 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1927 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame^] | 1928 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1929 | |
| 1930 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1931 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1932 | ASSERT_VK_SUCCESS(err); |
| 1933 | |
| 1934 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1935 | 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] | 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; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1941 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1942 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 1943 | |
| 1944 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1945 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1946 | ASSERT_VK_SUCCESS(err); |
| 1947 | |
| 1948 | VkPipelineShaderStageCreateInfo shaderStages[3]; |
| 1949 | memset(&shaderStages, 0, 3 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 1950 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 1951 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, this); |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1952 | // 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] | 1953 | VkShaderObj tc(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 1954 | VkShaderObj te(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1955 | |
| 1956 | shaderStages[0].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 1957 | shaderStages[0].stage = VK_SHADER_STAGE_VERTEX_BIT; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1958 | shaderStages[0].shader = vs.handle(); |
| 1959 | shaderStages[1].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 1960 | shaderStages[1].stage = VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1961 | shaderStages[1].shader = tc.handle(); |
| 1962 | shaderStages[2].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 1963 | shaderStages[2].stage = VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1964 | shaderStages[2].shader = te.handle(); |
| 1965 | |
| 1966 | VkPipelineInputAssemblyStateCreateInfo iaCI = {}; |
| 1967 | iaCI.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 1968 | iaCI.topology = VK_PRIMITIVE_TOPOLOGY_PATCH; |
| 1969 | |
| 1970 | VkPipelineTessellationStateCreateInfo tsCI = {}; |
| 1971 | tsCI.sType = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO; |
| 1972 | tsCI.patchControlPoints = 0; // This will cause an error |
| 1973 | |
| 1974 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 1975 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 1976 | gp_ci.pNext = NULL; |
| 1977 | gp_ci.stageCount = 3; |
| 1978 | gp_ci.pStages = shaderStages; |
| 1979 | gp_ci.pVertexInputState = NULL; |
| 1980 | gp_ci.pInputAssemblyState = &iaCI; |
| 1981 | gp_ci.pTessellationState = &tsCI; |
| 1982 | gp_ci.pViewportState = NULL; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1983 | gp_ci.pRasterizationState = NULL; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1984 | gp_ci.pMultisampleState = NULL; |
| 1985 | gp_ci.pDepthStencilState = NULL; |
| 1986 | gp_ci.pColorBlendState = NULL; |
| 1987 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 1988 | gp_ci.layout = pipeline_layout; |
| 1989 | gp_ci.renderPass = renderPass(); |
| 1990 | |
| 1991 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 1992 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 1993 | pc_ci.pNext = NULL; |
| 1994 | pc_ci.initialSize = 0; |
| 1995 | pc_ci.initialData = 0; |
| 1996 | pc_ci.maxSize = 0; |
| 1997 | |
| 1998 | VkPipeline pipeline; |
| 1999 | VkPipelineCache pipelineCache; |
| 2000 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2001 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2002 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2003 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2004 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2005 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2006 | FAIL() << "Did not receive Error 'Invalid Pipeline CreateInfo State: VK_PRIMITIVE_TOPOLOGY_PATCH primitive...'"; |
| 2007 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2008 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2009 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2010 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2011 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2012 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2013 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2014 | } |
| 2015 | */ |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2016 | // Set scissor and viewport counts to different numbers |
| 2017 | TEST_F(VkLayerTest, PSOViewportScissorCountMismatch) |
| 2018 | { |
| 2019 | // Attempt to Create Gfx Pipeline w/o a VS |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2020 | VkResult err; |
| 2021 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2022 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2023 | "Gfx Pipeline viewport count (1) must match scissor count (0)."); |
| 2024 | |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2025 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2026 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2027 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2028 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2029 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2030 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2031 | |
| 2032 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2033 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2034 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2035 | ds_pool_ci.poolSizeCount = 1; |
| 2036 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2037 | |
| 2038 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2039 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2040 | ASSERT_VK_SUCCESS(err); |
| 2041 | |
| 2042 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 2043 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2044 | dsl_binding.arraySize = 1; |
| 2045 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2046 | |
| 2047 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2048 | 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] | 2049 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame^] | 2050 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2051 | |
| 2052 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2053 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2054 | ASSERT_VK_SUCCESS(err); |
| 2055 | |
| 2056 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2057 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2058 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2059 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2060 | alloc_info.descriptorPool = ds_pool; |
| 2061 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2062 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2063 | ASSERT_VK_SUCCESS(err); |
| 2064 | |
| 2065 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 2066 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2067 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2068 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 2069 | |
| 2070 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2071 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2072 | ASSERT_VK_SUCCESS(err); |
| 2073 | |
| 2074 | VkViewport vp = {}; // Just need dummy vp to point to |
| 2075 | |
| 2076 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 2077 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 2078 | vp_state_ci.scissorCount = 0; |
| 2079 | vp_state_ci.viewportCount = 1; // Count mismatch should cause error |
| 2080 | vp_state_ci.pViewports = &vp; |
| 2081 | |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2082 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 2083 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2084 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2085 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, this); |
| 2086 | 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] | 2087 | // but add it to be able to run on more devices |
| 2088 | shaderStages[0].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2089 | shaderStages[0].shader = vs.handle(); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2090 | |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2091 | shaderStages[1].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2092 | shaderStages[1].shader = fs.handle(); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2093 | |
| 2094 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 2095 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2096 | gp_ci.stageCount = 2; |
| 2097 | gp_ci.pStages = shaderStages; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2098 | gp_ci.pViewportState = &vp_state_ci; |
| 2099 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2100 | gp_ci.layout = pipeline_layout; |
| 2101 | gp_ci.renderPass = renderPass(); |
| 2102 | |
| 2103 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 2104 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 2105 | |
| 2106 | VkPipeline pipeline; |
| 2107 | VkPipelineCache pipelineCache; |
| 2108 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2109 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2110 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2111 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2112 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2113 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2114 | FAIL() << "Did not receive Error 'Gfx Pipeline viewport count (1) must match scissor count (0).'"; |
| 2115 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2116 | } |
| 2117 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2118 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2119 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2120 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2121 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2122 | } |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2123 | // Don't set viewport state in PSO. This is an error b/c we always need this state |
| 2124 | // for the counts even if the data is going to be set dynamically. |
| 2125 | TEST_F(VkLayerTest, PSOViewportStateNotSet) |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2126 | { |
| 2127 | // Attempt to Create Gfx Pipeline w/o a VS |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2128 | VkResult err; |
| 2129 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2130 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2131 | "Gfx Pipeline pViewportState is null. Even if "); |
| 2132 | |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2133 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2134 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2135 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2136 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2137 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2138 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2139 | |
| 2140 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2141 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2142 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2143 | ds_pool_ci.poolSizeCount = 1; |
| 2144 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2145 | |
| 2146 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2147 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2148 | ASSERT_VK_SUCCESS(err); |
| 2149 | |
| 2150 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 2151 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2152 | dsl_binding.arraySize = 1; |
| 2153 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2154 | |
| 2155 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2156 | 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] | 2157 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame^] | 2158 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2159 | |
| 2160 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2161 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2162 | ASSERT_VK_SUCCESS(err); |
| 2163 | |
| 2164 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2165 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2166 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2167 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2168 | alloc_info.descriptorPool = ds_pool; |
| 2169 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2170 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2171 | ASSERT_VK_SUCCESS(err); |
| 2172 | |
| 2173 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 2174 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2175 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2176 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 2177 | |
| 2178 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2179 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2180 | ASSERT_VK_SUCCESS(err); |
| 2181 | |
| 2182 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 2183 | // Set scissor as dynamic to avoid second error |
| 2184 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 2185 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 2186 | dyn_state_ci.dynamicStateCount = 1; |
| 2187 | dyn_state_ci.pDynamicStates = &sc_state; |
| 2188 | |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2189 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 2190 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2191 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2192 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, this); |
| 2193 | 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] | 2194 | // but add it to be able to run on more devices |
| 2195 | shaderStages[0].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2196 | shaderStages[0].shader = vs.handle(); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2197 | |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2198 | shaderStages[1].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2199 | shaderStages[1].shader = fs.handle(); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2200 | |
| 2201 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 2202 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2203 | gp_ci.stageCount = 2; |
| 2204 | gp_ci.pStages = shaderStages; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2205 | gp_ci.pViewportState = NULL; // Not setting VP state w/o dynamic vp state should cause validation error |
| 2206 | gp_ci.pDynamicState = &dyn_state_ci; |
| 2207 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2208 | gp_ci.layout = pipeline_layout; |
| 2209 | gp_ci.renderPass = renderPass(); |
| 2210 | |
| 2211 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 2212 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 2213 | |
| 2214 | VkPipeline pipeline; |
| 2215 | VkPipelineCache pipelineCache; |
| 2216 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2217 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2218 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2219 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2220 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2221 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2222 | FAIL() << "Did not receive Error 'Gfx Pipeline pViewportState is null. Even if...'"; |
| 2223 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2224 | } |
| 2225 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2226 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2227 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2228 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2229 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2230 | } |
| 2231 | // Create PSO w/o non-zero viewportCount but no viewport data |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2232 | // Then run second test where dynamic scissor count doesn't match PSO scissor count |
| 2233 | TEST_F(VkLayerTest, PSOViewportCountWithoutDataAndDynScissorMismatch) |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2234 | { |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2235 | VkResult err; |
| 2236 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2237 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2238 | "Gfx Pipeline viewportCount is 1, but pViewports is NULL. "); |
| 2239 | |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2240 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2241 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2242 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2243 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2244 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2245 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2246 | |
| 2247 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2248 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2249 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2250 | ds_pool_ci.poolSizeCount = 1; |
| 2251 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2252 | |
| 2253 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2254 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2255 | ASSERT_VK_SUCCESS(err); |
| 2256 | |
| 2257 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 2258 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2259 | dsl_binding.arraySize = 1; |
| 2260 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2261 | |
| 2262 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2263 | 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] | 2264 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame^] | 2265 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2266 | |
| 2267 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2268 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2269 | ASSERT_VK_SUCCESS(err); |
| 2270 | |
| 2271 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2272 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2273 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2274 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2275 | alloc_info.descriptorPool = ds_pool; |
| 2276 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2277 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2278 | ASSERT_VK_SUCCESS(err); |
| 2279 | |
| 2280 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 2281 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2282 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2283 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 2284 | |
| 2285 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2286 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2287 | ASSERT_VK_SUCCESS(err); |
| 2288 | |
| 2289 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 2290 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 2291 | vp_state_ci.viewportCount = 1; |
| 2292 | vp_state_ci.pViewports = NULL; // Null vp w/ count of 1 should cause error |
| 2293 | vp_state_ci.scissorCount = 1; |
| 2294 | vp_state_ci.pScissors = NULL; // Scissor is dynamic (below) so this won't cause error |
| 2295 | |
| 2296 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 2297 | // Set scissor as dynamic to avoid that error |
| 2298 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 2299 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 2300 | dyn_state_ci.dynamicStateCount = 1; |
| 2301 | dyn_state_ci.pDynamicStates = &sc_state; |
| 2302 | |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2303 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 2304 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2305 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2306 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, this); |
| 2307 | 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] | 2308 | // but add it to be able to run on more devices |
| 2309 | shaderStages[0].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2310 | shaderStages[0].shader = vs.handle(); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2311 | |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2312 | shaderStages[1].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2313 | shaderStages[1].shader = fs.handle(); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2314 | |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2315 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 2316 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 2317 | vi_ci.pNext = nullptr; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2318 | vi_ci.vertexBindingDescriptionCount = 0; |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2319 | vi_ci.pVertexBindingDescriptions = nullptr; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2320 | vi_ci.vertexAttributeDescriptionCount = 0; |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2321 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 2322 | |
| 2323 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 2324 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 2325 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 2326 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2327 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2328 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2329 | rs_ci.pNext = nullptr; |
| 2330 | |
| 2331 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 2332 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 2333 | cb_ci.pNext = nullptr; |
| 2334 | |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2335 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 2336 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2337 | gp_ci.stageCount = 2; |
| 2338 | gp_ci.pStages = shaderStages; |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2339 | gp_ci.pVertexInputState = &vi_ci; |
| 2340 | gp_ci.pInputAssemblyState = &ia_ci; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2341 | gp_ci.pViewportState = &vp_state_ci; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2342 | gp_ci.pRasterizationState = &rs_ci; |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2343 | gp_ci.pColorBlendState = &cb_ci; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2344 | gp_ci.pDynamicState = &dyn_state_ci; |
| 2345 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2346 | gp_ci.layout = pipeline_layout; |
| 2347 | gp_ci.renderPass = renderPass(); |
| 2348 | |
| 2349 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 2350 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 2351 | |
| 2352 | VkPipeline pipeline; |
| 2353 | VkPipelineCache pipelineCache; |
| 2354 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2355 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2356 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2357 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2358 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2359 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2360 | FAIL() << "Did not recieve Error 'Gfx Pipeline viewportCount is 1, but pViewports is NULL...'"; |
| 2361 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2362 | } |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2363 | |
| 2364 | |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2365 | // Now hit second fail case where we set scissor w/ different count than PSO |
| 2366 | // First need to successfully create the PSO from above by setting pViewports |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2367 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2368 | "Dynamic scissorCount from vkCmdSetScissor() is 2, but PSO scissorCount is 1. These counts must match."); |
| 2369 | |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2370 | VkViewport vp = {}; // Just need dummy vp to point to |
| 2371 | vp_state_ci.pViewports = &vp; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2372 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2373 | ASSERT_VK_SUCCESS(err); |
| 2374 | BeginCommandBuffer(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2375 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2376 | VkRect2D scissors[2] = {}; // don't care about data |
| 2377 | // Count of 2 doesn't match PSO count of 1 |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2378 | vkCmdSetScissor(m_commandBuffer->GetBufferHandle(), 2, scissors); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2379 | Draw(1, 0, 0, 0); |
| 2380 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2381 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2382 | FAIL() << "Did not receive Error 'Dynamic scissorCount from vkCmdSetScissor() is 2, but PSO scissorCount is 1...'"; |
| 2383 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2384 | } |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2385 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2386 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2387 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2388 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2389 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2390 | } |
| 2391 | // Create PSO w/o non-zero scissorCount but no scissor data |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2392 | // Then run second test where dynamic viewportCount doesn't match PSO viewportCount |
| 2393 | TEST_F(VkLayerTest, PSOScissorCountWithoutDataAndDynViewportMismatch) |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2394 | { |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2395 | VkResult err; |
| 2396 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2397 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2398 | "Gfx Pipeline scissorCount is 1, but pScissors is NULL. "); |
| 2399 | |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2400 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2401 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2402 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2403 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2404 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2405 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2406 | |
| 2407 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2408 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2409 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2410 | ds_pool_ci.poolSizeCount = 1; |
| 2411 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2412 | |
| 2413 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2414 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2415 | ASSERT_VK_SUCCESS(err); |
| 2416 | |
| 2417 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 2418 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2419 | dsl_binding.arraySize = 1; |
| 2420 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2421 | |
| 2422 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2423 | 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] | 2424 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame^] | 2425 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2426 | |
| 2427 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2428 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2429 | ASSERT_VK_SUCCESS(err); |
| 2430 | |
| 2431 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2432 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2433 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2434 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2435 | alloc_info.descriptorPool = ds_pool; |
| 2436 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2437 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2438 | ASSERT_VK_SUCCESS(err); |
| 2439 | |
| 2440 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 2441 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2442 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2443 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 2444 | |
| 2445 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2446 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2447 | ASSERT_VK_SUCCESS(err); |
| 2448 | |
| 2449 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 2450 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 2451 | vp_state_ci.scissorCount = 1; |
| 2452 | vp_state_ci.pScissors = NULL; // Null scissor w/ count of 1 should cause error |
| 2453 | vp_state_ci.viewportCount = 1; |
| 2454 | vp_state_ci.pViewports = NULL; // vp is dynamic (below) so this won't cause error |
| 2455 | |
| 2456 | VkDynamicState vp_state = VK_DYNAMIC_STATE_VIEWPORT; |
| 2457 | // Set scissor as dynamic to avoid that error |
| 2458 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 2459 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 2460 | dyn_state_ci.dynamicStateCount = 1; |
| 2461 | dyn_state_ci.pDynamicStates = &vp_state; |
| 2462 | |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2463 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 2464 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2465 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2466 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, this); |
| 2467 | 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] | 2468 | // but add it to be able to run on more devices |
| 2469 | shaderStages[0].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2470 | shaderStages[0].shader = vs.handle(); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2471 | |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2472 | shaderStages[1].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2473 | shaderStages[1].shader = fs.handle(); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2474 | |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2475 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 2476 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 2477 | vi_ci.pNext = nullptr; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2478 | vi_ci.vertexBindingDescriptionCount = 0; |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2479 | vi_ci.pVertexBindingDescriptions = nullptr; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2480 | vi_ci.vertexAttributeDescriptionCount = 0; |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2481 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 2482 | |
| 2483 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 2484 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 2485 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 2486 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2487 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2488 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2489 | rs_ci.pNext = nullptr; |
| 2490 | |
| 2491 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 2492 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 2493 | cb_ci.pNext = nullptr; |
| 2494 | |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2495 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 2496 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2497 | gp_ci.stageCount = 2; |
| 2498 | gp_ci.pStages = shaderStages; |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2499 | gp_ci.pVertexInputState = &vi_ci; |
| 2500 | gp_ci.pInputAssemblyState = &ia_ci; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2501 | gp_ci.pViewportState = &vp_state_ci; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2502 | gp_ci.pRasterizationState = &rs_ci; |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2503 | gp_ci.pColorBlendState = &cb_ci; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2504 | gp_ci.pDynamicState = &dyn_state_ci; |
| 2505 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2506 | gp_ci.layout = pipeline_layout; |
| 2507 | gp_ci.renderPass = renderPass(); |
| 2508 | |
| 2509 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 2510 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 2511 | |
| 2512 | VkPipeline pipeline; |
| 2513 | VkPipelineCache pipelineCache; |
| 2514 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2515 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2516 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2517 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2518 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2519 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2520 | FAIL() << "Did not recieve Error 'Gfx Pipeline scissorCount is 1, but pScissors is NULL...'"; |
| 2521 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2522 | } |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2523 | |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2524 | // Now hit second fail case where we set scissor w/ different count than PSO |
| 2525 | // First need to successfully create the PSO from above by setting pViewports |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2526 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2527 | "Dynamic viewportCount from vkCmdSetViewport() is 2, but PSO viewportCount is 1. These counts must match."); |
| 2528 | |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2529 | VkRect2D sc = {}; // Just need dummy vp to point to |
| 2530 | vp_state_ci.pScissors = ≻ |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2531 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2532 | ASSERT_VK_SUCCESS(err); |
| 2533 | BeginCommandBuffer(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2534 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2535 | VkViewport viewports[2] = {}; // don't care about data |
| 2536 | // Count of 2 doesn't match PSO count of 1 |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2537 | vkCmdSetViewport(m_commandBuffer->GetBufferHandle(), 2, viewports); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2538 | Draw(1, 0, 0, 0); |
| 2539 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2540 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2541 | FAIL() << "Did not receive Error 'Dynamic viewportCount from vkCmdSetViewport() is 2, but PSO viewportCount is 1...'"; |
| 2542 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2543 | } |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2544 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2545 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2546 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2547 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2548 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2549 | } |
| 2550 | |
Tobin Ehlis | b8b06b5 | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 2551 | TEST_F(VkLayerTest, NullRenderPass) |
| 2552 | { |
| 2553 | // Bind a NULL RenderPass |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2554 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2555 | "You cannot use a NULL RenderPass object in vkCmdBeginRenderPass()"); |
Tobin Ehlis | b8b06b5 | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 2556 | |
| 2557 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2558 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | b8b06b5 | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 2559 | |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 2560 | BeginCommandBuffer(); |
Tobin Ehlis | b8b06b5 | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 2561 | // 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] | 2562 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), NULL, VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | b8b06b5 | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 2563 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2564 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2565 | FAIL() << "Did not receive Error 'You cannot use a NULL RenderPass object in vkCmdBeginRenderPass()'"; |
| 2566 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | b8b06b5 | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 2567 | } |
| 2568 | } |
| 2569 | |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2570 | TEST_F(VkLayerTest, RenderPassWithinRenderPass) |
| 2571 | { |
| 2572 | // Bind a BeginRenderPass within an active RenderPass |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2573 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2574 | "It is invalid to issue this call inside an active render pass"); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2575 | |
| 2576 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2577 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2578 | |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 2579 | BeginCommandBuffer(); |
Tobin Ehlis | b8b06b5 | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 2580 | // 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] | 2581 | VkRenderPassBeginInfo rp_begin = {}; |
| 2582 | rp_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; |
| 2583 | rp_begin.pNext = NULL; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2584 | rp_begin.renderPass = renderPass(); |
| 2585 | rp_begin.framebuffer = framebuffer(); |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 2586 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2587 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &rp_begin, VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2588 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2589 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2590 | FAIL() << "Did not receive Error 'It is invalid to issue this call inside an active render pass...'"; |
| 2591 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 2592 | } |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2593 | } |
| 2594 | |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2595 | TEST_F(VkLayerTest, FillBufferWithinRenderPass) |
| 2596 | { |
| 2597 | // Call CmdFillBuffer within an active renderpass |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2598 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2599 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2600 | |
| 2601 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2602 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2603 | |
| 2604 | // Renderpass is started here |
| 2605 | BeginCommandBuffer(); |
| 2606 | |
| 2607 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2608 | vk_testing::Buffer dstBuffer; |
| 2609 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2610 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2611 | m_commandBuffer->FillBuffer(dstBuffer.handle(), 0, 4, 0x11111111); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2612 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2613 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2614 | FAIL() << "Did not receive Error 'It is invalid to issue this call inside an active render pass...'"; |
| 2615 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2616 | } |
| 2617 | } |
| 2618 | |
| 2619 | TEST_F(VkLayerTest, UpdateBufferWithinRenderPass) |
| 2620 | { |
| 2621 | // Call CmdUpdateBuffer within an active renderpass |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2622 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2623 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2624 | |
| 2625 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2626 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2627 | |
| 2628 | // Renderpass is started here |
| 2629 | BeginCommandBuffer(); |
| 2630 | |
| 2631 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2632 | vk_testing::Buffer dstBuffer; |
| 2633 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2634 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2635 | VkDeviceSize dstOffset = 0; |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2636 | VkDeviceSize dataSize = 1024; |
| 2637 | const uint32_t *pData = NULL; |
| 2638 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2639 | vkCmdUpdateBuffer(m_commandBuffer->GetBufferHandle(), dstBuffer.handle(), dstOffset, dataSize, pData); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2640 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2641 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2642 | FAIL() << "Did not receive Error 'It is invalid to issue this call inside an active render pass...'"; |
| 2643 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2644 | } |
| 2645 | } |
| 2646 | |
| 2647 | TEST_F(VkLayerTest, ClearColorImageWithinRenderPass) |
| 2648 | { |
| 2649 | // Call CmdClearColorImage within an active RenderPass |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2650 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2651 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2652 | |
| 2653 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2654 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2655 | |
| 2656 | // Renderpass is started here |
| 2657 | BeginCommandBuffer(); |
| 2658 | |
| 2659 | VkClearColorValue clear_color = {0}; |
| 2660 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 2661 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2662 | const int32_t tex_width = 32; |
| 2663 | const int32_t tex_height = 32; |
| 2664 | VkImageCreateInfo image_create_info = {}; |
| 2665 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 2666 | image_create_info.pNext = NULL; |
| 2667 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2668 | image_create_info.format = tex_format; |
| 2669 | image_create_info.extent.width = tex_width; |
| 2670 | image_create_info.extent.height = tex_height; |
| 2671 | image_create_info.extent.depth = 1; |
| 2672 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 2673 | image_create_info.arrayLayers = 1; |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2674 | image_create_info.samples = 1; |
| 2675 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 2676 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 2677 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2678 | vk_testing::Image dstImage; |
| 2679 | dstImage.init(*m_device, (const VkImageCreateInfo&)image_create_info, reqs); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2680 | |
| 2681 | const VkImageSubresourceRange range = |
| 2682 | vk_testing::Image::subresource_range(image_create_info, VK_IMAGE_ASPECT_COLOR_BIT); |
| 2683 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2684 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), |
| 2685 | dstImage.handle(), |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2686 | VK_IMAGE_LAYOUT_GENERAL, |
| 2687 | &clear_color, |
| 2688 | 1, |
| 2689 | &range); |
| 2690 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2691 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2692 | FAIL() << "Did not receive Error 'It is invalid to issue this call inside an active render pass...'"; |
| 2693 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2694 | } |
| 2695 | } |
| 2696 | |
| 2697 | TEST_F(VkLayerTest, ClearDepthStencilImageWithinRenderPass) |
| 2698 | { |
| 2699 | // Call CmdClearDepthStencilImage within an active RenderPass |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2700 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2701 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2702 | |
| 2703 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2704 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2705 | |
| 2706 | // Renderpass is started here |
| 2707 | BeginCommandBuffer(); |
| 2708 | |
| 2709 | VkClearDepthStencilValue clear_value = {0}; |
| 2710 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 2711 | VkImageCreateInfo image_create_info = vk_testing::Image::create_info(); |
| 2712 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2713 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 2714 | image_create_info.extent.width = 64; |
| 2715 | image_create_info.extent.height = 64; |
| 2716 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 2717 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 2718 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2719 | vk_testing::Image dstImage; |
| 2720 | dstImage.init(*m_device, (const VkImageCreateInfo&)image_create_info, reqs); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2721 | |
| 2722 | const VkImageSubresourceRange range = |
| 2723 | vk_testing::Image::subresource_range(image_create_info, VK_IMAGE_ASPECT_DEPTH_BIT); |
| 2724 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2725 | vkCmdClearDepthStencilImage(m_commandBuffer->GetBufferHandle(), |
| 2726 | dstImage.handle(), |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2727 | VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, |
| 2728 | &clear_value, |
| 2729 | 1, |
| 2730 | &range); |
| 2731 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2732 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2733 | FAIL() << "Did not receive Error 'It is invalid to issue this call inside an active render pass...'"; |
| 2734 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2735 | } |
| 2736 | } |
| 2737 | |
| 2738 | TEST_F(VkLayerTest, ClearColorAttachmentsOutsideRenderPass) |
| 2739 | { |
Courtney Goeltzenleuchter | 9feb073 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 2740 | // Call CmdClearAttachmentss outside of an active RenderPass |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2741 | VkResult err; |
| 2742 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2743 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2744 | "vkCmdClearAttachments: This call must be issued inside an active render pass"); |
| 2745 | |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2746 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2747 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2748 | |
| 2749 | // Start no RenderPass |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2750 | err = m_commandBuffer->BeginCommandBuffer(); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2751 | ASSERT_VK_SUCCESS(err); |
| 2752 | |
Courtney Goeltzenleuchter | 9feb073 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 2753 | VkClearAttachment color_attachment; |
| 2754 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 2755 | color_attachment.clearValue.color.float32[0] = 0; |
| 2756 | color_attachment.clearValue.color.float32[1] = 0; |
| 2757 | color_attachment.clearValue.color.float32[2] = 0; |
| 2758 | color_attachment.clearValue.color.float32[3] = 0; |
| 2759 | color_attachment.colorAttachment = 0; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 2760 | VkClearRect clear_rect = { { { 0, 0 }, { 32, 32 } } }; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2761 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), |
Courtney Goeltzenleuchter | 9feb073 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 2762 | 1, &color_attachment, |
| 2763 | 1, &clear_rect); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2764 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2765 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2766 | FAIL() << "Did not receive Error 'vkCmdClearAttachments: This call must be issued inside an active render pass.'"; |
| 2767 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2768 | } |
| 2769 | } |
| 2770 | |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2771 | TEST_F(VkLayerTest, InvalidDynamicStateObject) |
| 2772 | { |
| 2773 | // Create a valid cmd buffer |
| 2774 | // call vkCmdBindDynamicStateObject w/ false DS Obj |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 2775 | // TODO : Simple check for bad object should be added to ObjectTracker to catch this case |
| 2776 | // 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] | 2777 | } |
Tobin Ehlis | 201b1ba | 2015-05-27 14:55:35 -0600 | [diff] [blame] | 2778 | |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 2779 | TEST_F(VkLayerTest, IdxBufferAlignmentError) |
| 2780 | { |
| 2781 | // Bind a BeginRenderPass within an active RenderPass |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 2782 | VkResult err; |
| 2783 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2784 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2785 | "vkCmdBindIndexBuffer() offset (0x7) does not fall on "); |
| 2786 | |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 2787 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2788 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 2789 | uint32_t qfi = 0; |
| 2790 | VkBufferCreateInfo buffCI = {}; |
| 2791 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 2792 | buffCI.size = 1024; |
| 2793 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2794 | buffCI.queueFamilyIndexCount = 1; |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 2795 | buffCI.pQueueFamilyIndices = &qfi; |
| 2796 | |
| 2797 | VkBuffer ib; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2798 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 2799 | ASSERT_VK_SUCCESS(err); |
| 2800 | |
| 2801 | BeginCommandBuffer(); |
| 2802 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2803 | //vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 2804 | // 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] | 2805 | vkCmdBindIndexBuffer(m_commandBuffer->GetBufferHandle(), ib, 7, VK_INDEX_TYPE_UINT16); |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 2806 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2807 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2808 | FAIL() << "Did not receive Error 'vkCmdBindIndexBuffer() offset (0x7) does not fall on ...'"; |
| 2809 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 2810 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2811 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2812 | vkDestroyBuffer(m_device->device(), ib, NULL); |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 2813 | } |
| 2814 | |
Tobin Ehlis | 5f728d3 | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 2815 | TEST_F(VkLayerTest, ExecuteCommandsPrimaryCB) |
| 2816 | { |
| 2817 | // Attempt vkCmdExecuteCommands w/ a primary cmd buffer (should only be secondary) |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2818 | |
| 2819 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2820 | "vkCmdExecuteCommands() called w/ Primary Cmd Buffer "); |
Tobin Ehlis | 5f728d3 | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 2821 | |
| 2822 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2823 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 5f728d3 | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 2824 | |
| 2825 | BeginCommandBuffer(); |
| 2826 | //ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2827 | VkCommandBuffer primCB = m_commandBuffer->GetBufferHandle(); |
| 2828 | vkCmdExecuteCommands(m_commandBuffer->GetBufferHandle(), 1, &primCB); |
Tobin Ehlis | 5f728d3 | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 2829 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2830 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2831 | FAIL() << "Did not receive Error 'vkCmdExecuteCommands() called w/ Primary Cmd Buffer '"; |
| 2832 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 5f728d3 | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 2833 | } |
| 2834 | } |
| 2835 | |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2836 | TEST_F(VkLayerTest, DSTypeMismatch) |
| 2837 | { |
| 2838 | // 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] | 2839 | VkResult err; |
| 2840 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2841 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2842 | "Write descriptor update has descriptor type VK_DESCRIPTOR_TYPE_SAMPLER that does not match "); |
| 2843 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2844 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2845 | //VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2846 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2847 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2848 | ds_type_count.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2849 | |
| 2850 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2851 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2852 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 2853 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2854 | ds_pool_ci.poolSizeCount = 1; |
| 2855 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2856 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2857 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2858 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2859 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2860 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 2861 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2862 | dsl_binding.arraySize = 1; |
| 2863 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2864 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2865 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2866 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2867 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2868 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2869 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame^] | 2870 | ds_layout_ci.pBinding = &dsl_binding; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2871 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2872 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2873 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2874 | ASSERT_VK_SUCCESS(err); |
| 2875 | |
| 2876 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2877 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2878 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2879 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2880 | alloc_info.descriptorPool = ds_pool; |
| 2881 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2882 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2883 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2884 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2885 | VkSamplerCreateInfo sampler_ci = {}; |
| 2886 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 2887 | sampler_ci.pNext = NULL; |
Chia-I Wu | 3603b08 | 2015-10-26 16:49:32 +0800 | [diff] [blame] | 2888 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 2889 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 2890 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_BASE; |
Chia-I Wu | ce532f7 | 2015-10-26 17:32:47 +0800 | [diff] [blame] | 2891 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 2892 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 2893 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2894 | sampler_ci.mipLodBias = 1.0; |
| 2895 | sampler_ci.maxAnisotropy = 1; |
| 2896 | sampler_ci.compareEnable = VK_FALSE; |
| 2897 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 2898 | sampler_ci.minLod = 1.0; |
| 2899 | sampler_ci.maxLod = 1.0; |
| 2900 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
Mark Lobodzinski | 513acdf | 2015-09-01 15:42:56 -0600 | [diff] [blame] | 2901 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
| 2902 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2903 | VkSampler sampler; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2904 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2905 | ASSERT_VK_SUCCESS(err); |
| 2906 | |
Courtney Goeltzenleuchter | 34aa5c8 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 2907 | VkDescriptorImageInfo info = {}; |
| 2908 | info.sampler = sampler; |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 2909 | |
| 2910 | VkWriteDescriptorSet descriptor_write; |
| 2911 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 2912 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2913 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2914 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2915 | // This is a mismatched type for the layout which expects BUFFER |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 2916 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 34aa5c8 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 2917 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 2918 | |
| 2919 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 2920 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2921 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2922 | FAIL() << "Did not receive Error 'Write descriptor update has descriptor type VK_DESCRIPTOR_TYPE_SAMPLER that does not match...'"; |
| 2923 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2924 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2925 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2926 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 2927 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2928 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2929 | } |
| 2930 | |
| 2931 | TEST_F(VkLayerTest, DSUpdateOutOfBounds) |
| 2932 | { |
| 2933 | // For overlapping Update, have arrayIndex exceed that of layout |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2934 | VkResult err; |
| 2935 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2936 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2937 | "Descriptor update type of VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET is out of bounds for matching binding"); |
| 2938 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2939 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2940 | //VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2941 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2942 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2943 | ds_type_count.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2944 | |
| 2945 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2946 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2947 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 2948 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2949 | ds_pool_ci.poolSizeCount = 1; |
| 2950 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2951 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2952 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2953 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2954 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2955 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2956 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 2957 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2958 | dsl_binding.arraySize = 1; |
| 2959 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2960 | dsl_binding.pImmutableSamplers = NULL; |
| 2961 | |
| 2962 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2963 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2964 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2965 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame^] | 2966 | ds_layout_ci.pBinding = &dsl_binding; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2967 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2968 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2969 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2970 | ASSERT_VK_SUCCESS(err); |
| 2971 | |
| 2972 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2973 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2974 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2975 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2976 | alloc_info.descriptorPool = ds_pool; |
| 2977 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2978 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2979 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2980 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2981 | VkSamplerCreateInfo sampler_ci = {}; |
| 2982 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 2983 | sampler_ci.pNext = NULL; |
Chia-I Wu | 3603b08 | 2015-10-26 16:49:32 +0800 | [diff] [blame] | 2984 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 2985 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 2986 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_BASE; |
Chia-I Wu | ce532f7 | 2015-10-26 17:32:47 +0800 | [diff] [blame] | 2987 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 2988 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 2989 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2990 | sampler_ci.mipLodBias = 1.0; |
| 2991 | sampler_ci.maxAnisotropy = 1; |
| 2992 | sampler_ci.compareEnable = VK_FALSE; |
| 2993 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 2994 | sampler_ci.minLod = 1.0; |
| 2995 | sampler_ci.maxLod = 1.0; |
| 2996 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
Mark Lobodzinski | 513acdf | 2015-09-01 15:42:56 -0600 | [diff] [blame] | 2997 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2998 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2999 | VkSampler sampler; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3000 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3001 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3002 | |
Courtney Goeltzenleuchter | 34aa5c8 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3003 | VkDescriptorImageInfo info = {}; |
| 3004 | info.sampler = sampler; |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3005 | |
| 3006 | VkWriteDescriptorSet descriptor_write; |
| 3007 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3008 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3009 | descriptor_write.dstSet = descriptorSet; |
| 3010 | 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] | 3011 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3012 | // 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] | 3013 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 34aa5c8 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3014 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3015 | |
| 3016 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3017 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3018 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3019 | FAIL() << "Did not receive Error 'Descriptor update type of VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET is out of bounds for matching binding...'"; |
| 3020 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3021 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3022 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3023 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3024 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3025 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3026 | } |
| 3027 | |
| 3028 | TEST_F(VkLayerTest, InvalidDSUpdateIndex) |
| 3029 | { |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3030 | // 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] | 3031 | VkResult err; |
| 3032 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3033 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3034 | " does not have binding to match update binding "); |
| 3035 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3036 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3037 | //VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3038 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3039 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3040 | ds_type_count.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3041 | |
| 3042 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3043 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3044 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3045 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3046 | ds_pool_ci.poolSizeCount = 1; |
| 3047 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3048 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3049 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3050 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3051 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3052 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3053 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 3054 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3055 | dsl_binding.arraySize = 1; |
| 3056 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3057 | dsl_binding.pImmutableSamplers = NULL; |
| 3058 | |
| 3059 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3060 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3061 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3062 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame^] | 3063 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3064 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3065 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3066 | ASSERT_VK_SUCCESS(err); |
| 3067 | |
| 3068 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3069 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3070 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3071 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3072 | alloc_info.descriptorPool = ds_pool; |
| 3073 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3074 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3075 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3076 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3077 | VkSamplerCreateInfo sampler_ci = {}; |
| 3078 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3079 | sampler_ci.pNext = NULL; |
Chia-I Wu | 3603b08 | 2015-10-26 16:49:32 +0800 | [diff] [blame] | 3080 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 3081 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 3082 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_BASE; |
Chia-I Wu | ce532f7 | 2015-10-26 17:32:47 +0800 | [diff] [blame] | 3083 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3084 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3085 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3086 | sampler_ci.mipLodBias = 1.0; |
| 3087 | sampler_ci.maxAnisotropy = 1; |
| 3088 | sampler_ci.compareEnable = VK_FALSE; |
| 3089 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3090 | sampler_ci.minLod = 1.0; |
| 3091 | sampler_ci.maxLod = 1.0; |
| 3092 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
Mark Lobodzinski | 513acdf | 2015-09-01 15:42:56 -0600 | [diff] [blame] | 3093 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3094 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3095 | VkSampler sampler; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3096 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3097 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3098 | |
Courtney Goeltzenleuchter | 34aa5c8 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3099 | VkDescriptorImageInfo info = {}; |
| 3100 | info.sampler = sampler; |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3101 | |
| 3102 | VkWriteDescriptorSet descriptor_write; |
| 3103 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3104 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3105 | descriptor_write.dstSet = descriptorSet; |
| 3106 | descriptor_write.dstBinding = 2; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3107 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3108 | // 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] | 3109 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 34aa5c8 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3110 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3111 | |
| 3112 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3113 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3114 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3115 | FAIL() << "Did not receive Error 'Descriptor Set <blah> does not have binding to match update binding '"; |
| 3116 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3117 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3118 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3119 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3120 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3121 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3122 | } |
| 3123 | |
| 3124 | TEST_F(VkLayerTest, InvalidDSUpdateStruct) |
| 3125 | { |
| 3126 | // 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] | 3127 | VkResult err; |
| 3128 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3129 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3130 | "Unexpected UPDATE struct of type "); |
| 3131 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3132 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3133 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3134 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3135 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3136 | ds_type_count.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3137 | |
| 3138 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3139 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3140 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3141 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3142 | ds_pool_ci.poolSizeCount = 1; |
| 3143 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3144 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3145 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3146 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3147 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3148 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 3149 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3150 | dsl_binding.arraySize = 1; |
| 3151 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3152 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3153 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3154 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3155 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3156 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3157 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame^] | 3158 | ds_layout_ci.pBinding = &dsl_binding; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3159 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3160 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3161 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3162 | ASSERT_VK_SUCCESS(err); |
| 3163 | |
| 3164 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3165 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3166 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3167 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3168 | alloc_info.descriptorPool = ds_pool; |
| 3169 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3170 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3171 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3172 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3173 | VkSamplerCreateInfo sampler_ci = {}; |
| 3174 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3175 | sampler_ci.pNext = NULL; |
Chia-I Wu | 3603b08 | 2015-10-26 16:49:32 +0800 | [diff] [blame] | 3176 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 3177 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 3178 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_BASE; |
Chia-I Wu | ce532f7 | 2015-10-26 17:32:47 +0800 | [diff] [blame] | 3179 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3180 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3181 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3182 | sampler_ci.mipLodBias = 1.0; |
| 3183 | sampler_ci.maxAnisotropy = 1; |
| 3184 | sampler_ci.compareEnable = VK_FALSE; |
| 3185 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3186 | sampler_ci.minLod = 1.0; |
| 3187 | sampler_ci.maxLod = 1.0; |
| 3188 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
Mark Lobodzinski | 513acdf | 2015-09-01 15:42:56 -0600 | [diff] [blame] | 3189 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3190 | VkSampler sampler; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3191 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3192 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3193 | |
| 3194 | |
Courtney Goeltzenleuchter | 34aa5c8 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3195 | VkDescriptorImageInfo info = {}; |
| 3196 | info.sampler = sampler; |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3197 | |
| 3198 | VkWriteDescriptorSet descriptor_write; |
| 3199 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3200 | descriptor_write.sType = (VkStructureType)0x99999999; /* Intentionally broken struct type */ |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3201 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3202 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3203 | // 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] | 3204 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 34aa5c8 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3205 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3206 | |
| 3207 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3208 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3209 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3210 | FAIL() << "Did not receive Error 'Unexpected UPDATE struct of type '"; |
| 3211 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3212 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3213 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3214 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3215 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3216 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3217 | } |
| 3218 | |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3219 | TEST_F(VkLayerTest, SampleDescriptorUpdateError) |
| 3220 | { |
| 3221 | // Create a single Sampler descriptor and send it an invalid Sampler |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3222 | VkResult err; |
| 3223 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3224 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3225 | "Attempt to update descriptor with invalid sampler 0xbaadbeef"); |
| 3226 | |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3227 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3228 | // 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] | 3229 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3230 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3231 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3232 | |
| 3233 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3234 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3235 | ds_pool_ci.pNext = NULL; |
| 3236 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3237 | ds_pool_ci.poolSizeCount = 1; |
| 3238 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3239 | |
| 3240 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3241 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3242 | ASSERT_VK_SUCCESS(err); |
| 3243 | |
| 3244 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 3245 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 3246 | dsl_binding.arraySize = 1; |
| 3247 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3248 | dsl_binding.pImmutableSamplers = NULL; |
| 3249 | |
| 3250 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3251 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3252 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3253 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame^] | 3254 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3255 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3256 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3257 | ASSERT_VK_SUCCESS(err); |
| 3258 | |
| 3259 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3260 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3261 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3262 | alloc_info.setLayoutCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3263 | alloc_info.descriptorPool = ds_pool; |
| 3264 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3265 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3266 | ASSERT_VK_SUCCESS(err); |
| 3267 | |
Chia-I Wu | e420a33 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 3268 | VkSampler sampler = (VkSampler) 0xbaadbeef; // Sampler with invalid handle |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3269 | |
| 3270 | VkDescriptorImageInfo descriptor_info; |
| 3271 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 3272 | descriptor_info.sampler = sampler; |
| 3273 | |
| 3274 | VkWriteDescriptorSet descriptor_write; |
| 3275 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3276 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3277 | descriptor_write.dstSet = descriptorSet; |
| 3278 | descriptor_write.dstBinding = 0; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3279 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3280 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 3281 | descriptor_write.pImageInfo = &descriptor_info; |
| 3282 | |
| 3283 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3284 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3285 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3286 | FAIL() << "Did not receive Error 'Attempt to update descriptor with invalid sampler...'"; |
| 3287 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3288 | } |
| 3289 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3290 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3291 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3292 | } |
| 3293 | |
| 3294 | TEST_F(VkLayerTest, ImageViewDescriptorUpdateError) |
| 3295 | { |
| 3296 | // 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] | 3297 | VkResult err; |
| 3298 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3299 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3300 | "Attempt to update descriptor with invalid imageView 0xbaadbeef"); |
| 3301 | |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3302 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3303 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3304 | ds_type_count.type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3305 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3306 | |
| 3307 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3308 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3309 | ds_pool_ci.pNext = NULL; |
| 3310 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3311 | ds_pool_ci.poolSizeCount = 1; |
| 3312 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3313 | |
| 3314 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3315 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3316 | ASSERT_VK_SUCCESS(err); |
| 3317 | |
| 3318 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 3319 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 3320 | dsl_binding.arraySize = 1; |
| 3321 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3322 | dsl_binding.pImmutableSamplers = NULL; |
| 3323 | |
| 3324 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3325 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3326 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3327 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame^] | 3328 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3329 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3330 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3331 | ASSERT_VK_SUCCESS(err); |
| 3332 | |
| 3333 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3334 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3335 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3336 | alloc_info.setLayoutCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3337 | alloc_info.descriptorPool = ds_pool; |
| 3338 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3339 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3340 | ASSERT_VK_SUCCESS(err); |
| 3341 | |
| 3342 | VkSamplerCreateInfo sampler_ci = {}; |
| 3343 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3344 | sampler_ci.pNext = NULL; |
Chia-I Wu | 3603b08 | 2015-10-26 16:49:32 +0800 | [diff] [blame] | 3345 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 3346 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 3347 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_BASE; |
Chia-I Wu | ce532f7 | 2015-10-26 17:32:47 +0800 | [diff] [blame] | 3348 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3349 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3350 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3351 | sampler_ci.mipLodBias = 1.0; |
| 3352 | sampler_ci.maxAnisotropy = 1; |
| 3353 | sampler_ci.compareEnable = VK_FALSE; |
| 3354 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3355 | sampler_ci.minLod = 1.0; |
| 3356 | sampler_ci.maxLod = 1.0; |
| 3357 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 3358 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
| 3359 | |
| 3360 | VkSampler sampler; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3361 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3362 | ASSERT_VK_SUCCESS(err); |
| 3363 | |
Chia-I Wu | e420a33 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 3364 | VkImageView view = (VkImageView) 0xbaadbeef; // invalid imageView object |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3365 | |
| 3366 | VkDescriptorImageInfo descriptor_info; |
| 3367 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 3368 | descriptor_info.sampler = sampler; |
| 3369 | descriptor_info.imageView = view; |
| 3370 | |
| 3371 | VkWriteDescriptorSet descriptor_write; |
| 3372 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3373 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3374 | descriptor_write.dstSet = descriptorSet; |
| 3375 | descriptor_write.dstBinding = 0; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3376 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3377 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 3378 | descriptor_write.pImageInfo = &descriptor_info; |
| 3379 | |
| 3380 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3381 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3382 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3383 | FAIL() << "Did not receive Error 'Attempt to update descriptor with invalid imageView...'"; |
| 3384 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3385 | } |
| 3386 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3387 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3388 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3389 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3390 | } |
| 3391 | |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3392 | TEST_F(VkLayerTest, CopyDescriptorUpdateErrors) |
| 3393 | { |
| 3394 | // 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] | 3395 | VkResult err; |
| 3396 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3397 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3398 | "Copy descriptor update index 0, update count #1, has src update descriptor type VK_DESCRIPTOR_TYPE_SAMPLER "); |
| 3399 | |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3400 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3401 | //VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3402 | VkDescriptorPoolSize ds_type_count[2] = {}; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3403 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3404 | ds_type_count[0].descriptorCount = 1; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3405 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3406 | ds_type_count[1].descriptorCount = 1; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3407 | |
| 3408 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3409 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3410 | ds_pool_ci.pNext = NULL; |
| 3411 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3412 | ds_pool_ci.poolSizeCount = 2; |
| 3413 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3414 | |
| 3415 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3416 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3417 | ASSERT_VK_SUCCESS(err); |
| 3418 | VkDescriptorSetLayoutBinding dsl_binding[2] = {}; |
| 3419 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3420 | dsl_binding[0].arraySize = 1; |
| 3421 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 3422 | dsl_binding[0].pImmutableSamplers = NULL; |
| 3423 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 3424 | dsl_binding[1].arraySize = 1; |
| 3425 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 3426 | dsl_binding[1].pImmutableSamplers = NULL; |
| 3427 | |
| 3428 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3429 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3430 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3431 | ds_layout_ci.bindingCount = 2; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame^] | 3432 | ds_layout_ci.pBinding = dsl_binding; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3433 | |
| 3434 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3435 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3436 | ASSERT_VK_SUCCESS(err); |
| 3437 | |
| 3438 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3439 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3440 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3441 | alloc_info.setLayoutCount = 1; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3442 | alloc_info.descriptorPool = ds_pool; |
| 3443 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3444 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3445 | ASSERT_VK_SUCCESS(err); |
| 3446 | |
| 3447 | VkSamplerCreateInfo sampler_ci = {}; |
| 3448 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3449 | sampler_ci.pNext = NULL; |
Chia-I Wu | 3603b08 | 2015-10-26 16:49:32 +0800 | [diff] [blame] | 3450 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 3451 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 3452 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_BASE; |
Chia-I Wu | ce532f7 | 2015-10-26 17:32:47 +0800 | [diff] [blame] | 3453 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3454 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3455 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3456 | sampler_ci.mipLodBias = 1.0; |
| 3457 | sampler_ci.maxAnisotropy = 1; |
| 3458 | sampler_ci.compareEnable = VK_FALSE; |
| 3459 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3460 | sampler_ci.minLod = 1.0; |
| 3461 | sampler_ci.maxLod = 1.0; |
| 3462 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 3463 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
| 3464 | |
| 3465 | VkSampler sampler; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3466 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3467 | ASSERT_VK_SUCCESS(err); |
| 3468 | |
| 3469 | VkDescriptorImageInfo info = {}; |
| 3470 | info.sampler = sampler; |
| 3471 | |
| 3472 | VkWriteDescriptorSet descriptor_write; |
| 3473 | memset(&descriptor_write, 0, sizeof(VkWriteDescriptorSet)); |
| 3474 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3475 | descriptor_write.dstSet = descriptorSet; |
| 3476 | descriptor_write.dstBinding = 1; // SAMPLER binding from layout above |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3477 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3478 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 3479 | descriptor_write.pImageInfo = &info; |
| 3480 | // This write update should succeed |
| 3481 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3482 | // Now perform a copy update that fails due to type mismatch |
| 3483 | VkCopyDescriptorSet copy_ds_update; |
| 3484 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 3485 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 3486 | copy_ds_update.srcSet = descriptorSet; |
| 3487 | copy_ds_update.srcBinding = 1; // copy from SAMPLER binding |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3488 | copy_ds_update.dstSet = descriptorSet; |
| 3489 | copy_ds_update.dstBinding = 0; // ERROR : copy to UNIFORM binding |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3490 | copy_ds_update.descriptorCount = 1; // copy 1 descriptor |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3491 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 3492 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3493 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3494 | FAIL() << "Did not receive Error 'Copy descriptor update index 0, update count #1, has src update descriptor type_DESCRIPTOR_TYPE_SAMPLER'"; |
| 3495 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3496 | } |
| 3497 | // 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] | 3498 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3499 | "Copy descriptor update 0 has srcBinding 3 which is out of bounds "); |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3500 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 3501 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 3502 | copy_ds_update.srcSet = descriptorSet; |
| 3503 | copy_ds_update.srcBinding = 3; // ERROR : Invalid binding for matching layout |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3504 | copy_ds_update.dstSet = descriptorSet; |
| 3505 | copy_ds_update.dstBinding = 0; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3506 | copy_ds_update.descriptorCount = 1; // copy 1 descriptor |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3507 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 3508 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3509 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3510 | FAIL() << "Did not receive Error 'Copy descriptor update 0 has srcBinding 3 which is out of bounds...'"; |
| 3511 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3512 | } |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3513 | |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3514 | // 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] | 3515 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3516 | "Copy descriptor src update is out of bounds for matching binding 1 "); |
| 3517 | |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3518 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 3519 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 3520 | copy_ds_update.srcSet = descriptorSet; |
| 3521 | copy_ds_update.srcBinding = 1; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3522 | copy_ds_update.dstSet = descriptorSet; |
| 3523 | copy_ds_update.dstBinding = 0; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3524 | 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] | 3525 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 3526 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3527 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3528 | FAIL() << "Did not receive Error 'Copy descriptor src update is out of bounds for matching binding 1...'"; |
| 3529 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3530 | } |
| 3531 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3532 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3533 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3534 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3535 | } |
| 3536 | |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3537 | TEST_F(VkLayerTest, NumSamplesMismatch) |
| 3538 | { |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3539 | // Create CommandBuffer where MSAA samples doesn't match RenderPass sampleCount |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3540 | VkResult err; |
| 3541 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3542 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3543 | "Num samples mismatch! "); |
| 3544 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3545 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3546 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3547 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3548 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3549 | ds_type_count.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3550 | |
| 3551 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3552 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3553 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3554 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3555 | ds_pool_ci.poolSizeCount = 1; |
| 3556 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3557 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3558 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3559 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3560 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3561 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3562 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 3563 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3564 | dsl_binding.arraySize = 1; |
| 3565 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3566 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3567 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3568 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3569 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3570 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3571 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame^] | 3572 | ds_layout_ci.pBinding = &dsl_binding; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3573 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3574 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3575 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3576 | ASSERT_VK_SUCCESS(err); |
| 3577 | |
| 3578 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3579 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3580 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3581 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3582 | alloc_info.descriptorPool = ds_pool; |
| 3583 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3584 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3585 | ASSERT_VK_SUCCESS(err); |
| 3586 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3587 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 3588 | pipe_ms_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 3589 | pipe_ms_state_ci.pNext = NULL; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3590 | pipe_ms_state_ci.rasterizationSamples = 4; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3591 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 3592 | pipe_ms_state_ci.minSampleShading = 1.0; |
Cody Northrop | e9825b7 | 2015-08-04 14:34:54 -0600 | [diff] [blame] | 3593 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3594 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3595 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 3596 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3597 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3598 | pipeline_layout_ci.setLayoutCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3599 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3600 | |
| 3601 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3602 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3603 | ASSERT_VK_SUCCESS(err); |
| 3604 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 3605 | VkShaderObj vs(m_device, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 3606 | 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] | 3607 | // but add it to be able to run on more devices |
Tony Barbour | d7d828b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 3608 | VkPipelineObj pipe(m_device); |
| 3609 | pipe.AddShader(&vs); |
Tony Barbour | 3c9e3b1 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 3610 | pipe.AddShader(&fs); |
Tony Barbour | d7d828b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 3611 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 3612 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3613 | |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 3614 | BeginCommandBuffer(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3615 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3616 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3617 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3618 | FAIL() << "Did not recieve Error 'Num samples mismatch!...'"; |
| 3619 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3620 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3621 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3622 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3623 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3624 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3625 | } |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3626 | |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3627 | TEST_F(VkLayerTest, ClearCmdNoDraw) |
| 3628 | { |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3629 | // 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] | 3630 | VkResult err; |
| 3631 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3632 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_WARN_BIT, |
| 3633 | "vkCmdClearAttachments() issued on CB object "); |
| 3634 | |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3635 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3636 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3637 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3638 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3639 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3640 | ds_type_count.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3641 | |
| 3642 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3643 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3644 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3645 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3646 | ds_pool_ci.poolSizeCount = 1; |
| 3647 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3648 | |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3649 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3650 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3651 | ASSERT_VK_SUCCESS(err); |
| 3652 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3653 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 3654 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3655 | dsl_binding.arraySize = 1; |
| 3656 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3657 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3658 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3659 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3660 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3661 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3662 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame^] | 3663 | ds_layout_ci.pBinding = &dsl_binding; |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3664 | |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3665 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3666 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3667 | ASSERT_VK_SUCCESS(err); |
| 3668 | |
| 3669 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3670 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3671 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3672 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3673 | alloc_info.descriptorPool = ds_pool; |
| 3674 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3675 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3676 | ASSERT_VK_SUCCESS(err); |
| 3677 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3678 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 3679 | pipe_ms_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 3680 | pipe_ms_state_ci.pNext = NULL; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3681 | pipe_ms_state_ci.rasterizationSamples = 4; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3682 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 3683 | pipe_ms_state_ci.minSampleShading = 1.0; |
Cody Northrop | e9825b7 | 2015-08-04 14:34:54 -0600 | [diff] [blame] | 3684 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3685 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3686 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 3687 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3688 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3689 | pipeline_layout_ci.setLayoutCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3690 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3691 | |
| 3692 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3693 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3694 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3695 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 3696 | VkShaderObj vs(m_device, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3697 | // TODO - We shouldn't need a fragment shader but add it to be able to run on more devices |
| 3698 | VkShaderObj fs(m_device, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 3699 | |
Tony Barbour | d7d828b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 3700 | VkPipelineObj pipe(m_device); |
| 3701 | pipe.AddShader(&vs); |
Tony Barbour | 3c9e3b1 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 3702 | pipe.AddShader(&fs); |
Tony Barbour | d7d828b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 3703 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 3704 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 3705 | |
| 3706 | BeginCommandBuffer(); |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3707 | |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3708 | // Main thing we care about for this test is that the VkImage obj we're clearing matches Color Attachment of FB |
| 3709 | // Also pass down other dummy params to keep driver and paramchecker happy |
Courtney Goeltzenleuchter | 9feb073 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 3710 | VkClearAttachment color_attachment; |
| 3711 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 3712 | color_attachment.clearValue.color.float32[0] = 1.0; |
| 3713 | color_attachment.clearValue.color.float32[1] = 1.0; |
| 3714 | color_attachment.clearValue.color.float32[2] = 1.0; |
| 3715 | color_attachment.clearValue.color.float32[3] = 1.0; |
| 3716 | color_attachment.colorAttachment = 0; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 3717 | VkClearRect clear_rect = { { { 0, 0 }, { (int)m_width, (int)m_height } } }; |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3718 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3719 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3720 | |
| 3721 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3722 | FAIL() << "Did not receive Error 'vkCommandClearAttachments() issued on CB object...'"; |
| 3723 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3724 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3725 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3726 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3727 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3728 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3729 | } |
| 3730 | |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3731 | TEST_F(VkLayerTest, VtxBufferBadIndex) |
| 3732 | { |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3733 | // Create CommandBuffer where MSAA samples doesn't match RenderPass sampleCount |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3734 | VkResult err; |
| 3735 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3736 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3737 | "Vtx Buffer Index 1 was bound, but no vtx buffers are attached to PSO."); |
| 3738 | |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3739 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 3740 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3741 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3742 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3743 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3744 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3745 | ds_type_count.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3746 | |
| 3747 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3748 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3749 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3750 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3751 | ds_pool_ci.poolSizeCount = 1; |
| 3752 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3753 | |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3754 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3755 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3756 | ASSERT_VK_SUCCESS(err); |
| 3757 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3758 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 3759 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3760 | dsl_binding.arraySize = 1; |
| 3761 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3762 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3763 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3764 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3765 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3766 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3767 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame^] | 3768 | ds_layout_ci.pBinding = &dsl_binding; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3769 | |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3770 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3771 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3772 | ASSERT_VK_SUCCESS(err); |
| 3773 | |
| 3774 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3775 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3776 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3777 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3778 | alloc_info.descriptorPool = ds_pool; |
| 3779 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3780 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3781 | ASSERT_VK_SUCCESS(err); |
| 3782 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3783 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 3784 | pipe_ms_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 3785 | pipe_ms_state_ci.pNext = NULL; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3786 | pipe_ms_state_ci.rasterizationSamples = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3787 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 3788 | pipe_ms_state_ci.minSampleShading = 1.0; |
Cody Northrop | e9825b7 | 2015-08-04 14:34:54 -0600 | [diff] [blame] | 3789 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3790 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3791 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 3792 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3793 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3794 | pipeline_layout_ci.setLayoutCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3795 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 3796 | VkPipelineLayout pipeline_layout; |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3797 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3798 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3799 | ASSERT_VK_SUCCESS(err); |
| 3800 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 3801 | VkShaderObj vs(m_device, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 3802 | 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] | 3803 | // but add it to be able to run on more devices |
Tony Barbour | d7d828b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 3804 | VkPipelineObj pipe(m_device); |
| 3805 | pipe.AddShader(&vs); |
Tony Barbour | 3c9e3b1 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 3806 | pipe.AddShader(&fs); |
Tony Barbour | d7d828b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 3807 | pipe.SetMSAA(&pipe_ms_state_ci); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 3808 | pipe.SetViewport(m_viewports); |
| 3809 | pipe.SetScissor(m_scissors); |
Tony Barbour | d7d828b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 3810 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 3811 | |
| 3812 | BeginCommandBuffer(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3813 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | d28acef | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 3814 | // Don't care about actual data, just need to get to draw to flag error |
| 3815 | static const float vbo_data[3] = {1.f, 0.f, 1.f}; |
| 3816 | VkConstantBufferObj vbo(m_device, sizeof(vbo_data), sizeof(float), (const void*) &vbo_data); |
| 3817 | 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] | 3818 | Draw(1, 0, 0, 0); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3819 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3820 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3821 | FAIL() << "Did not receive Error 'Vtx Buffer Index 0 was bound, but no vtx buffers are attached to PSO.'"; |
| 3822 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3823 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3824 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3825 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3826 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3827 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3828 | } |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3829 | #endif // DRAW_STATE_TESTS |
| 3830 | |
Tobin Ehlis | 57e6a61 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 3831 | #if THREADING_TESTS |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3832 | #if GTEST_IS_THREADSAFE |
| 3833 | struct thread_data_struct { |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3834 | VkCommandBuffer commandBuffer; |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3835 | VkEvent event; |
| 3836 | bool bailout; |
| 3837 | }; |
| 3838 | |
| 3839 | extern "C" void *AddToCommandBuffer(void *arg) |
| 3840 | { |
| 3841 | struct thread_data_struct *data = (struct thread_data_struct *) arg; |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3842 | |
| 3843 | for (int i = 0; i<10000; i++) { |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3844 | vkCmdSetEvent(data->commandBuffer, data->event, VK_PIPELINE_STAGE_ALL_GPU_COMMANDS); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3845 | if (data->bailout) { |
| 3846 | break; |
| 3847 | } |
| 3848 | } |
| 3849 | return NULL; |
| 3850 | } |
| 3851 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3852 | TEST_F(VkLayerTest, ThreadCommandBufferCollision) |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3853 | { |
Mike Stroyan | 7016f4f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 3854 | test_platform_thread thread; |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3855 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3856 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, "THREADING ERROR"); |
| 3857 | |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3858 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3859 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 3860 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3861 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3862 | // Calls AllocateCommandBuffers |
| 3863 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Mark Lobodzinski | a0f061c | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 3864 | |
| 3865 | // Avoid creating RenderPass |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3866 | commandBuffer.BeginCommandBuffer(); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3867 | |
| 3868 | VkEventCreateInfo event_info; |
| 3869 | VkEvent event; |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3870 | VkResult err; |
| 3871 | |
| 3872 | memset(&event_info, 0, sizeof(event_info)); |
| 3873 | event_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 3874 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3875 | err = vkCreateEvent(device(), &event_info, NULL, &event); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3876 | ASSERT_VK_SUCCESS(err); |
| 3877 | |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3878 | err = vkResetEvent(device(), event); |
| 3879 | ASSERT_VK_SUCCESS(err); |
| 3880 | |
| 3881 | struct thread_data_struct data; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3882 | data.commandBuffer = commandBuffer.GetBufferHandle(); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3883 | data.event = event; |
| 3884 | data.bailout = false; |
| 3885 | m_errorMonitor->SetBailout(&data.bailout); |
| 3886 | // Add many entries to command buffer from another thread. |
Mike Stroyan | 7016f4f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 3887 | test_platform_thread_create(&thread, AddToCommandBuffer, (void *)&data); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3888 | // Add many entries to command buffer from this thread at the same time. |
| 3889 | AddToCommandBuffer(&data); |
Mark Lobodzinski | a0f061c | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 3890 | |
Mike Stroyan | 7016f4f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 3891 | test_platform_thread_join(thread, NULL); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3892 | commandBuffer.EndCommandBuffer(); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3893 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3894 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3895 | FAIL() << "Did not receive Error 'THREADING ERROR' from using one VkCommandBufferObj in two threads"; |
| 3896 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3897 | } |
| 3898 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3899 | vkDestroyEvent(device(), event, NULL); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3900 | } |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3901 | #endif // GTEST_IS_THREADSAFE |
| 3902 | #endif // THREADING_TESTS |
| 3903 | |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 3904 | #if SHADER_CHECKER_TESTS |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3905 | TEST_F(VkLayerTest, InvalidSPIRVCodeSize) |
| 3906 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3907 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3908 | "Shader is not SPIR-V"); |
| 3909 | |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3910 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3911 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3912 | |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3913 | VkShaderModule module; |
| 3914 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 3915 | struct icd_spv_header spv; |
| 3916 | |
| 3917 | spv.magic = ICD_SPV_MAGIC; |
| 3918 | spv.version = ICD_SPV_VERSION; |
| 3919 | spv.gen_magic = 0; |
| 3920 | |
| 3921 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 3922 | moduleCreateInfo.pNext = NULL; |
Chia-I Wu | 036b161 | 2015-10-26 19:22:06 +0800 | [diff] [blame] | 3923 | moduleCreateInfo.pCode = (const uint32_t *) &spv; |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3924 | moduleCreateInfo.codeSize = 4; |
| 3925 | moduleCreateInfo.flags = 0; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3926 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3927 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3928 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3929 | FAIL() << "Did not recieive Error 'Shader is not SPIR-V'"; |
| 3930 | m_errorMonitor->DumpFailureMsgs(); |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3931 | } |
| 3932 | } |
| 3933 | |
| 3934 | TEST_F(VkLayerTest, InvalidSPIRVMagic) |
| 3935 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3936 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3937 | "Shader is not SPIR-V"); |
| 3938 | |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3939 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3940 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3941 | |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3942 | VkShaderModule module; |
| 3943 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 3944 | struct icd_spv_header spv; |
| 3945 | |
| 3946 | spv.magic = ~ICD_SPV_MAGIC; |
| 3947 | spv.version = ICD_SPV_VERSION; |
| 3948 | spv.gen_magic = 0; |
| 3949 | |
| 3950 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 3951 | moduleCreateInfo.pNext = NULL; |
Chia-I Wu | 036b161 | 2015-10-26 19:22:06 +0800 | [diff] [blame] | 3952 | moduleCreateInfo.pCode = (const uint32_t *) &spv; |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3953 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 3954 | moduleCreateInfo.flags = 0; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3955 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3956 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3957 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3958 | FAIL() << "Did not recieive Error 'Shader is not SPIR-V'"; |
| 3959 | m_errorMonitor->DumpFailureMsgs(); |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3960 | } |
| 3961 | } |
| 3962 | |
| 3963 | TEST_F(VkLayerTest, InvalidSPIRVVersion) |
| 3964 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3965 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3966 | "Shader is not SPIR-V"); |
| 3967 | |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3968 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3969 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3970 | |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3971 | VkShaderModule module; |
| 3972 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 3973 | struct icd_spv_header spv; |
| 3974 | |
| 3975 | spv.magic = ICD_SPV_MAGIC; |
| 3976 | spv.version = ~ICD_SPV_VERSION; |
| 3977 | spv.gen_magic = 0; |
| 3978 | |
| 3979 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 3980 | moduleCreateInfo.pNext = NULL; |
| 3981 | |
Chia-I Wu | 036b161 | 2015-10-26 19:22:06 +0800 | [diff] [blame] | 3982 | moduleCreateInfo.pCode = (const uint32_t *) &spv; |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3983 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 3984 | moduleCreateInfo.flags = 0; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3985 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3986 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3987 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3988 | FAIL() << "Did not recieive Error 'Shader is not SPIR-V'"; |
| 3989 | m_errorMonitor->DumpFailureMsgs(); |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3990 | } |
| 3991 | } |
| 3992 | |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 3993 | TEST_F(VkLayerTest, CreatePipelineVertexOutputNotConsumed) |
| 3994 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3995 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_WARN_BIT, |
| 3996 | "not consumed by fragment shader"); |
| 3997 | |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 3998 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 3999 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4000 | |
| 4001 | char const *vsSource = |
| 4002 | "#version 140\n" |
| 4003 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4004 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4005 | "\n" |
| 4006 | "layout(location=0) out float x;\n" |
| 4007 | "void main(){\n" |
| 4008 | " gl_Position = vec4(1);\n" |
| 4009 | " x = 0;\n" |
| 4010 | "}\n"; |
| 4011 | char const *fsSource = |
| 4012 | "#version 140\n" |
| 4013 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4014 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4015 | "\n" |
| 4016 | "layout(location=0) out vec4 color;\n" |
| 4017 | "void main(){\n" |
| 4018 | " color = vec4(1);\n" |
| 4019 | "}\n"; |
| 4020 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4021 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4022 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4023 | |
| 4024 | VkPipelineObj pipe(m_device); |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4025 | pipe.AddColorAttachment(); |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4026 | pipe.AddShader(&vs); |
| 4027 | pipe.AddShader(&fs); |
| 4028 | |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4029 | VkDescriptorSetObj descriptorSet(m_device); |
| 4030 | descriptorSet.AppendDummy(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4031 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4032 | |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4033 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4034 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4035 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4036 | FAIL() << "Did not receive Warning 'not consumed by fragment shader'"; |
| 4037 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4038 | } |
| 4039 | } |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4040 | |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4041 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvided) |
| 4042 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4043 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4044 | "not written by vertex shader"); |
| 4045 | |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4046 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4047 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4048 | |
| 4049 | char const *vsSource = |
| 4050 | "#version 140\n" |
| 4051 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4052 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4053 | "\n" |
| 4054 | "void main(){\n" |
| 4055 | " gl_Position = vec4(1);\n" |
| 4056 | "}\n"; |
| 4057 | char const *fsSource = |
| 4058 | "#version 140\n" |
| 4059 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4060 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4061 | "\n" |
| 4062 | "layout(location=0) in float x;\n" |
| 4063 | "layout(location=0) out vec4 color;\n" |
| 4064 | "void main(){\n" |
| 4065 | " color = vec4(x);\n" |
| 4066 | "}\n"; |
| 4067 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4068 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4069 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4070 | |
| 4071 | VkPipelineObj pipe(m_device); |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4072 | pipe.AddColorAttachment(); |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4073 | pipe.AddShader(&vs); |
| 4074 | pipe.AddShader(&fs); |
| 4075 | |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4076 | VkDescriptorSetObj descriptorSet(m_device); |
| 4077 | descriptorSet.AppendDummy(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4078 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4079 | |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4080 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4081 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4082 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4083 | FAIL() << "Did not receive Error 'not written by vertex shader'"; |
| 4084 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4085 | } |
| 4086 | } |
| 4087 | |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4088 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatch) |
| 4089 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4090 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4091 | "Type mismatch on location 0"); |
| 4092 | |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4093 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4094 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4095 | |
| 4096 | char const *vsSource = |
| 4097 | "#version 140\n" |
| 4098 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4099 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4100 | "\n" |
| 4101 | "layout(location=0) out int x;\n" |
| 4102 | "void main(){\n" |
| 4103 | " x = 0;\n" |
| 4104 | " gl_Position = vec4(1);\n" |
| 4105 | "}\n"; |
| 4106 | char const *fsSource = |
| 4107 | "#version 140\n" |
| 4108 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4109 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4110 | "\n" |
| 4111 | "layout(location=0) in float x;\n" /* VS writes int */ |
| 4112 | "layout(location=0) out vec4 color;\n" |
| 4113 | "void main(){\n" |
| 4114 | " color = vec4(x);\n" |
| 4115 | "}\n"; |
| 4116 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4117 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4118 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4119 | |
| 4120 | VkPipelineObj pipe(m_device); |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4121 | pipe.AddColorAttachment(); |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4122 | pipe.AddShader(&vs); |
| 4123 | pipe.AddShader(&fs); |
| 4124 | |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4125 | VkDescriptorSetObj descriptorSet(m_device); |
| 4126 | descriptorSet.AppendDummy(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4127 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4128 | |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4129 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4130 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4131 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4132 | FAIL() << "Did not receive Error 'Type mismatch on location 0'"; |
| 4133 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4134 | } |
| 4135 | } |
| 4136 | |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4137 | TEST_F(VkLayerTest, CreatePipelineAttribNotConsumed) |
| 4138 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4139 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_WARN_BIT, |
| 4140 | "location 0 not consumed by VS"); |
| 4141 | |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4142 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4143 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4144 | |
| 4145 | VkVertexInputBindingDescription input_binding; |
| 4146 | memset(&input_binding, 0, sizeof(input_binding)); |
| 4147 | |
| 4148 | VkVertexInputAttributeDescription input_attrib; |
| 4149 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 4150 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 4151 | |
| 4152 | char const *vsSource = |
| 4153 | "#version 140\n" |
| 4154 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4155 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4156 | "\n" |
| 4157 | "void main(){\n" |
| 4158 | " gl_Position = vec4(1);\n" |
| 4159 | "}\n"; |
| 4160 | char const *fsSource = |
| 4161 | "#version 140\n" |
| 4162 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4163 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4164 | "\n" |
| 4165 | "layout(location=0) out vec4 color;\n" |
| 4166 | "void main(){\n" |
| 4167 | " color = vec4(1);\n" |
| 4168 | "}\n"; |
| 4169 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4170 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4171 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4172 | |
| 4173 | VkPipelineObj pipe(m_device); |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4174 | pipe.AddColorAttachment(); |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4175 | pipe.AddShader(&vs); |
| 4176 | pipe.AddShader(&fs); |
| 4177 | |
| 4178 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 4179 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 4180 | |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4181 | VkDescriptorSetObj descriptorSet(m_device); |
| 4182 | descriptorSet.AppendDummy(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4183 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4184 | |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4185 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4186 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4187 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4188 | FAIL() << "Did not receive Warning 'location 0 not consumed by VS'"; |
| 4189 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4190 | } |
| 4191 | } |
| 4192 | |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4193 | TEST_F(VkLayerTest, CreatePipelineAttribNotProvided) |
| 4194 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4195 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4196 | "VS consumes input at location 0 but not provided"); |
| 4197 | |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4198 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4199 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4200 | |
| 4201 | char const *vsSource = |
| 4202 | "#version 140\n" |
| 4203 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4204 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4205 | "\n" |
| 4206 | "layout(location=0) in vec4 x;\n" /* not provided */ |
| 4207 | "void main(){\n" |
| 4208 | " gl_Position = x;\n" |
| 4209 | "}\n"; |
| 4210 | char const *fsSource = |
| 4211 | "#version 140\n" |
| 4212 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4213 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4214 | "\n" |
| 4215 | "layout(location=0) out vec4 color;\n" |
| 4216 | "void main(){\n" |
| 4217 | " color = vec4(1);\n" |
| 4218 | "}\n"; |
| 4219 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4220 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4221 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4222 | |
| 4223 | VkPipelineObj pipe(m_device); |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4224 | pipe.AddColorAttachment(); |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4225 | pipe.AddShader(&vs); |
| 4226 | pipe.AddShader(&fs); |
| 4227 | |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4228 | VkDescriptorSetObj descriptorSet(m_device); |
| 4229 | descriptorSet.AppendDummy(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4230 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4231 | |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4232 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4233 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4234 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4235 | FAIL() << "Did not receive Error 'VS consumes input at location 0 but not provided'"; |
| 4236 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4237 | } |
| 4238 | } |
| 4239 | |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4240 | TEST_F(VkLayerTest, CreatePipelineAttribTypeMismatch) |
| 4241 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4242 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4243 | "location 0 does not match VS input type"); |
| 4244 | |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4245 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4246 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4247 | |
| 4248 | VkVertexInputBindingDescription input_binding; |
| 4249 | memset(&input_binding, 0, sizeof(input_binding)); |
| 4250 | |
| 4251 | VkVertexInputAttributeDescription input_attrib; |
| 4252 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 4253 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 4254 | |
| 4255 | char const *vsSource = |
| 4256 | "#version 140\n" |
| 4257 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4258 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4259 | "\n" |
| 4260 | "layout(location=0) in int x;\n" /* attrib provided float */ |
| 4261 | "void main(){\n" |
| 4262 | " gl_Position = vec4(x);\n" |
| 4263 | "}\n"; |
| 4264 | char const *fsSource = |
| 4265 | "#version 140\n" |
| 4266 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4267 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4268 | "\n" |
| 4269 | "layout(location=0) out vec4 color;\n" |
| 4270 | "void main(){\n" |
| 4271 | " color = vec4(1);\n" |
| 4272 | "}\n"; |
| 4273 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4274 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4275 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4276 | |
| 4277 | VkPipelineObj pipe(m_device); |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4278 | pipe.AddColorAttachment(); |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4279 | pipe.AddShader(&vs); |
| 4280 | pipe.AddShader(&fs); |
| 4281 | |
| 4282 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 4283 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 4284 | |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4285 | VkDescriptorSetObj descriptorSet(m_device); |
| 4286 | descriptorSet.AppendDummy(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4287 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4288 | |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4289 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4290 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4291 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4292 | FAIL() << "Did not receive Error 'location 0 does not match VS input type'"; |
| 4293 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4294 | } |
| 4295 | } |
| 4296 | |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4297 | TEST_F(VkLayerTest, CreatePipelineAttribBindingConflict) |
| 4298 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4299 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4300 | "Duplicate vertex input binding descriptions for binding 0"); |
| 4301 | |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4302 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4303 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4304 | |
| 4305 | /* Two binding descriptions for binding 0 */ |
| 4306 | VkVertexInputBindingDescription input_bindings[2]; |
| 4307 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 4308 | |
| 4309 | VkVertexInputAttributeDescription input_attrib; |
| 4310 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 4311 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 4312 | |
| 4313 | char const *vsSource = |
| 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) in float x;\n" /* attrib provided float */ |
| 4319 | "void main(){\n" |
| 4320 | " gl_Position = vec4(x);\n" |
| 4321 | "}\n"; |
| 4322 | char const *fsSource = |
| 4323 | "#version 140\n" |
| 4324 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4325 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4326 | "\n" |
| 4327 | "layout(location=0) out vec4 color;\n" |
| 4328 | "void main(){\n" |
| 4329 | " color = vec4(1);\n" |
| 4330 | "}\n"; |
| 4331 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4332 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4333 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4334 | |
| 4335 | VkPipelineObj pipe(m_device); |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4336 | pipe.AddColorAttachment(); |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4337 | pipe.AddShader(&vs); |
| 4338 | pipe.AddShader(&fs); |
| 4339 | |
| 4340 | pipe.AddVertexInputBindings(input_bindings, 2); |
| 4341 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 4342 | |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4343 | VkDescriptorSetObj descriptorSet(m_device); |
| 4344 | descriptorSet.AppendDummy(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4345 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4346 | |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4347 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4348 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4349 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4350 | FAIL() << "Did not receive Error 'Duplicate vertex input binding descriptions for binding 0'"; |
| 4351 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4352 | } |
| 4353 | } |
Chris Forbes | 4c94870 | 2015-05-25 11:13:32 +1200 | [diff] [blame] | 4354 | |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4355 | /* TODO: would be nice to test the mixed broadcast & custom case, but the GLSL->SPV compiler |
| 4356 | * rejects it. */ |
| 4357 | |
| 4358 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotWritten) |
| 4359 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4360 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4361 | "Attachment 0 not written by FS"); |
| 4362 | |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4363 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4364 | |
| 4365 | char const *vsSource = |
| 4366 | "#version 140\n" |
| 4367 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4368 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4369 | "\n" |
| 4370 | "void main(){\n" |
| 4371 | " gl_Position = vec4(1);\n" |
| 4372 | "}\n"; |
| 4373 | char const *fsSource = |
| 4374 | "#version 140\n" |
| 4375 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4376 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4377 | "\n" |
| 4378 | "void main(){\n" |
| 4379 | "}\n"; |
| 4380 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4381 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4382 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4383 | |
| 4384 | VkPipelineObj pipe(m_device); |
| 4385 | pipe.AddShader(&vs); |
| 4386 | pipe.AddShader(&fs); |
| 4387 | |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4388 | /* set up CB 0, not written */ |
| 4389 | pipe.AddColorAttachment(); |
| 4390 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4391 | |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4392 | VkDescriptorSetObj descriptorSet(m_device); |
| 4393 | descriptorSet.AppendDummy(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4394 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4395 | |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4396 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4397 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4398 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4399 | FAIL() << "Did not receive Error 'Attachment 0 not written by FS'"; |
| 4400 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4401 | } |
| 4402 | } |
| 4403 | |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4404 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotConsumed) |
| 4405 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4406 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_WARN_BIT, |
| 4407 | "FS writes to output location 1 with no matching attachment"); |
| 4408 | |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4409 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4410 | |
| 4411 | char const *vsSource = |
| 4412 | "#version 140\n" |
| 4413 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4414 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4415 | "\n" |
| 4416 | "void main(){\n" |
| 4417 | " gl_Position = vec4(1);\n" |
| 4418 | "}\n"; |
| 4419 | char const *fsSource = |
| 4420 | "#version 140\n" |
| 4421 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4422 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4423 | "\n" |
| 4424 | "layout(location=0) out vec4 x;\n" |
| 4425 | "layout(location=1) out vec4 y;\n" /* no matching attachment for this */ |
| 4426 | "void main(){\n" |
| 4427 | " x = vec4(1);\n" |
| 4428 | " y = vec4(1);\n" |
| 4429 | "}\n"; |
| 4430 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4431 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4432 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4433 | |
| 4434 | VkPipelineObj pipe(m_device); |
| 4435 | pipe.AddShader(&vs); |
| 4436 | pipe.AddShader(&fs); |
| 4437 | |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4438 | /* set up CB 0, not written */ |
| 4439 | pipe.AddColorAttachment(); |
| 4440 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4441 | /* FS writes CB 1, but we don't configure it */ |
| 4442 | |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4443 | VkDescriptorSetObj descriptorSet(m_device); |
| 4444 | descriptorSet.AppendDummy(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4445 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4446 | |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4447 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4448 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4449 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4450 | FAIL() << "Did not receive Error 'FS writes to output location 1 with no matching attachment'"; |
| 4451 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4452 | } |
| 4453 | } |
| 4454 | |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4455 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputTypeMismatch) |
| 4456 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4457 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4458 | "does not match FS output type"); |
| 4459 | |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4460 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4461 | |
| 4462 | char const *vsSource = |
| 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 | "void main(){\n" |
| 4468 | " gl_Position = vec4(1);\n" |
| 4469 | "}\n"; |
| 4470 | char const *fsSource = |
| 4471 | "#version 140\n" |
| 4472 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4473 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4474 | "\n" |
| 4475 | "layout(location=0) out ivec4 x;\n" /* not UNORM */ |
| 4476 | "void main(){\n" |
| 4477 | " x = ivec4(1);\n" |
| 4478 | "}\n"; |
| 4479 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4480 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4481 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4482 | |
| 4483 | VkPipelineObj pipe(m_device); |
| 4484 | pipe.AddShader(&vs); |
| 4485 | pipe.AddShader(&fs); |
| 4486 | |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4487 | /* set up CB 0; type is UNORM by default */ |
| 4488 | pipe.AddColorAttachment(); |
| 4489 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4490 | |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4491 | VkDescriptorSetObj descriptorSet(m_device); |
| 4492 | descriptorSet.AppendDummy(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4493 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4494 | |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4495 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4496 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4497 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4498 | FAIL() << "Did not receive Error 'does not match FS output type'"; |
| 4499 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4500 | } |
| 4501 | } |
Chris Forbes | c205073 | 2015-06-05 14:43:36 +1200 | [diff] [blame] | 4502 | |
Chris Forbes | 76ce788 | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 4503 | TEST_F(VkLayerTest, CreatePipelineUniformBlockNotProvided) |
| 4504 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4505 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4506 | "not declared in pipeline layout"); |
| 4507 | |
Chris Forbes | 76ce788 | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 4508 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 76ce788 | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 4509 | |
| 4510 | char const *vsSource = |
| 4511 | "#version 140\n" |
| 4512 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4513 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4514 | "\n" |
| 4515 | "void main(){\n" |
| 4516 | " gl_Position = vec4(1);\n" |
| 4517 | "}\n"; |
| 4518 | char const *fsSource = |
| 4519 | "#version 140\n" |
| 4520 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4521 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4522 | "\n" |
| 4523 | "layout(location=0) out vec4 x;\n" |
| 4524 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 4525 | "void main(){\n" |
| 4526 | " x = vec4(bar.y);\n" |
| 4527 | "}\n"; |
| 4528 | |
Chris Forbes | 76ce788 | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 4529 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4530 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4531 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 76ce788 | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 4532 | |
Chris Forbes | 76ce788 | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 4533 | VkPipelineObj pipe(m_device); |
| 4534 | pipe.AddShader(&vs); |
| 4535 | pipe.AddShader(&fs); |
| 4536 | |
| 4537 | /* set up CB 0; type is UNORM by default */ |
| 4538 | pipe.AddColorAttachment(); |
| 4539 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4540 | |
| 4541 | VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4542 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 76ce788 | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 4543 | |
| 4544 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 4545 | |
| 4546 | /* should have generated an error -- pipeline layout does not |
| 4547 | * provide a uniform buffer in 0.0 |
| 4548 | */ |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4549 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4550 | FAIL() << "Did not receive Error 'not declared in pipeline layout'"; |
| 4551 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 76ce788 | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 4552 | } |
| 4553 | } |
| 4554 | |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4555 | #endif // SHADER_CHECKER_TESTS |
| 4556 | |
| 4557 | #if DEVICE_LIMITS_TESTS |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4558 | TEST_F(VkLayerTest, CreateImageLimitsViolationWidth) |
| 4559 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4560 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4561 | "CreateImage extents exceed allowable limits for format"); |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4562 | |
| 4563 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4564 | |
| 4565 | // Create an image |
| 4566 | VkImage image; |
| 4567 | |
| 4568 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 4569 | const int32_t tex_width = 32; |
| 4570 | const int32_t tex_height = 32; |
| 4571 | |
| 4572 | VkImageCreateInfo image_create_info = {}; |
| 4573 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4574 | image_create_info.pNext = NULL; |
| 4575 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4576 | image_create_info.format = tex_format; |
| 4577 | image_create_info.extent.width = tex_width; |
| 4578 | image_create_info.extent.height = tex_height; |
| 4579 | image_create_info.extent.depth = 1; |
| 4580 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 4581 | image_create_info.arrayLayers = 1; |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4582 | image_create_info.samples = 1; |
| 4583 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 4584 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 4585 | image_create_info.flags = 0; |
| 4586 | |
| 4587 | // Introduce error by sending down a bogus width extent |
| 4588 | image_create_info.extent.width = 65536; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4589 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4590 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4591 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4592 | FAIL() << "Did not receive Error 'CreateImage extents exceed allowable limits for format'"; |
| 4593 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4594 | } |
| 4595 | } |
| 4596 | |
| 4597 | TEST_F(VkLayerTest, CreateImageResourceSizeViolation) |
| 4598 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4599 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4600 | "CreateImage resource size exceeds allowable maximum"); |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4601 | |
| 4602 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4603 | |
| 4604 | // Create an image |
| 4605 | VkImage image; |
| 4606 | |
| 4607 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 4608 | const int32_t tex_width = 32; |
| 4609 | const int32_t tex_height = 32; |
| 4610 | |
| 4611 | VkImageCreateInfo image_create_info = {}; |
| 4612 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4613 | image_create_info.pNext = NULL; |
| 4614 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4615 | image_create_info.format = tex_format; |
| 4616 | image_create_info.extent.width = tex_width; |
| 4617 | image_create_info.extent.height = tex_height; |
| 4618 | image_create_info.extent.depth = 1; |
| 4619 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 4620 | image_create_info.arrayLayers = 1; |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4621 | image_create_info.samples = 1; |
| 4622 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 4623 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 4624 | image_create_info.flags = 0; |
| 4625 | |
| 4626 | // Introduce error by sending down individually allowable values that result in a surface size |
| 4627 | // exceeding the device maximum |
| 4628 | image_create_info.extent.width = 8192; |
| 4629 | image_create_info.extent.height = 8192; |
| 4630 | image_create_info.extent.depth = 16; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 4631 | image_create_info.arrayLayers = 4; |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4632 | image_create_info.samples = 2; |
| 4633 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4634 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4635 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4636 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4637 | FAIL() << "Did not receive Error 'CreateImage resource size exceeds allowable maximum'"; |
| 4638 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4639 | } |
| 4640 | } |
| 4641 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4642 | TEST_F(VkLayerTest, UpdateBufferAlignment) |
| 4643 | { |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4644 | uint32_t updateData[] = { 1, 2, 3, 4, 5, 6, 7, 8 }; |
| 4645 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4646 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4647 | "dstOffset, is not a multiple of 4"); |
| 4648 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4649 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4650 | |
| 4651 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 4652 | vk_testing::Buffer buffer; |
| 4653 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 4654 | |
| 4655 | BeginCommandBuffer(); |
| 4656 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4657 | m_commandBuffer->UpdateBuffer(buffer.handle(), 1, 4, updateData); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4658 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4659 | FAIL() << "Did not receive Error 'vkCommandUpdateBuffer parameter, VkDeviceSize dstOffset, is not a multiple of 4'"; |
| 4660 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4661 | } |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4662 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4663 | // Introduce failure by using size that is not multiple of 4 |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4664 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4665 | "dataSize, is not a multiple of 4"); |
| 4666 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4667 | m_commandBuffer->UpdateBuffer(buffer.handle(), 0, 6, updateData); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4668 | |
| 4669 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4670 | FAIL() << "Did not receive Error 'vkCommandUpdateBuffer parameter, VkDeviceSize dataSize, is not a multiple of 4'"; |
| 4671 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4672 | } |
| 4673 | EndCommandBuffer(); |
| 4674 | } |
| 4675 | |
| 4676 | TEST_F(VkLayerTest, FillBufferAlignment) |
| 4677 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4678 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4679 | "dstOffset, is not a multiple of 4"); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4680 | |
| 4681 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4682 | |
| 4683 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 4684 | vk_testing::Buffer buffer; |
| 4685 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 4686 | |
| 4687 | BeginCommandBuffer(); |
| 4688 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4689 | m_commandBuffer->FillBuffer(buffer.handle(), 1, 4, 0x11111111); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4690 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4691 | FAIL() << "Did not receive Error 'vkCommandFillBuffer parameter, VkDeviceSize dstOffset, is not a multiple of 4'"; |
| 4692 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4693 | } |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4694 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4695 | // Introduce failure by using size that is not multiple of 4 |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4696 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4697 | "size, is not a multiple of 4"); |
| 4698 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4699 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 6, 0x11111111); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4700 | |
| 4701 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4702 | FAIL() << "Did not receive Error 'vkCommandFillBuffer parameter, VkDeviceSize size, is not a multiple of 4'"; |
| 4703 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4704 | } |
| 4705 | EndCommandBuffer(); |
| 4706 | } |
| 4707 | |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4708 | #endif // DEVICE_LIMITS_TESTS |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4709 | |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4710 | #if IMAGE_TESTS |
| 4711 | TEST_F(VkLayerTest, InvalidImageView) |
| 4712 | { |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4713 | VkResult err; |
| 4714 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4715 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4716 | "vkCreateImageView called with baseMipLevel 10 "); |
| 4717 | |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4718 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4719 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4720 | // Create an image and try to create a view with bad baseMipLevel |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4721 | VkImage image; |
| 4722 | |
| 4723 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 4724 | const int32_t tex_width = 32; |
| 4725 | const int32_t tex_height = 32; |
| 4726 | |
| 4727 | VkImageCreateInfo image_create_info = {}; |
| 4728 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4729 | image_create_info.pNext = NULL; |
| 4730 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4731 | image_create_info.format = tex_format; |
| 4732 | image_create_info.extent.width = tex_width; |
| 4733 | image_create_info.extent.height = tex_height; |
| 4734 | image_create_info.extent.depth = 1; |
| 4735 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 4736 | image_create_info.arrayLayers = 1; |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4737 | image_create_info.samples = 1; |
| 4738 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 4739 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 4740 | image_create_info.flags = 0; |
| 4741 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4742 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4743 | ASSERT_VK_SUCCESS(err); |
| 4744 | |
| 4745 | VkImageViewCreateInfo image_view_create_info = {}; |
| 4746 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4747 | image_view_create_info.image = image; |
| 4748 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 4749 | image_view_create_info.format = tex_format; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4750 | image_view_create_info.subresourceRange.layerCount = 1; |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4751 | image_view_create_info.subresourceRange.baseMipLevel = 10; // cause an error |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4752 | image_view_create_info.subresourceRange.levelCount = 1; |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 4753 | image_view_create_info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4754 | |
| 4755 | VkImageView view; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4756 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, &view); |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4757 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4758 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4759 | FAIL() << "Did not receive Error 'vkCreateImageView called with baseMipLevel 10...'"; |
| 4760 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4761 | } |
| 4762 | } |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4763 | |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 4764 | TEST_F(VkLayerTest, InvalidImageViewAspect) |
| 4765 | { |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 4766 | VkResult err; |
| 4767 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4768 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4769 | "vkCreateImageView: Color image formats must have ONLY the VK_IMAGE_ASPECT_COLOR_BIT set"); |
| 4770 | |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 4771 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 4772 | |
| 4773 | // Create an image and try to create a view with an invalid aspectMask |
| 4774 | VkImage image; |
| 4775 | |
| 4776 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 4777 | const int32_t tex_width = 32; |
| 4778 | const int32_t tex_height = 32; |
| 4779 | |
| 4780 | VkImageCreateInfo image_create_info = {}; |
| 4781 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4782 | image_create_info.pNext = NULL; |
| 4783 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4784 | image_create_info.format = tex_format; |
| 4785 | image_create_info.extent.width = tex_width; |
| 4786 | image_create_info.extent.height = tex_height; |
| 4787 | image_create_info.extent.depth = 1; |
| 4788 | image_create_info.mipLevels = 1; |
| 4789 | image_create_info.samples = 1; |
| 4790 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 4791 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 4792 | image_create_info.flags = 0; |
| 4793 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4794 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 4795 | ASSERT_VK_SUCCESS(err); |
| 4796 | |
| 4797 | VkImageViewCreateInfo image_view_create_info = {}; |
| 4798 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4799 | image_view_create_info.image = image; |
| 4800 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 4801 | image_view_create_info.format = tex_format; |
| 4802 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4803 | image_view_create_info.subresourceRange.levelCount = 1; |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 4804 | // Cause an error by setting an invalid image aspect |
| 4805 | image_view_create_info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_METADATA_BIT; |
| 4806 | |
| 4807 | VkImageView view; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4808 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, &view); |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 4809 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4810 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4811 | FAIL() << "Did not receive Error 'VkCreateImageView: Color image formats must have ...'"; |
| 4812 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 4813 | } |
| 4814 | } |
| 4815 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4816 | TEST_F(VkLayerTest, CopyImageTypeMismatch) |
| 4817 | { |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4818 | VkResult err; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 4819 | bool pass; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4820 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4821 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4822 | "vkCmdCopyImage called with unmatched source and dest image types"); |
| 4823 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4824 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4825 | |
| 4826 | // Create two images of different types and try to copy between them |
| 4827 | VkImage srcImage; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4828 | VkImage dstImage; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4829 | VkDeviceMemory srcMem; |
| 4830 | VkDeviceMemory destMem; |
| 4831 | VkMemoryRequirements memReqs; |
| 4832 | |
| 4833 | VkImageCreateInfo image_create_info = {}; |
| 4834 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4835 | image_create_info.pNext = NULL; |
| 4836 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4837 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 4838 | image_create_info.extent.width = 32; |
| 4839 | image_create_info.extent.height = 32; |
| 4840 | image_create_info.extent.depth = 1; |
| 4841 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 4842 | image_create_info.arrayLayers = 1; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4843 | image_create_info.samples = 1; |
| 4844 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4845 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4846 | image_create_info.flags = 0; |
| 4847 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4848 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4849 | ASSERT_VK_SUCCESS(err); |
| 4850 | |
| 4851 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4852 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4853 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4854 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4855 | ASSERT_VK_SUCCESS(err); |
| 4856 | |
| 4857 | // Allocate memory |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4858 | VkMemoryAllocateInfo memAlloc = {}; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4859 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 4860 | memAlloc.pNext = NULL; |
| 4861 | memAlloc.allocationSize = 0; |
| 4862 | memAlloc.memoryTypeIndex = 0; |
| 4863 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 4864 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4865 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 4866 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 4867 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4868 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4869 | ASSERT_VK_SUCCESS(err); |
| 4870 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4871 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4872 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 4873 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4874 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4875 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4876 | ASSERT_VK_SUCCESS(err); |
| 4877 | |
| 4878 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 4879 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4880 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4881 | ASSERT_VK_SUCCESS(err); |
| 4882 | |
| 4883 | BeginCommandBuffer(); |
| 4884 | VkImageCopy copyRegion; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 4885 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4886 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 63f0ead | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 4887 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4888 | copyRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4889 | copyRegion.srcOffset.x = 0; |
| 4890 | copyRegion.srcOffset.y = 0; |
| 4891 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 4892 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4893 | copyRegion.dstSubresource.mipLevel = 0; |
| 4894 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 4895 | copyRegion.dstSubresource.layerCount = 0; |
| 4896 | copyRegion.dstOffset.x = 0; |
| 4897 | copyRegion.dstOffset.y = 0; |
| 4898 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4899 | copyRegion.extent.width = 1; |
| 4900 | copyRegion.extent.height = 1; |
| 4901 | copyRegion.extent.depth = 1; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4902 | 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] | 4903 | EndCommandBuffer(); |
| 4904 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4905 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4906 | FAIL() << "Did not receive Error 'vkCmdCopyImage called with unmatched source and dest image types'"; |
| 4907 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4908 | } |
| 4909 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4910 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4911 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4912 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 4913 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4914 | } |
| 4915 | |
| 4916 | TEST_F(VkLayerTest, CopyImageFormatSizeMismatch) |
| 4917 | { |
| 4918 | // TODO : Create two images with different format sizes and vkCmdCopyImage between them |
| 4919 | } |
| 4920 | |
| 4921 | TEST_F(VkLayerTest, CopyImageDepthStencilFormatMismatch) |
| 4922 | { |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4923 | VkResult err; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 4924 | bool pass; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4925 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4926 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4927 | "vkCmdCopyImage called with unmatched source and dest image types"); |
| 4928 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4929 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4930 | |
| 4931 | // Create two images of different types and try to copy between them |
| 4932 | VkImage srcImage; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4933 | VkImage dstImage; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4934 | VkDeviceMemory srcMem; |
| 4935 | VkDeviceMemory destMem; |
| 4936 | VkMemoryRequirements memReqs; |
| 4937 | |
| 4938 | VkImageCreateInfo image_create_info = {}; |
| 4939 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4940 | image_create_info.pNext = NULL; |
| 4941 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4942 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 4943 | image_create_info.extent.width = 32; |
| 4944 | image_create_info.extent.height = 32; |
| 4945 | image_create_info.extent.depth = 1; |
| 4946 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 4947 | image_create_info.arrayLayers = 1; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4948 | image_create_info.samples = 1; |
| 4949 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4950 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4951 | image_create_info.flags = 0; |
| 4952 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4953 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4954 | ASSERT_VK_SUCCESS(err); |
| 4955 | |
| 4956 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4957 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4958 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4959 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4960 | ASSERT_VK_SUCCESS(err); |
| 4961 | |
| 4962 | // Allocate memory |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4963 | VkMemoryAllocateInfo memAlloc = {}; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4964 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 4965 | memAlloc.pNext = NULL; |
| 4966 | memAlloc.allocationSize = 0; |
| 4967 | memAlloc.memoryTypeIndex = 0; |
| 4968 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 4969 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4970 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 4971 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 4972 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4973 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4974 | ASSERT_VK_SUCCESS(err); |
| 4975 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4976 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4977 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 4978 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 4979 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4980 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4981 | ASSERT_VK_SUCCESS(err); |
| 4982 | |
| 4983 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 4984 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4985 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4986 | ASSERT_VK_SUCCESS(err); |
| 4987 | |
| 4988 | BeginCommandBuffer(); |
| 4989 | VkImageCopy copyRegion; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 4990 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4991 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 63f0ead | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 4992 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4993 | copyRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4994 | copyRegion.srcOffset.x = 0; |
| 4995 | copyRegion.srcOffset.y = 0; |
| 4996 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 4997 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4998 | copyRegion.dstSubresource.mipLevel = 0; |
| 4999 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 5000 | copyRegion.dstSubresource.layerCount = 0; |
| 5001 | copyRegion.dstOffset.x = 0; |
| 5002 | copyRegion.dstOffset.y = 0; |
| 5003 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5004 | copyRegion.extent.width = 1; |
| 5005 | copyRegion.extent.height = 1; |
| 5006 | copyRegion.extent.depth = 1; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5007 | 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] | 5008 | EndCommandBuffer(); |
| 5009 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5010 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5011 | FAIL() << "Did not receive Error 'vkCmdCopyImage called with unmatched source and dest image types'"; |
| 5012 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5013 | } |
| 5014 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5015 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5016 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5017 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 5018 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5019 | } |
| 5020 | |
| 5021 | TEST_F(VkLayerTest, ResolveImageLowSampleCount) |
| 5022 | { |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5023 | VkResult err; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5024 | bool pass; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5025 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5026 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 5027 | "vkCmdResolveImage called with source sample count less than 2."); |
| 5028 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5029 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5030 | |
| 5031 | // Create two images of sample count 1 and try to Resolve between them |
| 5032 | VkImage srcImage; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5033 | VkImage dstImage; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5034 | VkDeviceMemory srcMem; |
| 5035 | VkDeviceMemory destMem; |
| 5036 | VkMemoryRequirements memReqs; |
| 5037 | |
| 5038 | VkImageCreateInfo image_create_info = {}; |
| 5039 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5040 | image_create_info.pNext = NULL; |
| 5041 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5042 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5043 | image_create_info.extent.width = 32; |
| 5044 | image_create_info.extent.height = 1; |
| 5045 | image_create_info.extent.depth = 1; |
| 5046 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 5047 | image_create_info.arrayLayers = 1; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5048 | image_create_info.samples = 1; |
| 5049 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5050 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5051 | image_create_info.flags = 0; |
| 5052 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5053 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5054 | ASSERT_VK_SUCCESS(err); |
| 5055 | |
| 5056 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5057 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5058 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5059 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5060 | ASSERT_VK_SUCCESS(err); |
| 5061 | |
| 5062 | // Allocate memory |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5063 | VkMemoryAllocateInfo memAlloc = {}; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5064 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 5065 | memAlloc.pNext = NULL; |
| 5066 | memAlloc.allocationSize = 0; |
| 5067 | memAlloc.memoryTypeIndex = 0; |
| 5068 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 5069 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5070 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5071 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5072 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5073 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5074 | ASSERT_VK_SUCCESS(err); |
| 5075 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5076 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5077 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5078 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5079 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5080 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5081 | ASSERT_VK_SUCCESS(err); |
| 5082 | |
| 5083 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 5084 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5085 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5086 | ASSERT_VK_SUCCESS(err); |
| 5087 | |
| 5088 | BeginCommandBuffer(); |
| 5089 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
| 5090 | //VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 5091 | //VK_IMAGE_LAYOUT_GENERAL = 1, |
| 5092 | VkImageResolve resolveRegion; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5093 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5094 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 63f0ead | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5095 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5096 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5097 | resolveRegion.srcOffset.x = 0; |
| 5098 | resolveRegion.srcOffset.y = 0; |
| 5099 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5100 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5101 | resolveRegion.dstSubresource.mipLevel = 0; |
| 5102 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 5103 | resolveRegion.dstSubresource.layerCount = 0; |
| 5104 | resolveRegion.dstOffset.x = 0; |
| 5105 | resolveRegion.dstOffset.y = 0; |
| 5106 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5107 | resolveRegion.extent.width = 1; |
| 5108 | resolveRegion.extent.height = 1; |
| 5109 | resolveRegion.extent.depth = 1; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5110 | 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] | 5111 | EndCommandBuffer(); |
| 5112 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5113 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5114 | FAIL() << "Did not receive Error 'vkCmdResolveImage called with source sample count less than 2.'"; |
| 5115 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5116 | } |
| 5117 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5118 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5119 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5120 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 5121 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5122 | } |
| 5123 | |
| 5124 | TEST_F(VkLayerTest, ResolveImageHighSampleCount) |
| 5125 | { |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5126 | VkResult err; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5127 | bool pass; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5128 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5129 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 5130 | "vkCmdResolveImage called with dest sample count greater than 1."); |
| 5131 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5132 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5133 | |
| 5134 | // Create two images of sample count 2 and try to Resolve between them |
| 5135 | VkImage srcImage; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5136 | VkImage dstImage; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5137 | VkDeviceMemory srcMem; |
| 5138 | VkDeviceMemory destMem; |
| 5139 | VkMemoryRequirements memReqs; |
| 5140 | |
| 5141 | VkImageCreateInfo image_create_info = {}; |
| 5142 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5143 | image_create_info.pNext = NULL; |
| 5144 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5145 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5146 | image_create_info.extent.width = 32; |
| 5147 | image_create_info.extent.height = 1; |
| 5148 | image_create_info.extent.depth = 1; |
| 5149 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 5150 | image_create_info.arrayLayers = 1; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5151 | image_create_info.samples = 2; |
| 5152 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
Cody Northrop | b3bf94f | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 5153 | // Note: Some implementations expect color attachment usage for any multisample surface |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5154 | 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] | 5155 | image_create_info.flags = 0; |
| 5156 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5157 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5158 | ASSERT_VK_SUCCESS(err); |
| 5159 | |
| 5160 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
Cody Northrop | b3bf94f | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 5161 | // Note: Some implementations expect color attachment usage for any multisample surface |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5162 | 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] | 5163 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5164 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5165 | ASSERT_VK_SUCCESS(err); |
| 5166 | |
| 5167 | // Allocate memory |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5168 | VkMemoryAllocateInfo memAlloc = {}; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5169 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 5170 | memAlloc.pNext = NULL; |
| 5171 | memAlloc.allocationSize = 0; |
| 5172 | memAlloc.memoryTypeIndex = 0; |
| 5173 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 5174 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5175 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5176 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5177 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5178 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5179 | ASSERT_VK_SUCCESS(err); |
| 5180 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5181 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5182 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5183 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5184 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5185 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5186 | ASSERT_VK_SUCCESS(err); |
| 5187 | |
| 5188 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 5189 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5190 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5191 | ASSERT_VK_SUCCESS(err); |
| 5192 | |
| 5193 | BeginCommandBuffer(); |
| 5194 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
| 5195 | //VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 5196 | //VK_IMAGE_LAYOUT_GENERAL = 1, |
| 5197 | VkImageResolve resolveRegion; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5198 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5199 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 63f0ead | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5200 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5201 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5202 | resolveRegion.srcOffset.x = 0; |
| 5203 | resolveRegion.srcOffset.y = 0; |
| 5204 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5205 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5206 | resolveRegion.dstSubresource.mipLevel = 0; |
| 5207 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 5208 | resolveRegion.dstSubresource.layerCount = 0; |
| 5209 | resolveRegion.dstOffset.x = 0; |
| 5210 | resolveRegion.dstOffset.y = 0; |
| 5211 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5212 | resolveRegion.extent.width = 1; |
| 5213 | resolveRegion.extent.height = 1; |
| 5214 | resolveRegion.extent.depth = 1; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5215 | 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] | 5216 | EndCommandBuffer(); |
| 5217 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5218 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5219 | FAIL() << "Did not receive Error 'vkCmdResolveImage called with dest sample count greater than 1.'"; |
| 5220 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5221 | } |
| 5222 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5223 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5224 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5225 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 5226 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5227 | } |
| 5228 | |
| 5229 | TEST_F(VkLayerTest, ResolveImageFormatMismatch) |
| 5230 | { |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5231 | VkResult err; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5232 | bool pass; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5233 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5234 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 5235 | "vkCmdResolveImage called with unmatched source and dest formats."); |
| 5236 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5237 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5238 | |
| 5239 | // Create two images of different types and try to copy between them |
| 5240 | VkImage srcImage; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5241 | VkImage dstImage; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5242 | VkDeviceMemory srcMem; |
| 5243 | VkDeviceMemory destMem; |
| 5244 | VkMemoryRequirements memReqs; |
| 5245 | |
| 5246 | VkImageCreateInfo image_create_info = {}; |
| 5247 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5248 | image_create_info.pNext = NULL; |
| 5249 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5250 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5251 | image_create_info.extent.width = 32; |
| 5252 | image_create_info.extent.height = 1; |
| 5253 | image_create_info.extent.depth = 1; |
| 5254 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 5255 | image_create_info.arrayLayers = 1; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5256 | image_create_info.samples = 2; |
| 5257 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
Cody Northrop | b3bf94f | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 5258 | // Note: Some implementations expect color attachment usage for any multisample surface |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5259 | 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] | 5260 | image_create_info.flags = 0; |
| 5261 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5262 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5263 | ASSERT_VK_SUCCESS(err); |
| 5264 | |
Cody Northrop | b3bf94f | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 5265 | // Set format to something other than source image |
| 5266 | image_create_info.format = VK_FORMAT_R32_SFLOAT; |
| 5267 | // Note: Some implementations expect color attachment usage for any multisample surface |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5268 | 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] | 5269 | image_create_info.samples = 1; |
| 5270 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5271 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5272 | ASSERT_VK_SUCCESS(err); |
| 5273 | |
| 5274 | // Allocate memory |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5275 | VkMemoryAllocateInfo memAlloc = {}; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5276 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 5277 | memAlloc.pNext = NULL; |
| 5278 | memAlloc.allocationSize = 0; |
| 5279 | memAlloc.memoryTypeIndex = 0; |
| 5280 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 5281 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5282 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5283 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5284 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5285 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5286 | ASSERT_VK_SUCCESS(err); |
| 5287 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5288 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5289 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5290 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5291 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5292 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5293 | ASSERT_VK_SUCCESS(err); |
| 5294 | |
| 5295 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 5296 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5297 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5298 | ASSERT_VK_SUCCESS(err); |
| 5299 | |
| 5300 | BeginCommandBuffer(); |
| 5301 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
| 5302 | //VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 5303 | //VK_IMAGE_LAYOUT_GENERAL = 1, |
| 5304 | VkImageResolve resolveRegion; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5305 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5306 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 63f0ead | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5307 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5308 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5309 | resolveRegion.srcOffset.x = 0; |
| 5310 | resolveRegion.srcOffset.y = 0; |
| 5311 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5312 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5313 | resolveRegion.dstSubresource.mipLevel = 0; |
| 5314 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 5315 | resolveRegion.dstSubresource.layerCount = 0; |
| 5316 | resolveRegion.dstOffset.x = 0; |
| 5317 | resolveRegion.dstOffset.y = 0; |
| 5318 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5319 | resolveRegion.extent.width = 1; |
| 5320 | resolveRegion.extent.height = 1; |
| 5321 | resolveRegion.extent.depth = 1; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5322 | 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] | 5323 | EndCommandBuffer(); |
| 5324 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5325 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5326 | FAIL() << "Did not receive Error 'vkCmdResolveImage called with unmatched source and dest formats.'"; |
| 5327 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5328 | } |
| 5329 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5330 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5331 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5332 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 5333 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5334 | } |
| 5335 | |
| 5336 | TEST_F(VkLayerTest, ResolveImageTypeMismatch) |
| 5337 | { |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5338 | VkResult err; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5339 | bool pass; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5340 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5341 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 5342 | "vkCmdResolveImage called with unmatched source and dest image types."); |
| 5343 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5344 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5345 | |
| 5346 | // Create two images of different types and try to copy between them |
| 5347 | VkImage srcImage; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5348 | VkImage dstImage; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5349 | VkDeviceMemory srcMem; |
| 5350 | VkDeviceMemory destMem; |
| 5351 | VkMemoryRequirements memReqs; |
| 5352 | |
| 5353 | VkImageCreateInfo image_create_info = {}; |
| 5354 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5355 | image_create_info.pNext = NULL; |
| 5356 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5357 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5358 | image_create_info.extent.width = 32; |
| 5359 | image_create_info.extent.height = 1; |
| 5360 | image_create_info.extent.depth = 1; |
| 5361 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 5362 | image_create_info.arrayLayers = 1; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5363 | image_create_info.samples = 2; |
| 5364 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
Cody Northrop | b3bf94f | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 5365 | // Note: Some implementations expect color attachment usage for any multisample surface |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5366 | 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] | 5367 | image_create_info.flags = 0; |
| 5368 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5369 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5370 | ASSERT_VK_SUCCESS(err); |
| 5371 | |
| 5372 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
Cody Northrop | b3bf94f | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 5373 | // Note: Some implementations expect color attachment usage for any multisample surface |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5374 | 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] | 5375 | image_create_info.samples = 1; |
| 5376 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5377 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5378 | ASSERT_VK_SUCCESS(err); |
| 5379 | |
| 5380 | // Allocate memory |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5381 | VkMemoryAllocateInfo memAlloc = {}; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5382 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 5383 | memAlloc.pNext = NULL; |
| 5384 | memAlloc.allocationSize = 0; |
| 5385 | memAlloc.memoryTypeIndex = 0; |
| 5386 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 5387 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5388 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5389 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5390 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5391 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5392 | ASSERT_VK_SUCCESS(err); |
| 5393 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5394 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5395 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5396 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5397 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5398 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5399 | ASSERT_VK_SUCCESS(err); |
| 5400 | |
| 5401 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 5402 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5403 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5404 | ASSERT_VK_SUCCESS(err); |
| 5405 | |
| 5406 | BeginCommandBuffer(); |
| 5407 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
| 5408 | //VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 5409 | //VK_IMAGE_LAYOUT_GENERAL = 1, |
| 5410 | VkImageResolve resolveRegion; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5411 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5412 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 63f0ead | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5413 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5414 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5415 | resolveRegion.srcOffset.x = 0; |
| 5416 | resolveRegion.srcOffset.y = 0; |
| 5417 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5418 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5419 | resolveRegion.dstSubresource.mipLevel = 0; |
| 5420 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 5421 | resolveRegion.dstSubresource.layerCount = 0; |
| 5422 | resolveRegion.dstOffset.x = 0; |
| 5423 | resolveRegion.dstOffset.y = 0; |
| 5424 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5425 | resolveRegion.extent.width = 1; |
| 5426 | resolveRegion.extent.height = 1; |
| 5427 | resolveRegion.extent.depth = 1; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5428 | 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] | 5429 | EndCommandBuffer(); |
| 5430 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5431 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5432 | FAIL() << "Did not receive Error 'vkCmdResolveImage called with unmatched source and dest image types.'"; |
| 5433 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5434 | } |
| 5435 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5436 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5437 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5438 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 5439 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5440 | } |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5441 | |
| 5442 | TEST_F(VkLayerTest, DepthStencilImageViewWithColorAspectBitError) |
| 5443 | { |
| 5444 | // Create a single Image descriptor and cause it to first hit an error due |
| 5445 | // to using a DS format, then cause it to hit error due to COLOR_BIT not set in aspect |
| 5446 | // The image format check comes 2nd in validation so we trigger it first, |
| 5447 | // 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] | 5448 | VkResult err; |
| 5449 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5450 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 5451 | "Combination depth/stencil image formats can have only the "); |
| 5452 | |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5453 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5454 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5455 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5456 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5457 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5458 | |
| 5459 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 5460 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5461 | ds_pool_ci.pNext = NULL; |
| 5462 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5463 | ds_pool_ci.poolSizeCount = 1; |
| 5464 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5465 | |
| 5466 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5467 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5468 | ASSERT_VK_SUCCESS(err); |
| 5469 | |
| 5470 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 5471 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 5472 | dsl_binding.arraySize = 1; |
| 5473 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5474 | dsl_binding.pImmutableSamplers = NULL; |
| 5475 | |
| 5476 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 5477 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5478 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5479 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame^] | 5480 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5481 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5482 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5483 | ASSERT_VK_SUCCESS(err); |
| 5484 | |
| 5485 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5486 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5487 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5488 | alloc_info.setLayoutCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5489 | alloc_info.descriptorPool = ds_pool; |
| 5490 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5491 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5492 | ASSERT_VK_SUCCESS(err); |
| 5493 | |
| 5494 | VkImage image_bad; |
| 5495 | VkImage image_good; |
| 5496 | // One bad format and one good format for Color attachment |
| 5497 | const VkFormat tex_format_bad = VK_FORMAT_D32_SFLOAT_S8_UINT; |
| 5498 | const VkFormat tex_format_good = VK_FORMAT_B8G8R8A8_UNORM; |
| 5499 | const int32_t tex_width = 32; |
| 5500 | const int32_t tex_height = 32; |
| 5501 | |
| 5502 | VkImageCreateInfo image_create_info = {}; |
| 5503 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5504 | image_create_info.pNext = NULL; |
| 5505 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5506 | image_create_info.format = tex_format_bad; |
| 5507 | image_create_info.extent.width = tex_width; |
| 5508 | image_create_info.extent.height = tex_height; |
| 5509 | image_create_info.extent.depth = 1; |
| 5510 | image_create_info.mipLevels = 1; |
| 5511 | image_create_info.arrayLayers = 1; |
| 5512 | image_create_info.samples = 1; |
| 5513 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 5514 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 5515 | image_create_info.flags = 0; |
| 5516 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5517 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image_bad); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5518 | ASSERT_VK_SUCCESS(err); |
| 5519 | image_create_info.format = tex_format_good; |
| 5520 | 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] | 5521 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image_good); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5522 | ASSERT_VK_SUCCESS(err); |
| 5523 | |
| 5524 | VkImageViewCreateInfo image_view_create_info = {}; |
| 5525 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5526 | image_view_create_info.image = image_bad; |
| 5527 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 5528 | image_view_create_info.format = tex_format_bad; |
| 5529 | image_view_create_info.subresourceRange.baseArrayLayer = 0; |
| 5530 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5531 | image_view_create_info.subresourceRange.layerCount = 1; |
| 5532 | image_view_create_info.subresourceRange.levelCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5533 | image_view_create_info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 5534 | |
| 5535 | VkImageView view; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5536 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, &view); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5537 | |
| 5538 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5539 | FAIL() << "Did not receive Error 'Combination depth-stencil image formats can have only the....'"; |
| 5540 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5541 | } |
| 5542 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5543 | vkDestroyImage(m_device->device(), image_bad, NULL); |
| 5544 | vkDestroyImage(m_device->device(), image_good, NULL); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5545 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5546 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5547 | } |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 5548 | #endif // IMAGE_TESTS |
| 5549 | |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 5550 | int main(int argc, char **argv) { |
| 5551 | int result; |
| 5552 | |
| 5553 | ::testing::InitGoogleTest(&argc, argv); |
Tony Barbour | 0199918 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 5554 | VkTestFramework::InitArgs(&argc, argv); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 5555 | |
| 5556 | ::testing::AddGlobalTestEnvironment(new TestEnvironment); |
| 5557 | |
| 5558 | result = RUN_ALL_TESTS(); |
| 5559 | |
Tony Barbour | 0199918 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 5560 | VkTestFramework::Finish(); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 5561 | return result; |
| 5562 | } |