David Pinedo | 329ca9e | 2015-11-06 12:54:48 -0700 | [diff] [blame] | 1 | #include <vulkan/vulkan.h> |
| 2 | #include "vulkan/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 | { |
Tony Barbour | 192f02b | 2015-11-06 14:21:31 -0700 | [diff] [blame] | 185 | if (msgFlags & (VK_DBG_REPORT_WARN_BIT | VK_DBG_REPORT_PERF_WARN_BIT | VK_DBG_REPORT_ERROR_BIT)) { |
Tony Barbour | 8508b8e | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 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; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 564 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 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, |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 639 | // .samples = VK_SAMPLE_COUNT_1_BIT, |
Tobin Ehlis | 33ce8fd | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 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; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 711 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 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, |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 846 | .samples = VK_SAMPLE_COUNT_1_BIT, |
Tobin Ehlis | d94ba72 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 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 = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 901 | dsl_binding.binding = 0; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 902 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 903 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 904 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 905 | dsl_binding.pImmutableSamplers = NULL; |
| 906 | |
| 907 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 908 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 909 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 910 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 911 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 912 | |
| 913 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 914 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 915 | ASSERT_VK_SUCCESS(err); |
| 916 | |
| 917 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 918 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 919 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 920 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 921 | alloc_info.descriptorPool = ds_pool; |
| 922 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 923 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 924 | ASSERT_VK_SUCCESS(err); |
| 925 | |
| 926 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 927 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 928 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 929 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 930 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 931 | |
| 932 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 933 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 934 | ASSERT_VK_SUCCESS(err); |
| 935 | |
| 936 | VkPipeline badPipeline = (VkPipeline)0xbaadb1be; |
| 937 | |
| 938 | BeginCommandBuffer(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 939 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, badPipeline); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 940 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 941 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 942 | FAIL() << "Error received was not 'Invalid VkPipeline Object 0xbaadb1be'" << endl; |
| 943 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 944 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 945 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 946 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 947 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 948 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 949 | } |
| 950 | |
| 951 | TEST_F(VkLayerTest, BindInvalidMemory) |
| 952 | { |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 953 | VkResult err; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 954 | bool pass; |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 955 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 956 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 957 | "Invalid VkDeviceMemory Object "); |
| 958 | |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 959 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 960 | |
| 961 | // Create an image, allocate memory, free it, and then try to bind it |
| 962 | VkImage image; |
| 963 | VkDeviceMemory mem; |
| 964 | VkMemoryRequirements mem_reqs; |
| 965 | |
| 966 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 967 | const int32_t tex_width = 32; |
| 968 | const int32_t tex_height = 32; |
| 969 | |
| 970 | VkImageCreateInfo image_create_info = {}; |
| 971 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 972 | image_create_info.pNext = NULL; |
| 973 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 974 | image_create_info.format = tex_format; |
| 975 | image_create_info.extent.width = tex_width; |
| 976 | image_create_info.extent.height = tex_height; |
| 977 | image_create_info.extent.depth = 1; |
| 978 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 979 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 980 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 981 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 982 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 983 | image_create_info.flags = 0; |
| 984 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 985 | VkMemoryAllocateInfo mem_alloc = {}; |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 986 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 987 | mem_alloc.pNext = NULL; |
| 988 | mem_alloc.allocationSize = 0; |
| 989 | mem_alloc.memoryTypeIndex = 0; |
| 990 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 991 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 992 | ASSERT_VK_SUCCESS(err); |
| 993 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 994 | vkGetImageMemoryRequirements(m_device->device(), |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 995 | image, |
| 996 | &mem_reqs); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 997 | |
| 998 | mem_alloc.allocationSize = mem_reqs.size; |
| 999 | |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 1000 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
| 1001 | ASSERT_TRUE(pass); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1002 | |
| 1003 | // allocate memory |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1004 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1005 | ASSERT_VK_SUCCESS(err); |
| 1006 | |
| 1007 | // Introduce validation failure, free memory before binding |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1008 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1009 | |
| 1010 | // Try to bind free memory that has been freed |
| 1011 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 1012 | // This may very well return an error. |
| 1013 | (void)err; |
| 1014 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1015 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1016 | FAIL() << "Did not receive Error 'Invalid VkDeviceMemory Object 0x<handle>'"; |
| 1017 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1018 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1019 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1020 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1021 | } |
| 1022 | |
| 1023 | TEST_F(VkLayerTest, BindMemoryToDestroyedObject) |
| 1024 | { |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1025 | VkResult err; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 1026 | bool pass; |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1027 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1028 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, "Invalid VkImage Object "); |
| 1029 | |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1030 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1031 | |
| 1032 | // Create an image object, allocate memory, destroy the object and then try to bind it |
| 1033 | VkImage image; |
| 1034 | VkDeviceMemory mem; |
| 1035 | VkMemoryRequirements mem_reqs; |
| 1036 | |
| 1037 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 1038 | const int32_t tex_width = 32; |
| 1039 | const int32_t tex_height = 32; |
| 1040 | |
| 1041 | VkImageCreateInfo image_create_info = {}; |
| 1042 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 1043 | image_create_info.pNext = NULL; |
| 1044 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 1045 | image_create_info.format = tex_format; |
| 1046 | image_create_info.extent.width = tex_width; |
| 1047 | image_create_info.extent.height = tex_height; |
| 1048 | image_create_info.extent.depth = 1; |
| 1049 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 1050 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1051 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1052 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 1053 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 1054 | image_create_info.flags = 0; |
| 1055 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1056 | VkMemoryAllocateInfo mem_alloc = {}; |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1057 | mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 1058 | mem_alloc.pNext = NULL; |
| 1059 | mem_alloc.allocationSize = 0; |
| 1060 | mem_alloc.memoryTypeIndex = 0; |
| 1061 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1062 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1063 | ASSERT_VK_SUCCESS(err); |
| 1064 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 1065 | vkGetImageMemoryRequirements(m_device->device(), |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1066 | image, |
| 1067 | &mem_reqs); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1068 | |
| 1069 | mem_alloc.allocationSize = mem_reqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 1070 | pass = m_device->phy().set_memory_type(mem_reqs.memoryTypeBits, &mem_alloc, 0); |
| 1071 | ASSERT_TRUE(pass); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1072 | |
| 1073 | // Allocate memory |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1074 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1075 | ASSERT_VK_SUCCESS(err); |
| 1076 | |
| 1077 | // Introduce validation failure, destroy Image object before binding |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1078 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | 87f115c | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1079 | ASSERT_VK_SUCCESS(err); |
| 1080 | |
| 1081 | // Now Try to bind memory to this destroyed object |
| 1082 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
| 1083 | // This may very well return an error. |
| 1084 | (void) err; |
| 1085 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1086 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1087 | FAIL() << "Did not receive Error 'Invalid VkImage Object 0x<handle>'"; |
| 1088 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1089 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1090 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1091 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1092 | } |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1093 | |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 1094 | #endif // OBJ_TRACKER_TESTS |
| 1095 | |
Tobin Ehlis | 57e6a61 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 1096 | #if DRAW_STATE_TESTS |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1097 | TEST_F(VkLayerTest, LineWidthStateNotBound) |
| 1098 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1099 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1100 | "Dynamic line width state not set for this command buffer"); |
| 1101 | |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1102 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a line width state object is not bound beforehand"); |
| 1103 | |
| 1104 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailLineWidth); |
| 1105 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1106 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1107 | FAIL() << "Did not receive Error 'Dynamic line width state not set for this command buffer'"; |
| 1108 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1109 | } |
| 1110 | } |
| 1111 | |
| 1112 | TEST_F(VkLayerTest, DepthBiasStateNotBound) |
| 1113 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1114 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1115 | "Dynamic depth bias state not set for this command buffer"); |
| 1116 | |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1117 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a depth bias state object is not bound beforehand"); |
| 1118 | |
| 1119 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailDepthBias); |
| 1120 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1121 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1122 | FAIL() << "Did not receive Error 'Dynamic depth bias state not set for this command buffer'"; |
| 1123 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1124 | } |
| 1125 | } |
| 1126 | |
Cody Northrop | bca3bcd | 2015-10-27 16:54:28 -0600 | [diff] [blame] | 1127 | // 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] | 1128 | TEST_F(VkLayerTest, ViewportStateNotBound) |
| 1129 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1130 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1131 | "Dynamic viewport state not set for this command buffer"); |
| 1132 | |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1133 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a viewport state object is not bound beforehand"); |
| 1134 | |
| 1135 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailViewport); |
| 1136 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1137 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1138 | FAIL() << "Did not recieve Error 'Dynamic scissor state not set for this command buffer'"; |
| 1139 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1140 | } |
| 1141 | } |
| 1142 | |
| 1143 | TEST_F(VkLayerTest, ScissorStateNotBound) |
| 1144 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1145 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1146 | "Dynamic scissor state not set for this command buffer"); |
| 1147 | |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1148 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a viewport state object is not bound beforehand"); |
| 1149 | |
| 1150 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailScissor); |
| 1151 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1152 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1153 | FAIL() << "Did not recieve Error ' Expected: 'Dynamic scissor state not set for this command buffer'"; |
| 1154 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1155 | } |
| 1156 | } |
| 1157 | |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1158 | TEST_F(VkLayerTest, BlendStateNotBound) |
| 1159 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1160 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1161 | "Dynamic blend object state not set for this command buffer"); |
| 1162 | |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1163 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a blend state object is not bound beforehand"); |
| 1164 | |
| 1165 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailBlend); |
| 1166 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1167 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1168 | FAIL() << "Did not recieve Error 'Dynamic blend object state not set for this command buffer'"; |
| 1169 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1170 | } |
| 1171 | } |
| 1172 | |
| 1173 | TEST_F(VkLayerTest, DepthBoundsStateNotBound) |
| 1174 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1175 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1176 | "Dynamic depth bounds state not set for this command buffer"); |
| 1177 | |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1178 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a depth bounds state object is not bound beforehand"); |
| 1179 | |
| 1180 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailDepthBounds); |
| 1181 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1182 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1183 | FAIL() << "Did not receive Error 'Dynamic depth bounds state not set for this command buffer'"; |
| 1184 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1185 | } |
| 1186 | } |
| 1187 | |
| 1188 | TEST_F(VkLayerTest, StencilReadMaskNotSet) |
| 1189 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1190 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1191 | "Dynamic stencil read mask state not set for this command buffer"); |
| 1192 | |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1193 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1194 | |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1195 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a stencil read mask is not set beforehand"); |
| 1196 | |
| 1197 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailStencilReadMask); |
| 1198 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1199 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1200 | FAIL() << "Did not receive Error 'Dynamic stencil read mask state not set for this command buffer'"; |
| 1201 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1202 | } |
| 1203 | } |
| 1204 | |
| 1205 | TEST_F(VkLayerTest, StencilWriteMaskNotSet) |
| 1206 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1207 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1208 | "Dynamic stencil write mask state not set for this command buffer"); |
| 1209 | |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1210 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1211 | |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1212 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a stencil write mask is not set beforehand"); |
| 1213 | |
| 1214 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailStencilWriteMask); |
| 1215 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1216 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1217 | FAIL() << "Did not receive Error 'Dynamic stencil write mask state not set for this command buffer'"; |
| 1218 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1219 | } |
| 1220 | } |
| 1221 | |
| 1222 | TEST_F(VkLayerTest, StencilReferenceNotSet) |
| 1223 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1224 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1225 | "Dynamic stencil reference state not set for this command buffer"); |
| 1226 | |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1227 | TEST_DESCRIPTION("Simple Draw Call that validates failure when a stencil reference is not set beforehand"); |
| 1228 | |
| 1229 | VKTriangleTest(bindStateVertShaderText, bindStateFragShaderText, BsoFailStencilReference); |
| 1230 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1231 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1232 | FAIL() << "Did not receive Error 'Dynamic stencil reference state not set for this command buffer'"; |
| 1233 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | f6cb467 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1234 | } |
| 1235 | } |
| 1236 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1237 | TEST_F(VkLayerTest, CommandBufferTwoSubmits) |
Tobin Ehlis | 0cea408 | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1238 | { |
| 1239 | vk_testing::Fence testFence; |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1240 | |
| 1241 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1242 | "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] | 1243 | |
| 1244 | VkFenceCreateInfo fenceInfo = {}; |
| 1245 | fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
| 1246 | fenceInfo.pNext = NULL; |
| 1247 | fenceInfo.flags = 0; |
| 1248 | |
| 1249 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1250 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 1251 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1252 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1253 | // 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] | 1254 | BeginCommandBuffer(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1255 | 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] | 1256 | EndCommandBuffer(); |
| 1257 | |
| 1258 | testFence.init(*m_device, fenceInfo); |
| 1259 | |
| 1260 | // Bypass framework since it does the waits automatically |
| 1261 | VkResult err = VK_SUCCESS; |
Courtney Goeltzenleuchter | 1a748e9 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1262 | VkSubmitInfo submit_info; |
Chia-I Wu | 6ec33a0 | 2015-10-26 20:37:06 +0800 | [diff] [blame] | 1263 | submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
| 1264 | submit_info.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1265 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 1a748e9 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1266 | submit_info.pWaitSemaphores = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1267 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1268 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1269 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 1a748e9 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1270 | submit_info.pSignalSemaphores = NULL; |
| 1271 | |
Courtney Goeltzenleuchter | 3ec3162 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 1272 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Tobin Ehlis | 0cea408 | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1273 | ASSERT_VK_SUCCESS( err ); |
| 1274 | |
Tobin Ehlis | 0cea408 | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1275 | // 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] | 1276 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Tobin Ehlis | 0cea408 | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1277 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1278 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1279 | FAIL() << "Did not receive Error 'CB (0xaddress) was created w/ VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT set...'"; |
| 1280 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 0cea408 | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1281 | } |
| 1282 | } |
| 1283 | |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 1284 | TEST_F(VkLayerTest, BindPipelineNoRenderPass) |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1285 | { |
| 1286 | // Initiate Draw w/o a PSO bound |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1287 | VkResult err; |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1288 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1289 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1290 | "Incorrectly binding graphics pipeline "); |
| 1291 | |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1292 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1293 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1294 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1295 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1296 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1297 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1298 | |
| 1299 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1300 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1301 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 1302 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1303 | ds_pool_ci.poolSizeCount = 1; |
| 1304 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1305 | |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 1306 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1307 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1308 | ASSERT_VK_SUCCESS(err); |
| 1309 | |
| 1310 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1311 | dsl_binding.binding = 0; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1312 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 1313 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1314 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1315 | dsl_binding.pImmutableSamplers = NULL; |
| 1316 | |
| 1317 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1318 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1319 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1320 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1321 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1322 | |
| 1323 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1324 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1325 | ASSERT_VK_SUCCESS(err); |
| 1326 | |
| 1327 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1328 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1329 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1330 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1331 | alloc_info.descriptorPool = ds_pool; |
| 1332 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1333 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1334 | ASSERT_VK_SUCCESS(err); |
| 1335 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 1336 | pipe_ms_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 1337 | pipe_ms_state_ci.pNext = NULL; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1338 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1339 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 1340 | pipe_ms_state_ci.minSampleShading = 1.0; |
| 1341 | pipe_ms_state_ci.pSampleMask = NULL; |
| 1342 | |
| 1343 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 1344 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 1345 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1346 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1347 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 1348 | VkPipelineLayout pipeline_layout; |
| 1349 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1350 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1351 | ASSERT_VK_SUCCESS(err); |
| 1352 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 1353 | VkShaderObj vs(m_device, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 1354 | 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] | 1355 | // but add it to be able to run on more devices |
| 1356 | VkPipelineObj pipe(m_device); |
| 1357 | pipe.AddShader(&vs); |
| 1358 | pipe.AddShader(&fs); |
| 1359 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 1360 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1361 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1362 | // Calls AllocateCommandBuffers |
| 1363 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
| 1364 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
| 1365 | memset(&cmd_buf_info, 0, sizeof(VkCommandBufferBeginInfo)); |
| 1366 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1367 | cmd_buf_info.pNext = NULL; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1368 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1369 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1370 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
| 1371 | vkCmdBindPipeline(commandBuffer.GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1372 | |
| 1373 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1374 | FAIL() << "Did not receive Error 'Incorrectly binding graphics pipeline (0x<handle>) without an active RenderPass'"; |
| 1375 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1376 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1377 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1378 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 1379 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1380 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1381 | } |
| 1382 | |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1383 | TEST_F(VkLayerTest, AllocDescriptorFromEmptyPool) |
| 1384 | { |
| 1385 | // Initiate Draw w/o a PSO bound |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1386 | VkResult err; |
| 1387 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1388 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1389 | "Unable to allocate 1 descriptors of type VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER "); |
| 1390 | |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1391 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1392 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1393 | |
| 1394 | // 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] | 1395 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1396 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1397 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1398 | |
| 1399 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1400 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1401 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1402 | ds_pool_ci.flags = 0; |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1403 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1404 | ds_pool_ci.poolSizeCount = 1; |
| 1405 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1406 | |
| 1407 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1408 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1409 | ASSERT_VK_SUCCESS(err); |
| 1410 | |
| 1411 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1412 | dsl_binding.binding = 0; |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1413 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 1414 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1415 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1416 | dsl_binding.pImmutableSamplers = NULL; |
| 1417 | |
| 1418 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1419 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1420 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1421 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1422 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1423 | |
| 1424 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1425 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1426 | ASSERT_VK_SUCCESS(err); |
| 1427 | |
| 1428 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1429 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1430 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1431 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1432 | alloc_info.descriptorPool = ds_pool; |
| 1433 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1434 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1435 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1436 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1437 | FAIL() << "Did not receive Error 'Unable to allocate 1 descriptors of type VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER...'"; |
| 1438 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1439 | } |
| 1440 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1441 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1442 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | c6457d2 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1443 | } |
| 1444 | |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1445 | TEST_F(VkLayerTest, FreeDescriptorFromOneShotPool) |
| 1446 | { |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1447 | VkResult err; |
| 1448 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1449 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1450 | "It is invalid to call vkFreeDescriptorSets() with a pool created without setting VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT."); |
| 1451 | |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1452 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1453 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1454 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1455 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1456 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1457 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1458 | |
| 1459 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1460 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1461 | ds_pool_ci.pNext = NULL; |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1462 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1463 | ds_pool_ci.poolSizeCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1464 | ds_pool_ci.flags = 0; |
| 1465 | // Not specifying VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT means |
| 1466 | // app can only call vkResetDescriptorPool on this pool.; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1467 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1468 | |
| 1469 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1470 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1471 | ASSERT_VK_SUCCESS(err); |
| 1472 | |
| 1473 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1474 | dsl_binding.binding = 0; |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1475 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 1476 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1477 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1478 | dsl_binding.pImmutableSamplers = NULL; |
| 1479 | |
| 1480 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1481 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1482 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1483 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1484 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1485 | |
| 1486 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1487 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1488 | ASSERT_VK_SUCCESS(err); |
| 1489 | |
| 1490 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1491 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1492 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1493 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1494 | alloc_info.descriptorPool = ds_pool; |
| 1495 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1496 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1497 | ASSERT_VK_SUCCESS(err); |
| 1498 | |
| 1499 | err = vkFreeDescriptorSets(m_device->device(), ds_pool, 1, &descriptorSet); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1500 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1501 | FAIL() << "Did not receive Error 'It is invalid to call vkFreeDescriptorSets() with a pool created with...'"; |
| 1502 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1503 | } |
| 1504 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1505 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1506 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 3c54311 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1507 | } |
| 1508 | |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1509 | TEST_F(VkLayerTest, InvalidDescriptorPool) |
| 1510 | { |
| 1511 | // TODO : Simple check for bad object should be added to ObjectTracker to catch this case |
| 1512 | // The DS check for this is after driver has been called to validate DS internal data struct |
| 1513 | // Attempt to clear DS Pool with bad object |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1514 | /* |
| 1515 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1516 | "Unable to find pool node for pool 0xbaad6001 specified in vkResetDescriptorPool() call"); |
| 1517 | |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1518 | VkDescriptorPool badPool = (VkDescriptorPool)0xbaad6001; |
| 1519 | vkResetDescriptorPool(device(), badPool); |
| 1520 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1521 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1522 | FAIL() << "Did not receive Error 'Unable to find pool node for pool 0xbaad6001 specified in vkResetDescriptorPool() call'"; |
| 1523 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1524 | }*/ |
| 1525 | } |
| 1526 | |
| 1527 | TEST_F(VkLayerTest, InvalidDescriptorSet) |
| 1528 | { |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1529 | // TODO : Simple check for bad object should be added to ObjectTracker to catch this case |
| 1530 | // 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] | 1531 | // Create a valid cmd buffer |
| 1532 | // call vkCmdBindDescriptorSets w/ false DS |
| 1533 | } |
| 1534 | |
| 1535 | TEST_F(VkLayerTest, InvalidDescriptorSetLayout) |
| 1536 | { |
| 1537 | // TODO : Simple check for bad object should be added to ObjectTracker to catch this case |
| 1538 | // The DS check for this is after driver has been called to validate DS internal data struct |
| 1539 | } |
| 1540 | |
| 1541 | TEST_F(VkLayerTest, InvalidPipeline) |
| 1542 | { |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1543 | // TODO : Simple check for bad object should be added to ObjectTracker to catch this case |
| 1544 | // The DS check for this is after driver has been called to validate DS internal data struct |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1545 | // Create a valid cmd buffer |
| 1546 | // call vkCmdBindPipeline w/ false Pipeline |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1547 | // |
| 1548 | // m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1549 | // "Attempt to bind Pipeline "); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 1550 | // |
| 1551 | // ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1552 | // VkCommandBufferObj commandBuffer(m_device); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1553 | // BeginCommandBuffer(); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 1554 | // VkPipeline badPipeline = (VkPipeline)0xbaadb1be; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1555 | // vkCmdBindPipeline(commandBuffer.GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, badPipeline); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1556 | // |
| 1557 | // if (!m_errorMonitor->DesiredMsgFound()) { |
| 1558 | // FAIL() << "Did not receive Error 'Attempt to bind Pipeline 0xbaadb1be that doesn't exist!'"; |
| 1559 | // m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 1560 | // } |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1561 | } |
| 1562 | |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1563 | TEST_F(VkLayerTest, DescriptorSetNotUpdated) |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1564 | { |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1565 | // 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] | 1566 | VkResult err; |
| 1567 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1568 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_WARN_BIT, |
| 1569 | " bound but it was never updated. "); |
| 1570 | |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1571 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | d72da75 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 1572 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 1573 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1574 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1575 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1576 | ds_type_count.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1577 | |
| 1578 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1579 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1580 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 1581 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1582 | ds_pool_ci.poolSizeCount = 1; |
| 1583 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mike Stroyan | d72da75 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 1584 | |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1585 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1586 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1587 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1588 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1589 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1590 | dsl_binding.binding = 0; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1591 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 1592 | dsl_binding.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1593 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1594 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1595 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1596 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1597 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1598 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1599 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1600 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1601 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1602 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1603 | ASSERT_VK_SUCCESS(err); |
| 1604 | |
| 1605 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1606 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1607 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1608 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1609 | alloc_info.descriptorPool = ds_pool; |
| 1610 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1611 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1612 | ASSERT_VK_SUCCESS(err); |
| 1613 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1614 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 1615 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 1616 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1617 | pipeline_layout_ci.setLayoutCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1618 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1619 | |
| 1620 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1621 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1622 | ASSERT_VK_SUCCESS(err); |
| 1623 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 1624 | VkShaderObj vs(m_device, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1625 | // TODO - We shouldn't need a fragment shader but add it to be able to run on more devices |
| 1626 | VkShaderObj fs(m_device, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1627 | |
Tony Barbour | 4e8d1b1 | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 1628 | VkPipelineObj pipe(m_device); |
| 1629 | pipe.AddShader(&vs); |
Tony Barbour | 3c9e3b1 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 1630 | pipe.AddShader(&fs); |
Tony Barbour | 4e8d1b1 | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 1631 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1632 | |
| 1633 | BeginCommandBuffer(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1634 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
| 1635 | 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] | 1636 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1637 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1638 | FAIL() << "Did not recieve Warning 'DS <blah> bound but it was never updated. You may want to either update it or not bind it.'"; |
| 1639 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1640 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1641 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1642 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 1643 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1644 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1645 | } |
| 1646 | |
Tobin Ehlis | 093ef92 | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1647 | TEST_F(VkLayerTest, InvalidBufferViewObject) |
| 1648 | { |
| 1649 | // Create a single TEXEL_BUFFER descriptor and send it an invalid bufferView |
| 1650 | VkResult err; |
| 1651 | |
| 1652 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1653 | "Attempt to update descriptor with invalid bufferView "); |
| 1654 | |
| 1655 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1656 | VkDescriptorPoolSize ds_type_count = {}; |
| 1657 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 1658 | ds_type_count.descriptorCount = 1; |
| 1659 | |
| 1660 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1661 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1662 | ds_pool_ci.pNext = NULL; |
| 1663 | ds_pool_ci.maxSets = 1; |
| 1664 | ds_pool_ci.poolSizeCount = 1; |
| 1665 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 1666 | |
| 1667 | VkDescriptorPool ds_pool; |
| 1668 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 1669 | ASSERT_VK_SUCCESS(err); |
| 1670 | |
| 1671 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 1672 | dsl_binding.binding = 0; |
| 1673 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 1674 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | 093ef92 | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1675 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1676 | dsl_binding.pImmutableSamplers = NULL; |
| 1677 | |
| 1678 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1679 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1680 | ds_layout_ci.pNext = NULL; |
| 1681 | ds_layout_ci.bindingCount = 1; |
| 1682 | ds_layout_ci.pBinding = &dsl_binding; |
| 1683 | VkDescriptorSetLayout ds_layout; |
| 1684 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
| 1685 | ASSERT_VK_SUCCESS(err); |
| 1686 | |
| 1687 | VkDescriptorSet descriptorSet; |
| 1688 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 1689 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
| 1690 | alloc_info.setLayoutCount = 1; |
| 1691 | alloc_info.descriptorPool = ds_pool; |
| 1692 | alloc_info.pSetLayouts = &ds_layout; |
| 1693 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
| 1694 | ASSERT_VK_SUCCESS(err); |
| 1695 | |
| 1696 | VkBufferView view = (VkBufferView) 0xbaadbeef; // invalid bufferView object |
Tobin Ehlis | 093ef92 | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1697 | VkWriteDescriptorSet descriptor_write; |
| 1698 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 1699 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 1700 | descriptor_write.dstSet = descriptorSet; |
| 1701 | descriptor_write.dstBinding = 0; |
| 1702 | descriptor_write.descriptorCount = 1; |
| 1703 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 1704 | descriptor_write.pTexelBufferView = &view; |
| 1705 | |
| 1706 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 1707 | |
| 1708 | if (!m_errorMonitor->DesiredMsgFound()) { |
Tobin Ehlis | d949145 | 2015-11-05 10:27:49 -0700 | [diff] [blame] | 1709 | FAIL() << "Did not receive Error 'Attempt to update descriptor with invalid bufferView'"; |
Tobin Ehlis | 093ef92 | 2015-11-02 15:24:32 -0700 | [diff] [blame] | 1710 | m_errorMonitor->DumpFailureMsgs(); |
| 1711 | } |
| 1712 | |
| 1713 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1714 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 1715 | } |
| 1716 | |
Tobin Ehlis | e219486 | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1717 | TEST_F(VkLayerTest, InvalidDynamicOffsetCount) |
| 1718 | { |
| 1719 | // Create a descriptorSet w/ some dynamic descriptors and then don't send offsets when binding |
| 1720 | VkResult err; |
| 1721 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1722 | "Attempting to bind 1 descriptorSets with 1 dynamic descriptors, but dynamicOffsetCount is 0. "); |
| 1723 | |
| 1724 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1725 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 1726 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 1727 | |
| 1728 | VkDescriptorPoolSize ds_type_count = {}; |
| 1729 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 1730 | ds_type_count.descriptorCount = 1; |
| 1731 | |
| 1732 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1733 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1734 | ds_pool_ci.pNext = NULL; |
| 1735 | ds_pool_ci.maxSets = 1; |
| 1736 | ds_pool_ci.poolSizeCount = 1; |
| 1737 | ds_pool_ci.pPoolSizes = &ds_type_count; |
| 1738 | |
| 1739 | VkDescriptorPool ds_pool; |
| 1740 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
| 1741 | ASSERT_VK_SUCCESS(err); |
| 1742 | |
| 1743 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
| 1744 | dsl_binding.binding = 0; |
| 1745 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
Jon Ashburn | 96b714a | 2015-11-06 15:31:44 -0700 | [diff] [blame^] | 1746 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | e219486 | 2015-11-04 13:30:34 -0700 | [diff] [blame] | 1747 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1748 | dsl_binding.pImmutableSamplers = NULL; |
| 1749 | |
| 1750 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1751 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1752 | ds_layout_ci.pNext = NULL; |
| 1753 | ds_layout_ci.bindingCount = 1; |
| 1754 | ds_layout_ci.pBinding = &dsl_binding; |
| 1755 | VkDescriptorSetLayout ds_layout; |
| 1756 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
| 1757 | ASSERT_VK_SUCCESS(err); |
| 1758 | |
| 1759 | VkDescriptorSet descriptorSet; |
| 1760 | VkDescriptorSetAllocateInfo alloc_info = {}; |
| 1761 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
| 1762 | alloc_info.setLayoutCount = 1; |
| 1763 | alloc_info.descriptorPool = ds_pool; |
| 1764 | alloc_info.pSetLayouts = &ds_layout; |
| 1765 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
| 1766 | ASSERT_VK_SUCCESS(err); |
| 1767 | |
| 1768 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 1769 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 1770 | pipeline_layout_ci.pNext = NULL; |
| 1771 | pipeline_layout_ci.setLayoutCount = 1; |
| 1772 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 1773 | |
| 1774 | VkPipelineLayout pipeline_layout; |
| 1775 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
| 1776 | ASSERT_VK_SUCCESS(err); |
| 1777 | |
| 1778 | // Create a buffer to update the descriptor with |
| 1779 | uint32_t qfi = 0; |
| 1780 | VkBufferCreateInfo buffCI = {}; |
| 1781 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 1782 | buffCI.size = 1024; |
| 1783 | buffCI.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; |
| 1784 | buffCI.queueFamilyIndexCount = 1; |
| 1785 | buffCI.pQueueFamilyIndices = &qfi; |
| 1786 | |
| 1787 | VkBuffer dyub; |
| 1788 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &dyub); |
| 1789 | ASSERT_VK_SUCCESS(err); |
| 1790 | // Correctly update descriptor to avoid "NOT_UPDATED" error |
| 1791 | VkDescriptorBufferInfo buffInfo = {}; |
| 1792 | buffInfo.buffer = dyub; |
| 1793 | buffInfo.offset = 0; |
| 1794 | buffInfo.range = 1024; |
| 1795 | |
| 1796 | VkWriteDescriptorSet descriptor_write; |
| 1797 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 1798 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 1799 | descriptor_write.dstSet = descriptorSet; |
| 1800 | descriptor_write.dstBinding = 0; |
| 1801 | descriptor_write.descriptorCount = 1; |
| 1802 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; |
| 1803 | descriptor_write.pBufferInfo = &buffInfo; |
| 1804 | |
| 1805 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 1806 | |
| 1807 | BeginCommandBuffer(); |
| 1808 | vkCmdBindDescriptorSets(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout, 0, 1, &descriptorSet, 0, NULL); |
| 1809 | |
| 1810 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1811 | FAIL() << "Error received was not 'Attempting to bind 1 descriptorSets with 1 dynamic descriptors, but dynamicOffsetCount is 0...'"; |
| 1812 | m_errorMonitor->DumpFailureMsgs(); |
| 1813 | } |
| 1814 | |
| 1815 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 1816 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 1817 | } |
| 1818 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1819 | TEST_F(VkLayerTest, NoBeginCommandBuffer) |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1820 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1821 | |
| 1822 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1823 | "You must call vkBeginCommandBuffer() before this call to "); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1824 | |
| 1825 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1826 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1827 | // Call EndCommandBuffer() w/o calling BeginCommandBuffer() |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1828 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1829 | |
| 1830 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1831 | FAIL() << "Did not recieve Error 'You must call vkBeginCommandBuffer() before this call to vkEndCommandBuffer()'"; |
| 1832 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1833 | } |
| 1834 | } |
| 1835 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1836 | TEST_F(VkLayerTest, PrimaryCommandBufferFramebufferAndRenderpass) |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1837 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1838 | |
| 1839 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1840 | "may not specify framebuffer or renderpass parameters"); |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1841 | |
| 1842 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1843 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1844 | // Calls AllocateCommandBuffers |
| 1845 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1846 | |
| 1847 | // 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] | 1848 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
| 1849 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Cody Northrop | 10d8f98 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 1850 | cmd_buf_info.pNext = NULL; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1851 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
Cody Northrop | 10d8f98 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 1852 | cmd_buf_info.renderPass = (VkRenderPass)0xcadecade; |
| 1853 | cmd_buf_info.framebuffer = (VkFramebuffer)0xcadecade; |
| 1854 | |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1855 | |
| 1856 | // The error should be caught by validation of the BeginCommandBuffer call |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1857 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1858 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1859 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1860 | FAIL() << "Did not receive Error 'vkAllocateCommandBuffers(): Primary Command Buffer may not specify framebuffer or renderpass parameters'"; |
| 1861 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1862 | } |
| 1863 | } |
| 1864 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1865 | TEST_F(VkLayerTest, SecondaryCommandBufferFramebufferAndRenderpass) |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1866 | { |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1867 | VkResult err; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1868 | VkCommandBuffer draw_cmd; |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1869 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1870 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1871 | "must specify framebuffer and renderpass parameters"); |
| 1872 | |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1873 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1874 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1875 | VkCommandBufferAllocateInfo cmd = {}; |
| 1876 | cmd.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOC_INFO; |
Cody Northrop | 10d8f98 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 1877 | cmd.pNext = NULL; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1878 | cmd.commandPool = m_commandPool; |
| 1879 | cmd.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1880 | cmd.bufferCount = 1; |
Cody Northrop | 10d8f98 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 1881 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1882 | err = vkAllocateCommandBuffers(m_device->device(), &cmd, &draw_cmd); |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1883 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1884 | |
| 1885 | // Force the failure by not setting the Renderpass and Framebuffer fields |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1886 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
| 1887 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Cody Northrop | 10d8f98 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 1888 | cmd_buf_info.pNext = NULL; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1889 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1890 | |
| 1891 | // The error should be caught by validation of the BeginCommandBuffer call |
| 1892 | vkBeginCommandBuffer(draw_cmd, &cmd_buf_info); |
| 1893 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1894 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1895 | FAIL() << "Did not receive Error 'vkAllocateCommandBuffers(): Secondary Command Buffer must specify framebuffer and renderpass parameters'"; |
| 1896 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1897 | } |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1898 | vkFreeCommandBuffers(m_device->device(), m_commandPool, 1, &draw_cmd); |
Mark Lobodzinski | 90bf5b0 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1899 | } |
| 1900 | |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1901 | TEST_F(VkLayerTest, InvalidPipelineCreateState) |
| 1902 | { |
| 1903 | // Attempt to Create Gfx Pipeline w/o a VS |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1904 | VkResult err; |
| 1905 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1906 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1907 | "Invalid Pipeline CreateInfo State: Vtx Shader required"); |
| 1908 | |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1909 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1910 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 1911 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1912 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1913 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1914 | ds_type_count.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1915 | |
| 1916 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1917 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1918 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 1919 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1920 | ds_pool_ci.poolSizeCount = 1; |
| 1921 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 1922 | |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1923 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1924 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1925 | ASSERT_VK_SUCCESS(err); |
| 1926 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1927 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1928 | dsl_binding.binding = 0; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1929 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 1930 | dsl_binding.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1931 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1932 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1933 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1934 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1935 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1936 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1937 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1938 | ds_layout_ci.pBinding = &dsl_binding; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1939 | |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1940 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1941 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1942 | ASSERT_VK_SUCCESS(err); |
| 1943 | |
| 1944 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1945 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1946 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1947 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1948 | alloc_info.descriptorPool = ds_pool; |
| 1949 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1950 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1951 | ASSERT_VK_SUCCESS(err); |
| 1952 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1953 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 1954 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1955 | pipeline_layout_ci.setLayoutCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1956 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1957 | |
| 1958 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1959 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1960 | ASSERT_VK_SUCCESS(err); |
| 1961 | |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 1962 | VkViewport vp = {}; // Just need dummy vp to point to |
| 1963 | VkRect2D sc = {}; // dummy scissor to point to |
| 1964 | |
| 1965 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 1966 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 1967 | vp_state_ci.scissorCount = 1; |
| 1968 | vp_state_ci.pScissors = ≻ |
| 1969 | vp_state_ci.viewportCount = 1; |
| 1970 | vp_state_ci.pViewports = &vp; |
| 1971 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1972 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 1973 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 1974 | gp_ci.pViewportState = &vp_state_ci; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1975 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 1976 | gp_ci.layout = pipeline_layout; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1977 | gp_ci.renderPass = renderPass(); |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1978 | |
| 1979 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 1980 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Chia-I Wu | 7e47070 | 2015-10-26 17:24:52 +0800 | [diff] [blame] | 1981 | pc_ci.initialDataSize = 0; |
| 1982 | pc_ci.pInitialData = 0; |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1983 | |
| 1984 | VkPipeline pipeline; |
Jon Ashburn | 0d60d27 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 1985 | VkPipelineCache pipelineCache; |
| 1986 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1987 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Jon Ashburn | 0d60d27 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 1988 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1989 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1990 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1991 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1992 | FAIL() << "Did not receive Error 'Invalid Pipeline CreateInfo State: Vtx Shader required'"; |
| 1993 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1994 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1995 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1996 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 1997 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 1998 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1999 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2000 | } |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2001 | /*// TODO : This test should be good, but needs Tess support in compiler to run |
| 2002 | TEST_F(VkLayerTest, InvalidPatchControlPoints) |
| 2003 | { |
| 2004 | // Attempt to Create Gfx Pipeline w/o a VS |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2005 | VkResult err; |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2006 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2007 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2008 | "Invalid Pipeline CreateInfo State: VK_PRIMITIVE_TOPOLOGY_PATCH primitive "); |
| 2009 | |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2010 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2011 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2012 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2013 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2014 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2015 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2016 | |
| 2017 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2018 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2019 | ds_pool_ci.pNext = NULL; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2020 | ds_pool_ci.poolSizeCount = 1; |
| 2021 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2022 | |
| 2023 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2024 | 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] | 2025 | ASSERT_VK_SUCCESS(err); |
| 2026 | |
| 2027 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2028 | dsl_binding.binding = 0; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2029 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 2030 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2031 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2032 | dsl_binding.pImmutableSamplers = NULL; |
| 2033 | |
| 2034 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2035 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2036 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2037 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2038 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2039 | |
| 2040 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2041 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2042 | ASSERT_VK_SUCCESS(err); |
| 2043 | |
| 2044 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2045 | 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] | 2046 | ASSERT_VK_SUCCESS(err); |
| 2047 | |
| 2048 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 2049 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 2050 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2051 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2052 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 2053 | |
| 2054 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2055 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2056 | ASSERT_VK_SUCCESS(err); |
| 2057 | |
| 2058 | VkPipelineShaderStageCreateInfo shaderStages[3]; |
| 2059 | memset(&shaderStages, 0, 3 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 2060 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2061 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, this); |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2062 | // 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] | 2063 | VkShaderObj tc(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 2064 | VkShaderObj te(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2065 | |
| 2066 | shaderStages[0].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2067 | shaderStages[0].stage = VK_SHADER_STAGE_VERTEX_BIT; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2068 | shaderStages[0].shader = vs.handle(); |
| 2069 | shaderStages[1].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2070 | shaderStages[1].stage = VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2071 | shaderStages[1].shader = tc.handle(); |
| 2072 | shaderStages[2].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2073 | shaderStages[2].stage = VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2074 | shaderStages[2].shader = te.handle(); |
| 2075 | |
| 2076 | VkPipelineInputAssemblyStateCreateInfo iaCI = {}; |
| 2077 | iaCI.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
Chia-I Wu | 99ba2bb | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2078 | iaCI.topology = VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2079 | |
| 2080 | VkPipelineTessellationStateCreateInfo tsCI = {}; |
| 2081 | tsCI.sType = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO; |
| 2082 | tsCI.patchControlPoints = 0; // This will cause an error |
| 2083 | |
| 2084 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 2085 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 2086 | gp_ci.pNext = NULL; |
| 2087 | gp_ci.stageCount = 3; |
| 2088 | gp_ci.pStages = shaderStages; |
| 2089 | gp_ci.pVertexInputState = NULL; |
| 2090 | gp_ci.pInputAssemblyState = &iaCI; |
| 2091 | gp_ci.pTessellationState = &tsCI; |
| 2092 | gp_ci.pViewportState = NULL; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2093 | gp_ci.pRasterizationState = NULL; |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2094 | gp_ci.pMultisampleState = NULL; |
| 2095 | gp_ci.pDepthStencilState = NULL; |
| 2096 | gp_ci.pColorBlendState = NULL; |
| 2097 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2098 | gp_ci.layout = pipeline_layout; |
| 2099 | gp_ci.renderPass = renderPass(); |
| 2100 | |
| 2101 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 2102 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 2103 | pc_ci.pNext = NULL; |
| 2104 | pc_ci.initialSize = 0; |
| 2105 | pc_ci.initialData = 0; |
| 2106 | pc_ci.maxSize = 0; |
| 2107 | |
| 2108 | VkPipeline pipeline; |
| 2109 | VkPipelineCache pipelineCache; |
| 2110 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2111 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2112 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2113 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2114 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2115 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2116 | FAIL() << "Did not receive Error 'Invalid Pipeline CreateInfo State: VK_PRIMITIVE_TOPOLOGY_PATCH primitive...'"; |
| 2117 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2118 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2119 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2120 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2121 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2122 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2123 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 2069317 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2124 | } |
| 2125 | */ |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2126 | // Set scissor and viewport counts to different numbers |
| 2127 | TEST_F(VkLayerTest, PSOViewportScissorCountMismatch) |
| 2128 | { |
| 2129 | // Attempt to Create Gfx Pipeline w/o a VS |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2130 | VkResult err; |
| 2131 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2132 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2133 | "Gfx Pipeline viewport count (1) must match scissor count (0)."); |
| 2134 | |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2135 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2136 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2137 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2138 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2139 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2140 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2141 | |
| 2142 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2143 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2144 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2145 | ds_pool_ci.poolSizeCount = 1; |
| 2146 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2147 | |
| 2148 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2149 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2150 | ASSERT_VK_SUCCESS(err); |
| 2151 | |
| 2152 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2153 | dsl_binding.binding = 0; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2154 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 2155 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2156 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2157 | |
| 2158 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2159 | 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] | 2160 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2161 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2162 | |
| 2163 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2164 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2165 | ASSERT_VK_SUCCESS(err); |
| 2166 | |
| 2167 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2168 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2169 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2170 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2171 | alloc_info.descriptorPool = ds_pool; |
| 2172 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2173 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2174 | ASSERT_VK_SUCCESS(err); |
| 2175 | |
| 2176 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 2177 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2178 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2179 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 2180 | |
| 2181 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2182 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2183 | ASSERT_VK_SUCCESS(err); |
| 2184 | |
| 2185 | VkViewport vp = {}; // Just need dummy vp to point to |
| 2186 | |
| 2187 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 2188 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 2189 | vp_state_ci.scissorCount = 0; |
| 2190 | vp_state_ci.viewportCount = 1; // Count mismatch should cause error |
| 2191 | vp_state_ci.pViewports = &vp; |
| 2192 | |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2193 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 2194 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2195 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2196 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, this); |
| 2197 | 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] | 2198 | // but add it to be able to run on more devices |
Chia-I Wu | 062ad15 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2199 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 2200 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2201 | |
| 2202 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 2203 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2204 | gp_ci.stageCount = 2; |
| 2205 | gp_ci.pStages = shaderStages; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2206 | gp_ci.pViewportState = &vp_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 viewport count (1) must match scissor count (0).'"; |
| 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 | } |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2231 | // Don't set viewport state in PSO. This is an error b/c we always need this state |
| 2232 | // for the counts even if the data is going to be set dynamically. |
| 2233 | TEST_F(VkLayerTest, PSOViewportStateNotSet) |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2234 | { |
| 2235 | // Attempt to Create Gfx Pipeline w/o a VS |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2236 | VkResult err; |
| 2237 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2238 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2239 | "Gfx Pipeline pViewportState is null. Even if "); |
| 2240 | |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2241 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2242 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2243 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2244 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2245 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2246 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2247 | |
| 2248 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2249 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2250 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2251 | ds_pool_ci.poolSizeCount = 1; |
| 2252 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2253 | |
| 2254 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2255 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2256 | ASSERT_VK_SUCCESS(err); |
| 2257 | |
| 2258 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2259 | dsl_binding.binding = 0; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2260 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 2261 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2262 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2263 | |
| 2264 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2265 | 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] | 2266 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2267 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2268 | |
| 2269 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2270 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2271 | ASSERT_VK_SUCCESS(err); |
| 2272 | |
| 2273 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2274 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2275 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2276 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2277 | alloc_info.descriptorPool = ds_pool; |
| 2278 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2279 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2280 | ASSERT_VK_SUCCESS(err); |
| 2281 | |
| 2282 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 2283 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2284 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2285 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 2286 | |
| 2287 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2288 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2289 | ASSERT_VK_SUCCESS(err); |
| 2290 | |
| 2291 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 2292 | // Set scissor as dynamic to avoid second error |
| 2293 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 2294 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 2295 | dyn_state_ci.dynamicStateCount = 1; |
| 2296 | dyn_state_ci.pDynamicStates = &sc_state; |
| 2297 | |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2298 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 2299 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2300 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2301 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, this); |
| 2302 | 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] | 2303 | // but add it to be able to run on more devices |
Chia-I Wu | 062ad15 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2304 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 2305 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2306 | |
| 2307 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 2308 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2309 | gp_ci.stageCount = 2; |
| 2310 | gp_ci.pStages = shaderStages; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2311 | gp_ci.pViewportState = NULL; // Not setting VP state w/o dynamic vp state should cause validation error |
| 2312 | gp_ci.pDynamicState = &dyn_state_ci; |
| 2313 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2314 | gp_ci.layout = pipeline_layout; |
| 2315 | gp_ci.renderPass = renderPass(); |
| 2316 | |
| 2317 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 2318 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 2319 | |
| 2320 | VkPipeline pipeline; |
| 2321 | VkPipelineCache pipelineCache; |
| 2322 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2323 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2324 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2325 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2326 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2327 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2328 | FAIL() << "Did not receive Error 'Gfx Pipeline pViewportState is null. Even if...'"; |
| 2329 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2330 | } |
| 2331 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2332 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2333 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2334 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2335 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2336 | } |
| 2337 | // Create PSO w/o non-zero viewportCount but no viewport data |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2338 | // Then run second test where dynamic scissor count doesn't match PSO scissor count |
| 2339 | TEST_F(VkLayerTest, PSOViewportCountWithoutDataAndDynScissorMismatch) |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2340 | { |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2341 | VkResult err; |
| 2342 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2343 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2344 | "Gfx Pipeline viewportCount is 1, but pViewports is NULL. "); |
| 2345 | |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2346 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2347 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2348 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2349 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2350 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2351 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2352 | |
| 2353 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2354 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2355 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2356 | ds_pool_ci.poolSizeCount = 1; |
| 2357 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2358 | |
| 2359 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2360 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2361 | ASSERT_VK_SUCCESS(err); |
| 2362 | |
| 2363 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2364 | dsl_binding.binding = 0; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2365 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 2366 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2367 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2368 | |
| 2369 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2370 | 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] | 2371 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2372 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2373 | |
| 2374 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2375 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2376 | ASSERT_VK_SUCCESS(err); |
| 2377 | |
| 2378 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2379 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2380 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2381 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2382 | alloc_info.descriptorPool = ds_pool; |
| 2383 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2384 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2385 | ASSERT_VK_SUCCESS(err); |
| 2386 | |
| 2387 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 2388 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2389 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2390 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 2391 | |
| 2392 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2393 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2394 | ASSERT_VK_SUCCESS(err); |
| 2395 | |
| 2396 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 2397 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 2398 | vp_state_ci.viewportCount = 1; |
| 2399 | vp_state_ci.pViewports = NULL; // Null vp w/ count of 1 should cause error |
| 2400 | vp_state_ci.scissorCount = 1; |
| 2401 | vp_state_ci.pScissors = NULL; // Scissor is dynamic (below) so this won't cause error |
| 2402 | |
| 2403 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 2404 | // Set scissor as dynamic to avoid that error |
| 2405 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 2406 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 2407 | dyn_state_ci.dynamicStateCount = 1; |
| 2408 | dyn_state_ci.pDynamicStates = &sc_state; |
| 2409 | |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2410 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 2411 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2412 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2413 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, this); |
| 2414 | 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] | 2415 | // but add it to be able to run on more devices |
Chia-I Wu | 062ad15 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2416 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 2417 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2418 | |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2419 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 2420 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 2421 | vi_ci.pNext = nullptr; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2422 | vi_ci.vertexBindingDescriptionCount = 0; |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2423 | vi_ci.pVertexBindingDescriptions = nullptr; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2424 | vi_ci.vertexAttributeDescriptionCount = 0; |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2425 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 2426 | |
| 2427 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 2428 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 2429 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 2430 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2431 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2432 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2433 | rs_ci.pNext = nullptr; |
| 2434 | |
| 2435 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 2436 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 2437 | cb_ci.pNext = nullptr; |
| 2438 | |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2439 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 2440 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2441 | gp_ci.stageCount = 2; |
| 2442 | gp_ci.pStages = shaderStages; |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2443 | gp_ci.pVertexInputState = &vi_ci; |
| 2444 | gp_ci.pInputAssemblyState = &ia_ci; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2445 | gp_ci.pViewportState = &vp_state_ci; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2446 | gp_ci.pRasterizationState = &rs_ci; |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2447 | gp_ci.pColorBlendState = &cb_ci; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2448 | gp_ci.pDynamicState = &dyn_state_ci; |
| 2449 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2450 | gp_ci.layout = pipeline_layout; |
| 2451 | gp_ci.renderPass = renderPass(); |
| 2452 | |
| 2453 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 2454 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 2455 | |
| 2456 | VkPipeline pipeline; |
| 2457 | VkPipelineCache pipelineCache; |
| 2458 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2459 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2460 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2461 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2462 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2463 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2464 | FAIL() << "Did not recieve Error 'Gfx Pipeline viewportCount is 1, but pViewports is NULL...'"; |
| 2465 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2466 | } |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2467 | |
| 2468 | |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2469 | // Now hit second fail case where we set scissor w/ different count than PSO |
| 2470 | // First need to successfully create the PSO from above by setting pViewports |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2471 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2472 | "Dynamic scissorCount from vkCmdSetScissor() is 2, but PSO scissorCount is 1. These counts must match."); |
| 2473 | |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2474 | VkViewport vp = {}; // Just need dummy vp to point to |
| 2475 | vp_state_ci.pViewports = &vp; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2476 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2477 | ASSERT_VK_SUCCESS(err); |
| 2478 | BeginCommandBuffer(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2479 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2480 | VkRect2D scissors[2] = {}; // don't care about data |
| 2481 | // Count of 2 doesn't match PSO count of 1 |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2482 | vkCmdSetScissor(m_commandBuffer->GetBufferHandle(), 2, scissors); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2483 | Draw(1, 0, 0, 0); |
| 2484 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2485 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2486 | FAIL() << "Did not receive Error 'Dynamic scissorCount from vkCmdSetScissor() is 2, but PSO scissorCount is 1...'"; |
| 2487 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2488 | } |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2489 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2490 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2491 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2492 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2493 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2494 | } |
| 2495 | // Create PSO w/o non-zero scissorCount but no scissor data |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2496 | // Then run second test where dynamic viewportCount doesn't match PSO viewportCount |
| 2497 | TEST_F(VkLayerTest, PSOScissorCountWithoutDataAndDynViewportMismatch) |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2498 | { |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2499 | VkResult err; |
| 2500 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2501 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2502 | "Gfx Pipeline scissorCount is 1, but pScissors is NULL. "); |
| 2503 | |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2504 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2505 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2506 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2507 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2508 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2509 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2510 | |
| 2511 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2512 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2513 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2514 | ds_pool_ci.poolSizeCount = 1; |
| 2515 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2516 | |
| 2517 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2518 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2519 | ASSERT_VK_SUCCESS(err); |
| 2520 | |
| 2521 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2522 | dsl_binding.binding = 0; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2523 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 2524 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2525 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2526 | |
| 2527 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2528 | 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] | 2529 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2530 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2531 | |
| 2532 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2533 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2534 | ASSERT_VK_SUCCESS(err); |
| 2535 | |
| 2536 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2537 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2538 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2539 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2540 | alloc_info.descriptorPool = ds_pool; |
| 2541 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2542 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2543 | ASSERT_VK_SUCCESS(err); |
| 2544 | |
| 2545 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 2546 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2547 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2548 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 2549 | |
| 2550 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2551 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2552 | ASSERT_VK_SUCCESS(err); |
| 2553 | |
| 2554 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 2555 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 2556 | vp_state_ci.scissorCount = 1; |
| 2557 | vp_state_ci.pScissors = NULL; // Null scissor w/ count of 1 should cause error |
| 2558 | vp_state_ci.viewportCount = 1; |
| 2559 | vp_state_ci.pViewports = NULL; // vp is dynamic (below) so this won't cause error |
| 2560 | |
| 2561 | VkDynamicState vp_state = VK_DYNAMIC_STATE_VIEWPORT; |
| 2562 | // Set scissor as dynamic to avoid that error |
| 2563 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 2564 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 2565 | dyn_state_ci.dynamicStateCount = 1; |
| 2566 | dyn_state_ci.pDynamicStates = &vp_state; |
| 2567 | |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2568 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 2569 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2570 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2571 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, this); |
| 2572 | 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] | 2573 | // but add it to be able to run on more devices |
Chia-I Wu | 062ad15 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2574 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 2575 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2576 | |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2577 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 2578 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 2579 | vi_ci.pNext = nullptr; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2580 | vi_ci.vertexBindingDescriptionCount = 0; |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2581 | vi_ci.pVertexBindingDescriptions = nullptr; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2582 | vi_ci.vertexAttributeDescriptionCount = 0; |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2583 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 2584 | |
| 2585 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 2586 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 2587 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 2588 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2589 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2590 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2591 | rs_ci.pNext = nullptr; |
| 2592 | |
| 2593 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 2594 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 2595 | cb_ci.pNext = nullptr; |
| 2596 | |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2597 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 2598 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
Cody Northrop | 1a0f3e6 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2599 | gp_ci.stageCount = 2; |
| 2600 | gp_ci.pStages = shaderStages; |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2601 | gp_ci.pVertexInputState = &vi_ci; |
| 2602 | gp_ci.pInputAssemblyState = &ia_ci; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2603 | gp_ci.pViewportState = &vp_state_ci; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2604 | gp_ci.pRasterizationState = &rs_ci; |
Cody Northrop | 42cbe3b | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2605 | gp_ci.pColorBlendState = &cb_ci; |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2606 | gp_ci.pDynamicState = &dyn_state_ci; |
| 2607 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2608 | gp_ci.layout = pipeline_layout; |
| 2609 | gp_ci.renderPass = renderPass(); |
| 2610 | |
| 2611 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 2612 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 2613 | |
| 2614 | VkPipeline pipeline; |
| 2615 | VkPipelineCache pipelineCache; |
| 2616 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2617 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2618 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2619 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2620 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2621 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2622 | FAIL() << "Did not recieve Error 'Gfx Pipeline scissorCount is 1, but pScissors is NULL...'"; |
| 2623 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2624 | } |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2625 | |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2626 | // Now hit second fail case where we set scissor w/ different count than PSO |
| 2627 | // First need to successfully create the PSO from above by setting pViewports |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2628 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2629 | "Dynamic viewportCount from vkCmdSetViewport() is 2, but PSO viewportCount is 1. These counts must match."); |
| 2630 | |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2631 | VkRect2D sc = {}; // Just need dummy vp to point to |
| 2632 | vp_state_ci.pScissors = ≻ |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2633 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2634 | ASSERT_VK_SUCCESS(err); |
| 2635 | BeginCommandBuffer(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2636 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2637 | VkViewport viewports[2] = {}; // don't care about data |
| 2638 | // Count of 2 doesn't match PSO count of 1 |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2639 | vkCmdSetViewport(m_commandBuffer->GetBufferHandle(), 2, viewports); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2640 | Draw(1, 0, 0, 0); |
| 2641 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2642 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2643 | FAIL() << "Did not receive Error 'Dynamic viewportCount from vkCmdSetViewport() is 2, but PSO viewportCount is 1...'"; |
| 2644 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2645 | } |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2646 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2647 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2648 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2649 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2650 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 9e839e5 | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2651 | } |
| 2652 | |
Tobin Ehlis | b8b06b5 | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 2653 | TEST_F(VkLayerTest, NullRenderPass) |
| 2654 | { |
| 2655 | // Bind a NULL RenderPass |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2656 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2657 | "You cannot use a NULL RenderPass object in vkCmdBeginRenderPass()"); |
Tobin Ehlis | b8b06b5 | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 2658 | |
| 2659 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2660 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | b8b06b5 | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 2661 | |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 2662 | BeginCommandBuffer(); |
Tobin Ehlis | b8b06b5 | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 2663 | // 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] | 2664 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), NULL, VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | b8b06b5 | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 2665 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2666 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2667 | FAIL() << "Did not receive Error 'You cannot use a NULL RenderPass object in vkCmdBeginRenderPass()'"; |
| 2668 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | b8b06b5 | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 2669 | } |
| 2670 | } |
| 2671 | |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2672 | TEST_F(VkLayerTest, RenderPassWithinRenderPass) |
| 2673 | { |
| 2674 | // Bind a BeginRenderPass within an active RenderPass |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2675 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2676 | "It is invalid to issue this call inside an active render pass"); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2677 | |
| 2678 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2679 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2680 | |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 2681 | BeginCommandBuffer(); |
Tobin Ehlis | b8b06b5 | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 2682 | // 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] | 2683 | VkRenderPassBeginInfo rp_begin = {}; |
| 2684 | rp_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; |
| 2685 | rp_begin.pNext = NULL; |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2686 | rp_begin.renderPass = renderPass(); |
| 2687 | rp_begin.framebuffer = framebuffer(); |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 2688 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2689 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &rp_begin, VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | 254eca0 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 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(); |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 2694 | } |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2695 | } |
| 2696 | |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2697 | TEST_F(VkLayerTest, FillBufferWithinRenderPass) |
| 2698 | { |
| 2699 | // Call CmdFillBuffer 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 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2710 | vk_testing::Buffer dstBuffer; |
| 2711 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2712 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2713 | m_commandBuffer->FillBuffer(dstBuffer.handle(), 0, 4, 0x11111111); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2714 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2715 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2716 | FAIL() << "Did not receive Error 'It is invalid to issue this call inside an active render pass...'"; |
| 2717 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2718 | } |
| 2719 | } |
| 2720 | |
| 2721 | TEST_F(VkLayerTest, UpdateBufferWithinRenderPass) |
| 2722 | { |
| 2723 | // Call CmdUpdateBuffer within an active renderpass |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2724 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2725 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2726 | |
| 2727 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2728 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2729 | |
| 2730 | // Renderpass is started here |
| 2731 | BeginCommandBuffer(); |
| 2732 | |
| 2733 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2734 | vk_testing::Buffer dstBuffer; |
| 2735 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2736 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2737 | VkDeviceSize dstOffset = 0; |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2738 | VkDeviceSize dataSize = 1024; |
| 2739 | const uint32_t *pData = NULL; |
| 2740 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2741 | vkCmdUpdateBuffer(m_commandBuffer->GetBufferHandle(), dstBuffer.handle(), dstOffset, dataSize, pData); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2742 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2743 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2744 | FAIL() << "Did not receive Error 'It is invalid to issue this call inside an active render pass...'"; |
| 2745 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2746 | } |
| 2747 | } |
| 2748 | |
| 2749 | TEST_F(VkLayerTest, ClearColorImageWithinRenderPass) |
| 2750 | { |
| 2751 | // Call CmdClearColorImage within an active RenderPass |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2752 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2753 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2754 | |
| 2755 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2756 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2757 | |
| 2758 | // Renderpass is started here |
| 2759 | BeginCommandBuffer(); |
| 2760 | |
| 2761 | VkClearColorValue clear_color = {0}; |
| 2762 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 2763 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2764 | const int32_t tex_width = 32; |
| 2765 | const int32_t tex_height = 32; |
| 2766 | VkImageCreateInfo image_create_info = {}; |
| 2767 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 2768 | image_create_info.pNext = NULL; |
| 2769 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2770 | image_create_info.format = tex_format; |
| 2771 | image_create_info.extent.width = tex_width; |
| 2772 | image_create_info.extent.height = tex_height; |
| 2773 | image_create_info.extent.depth = 1; |
| 2774 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 2775 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2776 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2777 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 2778 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 2779 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2780 | vk_testing::Image dstImage; |
| 2781 | dstImage.init(*m_device, (const VkImageCreateInfo&)image_create_info, reqs); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2782 | |
| 2783 | const VkImageSubresourceRange range = |
| 2784 | vk_testing::Image::subresource_range(image_create_info, VK_IMAGE_ASPECT_COLOR_BIT); |
| 2785 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2786 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), |
| 2787 | dstImage.handle(), |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2788 | VK_IMAGE_LAYOUT_GENERAL, |
| 2789 | &clear_color, |
| 2790 | 1, |
| 2791 | &range); |
| 2792 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2793 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2794 | FAIL() << "Did not receive Error 'It is invalid to issue this call inside an active render pass...'"; |
| 2795 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2796 | } |
| 2797 | } |
| 2798 | |
| 2799 | TEST_F(VkLayerTest, ClearDepthStencilImageWithinRenderPass) |
| 2800 | { |
| 2801 | // Call CmdClearDepthStencilImage within an active RenderPass |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2802 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2803 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2804 | |
| 2805 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2806 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2807 | |
| 2808 | // Renderpass is started here |
| 2809 | BeginCommandBuffer(); |
| 2810 | |
| 2811 | VkClearDepthStencilValue clear_value = {0}; |
| 2812 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 2813 | VkImageCreateInfo image_create_info = vk_testing::Image::create_info(); |
| 2814 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2815 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 2816 | image_create_info.extent.width = 64; |
| 2817 | image_create_info.extent.height = 64; |
| 2818 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 2819 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 2820 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2821 | vk_testing::Image dstImage; |
| 2822 | dstImage.init(*m_device, (const VkImageCreateInfo&)image_create_info, reqs); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2823 | |
| 2824 | const VkImageSubresourceRange range = |
| 2825 | vk_testing::Image::subresource_range(image_create_info, VK_IMAGE_ASPECT_DEPTH_BIT); |
| 2826 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2827 | vkCmdClearDepthStencilImage(m_commandBuffer->GetBufferHandle(), |
| 2828 | dstImage.handle(), |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2829 | VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, |
| 2830 | &clear_value, |
| 2831 | 1, |
| 2832 | &range); |
| 2833 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2834 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2835 | FAIL() << "Did not receive Error 'It is invalid to issue this call inside an active render pass...'"; |
| 2836 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2837 | } |
| 2838 | } |
| 2839 | |
| 2840 | TEST_F(VkLayerTest, ClearColorAttachmentsOutsideRenderPass) |
| 2841 | { |
Courtney Goeltzenleuchter | 9feb073 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 2842 | // Call CmdClearAttachmentss outside of an active RenderPass |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2843 | VkResult err; |
| 2844 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2845 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2846 | "vkCmdClearAttachments: This call must be issued inside an active render pass"); |
| 2847 | |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2848 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2849 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2850 | |
| 2851 | // Start no RenderPass |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2852 | err = m_commandBuffer->BeginCommandBuffer(); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2853 | ASSERT_VK_SUCCESS(err); |
| 2854 | |
Courtney Goeltzenleuchter | 9feb073 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 2855 | VkClearAttachment color_attachment; |
| 2856 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 2857 | color_attachment.clearValue.color.float32[0] = 0; |
| 2858 | color_attachment.clearValue.color.float32[1] = 0; |
| 2859 | color_attachment.clearValue.color.float32[2] = 0; |
| 2860 | color_attachment.clearValue.color.float32[3] = 0; |
| 2861 | color_attachment.colorAttachment = 0; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 2862 | VkClearRect clear_rect = { { { 0, 0 }, { 32, 32 } } }; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2863 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), |
Courtney Goeltzenleuchter | 9feb073 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 2864 | 1, &color_attachment, |
| 2865 | 1, &clear_rect); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2866 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2867 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2868 | FAIL() << "Did not receive Error 'vkCmdClearAttachments: This call must be issued inside an active render pass.'"; |
| 2869 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | f5b3cc1 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2870 | } |
| 2871 | } |
| 2872 | |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2873 | TEST_F(VkLayerTest, InvalidDynamicStateObject) |
| 2874 | { |
| 2875 | // Create a valid cmd buffer |
| 2876 | // call vkCmdBindDynamicStateObject w/ false DS Obj |
Tobin Ehlis | 6bdfa37 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 2877 | // TODO : Simple check for bad object should be added to ObjectTracker to catch this case |
| 2878 | // 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] | 2879 | } |
Tobin Ehlis | 201b1ba | 2015-05-27 14:55:35 -0600 | [diff] [blame] | 2880 | |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 2881 | TEST_F(VkLayerTest, IdxBufferAlignmentError) |
| 2882 | { |
| 2883 | // Bind a BeginRenderPass within an active RenderPass |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 2884 | VkResult err; |
| 2885 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2886 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2887 | "vkCmdBindIndexBuffer() offset (0x7) does not fall on "); |
| 2888 | |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 2889 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2890 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 2891 | uint32_t qfi = 0; |
| 2892 | VkBufferCreateInfo buffCI = {}; |
| 2893 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 2894 | buffCI.size = 1024; |
| 2895 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2896 | buffCI.queueFamilyIndexCount = 1; |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 2897 | buffCI.pQueueFamilyIndices = &qfi; |
| 2898 | |
| 2899 | VkBuffer ib; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2900 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 2901 | ASSERT_VK_SUCCESS(err); |
| 2902 | |
| 2903 | BeginCommandBuffer(); |
| 2904 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2905 | //vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 2906 | // 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] | 2907 | vkCmdBindIndexBuffer(m_commandBuffer->GetBufferHandle(), ib, 7, VK_INDEX_TYPE_UINT16); |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 2908 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2909 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2910 | FAIL() << "Did not receive Error 'vkCmdBindIndexBuffer() offset (0x7) does not fall on ...'"; |
| 2911 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 2912 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2913 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2914 | vkDestroyBuffer(m_device->device(), ib, NULL); |
Tobin Ehlis | 8d199e5 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 2915 | } |
| 2916 | |
Tobin Ehlis | 5f728d3 | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 2917 | TEST_F(VkLayerTest, ExecuteCommandsPrimaryCB) |
| 2918 | { |
| 2919 | // Attempt vkCmdExecuteCommands w/ a primary cmd buffer (should only be secondary) |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2920 | |
| 2921 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2922 | "vkCmdExecuteCommands() called w/ Primary Cmd Buffer "); |
Tobin Ehlis | 5f728d3 | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 2923 | |
| 2924 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2925 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 5f728d3 | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 2926 | |
| 2927 | BeginCommandBuffer(); |
| 2928 | //ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2929 | VkCommandBuffer primCB = m_commandBuffer->GetBufferHandle(); |
| 2930 | vkCmdExecuteCommands(m_commandBuffer->GetBufferHandle(), 1, &primCB); |
Tobin Ehlis | 5f728d3 | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 2931 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2932 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2933 | FAIL() << "Did not receive Error 'vkCmdExecuteCommands() called w/ Primary Cmd Buffer '"; |
| 2934 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 5f728d3 | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 2935 | } |
| 2936 | } |
| 2937 | |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2938 | TEST_F(VkLayerTest, DSTypeMismatch) |
| 2939 | { |
| 2940 | // 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] | 2941 | VkResult err; |
| 2942 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2943 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2944 | "Write descriptor update has descriptor type VK_DESCRIPTOR_TYPE_SAMPLER that does not match "); |
| 2945 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2946 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2947 | //VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2948 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2949 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2950 | ds_type_count.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2951 | |
| 2952 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2953 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2954 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 2955 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2956 | ds_pool_ci.poolSizeCount = 1; |
| 2957 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2958 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2959 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2960 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2961 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2962 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2963 | dsl_binding.binding = 0; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2964 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 2965 | dsl_binding.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2966 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2967 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2968 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2969 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2970 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2971 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2972 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2973 | ds_layout_ci.pBinding = &dsl_binding; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2974 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2975 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2976 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2977 | ASSERT_VK_SUCCESS(err); |
| 2978 | |
| 2979 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2980 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2981 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2982 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2983 | alloc_info.descriptorPool = ds_pool; |
| 2984 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2985 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2986 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2987 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2988 | VkSamplerCreateInfo sampler_ci = {}; |
| 2989 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 2990 | sampler_ci.pNext = NULL; |
Chia-I Wu | 3603b08 | 2015-10-26 16:49:32 +0800 | [diff] [blame] | 2991 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 2992 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 2993 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_BASE; |
Chia-I Wu | ce532f7 | 2015-10-26 17:32:47 +0800 | [diff] [blame] | 2994 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 2995 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 2996 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2997 | sampler_ci.mipLodBias = 1.0; |
| 2998 | sampler_ci.maxAnisotropy = 1; |
| 2999 | sampler_ci.compareEnable = VK_FALSE; |
| 3000 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3001 | sampler_ci.minLod = 1.0; |
| 3002 | sampler_ci.maxLod = 1.0; |
| 3003 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
Mark Lobodzinski | 513acdf | 2015-09-01 15:42:56 -0600 | [diff] [blame] | 3004 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
| 3005 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3006 | VkSampler sampler; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3007 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3008 | ASSERT_VK_SUCCESS(err); |
| 3009 | |
Courtney Goeltzenleuchter | 34aa5c8 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3010 | VkDescriptorImageInfo info = {}; |
| 3011 | info.sampler = sampler; |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3012 | |
| 3013 | VkWriteDescriptorSet descriptor_write; |
| 3014 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3015 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3016 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3017 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3018 | // This is a mismatched type for the layout which expects BUFFER |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3019 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 34aa5c8 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3020 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3021 | |
| 3022 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3023 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3024 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3025 | FAIL() << "Did not receive Error 'Write descriptor update has descriptor type VK_DESCRIPTOR_TYPE_SAMPLER that does not match...'"; |
| 3026 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3027 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3028 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3029 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3030 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3031 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3032 | } |
| 3033 | |
| 3034 | TEST_F(VkLayerTest, DSUpdateOutOfBounds) |
| 3035 | { |
| 3036 | // For overlapping Update, have arrayIndex exceed that of layout |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3037 | VkResult err; |
| 3038 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3039 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3040 | "Descriptor update type of VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET is out of bounds for matching binding"); |
| 3041 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3042 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3043 | //VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3044 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3045 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3046 | ds_type_count.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3047 | |
| 3048 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3049 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3050 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3051 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3052 | ds_pool_ci.poolSizeCount = 1; |
| 3053 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3054 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3055 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3056 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3057 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3058 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3059 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3060 | dsl_binding.binding = 0; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3061 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 3062 | dsl_binding.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3063 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3064 | dsl_binding.pImmutableSamplers = NULL; |
| 3065 | |
| 3066 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3067 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3068 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3069 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3070 | ds_layout_ci.pBinding = &dsl_binding; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3071 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3072 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3073 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3074 | ASSERT_VK_SUCCESS(err); |
| 3075 | |
| 3076 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3077 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3078 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3079 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3080 | alloc_info.descriptorPool = ds_pool; |
| 3081 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3082 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3083 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3084 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3085 | VkSamplerCreateInfo sampler_ci = {}; |
| 3086 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3087 | sampler_ci.pNext = NULL; |
Chia-I Wu | 3603b08 | 2015-10-26 16:49:32 +0800 | [diff] [blame] | 3088 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 3089 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 3090 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_BASE; |
Chia-I Wu | ce532f7 | 2015-10-26 17:32:47 +0800 | [diff] [blame] | 3091 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3092 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3093 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3094 | sampler_ci.mipLodBias = 1.0; |
| 3095 | sampler_ci.maxAnisotropy = 1; |
| 3096 | sampler_ci.compareEnable = VK_FALSE; |
| 3097 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3098 | sampler_ci.minLod = 1.0; |
| 3099 | sampler_ci.maxLod = 1.0; |
| 3100 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
Mark Lobodzinski | 513acdf | 2015-09-01 15:42:56 -0600 | [diff] [blame] | 3101 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3102 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3103 | VkSampler sampler; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3104 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3105 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3106 | |
Courtney Goeltzenleuchter | 34aa5c8 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3107 | VkDescriptorImageInfo info = {}; |
| 3108 | info.sampler = sampler; |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3109 | |
| 3110 | VkWriteDescriptorSet descriptor_write; |
| 3111 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3112 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3113 | descriptor_write.dstSet = descriptorSet; |
| 3114 | 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] | 3115 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3116 | // 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] | 3117 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 34aa5c8 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3118 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3119 | |
| 3120 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3121 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3122 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3123 | FAIL() << "Did not receive Error 'Descriptor update type of VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET is out of bounds for matching binding...'"; |
| 3124 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3125 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3126 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3127 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3128 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3129 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3130 | } |
| 3131 | |
| 3132 | TEST_F(VkLayerTest, InvalidDSUpdateIndex) |
| 3133 | { |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3134 | // 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] | 3135 | VkResult err; |
| 3136 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3137 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3138 | " does not have binding to match update binding "); |
| 3139 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3140 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3141 | //VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3142 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3143 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3144 | ds_type_count.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3145 | |
| 3146 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3147 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3148 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3149 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3150 | ds_pool_ci.poolSizeCount = 1; |
| 3151 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3152 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3153 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3154 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3155 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3156 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3157 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3158 | dsl_binding.binding = 0; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3159 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 3160 | dsl_binding.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3161 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3162 | dsl_binding.pImmutableSamplers = NULL; |
| 3163 | |
| 3164 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3165 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3166 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3167 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3168 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3169 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3170 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3171 | ASSERT_VK_SUCCESS(err); |
| 3172 | |
| 3173 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3174 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3175 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3176 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3177 | alloc_info.descriptorPool = ds_pool; |
| 3178 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3179 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3180 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3181 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3182 | VkSamplerCreateInfo sampler_ci = {}; |
| 3183 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3184 | sampler_ci.pNext = NULL; |
Chia-I Wu | 3603b08 | 2015-10-26 16:49:32 +0800 | [diff] [blame] | 3185 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 3186 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 3187 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_BASE; |
Chia-I Wu | ce532f7 | 2015-10-26 17:32:47 +0800 | [diff] [blame] | 3188 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3189 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3190 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3191 | sampler_ci.mipLodBias = 1.0; |
| 3192 | sampler_ci.maxAnisotropy = 1; |
| 3193 | sampler_ci.compareEnable = VK_FALSE; |
| 3194 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3195 | sampler_ci.minLod = 1.0; |
| 3196 | sampler_ci.maxLod = 1.0; |
| 3197 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
Mark Lobodzinski | 513acdf | 2015-09-01 15:42:56 -0600 | [diff] [blame] | 3198 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3199 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3200 | VkSampler sampler; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3201 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3202 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3203 | |
Courtney Goeltzenleuchter | 34aa5c8 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3204 | VkDescriptorImageInfo info = {}; |
| 3205 | info.sampler = sampler; |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3206 | |
| 3207 | VkWriteDescriptorSet descriptor_write; |
| 3208 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3209 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3210 | descriptor_write.dstSet = descriptorSet; |
| 3211 | descriptor_write.dstBinding = 2; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3212 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3213 | // 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] | 3214 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 34aa5c8 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3215 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3216 | |
| 3217 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3218 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3219 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3220 | FAIL() << "Did not receive Error 'Descriptor Set <blah> does not have binding to match update binding '"; |
| 3221 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3222 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3223 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3224 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3225 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3226 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3227 | } |
| 3228 | |
| 3229 | TEST_F(VkLayerTest, InvalidDSUpdateStruct) |
| 3230 | { |
| 3231 | // 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] | 3232 | VkResult err; |
| 3233 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3234 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3235 | "Unexpected UPDATE struct of type "); |
| 3236 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3237 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3238 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3239 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3240 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3241 | ds_type_count.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3242 | |
| 3243 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3244 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3245 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3246 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3247 | ds_pool_ci.poolSizeCount = 1; |
| 3248 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3249 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3250 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3251 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3252 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3253 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3254 | dsl_binding.binding = 0; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3255 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 3256 | dsl_binding.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3257 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3258 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3259 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3260 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3261 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3262 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3263 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3264 | ds_layout_ci.pBinding = &dsl_binding; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3265 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3266 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3267 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3268 | ASSERT_VK_SUCCESS(err); |
| 3269 | |
| 3270 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3271 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3272 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3273 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3274 | alloc_info.descriptorPool = ds_pool; |
| 3275 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3276 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3277 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3278 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3279 | VkSamplerCreateInfo sampler_ci = {}; |
| 3280 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3281 | sampler_ci.pNext = NULL; |
Chia-I Wu | 3603b08 | 2015-10-26 16:49:32 +0800 | [diff] [blame] | 3282 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 3283 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 3284 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_BASE; |
Chia-I Wu | ce532f7 | 2015-10-26 17:32:47 +0800 | [diff] [blame] | 3285 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3286 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3287 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3288 | sampler_ci.mipLodBias = 1.0; |
| 3289 | sampler_ci.maxAnisotropy = 1; |
| 3290 | sampler_ci.compareEnable = VK_FALSE; |
| 3291 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3292 | sampler_ci.minLod = 1.0; |
| 3293 | sampler_ci.maxLod = 1.0; |
| 3294 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
Mark Lobodzinski | 513acdf | 2015-09-01 15:42:56 -0600 | [diff] [blame] | 3295 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3296 | VkSampler sampler; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3297 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3298 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3299 | |
| 3300 | |
Courtney Goeltzenleuchter | 34aa5c8 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3301 | VkDescriptorImageInfo info = {}; |
| 3302 | info.sampler = sampler; |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3303 | |
| 3304 | VkWriteDescriptorSet descriptor_write; |
| 3305 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3306 | descriptor_write.sType = (VkStructureType)0x99999999; /* Intentionally broken struct type */ |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3307 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3308 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3309 | // 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] | 3310 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 34aa5c8 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3311 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 8cd8ecd | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3312 | |
| 3313 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3314 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3315 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3316 | FAIL() << "Did not receive Error 'Unexpected UPDATE struct of type '"; |
| 3317 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3318 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3319 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3320 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3321 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3322 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3323 | } |
| 3324 | |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3325 | TEST_F(VkLayerTest, SampleDescriptorUpdateError) |
| 3326 | { |
| 3327 | // Create a single Sampler descriptor and send it an invalid Sampler |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3328 | VkResult err; |
| 3329 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3330 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3331 | "Attempt to update descriptor with invalid sampler 0xbaadbeef"); |
| 3332 | |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3333 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3334 | // 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] | 3335 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3336 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3337 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3338 | |
| 3339 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3340 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3341 | ds_pool_ci.pNext = NULL; |
| 3342 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3343 | ds_pool_ci.poolSizeCount = 1; |
| 3344 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3345 | |
| 3346 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3347 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3348 | ASSERT_VK_SUCCESS(err); |
| 3349 | |
| 3350 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3351 | dsl_binding.binding = 0; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3352 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 3353 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3354 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3355 | dsl_binding.pImmutableSamplers = NULL; |
| 3356 | |
| 3357 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3358 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3359 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3360 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3361 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3362 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3363 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3364 | ASSERT_VK_SUCCESS(err); |
| 3365 | |
| 3366 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3367 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3368 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3369 | alloc_info.setLayoutCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3370 | alloc_info.descriptorPool = ds_pool; |
| 3371 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3372 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3373 | ASSERT_VK_SUCCESS(err); |
| 3374 | |
Chia-I Wu | e420a33 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 3375 | VkSampler sampler = (VkSampler) 0xbaadbeef; // Sampler with invalid handle |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3376 | |
| 3377 | VkDescriptorImageInfo descriptor_info; |
| 3378 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 3379 | descriptor_info.sampler = sampler; |
| 3380 | |
| 3381 | VkWriteDescriptorSet descriptor_write; |
| 3382 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3383 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3384 | descriptor_write.dstSet = descriptorSet; |
| 3385 | descriptor_write.dstBinding = 0; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3386 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3387 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 3388 | descriptor_write.pImageInfo = &descriptor_info; |
| 3389 | |
| 3390 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3391 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3392 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3393 | FAIL() << "Did not receive Error 'Attempt to update descriptor with invalid sampler...'"; |
| 3394 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3395 | } |
| 3396 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3397 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3398 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3399 | } |
| 3400 | |
| 3401 | TEST_F(VkLayerTest, ImageViewDescriptorUpdateError) |
| 3402 | { |
| 3403 | // 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] | 3404 | VkResult err; |
| 3405 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3406 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3407 | "Attempt to update descriptor with invalid imageView 0xbaadbeef"); |
| 3408 | |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3409 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3410 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3411 | ds_type_count.type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3412 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3413 | |
| 3414 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3415 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3416 | ds_pool_ci.pNext = NULL; |
| 3417 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3418 | ds_pool_ci.poolSizeCount = 1; |
| 3419 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3420 | |
| 3421 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3422 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3423 | ASSERT_VK_SUCCESS(err); |
| 3424 | |
| 3425 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3426 | dsl_binding.binding = 0; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3427 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 3428 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3429 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3430 | dsl_binding.pImmutableSamplers = NULL; |
| 3431 | |
| 3432 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3433 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3434 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3435 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3436 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3437 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3438 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3439 | ASSERT_VK_SUCCESS(err); |
| 3440 | |
| 3441 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3442 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3443 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3444 | alloc_info.setLayoutCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3445 | alloc_info.descriptorPool = ds_pool; |
| 3446 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3447 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3448 | ASSERT_VK_SUCCESS(err); |
| 3449 | |
| 3450 | VkSamplerCreateInfo sampler_ci = {}; |
| 3451 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3452 | sampler_ci.pNext = NULL; |
Chia-I Wu | 3603b08 | 2015-10-26 16:49:32 +0800 | [diff] [blame] | 3453 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 3454 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 3455 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_BASE; |
Chia-I Wu | ce532f7 | 2015-10-26 17:32:47 +0800 | [diff] [blame] | 3456 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3457 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3458 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3459 | sampler_ci.mipLodBias = 1.0; |
| 3460 | sampler_ci.maxAnisotropy = 1; |
| 3461 | sampler_ci.compareEnable = VK_FALSE; |
| 3462 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3463 | sampler_ci.minLod = 1.0; |
| 3464 | sampler_ci.maxLod = 1.0; |
| 3465 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 3466 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
| 3467 | |
| 3468 | VkSampler sampler; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3469 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3470 | ASSERT_VK_SUCCESS(err); |
| 3471 | |
Chia-I Wu | e420a33 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 3472 | VkImageView view = (VkImageView) 0xbaadbeef; // invalid imageView object |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3473 | |
| 3474 | VkDescriptorImageInfo descriptor_info; |
| 3475 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 3476 | descriptor_info.sampler = sampler; |
| 3477 | descriptor_info.imageView = view; |
| 3478 | |
| 3479 | VkWriteDescriptorSet descriptor_write; |
| 3480 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3481 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3482 | descriptor_write.dstSet = descriptorSet; |
| 3483 | descriptor_write.dstBinding = 0; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3484 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3485 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 3486 | descriptor_write.pImageInfo = &descriptor_info; |
| 3487 | |
| 3488 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3489 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3490 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3491 | FAIL() << "Did not receive Error 'Attempt to update descriptor with invalid imageView...'"; |
| 3492 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3493 | } |
| 3494 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3495 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3496 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3497 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3498 | } |
| 3499 | |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3500 | TEST_F(VkLayerTest, CopyDescriptorUpdateErrors) |
| 3501 | { |
| 3502 | // 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] | 3503 | VkResult err; |
| 3504 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3505 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3506 | "Copy descriptor update index 0, update count #1, has src update descriptor type VK_DESCRIPTOR_TYPE_SAMPLER "); |
| 3507 | |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3508 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3509 | //VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3510 | VkDescriptorPoolSize ds_type_count[2] = {}; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3511 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3512 | ds_type_count[0].descriptorCount = 1; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3513 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3514 | ds_type_count[1].descriptorCount = 1; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3515 | |
| 3516 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3517 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3518 | ds_pool_ci.pNext = NULL; |
| 3519 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3520 | ds_pool_ci.poolSizeCount = 2; |
| 3521 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3522 | |
| 3523 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3524 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3525 | ASSERT_VK_SUCCESS(err); |
| 3526 | VkDescriptorSetLayoutBinding dsl_binding[2] = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3527 | dsl_binding[0].binding = 0; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3528 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 3529 | dsl_binding[0].descriptorCount = 1; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3530 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 3531 | dsl_binding[0].pImmutableSamplers = NULL; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3532 | dsl_binding[1].binding = 1; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3533 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 3534 | dsl_binding[1].descriptorCount = 1; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3535 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 3536 | dsl_binding[1].pImmutableSamplers = NULL; |
| 3537 | |
| 3538 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3539 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3540 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3541 | ds_layout_ci.bindingCount = 2; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3542 | ds_layout_ci.pBinding = dsl_binding; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3543 | |
| 3544 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3545 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3546 | ASSERT_VK_SUCCESS(err); |
| 3547 | |
| 3548 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3549 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3550 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3551 | alloc_info.setLayoutCount = 1; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3552 | alloc_info.descriptorPool = ds_pool; |
| 3553 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3554 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3555 | ASSERT_VK_SUCCESS(err); |
| 3556 | |
| 3557 | VkSamplerCreateInfo sampler_ci = {}; |
| 3558 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3559 | sampler_ci.pNext = NULL; |
Chia-I Wu | 3603b08 | 2015-10-26 16:49:32 +0800 | [diff] [blame] | 3560 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 3561 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 3562 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_BASE; |
Chia-I Wu | ce532f7 | 2015-10-26 17:32:47 +0800 | [diff] [blame] | 3563 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3564 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3565 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3566 | sampler_ci.mipLodBias = 1.0; |
| 3567 | sampler_ci.maxAnisotropy = 1; |
| 3568 | sampler_ci.compareEnable = VK_FALSE; |
| 3569 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3570 | sampler_ci.minLod = 1.0; |
| 3571 | sampler_ci.maxLod = 1.0; |
| 3572 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 3573 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
| 3574 | |
| 3575 | VkSampler sampler; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3576 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3577 | ASSERT_VK_SUCCESS(err); |
| 3578 | |
| 3579 | VkDescriptorImageInfo info = {}; |
| 3580 | info.sampler = sampler; |
| 3581 | |
| 3582 | VkWriteDescriptorSet descriptor_write; |
| 3583 | memset(&descriptor_write, 0, sizeof(VkWriteDescriptorSet)); |
| 3584 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3585 | descriptor_write.dstSet = descriptorSet; |
| 3586 | descriptor_write.dstBinding = 1; // SAMPLER binding from layout above |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3587 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3588 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 3589 | descriptor_write.pImageInfo = &info; |
| 3590 | // This write update should succeed |
| 3591 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3592 | // Now perform a copy update that fails due to type mismatch |
| 3593 | VkCopyDescriptorSet copy_ds_update; |
| 3594 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 3595 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 3596 | copy_ds_update.srcSet = descriptorSet; |
| 3597 | copy_ds_update.srcBinding = 1; // copy from SAMPLER binding |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3598 | copy_ds_update.dstSet = descriptorSet; |
| 3599 | copy_ds_update.dstBinding = 0; // ERROR : copy to UNIFORM binding |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3600 | copy_ds_update.descriptorCount = 1; // copy 1 descriptor |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3601 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 3602 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3603 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3604 | FAIL() << "Did not receive Error 'Copy descriptor update index 0, update count #1, has src update descriptor type_DESCRIPTOR_TYPE_SAMPLER'"; |
| 3605 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3606 | } |
| 3607 | // 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] | 3608 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3609 | "Copy descriptor update 0 has srcBinding 3 which is out of bounds "); |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3610 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 3611 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 3612 | copy_ds_update.srcSet = descriptorSet; |
| 3613 | copy_ds_update.srcBinding = 3; // ERROR : Invalid binding for matching layout |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3614 | copy_ds_update.dstSet = descriptorSet; |
| 3615 | copy_ds_update.dstBinding = 0; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3616 | copy_ds_update.descriptorCount = 1; // copy 1 descriptor |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3617 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 3618 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3619 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3620 | FAIL() << "Did not receive Error 'Copy descriptor update 0 has srcBinding 3 which is out of bounds...'"; |
| 3621 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3622 | } |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3623 | |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3624 | // 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] | 3625 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3626 | "Copy descriptor src update is out of bounds for matching binding 1 "); |
| 3627 | |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3628 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 3629 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 3630 | copy_ds_update.srcSet = descriptorSet; |
| 3631 | copy_ds_update.srcBinding = 1; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3632 | copy_ds_update.dstSet = descriptorSet; |
| 3633 | copy_ds_update.dstBinding = 0; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3634 | 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] | 3635 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 3636 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3637 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3638 | FAIL() << "Did not receive Error 'Copy descriptor src update is out of bounds for matching binding 1...'"; |
| 3639 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3640 | } |
| 3641 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3642 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3643 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3644 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 3e67626 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3645 | } |
| 3646 | |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3647 | TEST_F(VkLayerTest, NumSamplesMismatch) |
| 3648 | { |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3649 | // Create CommandBuffer where MSAA samples doesn't match RenderPass sampleCount |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3650 | VkResult err; |
| 3651 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3652 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3653 | "Num samples mismatch! "); |
| 3654 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3655 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3656 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3657 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3658 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3659 | ds_type_count.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3660 | |
| 3661 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3662 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3663 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3664 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3665 | ds_pool_ci.poolSizeCount = 1; |
| 3666 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3667 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3668 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3669 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3670 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3671 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3672 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3673 | dsl_binding.binding = 0; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3674 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 3675 | dsl_binding.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3676 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3677 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3678 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3679 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3680 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3681 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3682 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3683 | ds_layout_ci.pBinding = &dsl_binding; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3684 | |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3685 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3686 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3687 | ASSERT_VK_SUCCESS(err); |
| 3688 | |
| 3689 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3690 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3691 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3692 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3693 | alloc_info.descriptorPool = ds_pool; |
| 3694 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3695 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3696 | ASSERT_VK_SUCCESS(err); |
| 3697 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3698 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 3699 | pipe_ms_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 3700 | pipe_ms_state_ci.pNext = NULL; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3701 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3702 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 3703 | pipe_ms_state_ci.minSampleShading = 1.0; |
Cody Northrop | e9825b7 | 2015-08-04 14:34:54 -0600 | [diff] [blame] | 3704 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3705 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3706 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 3707 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3708 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3709 | pipeline_layout_ci.setLayoutCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3710 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3711 | |
| 3712 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3713 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3714 | ASSERT_VK_SUCCESS(err); |
| 3715 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 3716 | VkShaderObj vs(m_device, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 3717 | 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] | 3718 | // but add it to be able to run on more devices |
Tony Barbour | d7d828b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 3719 | VkPipelineObj pipe(m_device); |
| 3720 | pipe.AddShader(&vs); |
Tony Barbour | 3c9e3b1 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 3721 | pipe.AddShader(&fs); |
Tony Barbour | d7d828b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 3722 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 3723 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3724 | |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 3725 | BeginCommandBuffer(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3726 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3727 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3728 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3729 | FAIL() << "Did not recieve Error 'Num samples mismatch!...'"; |
| 3730 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 2f87d2d | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3731 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3732 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3733 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3734 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3735 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 138b7f1 | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3736 | } |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3737 | |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3738 | TEST_F(VkLayerTest, ClearCmdNoDraw) |
| 3739 | { |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3740 | // 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] | 3741 | VkResult err; |
| 3742 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3743 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_WARN_BIT, |
| 3744 | "vkCmdClearAttachments() issued on CB object "); |
| 3745 | |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3746 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3747 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3748 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3749 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3750 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3751 | ds_type_count.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3752 | |
| 3753 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3754 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3755 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3756 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3757 | ds_pool_ci.poolSizeCount = 1; |
| 3758 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3759 | |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3760 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3761 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3762 | ASSERT_VK_SUCCESS(err); |
| 3763 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3764 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3765 | dsl_binding.binding = 0; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3766 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 3767 | dsl_binding.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3768 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3769 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3770 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3771 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3772 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3773 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3774 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3775 | ds_layout_ci.pBinding = &dsl_binding; |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3776 | |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3777 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3778 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3779 | ASSERT_VK_SUCCESS(err); |
| 3780 | |
| 3781 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3782 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3783 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3784 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3785 | alloc_info.descriptorPool = ds_pool; |
| 3786 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3787 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3788 | ASSERT_VK_SUCCESS(err); |
| 3789 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3790 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 3791 | pipe_ms_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 3792 | pipe_ms_state_ci.pNext = NULL; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3793 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3794 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 3795 | pipe_ms_state_ci.minSampleShading = 1.0; |
Cody Northrop | e9825b7 | 2015-08-04 14:34:54 -0600 | [diff] [blame] | 3796 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3797 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3798 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 3799 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3800 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3801 | pipeline_layout_ci.setLayoutCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3802 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3803 | |
| 3804 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3805 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3806 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3807 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 3808 | VkShaderObj vs(m_device, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3809 | // TODO - We shouldn't need a fragment shader but add it to be able to run on more devices |
| 3810 | VkShaderObj fs(m_device, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 3811 | |
Tony Barbour | d7d828b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 3812 | VkPipelineObj pipe(m_device); |
| 3813 | pipe.AddShader(&vs); |
Tony Barbour | 3c9e3b1 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 3814 | pipe.AddShader(&fs); |
Tony Barbour | d7d828b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 3815 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 3816 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 3817 | |
| 3818 | BeginCommandBuffer(); |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3819 | |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3820 | // Main thing we care about for this test is that the VkImage obj we're clearing matches Color Attachment of FB |
| 3821 | // Also pass down other dummy params to keep driver and paramchecker happy |
Courtney Goeltzenleuchter | 9feb073 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 3822 | VkClearAttachment color_attachment; |
| 3823 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 3824 | color_attachment.clearValue.color.float32[0] = 1.0; |
| 3825 | color_attachment.clearValue.color.float32[1] = 1.0; |
| 3826 | color_attachment.clearValue.color.float32[2] = 1.0; |
| 3827 | color_attachment.clearValue.color.float32[3] = 1.0; |
| 3828 | color_attachment.colorAttachment = 0; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 3829 | VkClearRect clear_rect = { { { 0, 0 }, { (int)m_width, (int)m_height } } }; |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3830 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3831 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3832 | |
| 3833 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3834 | FAIL() << "Did not receive Error 'vkCommandClearAttachments() issued on CB object...'"; |
| 3835 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3836 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3837 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3838 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3839 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3840 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 8cd650e | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3841 | } |
| 3842 | |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3843 | TEST_F(VkLayerTest, VtxBufferBadIndex) |
| 3844 | { |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3845 | // Create CommandBuffer where MSAA samples doesn't match RenderPass sampleCount |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3846 | VkResult err; |
| 3847 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3848 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3849 | "Vtx Buffer Index 1 was bound, but no vtx buffers are attached to PSO."); |
| 3850 | |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3851 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 3852 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3853 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3854 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3855 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3856 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3857 | ds_type_count.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3858 | |
| 3859 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3860 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3861 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3862 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3863 | ds_pool_ci.poolSizeCount = 1; |
| 3864 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3865 | |
Courtney Goeltzenleuchter | d9e966a | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3866 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3867 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3868 | ASSERT_VK_SUCCESS(err); |
| 3869 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3870 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3871 | dsl_binding.binding = 0; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3872 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 3873 | dsl_binding.descriptorCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3874 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3875 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3876 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3877 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3878 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3879 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3880 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3881 | ds_layout_ci.pBinding = &dsl_binding; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3882 | |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3883 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3884 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3885 | ASSERT_VK_SUCCESS(err); |
| 3886 | |
| 3887 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3888 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3889 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3890 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3891 | alloc_info.descriptorPool = ds_pool; |
| 3892 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3893 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3894 | ASSERT_VK_SUCCESS(err); |
| 3895 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3896 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 3897 | pipe_ms_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 3898 | pipe_ms_state_ci.pNext = NULL; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3899 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3900 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 3901 | pipe_ms_state_ci.minSampleShading = 1.0; |
Cody Northrop | e9825b7 | 2015-08-04 14:34:54 -0600 | [diff] [blame] | 3902 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3903 | |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3904 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 3905 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3906 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3907 | pipeline_layout_ci.setLayoutCount = 1; |
Tony Barbour | efbe9ca | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3908 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 3909 | VkPipelineLayout pipeline_layout; |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3910 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3911 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3912 | ASSERT_VK_SUCCESS(err); |
| 3913 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 3914 | VkShaderObj vs(m_device, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 3915 | 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] | 3916 | // but add it to be able to run on more devices |
Tony Barbour | d7d828b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 3917 | VkPipelineObj pipe(m_device); |
| 3918 | pipe.AddShader(&vs); |
Tony Barbour | 3c9e3b1 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 3919 | pipe.AddShader(&fs); |
Tony Barbour | d7d828b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 3920 | pipe.SetMSAA(&pipe_ms_state_ci); |
Tobin Ehlis | a88e2f5 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 3921 | pipe.SetViewport(m_viewports); |
| 3922 | pipe.SetScissor(m_scissors); |
Tony Barbour | d7d828b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 3923 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | 1490c91 | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 3924 | |
| 3925 | BeginCommandBuffer(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3926 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | d28acef | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 3927 | // Don't care about actual data, just need to get to draw to flag error |
| 3928 | static const float vbo_data[3] = {1.f, 0.f, 1.f}; |
| 3929 | VkConstantBufferObj vbo(m_device, sizeof(vbo_data), sizeof(float), (const void*) &vbo_data); |
| 3930 | 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] | 3931 | Draw(1, 0, 0, 0); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3932 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3933 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3934 | FAIL() << "Did not receive Error 'Vtx Buffer Index 0 was bound, but no vtx buffers are attached to PSO.'"; |
| 3935 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3936 | } |
Mike Stroyan | 2237f52 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3937 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3938 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3939 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3940 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e407678 | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3941 | } |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3942 | #endif // DRAW_STATE_TESTS |
| 3943 | |
Tobin Ehlis | 57e6a61 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 3944 | #if THREADING_TESTS |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3945 | #if GTEST_IS_THREADSAFE |
| 3946 | struct thread_data_struct { |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3947 | VkCommandBuffer commandBuffer; |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3948 | VkEvent event; |
| 3949 | bool bailout; |
| 3950 | }; |
| 3951 | |
| 3952 | extern "C" void *AddToCommandBuffer(void *arg) |
| 3953 | { |
| 3954 | struct thread_data_struct *data = (struct thread_data_struct *) arg; |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3955 | |
| 3956 | for (int i = 0; i<10000; i++) { |
Chia-I Wu | cba6cea | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3957 | vkCmdSetEvent(data->commandBuffer, data->event, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3958 | if (data->bailout) { |
| 3959 | break; |
| 3960 | } |
| 3961 | } |
| 3962 | return NULL; |
| 3963 | } |
| 3964 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3965 | TEST_F(VkLayerTest, ThreadCommandBufferCollision) |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3966 | { |
Mike Stroyan | 7016f4f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 3967 | test_platform_thread thread; |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3968 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3969 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, "THREADING ERROR"); |
| 3970 | |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3971 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3972 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 3973 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3974 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3975 | // Calls AllocateCommandBuffers |
| 3976 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Mark Lobodzinski | a0f061c | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 3977 | |
| 3978 | // Avoid creating RenderPass |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3979 | commandBuffer.BeginCommandBuffer(); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3980 | |
| 3981 | VkEventCreateInfo event_info; |
| 3982 | VkEvent event; |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3983 | VkResult err; |
| 3984 | |
| 3985 | memset(&event_info, 0, sizeof(event_info)); |
| 3986 | event_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 3987 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3988 | err = vkCreateEvent(device(), &event_info, NULL, &event); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3989 | ASSERT_VK_SUCCESS(err); |
| 3990 | |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3991 | err = vkResetEvent(device(), event); |
| 3992 | ASSERT_VK_SUCCESS(err); |
| 3993 | |
| 3994 | struct thread_data_struct data; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3995 | data.commandBuffer = commandBuffer.GetBufferHandle(); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3996 | data.event = event; |
| 3997 | data.bailout = false; |
| 3998 | m_errorMonitor->SetBailout(&data.bailout); |
| 3999 | // Add many entries to command buffer from another thread. |
Mike Stroyan | 7016f4f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 4000 | test_platform_thread_create(&thread, AddToCommandBuffer, (void *)&data); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4001 | // Add many entries to command buffer from this thread at the same time. |
| 4002 | AddToCommandBuffer(&data); |
Mark Lobodzinski | a0f061c | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 4003 | |
Mike Stroyan | 7016f4f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 4004 | test_platform_thread_join(thread, NULL); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4005 | commandBuffer.EndCommandBuffer(); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4006 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4007 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4008 | FAIL() << "Did not receive Error 'THREADING ERROR' from using one VkCommandBufferObj in two threads"; |
| 4009 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4010 | } |
| 4011 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4012 | vkDestroyEvent(device(), event, NULL); |
Mike Stroyan | 09aae81 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 4013 | } |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4014 | #endif // GTEST_IS_THREADSAFE |
| 4015 | #endif // THREADING_TESTS |
| 4016 | |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4017 | #if SHADER_CHECKER_TESTS |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4018 | TEST_F(VkLayerTest, InvalidSPIRVCodeSize) |
| 4019 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4020 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4021 | "Shader is not SPIR-V"); |
| 4022 | |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4023 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4024 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4025 | |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4026 | VkShaderModule module; |
| 4027 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 4028 | struct icd_spv_header spv; |
| 4029 | |
| 4030 | spv.magic = ICD_SPV_MAGIC; |
| 4031 | spv.version = ICD_SPV_VERSION; |
| 4032 | spv.gen_magic = 0; |
| 4033 | |
| 4034 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 4035 | moduleCreateInfo.pNext = NULL; |
Chia-I Wu | 036b161 | 2015-10-26 19:22:06 +0800 | [diff] [blame] | 4036 | moduleCreateInfo.pCode = (const uint32_t *) &spv; |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4037 | moduleCreateInfo.codeSize = 4; |
| 4038 | moduleCreateInfo.flags = 0; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4039 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4040 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4041 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4042 | FAIL() << "Did not recieive Error 'Shader is not SPIR-V'"; |
| 4043 | m_errorMonitor->DumpFailureMsgs(); |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4044 | } |
| 4045 | } |
| 4046 | |
| 4047 | TEST_F(VkLayerTest, InvalidSPIRVMagic) |
| 4048 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4049 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4050 | "Shader is not SPIR-V"); |
| 4051 | |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4052 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4053 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4054 | |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4055 | VkShaderModule module; |
| 4056 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 4057 | struct icd_spv_header spv; |
| 4058 | |
| 4059 | spv.magic = ~ICD_SPV_MAGIC; |
| 4060 | spv.version = ICD_SPV_VERSION; |
| 4061 | spv.gen_magic = 0; |
| 4062 | |
| 4063 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 4064 | moduleCreateInfo.pNext = NULL; |
Chia-I Wu | 036b161 | 2015-10-26 19:22:06 +0800 | [diff] [blame] | 4065 | moduleCreateInfo.pCode = (const uint32_t *) &spv; |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4066 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 4067 | moduleCreateInfo.flags = 0; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4068 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4069 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4070 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4071 | FAIL() << "Did not recieive Error 'Shader is not SPIR-V'"; |
| 4072 | m_errorMonitor->DumpFailureMsgs(); |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4073 | } |
| 4074 | } |
| 4075 | |
| 4076 | TEST_F(VkLayerTest, InvalidSPIRVVersion) |
| 4077 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4078 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4079 | "Shader is not SPIR-V"); |
| 4080 | |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4081 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4082 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4083 | |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4084 | VkShaderModule module; |
| 4085 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 4086 | struct icd_spv_header spv; |
| 4087 | |
| 4088 | spv.magic = ICD_SPV_MAGIC; |
| 4089 | spv.version = ~ICD_SPV_VERSION; |
| 4090 | spv.gen_magic = 0; |
| 4091 | |
| 4092 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 4093 | moduleCreateInfo.pNext = NULL; |
| 4094 | |
Chia-I Wu | 036b161 | 2015-10-26 19:22:06 +0800 | [diff] [blame] | 4095 | moduleCreateInfo.pCode = (const uint32_t *) &spv; |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4096 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 4097 | moduleCreateInfo.flags = 0; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4098 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4099 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4100 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4101 | FAIL() << "Did not recieive Error 'Shader is not SPIR-V'"; |
| 4102 | m_errorMonitor->DumpFailureMsgs(); |
Courtney Goeltzenleuchter | 201387f | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4103 | } |
| 4104 | } |
| 4105 | |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4106 | TEST_F(VkLayerTest, CreatePipelineVertexOutputNotConsumed) |
| 4107 | { |
Tony Barbour | 192f02b | 2015-11-06 14:21:31 -0700 | [diff] [blame] | 4108 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_PERF_WARN_BIT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4109 | "not consumed by fragment shader"); |
| 4110 | |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4111 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4112 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4113 | |
| 4114 | char const *vsSource = |
| 4115 | "#version 140\n" |
| 4116 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4117 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4118 | "\n" |
| 4119 | "layout(location=0) out float x;\n" |
| 4120 | "void main(){\n" |
| 4121 | " gl_Position = vec4(1);\n" |
| 4122 | " x = 0;\n" |
| 4123 | "}\n"; |
| 4124 | char const *fsSource = |
| 4125 | "#version 140\n" |
| 4126 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4127 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4128 | "\n" |
| 4129 | "layout(location=0) out vec4 color;\n" |
| 4130 | "void main(){\n" |
| 4131 | " color = vec4(1);\n" |
| 4132 | "}\n"; |
| 4133 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4134 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4135 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4136 | |
| 4137 | VkPipelineObj pipe(m_device); |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4138 | pipe.AddColorAttachment(); |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4139 | pipe.AddShader(&vs); |
| 4140 | pipe.AddShader(&fs); |
| 4141 | |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4142 | VkDescriptorSetObj descriptorSet(m_device); |
| 4143 | descriptorSet.AppendDummy(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4144 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4145 | |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4146 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4147 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4148 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4149 | FAIL() << "Did not receive Warning 'not consumed by fragment shader'"; |
| 4150 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4151 | } |
| 4152 | } |
Chris Forbes | 5af3bf2 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4153 | |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4154 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvided) |
| 4155 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4156 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4157 | "not written by vertex shader"); |
| 4158 | |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4159 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4160 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4161 | |
| 4162 | char const *vsSource = |
| 4163 | "#version 140\n" |
| 4164 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4165 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4166 | "\n" |
| 4167 | "void main(){\n" |
| 4168 | " gl_Position = vec4(1);\n" |
| 4169 | "}\n"; |
| 4170 | char const *fsSource = |
| 4171 | "#version 140\n" |
| 4172 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4173 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4174 | "\n" |
| 4175 | "layout(location=0) in float x;\n" |
| 4176 | "layout(location=0) out vec4 color;\n" |
| 4177 | "void main(){\n" |
| 4178 | " color = vec4(x);\n" |
| 4179 | "}\n"; |
| 4180 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4181 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4182 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4183 | |
| 4184 | VkPipelineObj pipe(m_device); |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4185 | pipe.AddColorAttachment(); |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4186 | pipe.AddShader(&vs); |
| 4187 | pipe.AddShader(&fs); |
| 4188 | |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4189 | VkDescriptorSetObj descriptorSet(m_device); |
| 4190 | descriptorSet.AppendDummy(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4191 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4192 | |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4193 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4194 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4195 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4196 | FAIL() << "Did not receive Error 'not written by vertex shader'"; |
| 4197 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 3c10b85 | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4198 | } |
| 4199 | } |
| 4200 | |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4201 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatch) |
| 4202 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4203 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4204 | "Type mismatch on location 0"); |
| 4205 | |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4206 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4207 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4208 | |
| 4209 | char const *vsSource = |
| 4210 | "#version 140\n" |
| 4211 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4212 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4213 | "\n" |
| 4214 | "layout(location=0) out int x;\n" |
| 4215 | "void main(){\n" |
| 4216 | " x = 0;\n" |
| 4217 | " gl_Position = vec4(1);\n" |
| 4218 | "}\n"; |
| 4219 | char const *fsSource = |
| 4220 | "#version 140\n" |
| 4221 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4222 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4223 | "\n" |
| 4224 | "layout(location=0) in float x;\n" /* VS writes int */ |
| 4225 | "layout(location=0) out vec4 color;\n" |
| 4226 | "void main(){\n" |
| 4227 | " color = vec4(x);\n" |
| 4228 | "}\n"; |
| 4229 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4230 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4231 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4232 | |
| 4233 | VkPipelineObj pipe(m_device); |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4234 | pipe.AddColorAttachment(); |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4235 | pipe.AddShader(&vs); |
| 4236 | pipe.AddShader(&fs); |
| 4237 | |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4238 | VkDescriptorSetObj descriptorSet(m_device); |
| 4239 | descriptorSet.AppendDummy(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4240 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4241 | |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4242 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4243 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4244 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4245 | FAIL() << "Did not receive Error 'Type mismatch on location 0'"; |
| 4246 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | cc28169 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4247 | } |
| 4248 | } |
| 4249 | |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4250 | TEST_F(VkLayerTest, CreatePipelineAttribNotConsumed) |
| 4251 | { |
Tony Barbour | 192f02b | 2015-11-06 14:21:31 -0700 | [diff] [blame] | 4252 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_PERF_WARN_BIT, |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4253 | "location 0 not consumed by VS"); |
| 4254 | |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4255 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4256 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4257 | |
| 4258 | VkVertexInputBindingDescription input_binding; |
| 4259 | memset(&input_binding, 0, sizeof(input_binding)); |
| 4260 | |
| 4261 | VkVertexInputAttributeDescription input_attrib; |
| 4262 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 4263 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 4264 | |
| 4265 | char const *vsSource = |
| 4266 | "#version 140\n" |
| 4267 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4268 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4269 | "\n" |
| 4270 | "void main(){\n" |
| 4271 | " gl_Position = vec4(1);\n" |
| 4272 | "}\n"; |
| 4273 | char const *fsSource = |
| 4274 | "#version 140\n" |
| 4275 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4276 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4277 | "\n" |
| 4278 | "layout(location=0) out vec4 color;\n" |
| 4279 | "void main(){\n" |
| 4280 | " color = vec4(1);\n" |
| 4281 | "}\n"; |
| 4282 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4283 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4284 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4285 | |
| 4286 | VkPipelineObj pipe(m_device); |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4287 | pipe.AddColorAttachment(); |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4288 | pipe.AddShader(&vs); |
| 4289 | pipe.AddShader(&fs); |
| 4290 | |
| 4291 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 4292 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 4293 | |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4294 | VkDescriptorSetObj descriptorSet(m_device); |
| 4295 | descriptorSet.AppendDummy(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4296 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4297 | |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4298 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4299 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4300 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4301 | FAIL() << "Did not receive Warning 'location 0 not consumed by VS'"; |
| 4302 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 8291c05 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4303 | } |
| 4304 | } |
| 4305 | |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4306 | TEST_F(VkLayerTest, CreatePipelineAttribNotProvided) |
| 4307 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4308 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4309 | "VS consumes input at location 0 but not provided"); |
| 4310 | |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4311 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4312 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4313 | |
| 4314 | char const *vsSource = |
| 4315 | "#version 140\n" |
| 4316 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4317 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4318 | "\n" |
| 4319 | "layout(location=0) in vec4 x;\n" /* not provided */ |
| 4320 | "void main(){\n" |
| 4321 | " gl_Position = x;\n" |
| 4322 | "}\n"; |
| 4323 | char const *fsSource = |
| 4324 | "#version 140\n" |
| 4325 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4326 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4327 | "\n" |
| 4328 | "layout(location=0) out vec4 color;\n" |
| 4329 | "void main(){\n" |
| 4330 | " color = vec4(1);\n" |
| 4331 | "}\n"; |
| 4332 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4333 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4334 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4335 | |
| 4336 | VkPipelineObj pipe(m_device); |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4337 | pipe.AddColorAttachment(); |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4338 | pipe.AddShader(&vs); |
| 4339 | pipe.AddShader(&fs); |
| 4340 | |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4341 | VkDescriptorSetObj descriptorSet(m_device); |
| 4342 | descriptorSet.AppendDummy(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4343 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4344 | |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4345 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4346 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4347 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4348 | FAIL() << "Did not receive Error 'VS consumes input at location 0 but not provided'"; |
| 4349 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 37367e6 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4350 | } |
| 4351 | } |
| 4352 | |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4353 | TEST_F(VkLayerTest, CreatePipelineAttribTypeMismatch) |
| 4354 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4355 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4356 | "location 0 does not match VS input type"); |
| 4357 | |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4358 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4359 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4360 | |
| 4361 | VkVertexInputBindingDescription input_binding; |
| 4362 | memset(&input_binding, 0, sizeof(input_binding)); |
| 4363 | |
| 4364 | VkVertexInputAttributeDescription input_attrib; |
| 4365 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 4366 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 4367 | |
| 4368 | char const *vsSource = |
| 4369 | "#version 140\n" |
| 4370 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4371 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4372 | "\n" |
| 4373 | "layout(location=0) in int x;\n" /* attrib provided float */ |
| 4374 | "void main(){\n" |
| 4375 | " gl_Position = vec4(x);\n" |
| 4376 | "}\n"; |
| 4377 | char const *fsSource = |
| 4378 | "#version 140\n" |
| 4379 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4380 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4381 | "\n" |
| 4382 | "layout(location=0) out vec4 color;\n" |
| 4383 | "void main(){\n" |
| 4384 | " color = vec4(1);\n" |
| 4385 | "}\n"; |
| 4386 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4387 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4388 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4389 | |
| 4390 | VkPipelineObj pipe(m_device); |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4391 | pipe.AddColorAttachment(); |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4392 | pipe.AddShader(&vs); |
| 4393 | pipe.AddShader(&fs); |
| 4394 | |
| 4395 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 4396 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 4397 | |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4398 | VkDescriptorSetObj descriptorSet(m_device); |
| 4399 | descriptorSet.AppendDummy(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4400 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4401 | |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4402 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4403 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4404 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4405 | FAIL() << "Did not receive Error 'location 0 does not match VS input type'"; |
| 4406 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | a4b0232 | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4407 | } |
| 4408 | } |
| 4409 | |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4410 | TEST_F(VkLayerTest, CreatePipelineAttribBindingConflict) |
| 4411 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4412 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4413 | "Duplicate vertex input binding descriptions for binding 0"); |
| 4414 | |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4415 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | f2f9740 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4416 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4417 | |
| 4418 | /* Two binding descriptions for binding 0 */ |
| 4419 | VkVertexInputBindingDescription input_bindings[2]; |
| 4420 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 4421 | |
| 4422 | VkVertexInputAttributeDescription input_attrib; |
| 4423 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 4424 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 4425 | |
| 4426 | char const *vsSource = |
| 4427 | "#version 140\n" |
| 4428 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4429 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4430 | "\n" |
| 4431 | "layout(location=0) in float x;\n" /* attrib provided float */ |
| 4432 | "void main(){\n" |
| 4433 | " gl_Position = vec4(x);\n" |
| 4434 | "}\n"; |
| 4435 | char const *fsSource = |
| 4436 | "#version 140\n" |
| 4437 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4438 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4439 | "\n" |
| 4440 | "layout(location=0) out vec4 color;\n" |
| 4441 | "void main(){\n" |
| 4442 | " color = vec4(1);\n" |
| 4443 | "}\n"; |
| 4444 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4445 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4446 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4447 | |
| 4448 | VkPipelineObj pipe(m_device); |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4449 | pipe.AddColorAttachment(); |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4450 | pipe.AddShader(&vs); |
| 4451 | pipe.AddShader(&fs); |
| 4452 | |
| 4453 | pipe.AddVertexInputBindings(input_bindings, 2); |
| 4454 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 4455 | |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4456 | VkDescriptorSetObj descriptorSet(m_device); |
| 4457 | descriptorSet.AppendDummy(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4458 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4459 | |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4460 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4461 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4462 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4463 | FAIL() << "Did not receive Error 'Duplicate vertex input binding descriptions for binding 0'"; |
| 4464 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 0bf8fe1 | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4465 | } |
| 4466 | } |
Chris Forbes | 4c94870 | 2015-05-25 11:13:32 +1200 | [diff] [blame] | 4467 | |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4468 | /* TODO: would be nice to test the mixed broadcast & custom case, but the GLSL->SPV compiler |
| 4469 | * rejects it. */ |
| 4470 | |
| 4471 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotWritten) |
| 4472 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4473 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4474 | "Attachment 0 not written by FS"); |
| 4475 | |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4476 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4477 | |
| 4478 | char const *vsSource = |
| 4479 | "#version 140\n" |
| 4480 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4481 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4482 | "\n" |
| 4483 | "void main(){\n" |
| 4484 | " gl_Position = vec4(1);\n" |
| 4485 | "}\n"; |
| 4486 | char const *fsSource = |
| 4487 | "#version 140\n" |
| 4488 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4489 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4490 | "\n" |
| 4491 | "void main(){\n" |
| 4492 | "}\n"; |
| 4493 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4494 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4495 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4496 | |
| 4497 | VkPipelineObj pipe(m_device); |
| 4498 | pipe.AddShader(&vs); |
| 4499 | pipe.AddShader(&fs); |
| 4500 | |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4501 | /* set up CB 0, not written */ |
| 4502 | pipe.AddColorAttachment(); |
| 4503 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4504 | |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4505 | VkDescriptorSetObj descriptorSet(m_device); |
| 4506 | descriptorSet.AppendDummy(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4507 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4508 | |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4509 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4510 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4511 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4512 | FAIL() << "Did not receive Error 'Attachment 0 not written by FS'"; |
| 4513 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | c12ef12 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4514 | } |
| 4515 | } |
| 4516 | |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4517 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotConsumed) |
| 4518 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4519 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_WARN_BIT, |
| 4520 | "FS writes to output location 1 with no matching attachment"); |
| 4521 | |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4522 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4523 | |
| 4524 | char const *vsSource = |
| 4525 | "#version 140\n" |
| 4526 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4527 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4528 | "\n" |
| 4529 | "void main(){\n" |
| 4530 | " gl_Position = vec4(1);\n" |
| 4531 | "}\n"; |
| 4532 | char const *fsSource = |
| 4533 | "#version 140\n" |
| 4534 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4535 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4536 | "\n" |
| 4537 | "layout(location=0) out vec4 x;\n" |
| 4538 | "layout(location=1) out vec4 y;\n" /* no matching attachment for this */ |
| 4539 | "void main(){\n" |
| 4540 | " x = vec4(1);\n" |
| 4541 | " y = vec4(1);\n" |
| 4542 | "}\n"; |
| 4543 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4544 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4545 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4546 | |
| 4547 | VkPipelineObj pipe(m_device); |
| 4548 | pipe.AddShader(&vs); |
| 4549 | pipe.AddShader(&fs); |
| 4550 | |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4551 | /* set up CB 0, not written */ |
| 4552 | pipe.AddColorAttachment(); |
| 4553 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4554 | /* FS writes CB 1, but we don't configure it */ |
| 4555 | |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4556 | VkDescriptorSetObj descriptorSet(m_device); |
| 4557 | descriptorSet.AppendDummy(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4558 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4559 | |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4560 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4561 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4562 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4563 | FAIL() << "Did not receive Error 'FS writes to output location 1 with no matching attachment'"; |
| 4564 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 5d15a4f | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4565 | } |
| 4566 | } |
| 4567 | |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4568 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputTypeMismatch) |
| 4569 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4570 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4571 | "does not match FS output type"); |
| 4572 | |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4573 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4574 | |
| 4575 | char const *vsSource = |
| 4576 | "#version 140\n" |
| 4577 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4578 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4579 | "\n" |
| 4580 | "void main(){\n" |
| 4581 | " gl_Position = vec4(1);\n" |
| 4582 | "}\n"; |
| 4583 | char const *fsSource = |
| 4584 | "#version 140\n" |
| 4585 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4586 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4587 | "\n" |
| 4588 | "layout(location=0) out ivec4 x;\n" /* not UNORM */ |
| 4589 | "void main(){\n" |
| 4590 | " x = ivec4(1);\n" |
| 4591 | "}\n"; |
| 4592 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4593 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4594 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4595 | |
| 4596 | VkPipelineObj pipe(m_device); |
| 4597 | pipe.AddShader(&vs); |
| 4598 | pipe.AddShader(&fs); |
| 4599 | |
Chia-I Wu | c278df8 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4600 | /* set up CB 0; type is UNORM by default */ |
| 4601 | pipe.AddColorAttachment(); |
| 4602 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4603 | |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4604 | VkDescriptorSetObj descriptorSet(m_device); |
| 4605 | descriptorSet.AppendDummy(); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4606 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4607 | |
Tony Barbour | ed13243 | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4608 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4609 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4610 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4611 | FAIL() << "Did not receive Error 'does not match FS output type'"; |
| 4612 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4613 | } |
| 4614 | } |
Chris Forbes | c205073 | 2015-06-05 14:43:36 +1200 | [diff] [blame] | 4615 | |
Chris Forbes | 76ce788 | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 4616 | TEST_F(VkLayerTest, CreatePipelineUniformBlockNotProvided) |
| 4617 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4618 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4619 | "not declared in pipeline layout"); |
| 4620 | |
Chris Forbes | 76ce788 | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 4621 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 76ce788 | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 4622 | |
| 4623 | char const *vsSource = |
| 4624 | "#version 140\n" |
| 4625 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4626 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4627 | "\n" |
| 4628 | "void main(){\n" |
| 4629 | " gl_Position = vec4(1);\n" |
| 4630 | "}\n"; |
| 4631 | char const *fsSource = |
| 4632 | "#version 140\n" |
| 4633 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4634 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4635 | "\n" |
| 4636 | "layout(location=0) out vec4 x;\n" |
| 4637 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 4638 | "void main(){\n" |
| 4639 | " x = vec4(bar.y);\n" |
| 4640 | "}\n"; |
| 4641 | |
Chris Forbes | 76ce788 | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 4642 | |
Courtney Goeltzenleuchter | 8e2f097 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4643 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4644 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 76ce788 | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 4645 | |
Chris Forbes | 76ce788 | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 4646 | VkPipelineObj pipe(m_device); |
| 4647 | pipe.AddShader(&vs); |
| 4648 | pipe.AddShader(&fs); |
| 4649 | |
| 4650 | /* set up CB 0; type is UNORM by default */ |
| 4651 | pipe.AddColorAttachment(); |
| 4652 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4653 | |
| 4654 | VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4655 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 76ce788 | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 4656 | |
| 4657 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 4658 | |
| 4659 | /* should have generated an error -- pipeline layout does not |
| 4660 | * provide a uniform buffer in 0.0 |
| 4661 | */ |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4662 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4663 | FAIL() << "Did not receive Error 'not declared in pipeline layout'"; |
| 4664 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 76ce788 | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 4665 | } |
| 4666 | } |
| 4667 | |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4668 | #endif // SHADER_CHECKER_TESTS |
| 4669 | |
| 4670 | #if DEVICE_LIMITS_TESTS |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4671 | TEST_F(VkLayerTest, CreateImageLimitsViolationWidth) |
| 4672 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4673 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4674 | "CreateImage extents exceed allowable limits for format"); |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4675 | |
| 4676 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4677 | |
| 4678 | // Create an image |
| 4679 | VkImage image; |
| 4680 | |
| 4681 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 4682 | const int32_t tex_width = 32; |
| 4683 | const int32_t tex_height = 32; |
| 4684 | |
| 4685 | VkImageCreateInfo image_create_info = {}; |
| 4686 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4687 | image_create_info.pNext = NULL; |
| 4688 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4689 | image_create_info.format = tex_format; |
| 4690 | image_create_info.extent.width = tex_width; |
| 4691 | image_create_info.extent.height = tex_height; |
| 4692 | image_create_info.extent.depth = 1; |
| 4693 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 4694 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4695 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4696 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 4697 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 4698 | image_create_info.flags = 0; |
| 4699 | |
| 4700 | // Introduce error by sending down a bogus width extent |
| 4701 | image_create_info.extent.width = 65536; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4702 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4703 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4704 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4705 | FAIL() << "Did not receive Error 'CreateImage extents exceed allowable limits for format'"; |
| 4706 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4707 | } |
| 4708 | } |
| 4709 | |
| 4710 | TEST_F(VkLayerTest, CreateImageResourceSizeViolation) |
| 4711 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4712 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4713 | "CreateImage resource size exceeds allowable maximum"); |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4714 | |
| 4715 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4716 | |
| 4717 | // Create an image |
| 4718 | VkImage image; |
| 4719 | |
| 4720 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 4721 | const int32_t tex_width = 32; |
| 4722 | const int32_t tex_height = 32; |
| 4723 | |
| 4724 | VkImageCreateInfo image_create_info = {}; |
| 4725 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4726 | image_create_info.pNext = NULL; |
| 4727 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4728 | image_create_info.format = tex_format; |
| 4729 | image_create_info.extent.width = tex_width; |
| 4730 | image_create_info.extent.height = tex_height; |
| 4731 | image_create_info.extent.depth = 1; |
| 4732 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 4733 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4734 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4735 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 4736 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 4737 | image_create_info.flags = 0; |
| 4738 | |
| 4739 | // Introduce error by sending down individually allowable values that result in a surface size |
| 4740 | // exceeding the device maximum |
| 4741 | image_create_info.extent.width = 8192; |
| 4742 | image_create_info.extent.height = 8192; |
| 4743 | image_create_info.extent.depth = 16; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 4744 | image_create_info.arrayLayers = 4; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4745 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4746 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4747 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4748 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4749 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4750 | FAIL() << "Did not receive Error 'CreateImage resource size exceeds allowable maximum'"; |
| 4751 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | ddaecf8 | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4752 | } |
| 4753 | } |
| 4754 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4755 | TEST_F(VkLayerTest, UpdateBufferAlignment) |
| 4756 | { |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4757 | uint32_t updateData[] = { 1, 2, 3, 4, 5, 6, 7, 8 }; |
| 4758 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4759 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4760 | "dstOffset, is not a multiple of 4"); |
| 4761 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4762 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4763 | |
| 4764 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 4765 | vk_testing::Buffer buffer; |
| 4766 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 4767 | |
| 4768 | BeginCommandBuffer(); |
| 4769 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4770 | m_commandBuffer->UpdateBuffer(buffer.handle(), 1, 4, updateData); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4771 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4772 | FAIL() << "Did not receive Error 'vkCommandUpdateBuffer parameter, VkDeviceSize dstOffset, is not a multiple of 4'"; |
| 4773 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4774 | } |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4775 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4776 | // Introduce failure by using size that is not multiple of 4 |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4777 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4778 | "dataSize, is not a multiple of 4"); |
| 4779 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4780 | m_commandBuffer->UpdateBuffer(buffer.handle(), 0, 6, updateData); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4781 | |
| 4782 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4783 | FAIL() << "Did not receive Error 'vkCommandUpdateBuffer parameter, VkDeviceSize dataSize, is not a multiple of 4'"; |
| 4784 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4785 | } |
| 4786 | EndCommandBuffer(); |
| 4787 | } |
| 4788 | |
| 4789 | TEST_F(VkLayerTest, FillBufferAlignment) |
| 4790 | { |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4791 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4792 | "dstOffset, is not a multiple of 4"); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4793 | |
| 4794 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4795 | |
| 4796 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 4797 | vk_testing::Buffer buffer; |
| 4798 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 4799 | |
| 4800 | BeginCommandBuffer(); |
| 4801 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4802 | m_commandBuffer->FillBuffer(buffer.handle(), 1, 4, 0x11111111); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4803 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4804 | FAIL() << "Did not receive Error 'vkCommandFillBuffer parameter, VkDeviceSize dstOffset, is not a multiple of 4'"; |
| 4805 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4806 | } |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4807 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4808 | // Introduce failure by using size that is not multiple of 4 |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4809 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4810 | "size, is not a multiple of 4"); |
| 4811 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4812 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 6, 0x11111111); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4813 | |
| 4814 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4815 | FAIL() << "Did not receive Error 'vkCommandFillBuffer parameter, VkDeviceSize size, is not a multiple of 4'"; |
| 4816 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4817 | } |
| 4818 | EndCommandBuffer(); |
| 4819 | } |
| 4820 | |
Mark Lobodzinski | c11cd2c | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4821 | #endif // DEVICE_LIMITS_TESTS |
Chris Forbes | 7d64a4f | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4822 | |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4823 | #if IMAGE_TESTS |
| 4824 | TEST_F(VkLayerTest, InvalidImageView) |
| 4825 | { |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4826 | VkResult err; |
| 4827 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4828 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4829 | "vkCreateImageView called with baseMipLevel 10 "); |
| 4830 | |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4831 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4832 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4833 | // Create an image and try to create a view with bad baseMipLevel |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4834 | VkImage image; |
| 4835 | |
| 4836 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 4837 | const int32_t tex_width = 32; |
| 4838 | const int32_t tex_height = 32; |
| 4839 | |
| 4840 | VkImageCreateInfo image_create_info = {}; |
| 4841 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4842 | image_create_info.pNext = NULL; |
| 4843 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4844 | image_create_info.format = tex_format; |
| 4845 | image_create_info.extent.width = tex_width; |
| 4846 | image_create_info.extent.height = tex_height; |
| 4847 | image_create_info.extent.depth = 1; |
| 4848 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 4849 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4850 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4851 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 4852 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 4853 | image_create_info.flags = 0; |
| 4854 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4855 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4856 | ASSERT_VK_SUCCESS(err); |
| 4857 | |
| 4858 | VkImageViewCreateInfo image_view_create_info = {}; |
| 4859 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4860 | image_view_create_info.image = image; |
| 4861 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 4862 | image_view_create_info.format = tex_format; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4863 | image_view_create_info.subresourceRange.layerCount = 1; |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4864 | image_view_create_info.subresourceRange.baseMipLevel = 10; // cause an error |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4865 | image_view_create_info.subresourceRange.levelCount = 1; |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 4866 | image_view_create_info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4867 | |
| 4868 | VkImageView view; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4869 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, &view); |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4870 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4871 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4872 | FAIL() << "Did not receive Error 'vkCreateImageView called with baseMipLevel 10...'"; |
| 4873 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4874 | } |
| 4875 | } |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4876 | |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 4877 | TEST_F(VkLayerTest, InvalidImageViewAspect) |
| 4878 | { |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 4879 | VkResult err; |
| 4880 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4881 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4882 | "vkCreateImageView: Color image formats must have ONLY the VK_IMAGE_ASPECT_COLOR_BIT set"); |
| 4883 | |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 4884 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 4885 | |
| 4886 | // Create an image and try to create a view with an invalid aspectMask |
| 4887 | VkImage image; |
| 4888 | |
| 4889 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 4890 | const int32_t tex_width = 32; |
| 4891 | const int32_t tex_height = 32; |
| 4892 | |
| 4893 | VkImageCreateInfo image_create_info = {}; |
| 4894 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4895 | image_create_info.pNext = NULL; |
| 4896 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4897 | image_create_info.format = tex_format; |
| 4898 | image_create_info.extent.width = tex_width; |
| 4899 | image_create_info.extent.height = tex_height; |
| 4900 | image_create_info.extent.depth = 1; |
| 4901 | image_create_info.mipLevels = 1; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4902 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 4903 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 4904 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 4905 | image_create_info.flags = 0; |
| 4906 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4907 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 4908 | ASSERT_VK_SUCCESS(err); |
| 4909 | |
| 4910 | VkImageViewCreateInfo image_view_create_info = {}; |
| 4911 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4912 | image_view_create_info.image = image; |
| 4913 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 4914 | image_view_create_info.format = tex_format; |
| 4915 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4916 | image_view_create_info.subresourceRange.levelCount = 1; |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 4917 | // Cause an error by setting an invalid image aspect |
| 4918 | image_view_create_info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_METADATA_BIT; |
| 4919 | |
| 4920 | VkImageView view; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4921 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, &view); |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 4922 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4923 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4924 | FAIL() << "Did not receive Error 'VkCreateImageView: Color image formats must have ...'"; |
| 4925 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | b4092de | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 4926 | } |
| 4927 | } |
| 4928 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4929 | TEST_F(VkLayerTest, CopyImageTypeMismatch) |
| 4930 | { |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4931 | VkResult err; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 4932 | bool pass; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4933 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4934 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4935 | "vkCmdCopyImage called with unmatched source and dest image types"); |
| 4936 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4937 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4938 | |
| 4939 | // Create two images of different types and try to copy between them |
| 4940 | VkImage srcImage; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4941 | VkImage dstImage; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4942 | VkDeviceMemory srcMem; |
| 4943 | VkDeviceMemory destMem; |
| 4944 | VkMemoryRequirements memReqs; |
| 4945 | |
| 4946 | VkImageCreateInfo image_create_info = {}; |
| 4947 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4948 | image_create_info.pNext = NULL; |
| 4949 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4950 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 4951 | image_create_info.extent.width = 32; |
| 4952 | image_create_info.extent.height = 32; |
| 4953 | image_create_info.extent.depth = 1; |
| 4954 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 4955 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4956 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4957 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4958 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4959 | image_create_info.flags = 0; |
| 4960 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4961 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4962 | ASSERT_VK_SUCCESS(err); |
| 4963 | |
| 4964 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4965 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4966 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4967 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4968 | ASSERT_VK_SUCCESS(err); |
| 4969 | |
| 4970 | // Allocate memory |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4971 | VkMemoryAllocateInfo memAlloc = {}; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4972 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 4973 | memAlloc.pNext = NULL; |
| 4974 | memAlloc.allocationSize = 0; |
| 4975 | memAlloc.memoryTypeIndex = 0; |
| 4976 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 4977 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4978 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 4979 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 4980 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4981 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4982 | ASSERT_VK_SUCCESS(err); |
| 4983 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4984 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4985 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 4986 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4987 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4988 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4989 | ASSERT_VK_SUCCESS(err); |
| 4990 | |
| 4991 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 4992 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4993 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4994 | ASSERT_VK_SUCCESS(err); |
| 4995 | |
| 4996 | BeginCommandBuffer(); |
| 4997 | VkImageCopy copyRegion; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 4998 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4999 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 63f0ead | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5000 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5001 | copyRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5002 | copyRegion.srcOffset.x = 0; |
| 5003 | copyRegion.srcOffset.y = 0; |
| 5004 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5005 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5006 | copyRegion.dstSubresource.mipLevel = 0; |
| 5007 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 5008 | copyRegion.dstSubresource.layerCount = 0; |
| 5009 | copyRegion.dstOffset.x = 0; |
| 5010 | copyRegion.dstOffset.y = 0; |
| 5011 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5012 | copyRegion.extent.width = 1; |
| 5013 | copyRegion.extent.height = 1; |
| 5014 | copyRegion.extent.depth = 1; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5015 | 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] | 5016 | EndCommandBuffer(); |
| 5017 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5018 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5019 | FAIL() << "Did not receive Error 'vkCmdCopyImage called with unmatched source and dest image types'"; |
| 5020 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5021 | } |
| 5022 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5023 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5024 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5025 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 5026 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5027 | } |
| 5028 | |
| 5029 | TEST_F(VkLayerTest, CopyImageFormatSizeMismatch) |
| 5030 | { |
| 5031 | // TODO : Create two images with different format sizes and vkCmdCopyImage between them |
| 5032 | } |
| 5033 | |
| 5034 | TEST_F(VkLayerTest, CopyImageDepthStencilFormatMismatch) |
| 5035 | { |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5036 | VkResult err; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5037 | bool pass; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5038 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5039 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 5040 | "vkCmdCopyImage called with unmatched source and dest image types"); |
| 5041 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5042 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5043 | |
| 5044 | // Create two images of different types and try to copy between them |
| 5045 | VkImage srcImage; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5046 | VkImage dstImage; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5047 | VkDeviceMemory srcMem; |
| 5048 | VkDeviceMemory destMem; |
| 5049 | VkMemoryRequirements memReqs; |
| 5050 | |
| 5051 | VkImageCreateInfo image_create_info = {}; |
| 5052 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5053 | image_create_info.pNext = NULL; |
| 5054 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5055 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5056 | image_create_info.extent.width = 32; |
| 5057 | image_create_info.extent.height = 32; |
| 5058 | image_create_info.extent.depth = 1; |
| 5059 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 5060 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5061 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5062 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5063 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5064 | image_create_info.flags = 0; |
| 5065 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5066 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5067 | ASSERT_VK_SUCCESS(err); |
| 5068 | |
| 5069 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5070 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5071 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5072 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5073 | ASSERT_VK_SUCCESS(err); |
| 5074 | |
| 5075 | // Allocate memory |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5076 | VkMemoryAllocateInfo memAlloc = {}; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5077 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 5078 | memAlloc.pNext = NULL; |
| 5079 | memAlloc.allocationSize = 0; |
| 5080 | memAlloc.memoryTypeIndex = 0; |
| 5081 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 5082 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5083 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5084 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5085 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5086 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5087 | ASSERT_VK_SUCCESS(err); |
| 5088 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5089 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5090 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5091 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5092 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5093 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5094 | ASSERT_VK_SUCCESS(err); |
| 5095 | |
| 5096 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 5097 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5098 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5099 | ASSERT_VK_SUCCESS(err); |
| 5100 | |
| 5101 | BeginCommandBuffer(); |
| 5102 | VkImageCopy copyRegion; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5103 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5104 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 63f0ead | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5105 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5106 | copyRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5107 | copyRegion.srcOffset.x = 0; |
| 5108 | copyRegion.srcOffset.y = 0; |
| 5109 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5110 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5111 | copyRegion.dstSubresource.mipLevel = 0; |
| 5112 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 5113 | copyRegion.dstSubresource.layerCount = 0; |
| 5114 | copyRegion.dstOffset.x = 0; |
| 5115 | copyRegion.dstOffset.y = 0; |
| 5116 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5117 | copyRegion.extent.width = 1; |
| 5118 | copyRegion.extent.height = 1; |
| 5119 | copyRegion.extent.depth = 1; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5120 | 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] | 5121 | EndCommandBuffer(); |
| 5122 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5123 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5124 | FAIL() << "Did not receive Error 'vkCmdCopyImage called with unmatched source and dest image types'"; |
| 5125 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5126 | } |
| 5127 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5128 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5129 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5130 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 5131 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5132 | } |
| 5133 | |
| 5134 | TEST_F(VkLayerTest, ResolveImageLowSampleCount) |
| 5135 | { |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5136 | VkResult err; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5137 | bool pass; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5138 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5139 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 5140 | "vkCmdResolveImage called with source sample count less than 2."); |
| 5141 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5142 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5143 | |
| 5144 | // Create two images of sample count 1 and try to Resolve between them |
| 5145 | VkImage srcImage; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5146 | VkImage dstImage; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5147 | VkDeviceMemory srcMem; |
| 5148 | VkDeviceMemory destMem; |
| 5149 | VkMemoryRequirements memReqs; |
| 5150 | |
| 5151 | VkImageCreateInfo image_create_info = {}; |
| 5152 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5153 | image_create_info.pNext = NULL; |
| 5154 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5155 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5156 | image_create_info.extent.width = 32; |
| 5157 | image_create_info.extent.height = 1; |
| 5158 | image_create_info.extent.depth = 1; |
| 5159 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 5160 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5161 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5162 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5163 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5164 | image_create_info.flags = 0; |
| 5165 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5166 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5167 | ASSERT_VK_SUCCESS(err); |
| 5168 | |
| 5169 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5170 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5171 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5172 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5173 | ASSERT_VK_SUCCESS(err); |
| 5174 | |
| 5175 | // Allocate memory |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5176 | VkMemoryAllocateInfo memAlloc = {}; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5177 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 5178 | memAlloc.pNext = NULL; |
| 5179 | memAlloc.allocationSize = 0; |
| 5180 | memAlloc.memoryTypeIndex = 0; |
| 5181 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 5182 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5183 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5184 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5185 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5186 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5187 | ASSERT_VK_SUCCESS(err); |
| 5188 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5189 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5190 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5191 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5192 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5193 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5194 | ASSERT_VK_SUCCESS(err); |
| 5195 | |
| 5196 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 5197 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5198 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5199 | ASSERT_VK_SUCCESS(err); |
| 5200 | |
| 5201 | BeginCommandBuffer(); |
| 5202 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
| 5203 | //VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 5204 | //VK_IMAGE_LAYOUT_GENERAL = 1, |
| 5205 | VkImageResolve resolveRegion; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5206 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5207 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 63f0ead | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5208 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5209 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5210 | resolveRegion.srcOffset.x = 0; |
| 5211 | resolveRegion.srcOffset.y = 0; |
| 5212 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5213 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5214 | resolveRegion.dstSubresource.mipLevel = 0; |
| 5215 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 5216 | resolveRegion.dstSubresource.layerCount = 0; |
| 5217 | resolveRegion.dstOffset.x = 0; |
| 5218 | resolveRegion.dstOffset.y = 0; |
| 5219 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5220 | resolveRegion.extent.width = 1; |
| 5221 | resolveRegion.extent.height = 1; |
| 5222 | resolveRegion.extent.depth = 1; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5223 | 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] | 5224 | EndCommandBuffer(); |
| 5225 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5226 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5227 | FAIL() << "Did not receive Error 'vkCmdResolveImage called with source sample count less than 2.'"; |
| 5228 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5229 | } |
| 5230 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5231 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5232 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5233 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 5234 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5235 | } |
| 5236 | |
| 5237 | TEST_F(VkLayerTest, ResolveImageHighSampleCount) |
| 5238 | { |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5239 | VkResult err; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5240 | bool pass; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5241 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5242 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 5243 | "vkCmdResolveImage called with dest sample count greater than 1."); |
| 5244 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5245 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5246 | |
| 5247 | // Create two images of sample count 2 and try to Resolve between them |
| 5248 | VkImage srcImage; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5249 | VkImage dstImage; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5250 | VkDeviceMemory srcMem; |
| 5251 | VkDeviceMemory destMem; |
| 5252 | VkMemoryRequirements memReqs; |
| 5253 | |
| 5254 | VkImageCreateInfo image_create_info = {}; |
| 5255 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5256 | image_create_info.pNext = NULL; |
| 5257 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5258 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5259 | image_create_info.extent.width = 32; |
| 5260 | image_create_info.extent.height = 1; |
| 5261 | image_create_info.extent.depth = 1; |
| 5262 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 5263 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5264 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5265 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
Cody Northrop | b3bf94f | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 5266 | // Note: Some implementations expect color attachment usage for any multisample surface |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5267 | 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] | 5268 | image_create_info.flags = 0; |
| 5269 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5270 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5271 | ASSERT_VK_SUCCESS(err); |
| 5272 | |
| 5273 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
Cody Northrop | b3bf94f | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 5274 | // Note: Some implementations expect color attachment usage for any multisample surface |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5275 | 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] | 5276 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5277 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5278 | ASSERT_VK_SUCCESS(err); |
| 5279 | |
| 5280 | // Allocate memory |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5281 | VkMemoryAllocateInfo memAlloc = {}; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5282 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 5283 | memAlloc.pNext = NULL; |
| 5284 | memAlloc.allocationSize = 0; |
| 5285 | memAlloc.memoryTypeIndex = 0; |
| 5286 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 5287 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5288 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5289 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5290 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5291 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5292 | ASSERT_VK_SUCCESS(err); |
| 5293 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5294 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5295 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5296 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5297 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5298 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5299 | ASSERT_VK_SUCCESS(err); |
| 5300 | |
| 5301 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 5302 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5303 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5304 | ASSERT_VK_SUCCESS(err); |
| 5305 | |
| 5306 | BeginCommandBuffer(); |
| 5307 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
| 5308 | //VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 5309 | //VK_IMAGE_LAYOUT_GENERAL = 1, |
| 5310 | VkImageResolve resolveRegion; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5311 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5312 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 63f0ead | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5313 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5314 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5315 | resolveRegion.srcOffset.x = 0; |
| 5316 | resolveRegion.srcOffset.y = 0; |
| 5317 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5318 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5319 | resolveRegion.dstSubresource.mipLevel = 0; |
| 5320 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 5321 | resolveRegion.dstSubresource.layerCount = 0; |
| 5322 | resolveRegion.dstOffset.x = 0; |
| 5323 | resolveRegion.dstOffset.y = 0; |
| 5324 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5325 | resolveRegion.extent.width = 1; |
| 5326 | resolveRegion.extent.height = 1; |
| 5327 | resolveRegion.extent.depth = 1; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5328 | 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] | 5329 | EndCommandBuffer(); |
| 5330 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5331 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5332 | FAIL() << "Did not receive Error 'vkCmdResolveImage called with dest sample count greater than 1.'"; |
| 5333 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5334 | } |
| 5335 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5336 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5337 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5338 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 5339 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5340 | } |
| 5341 | |
| 5342 | TEST_F(VkLayerTest, ResolveImageFormatMismatch) |
| 5343 | { |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5344 | VkResult err; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5345 | bool pass; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5346 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5347 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 5348 | "vkCmdResolveImage called with unmatched source and dest formats."); |
| 5349 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5350 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5351 | |
| 5352 | // Create two images of different types and try to copy between them |
| 5353 | VkImage srcImage; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5354 | VkImage dstImage; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5355 | VkDeviceMemory srcMem; |
| 5356 | VkDeviceMemory destMem; |
| 5357 | VkMemoryRequirements memReqs; |
| 5358 | |
| 5359 | VkImageCreateInfo image_create_info = {}; |
| 5360 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5361 | image_create_info.pNext = NULL; |
| 5362 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5363 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5364 | image_create_info.extent.width = 32; |
| 5365 | image_create_info.extent.height = 1; |
| 5366 | image_create_info.extent.depth = 1; |
| 5367 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 5368 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5369 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5370 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
Cody Northrop | b3bf94f | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 5371 | // Note: Some implementations expect color attachment usage for any multisample surface |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5372 | 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] | 5373 | image_create_info.flags = 0; |
| 5374 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5375 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5376 | ASSERT_VK_SUCCESS(err); |
| 5377 | |
Cody Northrop | b3bf94f | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 5378 | // Set format to something other than source image |
| 5379 | image_create_info.format = VK_FORMAT_R32_SFLOAT; |
| 5380 | // Note: Some implementations expect color attachment usage for any multisample surface |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5381 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5382 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5383 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5384 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5385 | ASSERT_VK_SUCCESS(err); |
| 5386 | |
| 5387 | // Allocate memory |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5388 | VkMemoryAllocateInfo memAlloc = {}; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5389 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 5390 | memAlloc.pNext = NULL; |
| 5391 | memAlloc.allocationSize = 0; |
| 5392 | memAlloc.memoryTypeIndex = 0; |
| 5393 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 5394 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &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, &srcMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5399 | ASSERT_VK_SUCCESS(err); |
| 5400 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5401 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5402 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5403 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5404 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5405 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5406 | ASSERT_VK_SUCCESS(err); |
| 5407 | |
| 5408 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 5409 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5410 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5411 | ASSERT_VK_SUCCESS(err); |
| 5412 | |
| 5413 | BeginCommandBuffer(); |
| 5414 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
| 5415 | //VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 5416 | //VK_IMAGE_LAYOUT_GENERAL = 1, |
| 5417 | VkImageResolve resolveRegion; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5418 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5419 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 63f0ead | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5420 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5421 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5422 | resolveRegion.srcOffset.x = 0; |
| 5423 | resolveRegion.srcOffset.y = 0; |
| 5424 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5425 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5426 | resolveRegion.dstSubresource.mipLevel = 0; |
| 5427 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 5428 | resolveRegion.dstSubresource.layerCount = 0; |
| 5429 | resolveRegion.dstOffset.x = 0; |
| 5430 | resolveRegion.dstOffset.y = 0; |
| 5431 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5432 | resolveRegion.extent.width = 1; |
| 5433 | resolveRegion.extent.height = 1; |
| 5434 | resolveRegion.extent.depth = 1; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5435 | 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] | 5436 | EndCommandBuffer(); |
| 5437 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5438 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5439 | FAIL() << "Did not receive Error 'vkCmdResolveImage called with unmatched source and dest formats.'"; |
| 5440 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5441 | } |
| 5442 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5443 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5444 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5445 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 5446 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5447 | } |
| 5448 | |
| 5449 | TEST_F(VkLayerTest, ResolveImageTypeMismatch) |
| 5450 | { |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5451 | VkResult err; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5452 | bool pass; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5453 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5454 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 5455 | "vkCmdResolveImage called with unmatched source and dest image types."); |
| 5456 | |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5457 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5458 | |
| 5459 | // Create two images of different types and try to copy between them |
| 5460 | VkImage srcImage; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5461 | VkImage dstImage; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5462 | VkDeviceMemory srcMem; |
| 5463 | VkDeviceMemory destMem; |
| 5464 | VkMemoryRequirements memReqs; |
| 5465 | |
| 5466 | VkImageCreateInfo image_create_info = {}; |
| 5467 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5468 | image_create_info.pNext = NULL; |
| 5469 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5470 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5471 | image_create_info.extent.width = 32; |
| 5472 | image_create_info.extent.height = 1; |
| 5473 | image_create_info.extent.depth = 1; |
| 5474 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 2ebc234 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 5475 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5476 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5477 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
Cody Northrop | b3bf94f | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 5478 | // Note: Some implementations expect color attachment usage for any multisample surface |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5479 | 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] | 5480 | image_create_info.flags = 0; |
| 5481 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5482 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5483 | ASSERT_VK_SUCCESS(err); |
| 5484 | |
| 5485 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
Cody Northrop | b3bf94f | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 5486 | // Note: Some implementations expect color attachment usage for any multisample surface |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5487 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5488 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5489 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5490 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5491 | ASSERT_VK_SUCCESS(err); |
| 5492 | |
| 5493 | // Allocate memory |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5494 | VkMemoryAllocateInfo memAlloc = {}; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5495 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 5496 | memAlloc.pNext = NULL; |
| 5497 | memAlloc.allocationSize = 0; |
| 5498 | memAlloc.memoryTypeIndex = 0; |
| 5499 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 5500 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5501 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5502 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5503 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5504 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5505 | ASSERT_VK_SUCCESS(err); |
| 5506 | |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5507 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5508 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 37a43a6 | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5509 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5510 | ASSERT_TRUE(pass); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5511 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5512 | ASSERT_VK_SUCCESS(err); |
| 5513 | |
| 5514 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 5515 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5516 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5517 | ASSERT_VK_SUCCESS(err); |
| 5518 | |
| 5519 | BeginCommandBuffer(); |
| 5520 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
| 5521 | //VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 5522 | //VK_IMAGE_LAYOUT_GENERAL = 1, |
| 5523 | VkImageResolve resolveRegion; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5524 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5525 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 63f0ead | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5526 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5527 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5528 | resolveRegion.srcOffset.x = 0; |
| 5529 | resolveRegion.srcOffset.y = 0; |
| 5530 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | 4291d88 | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5531 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5532 | resolveRegion.dstSubresource.mipLevel = 0; |
| 5533 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 5534 | resolveRegion.dstSubresource.layerCount = 0; |
| 5535 | resolveRegion.dstOffset.x = 0; |
| 5536 | resolveRegion.dstOffset.y = 0; |
| 5537 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5538 | resolveRegion.extent.width = 1; |
| 5539 | resolveRegion.extent.height = 1; |
| 5540 | resolveRegion.extent.depth = 1; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5541 | 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] | 5542 | EndCommandBuffer(); |
| 5543 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5544 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5545 | FAIL() << "Did not receive Error 'vkCmdResolveImage called with unmatched source and dest image types.'"; |
| 5546 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5547 | } |
| 5548 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5549 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5550 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5551 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 5552 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | 43909d8 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5553 | } |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5554 | |
| 5555 | TEST_F(VkLayerTest, DepthStencilImageViewWithColorAspectBitError) |
| 5556 | { |
| 5557 | // Create a single Image descriptor and cause it to first hit an error due |
| 5558 | // to using a DS format, then cause it to hit error due to COLOR_BIT not set in aspect |
| 5559 | // The image format check comes 2nd in validation so we trigger it first, |
| 5560 | // 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] | 5561 | VkResult err; |
| 5562 | |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5563 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 5564 | "Combination depth/stencil image formats can have only the "); |
| 5565 | |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5566 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5567 | |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5568 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5569 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5570 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5571 | |
| 5572 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 5573 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5574 | ds_pool_ci.pNext = NULL; |
| 5575 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | c51b121 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5576 | ds_pool_ci.poolSizeCount = 1; |
| 5577 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5578 | |
| 5579 | VkDescriptorPool ds_pool; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5580 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5581 | ASSERT_VK_SUCCESS(err); |
| 5582 | |
| 5583 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | b5689ee | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5584 | dsl_binding.binding = 0; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5585 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
Chia-I Wu | 045654f | 2015-11-06 06:42:02 +0800 | [diff] [blame] | 5586 | dsl_binding.descriptorCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5587 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5588 | dsl_binding.pImmutableSamplers = NULL; |
| 5589 | |
| 5590 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 5591 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5592 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5593 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | f03cbf7 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5594 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5595 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5596 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5597 | ASSERT_VK_SUCCESS(err); |
| 5598 | |
| 5599 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5600 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5601 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | 763a749 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5602 | alloc_info.setLayoutCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5603 | alloc_info.descriptorPool = ds_pool; |
| 5604 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5605 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5606 | ASSERT_VK_SUCCESS(err); |
| 5607 | |
| 5608 | VkImage image_bad; |
| 5609 | VkImage image_good; |
| 5610 | // One bad format and one good format for Color attachment |
| 5611 | const VkFormat tex_format_bad = VK_FORMAT_D32_SFLOAT_S8_UINT; |
| 5612 | const VkFormat tex_format_good = VK_FORMAT_B8G8R8A8_UNORM; |
| 5613 | const int32_t tex_width = 32; |
| 5614 | const int32_t tex_height = 32; |
| 5615 | |
| 5616 | VkImageCreateInfo image_create_info = {}; |
| 5617 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5618 | image_create_info.pNext = NULL; |
| 5619 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5620 | image_create_info.format = tex_format_bad; |
| 5621 | image_create_info.extent.width = tex_width; |
| 5622 | image_create_info.extent.height = tex_height; |
| 5623 | image_create_info.extent.depth = 1; |
| 5624 | image_create_info.mipLevels = 1; |
| 5625 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 3138d6a | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5626 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5627 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 5628 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 5629 | image_create_info.flags = 0; |
| 5630 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5631 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image_bad); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5632 | ASSERT_VK_SUCCESS(err); |
| 5633 | image_create_info.format = tex_format_good; |
| 5634 | 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] | 5635 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image_good); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5636 | ASSERT_VK_SUCCESS(err); |
| 5637 | |
| 5638 | VkImageViewCreateInfo image_view_create_info = {}; |
| 5639 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5640 | image_view_create_info.image = image_bad; |
| 5641 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 5642 | image_view_create_info.format = tex_format_bad; |
| 5643 | image_view_create_info.subresourceRange.baseArrayLayer = 0; |
| 5644 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
Chia-I Wu | 1f85191 | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5645 | image_view_create_info.subresourceRange.layerCount = 1; |
| 5646 | image_view_create_info.subresourceRange.levelCount = 1; |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5647 | image_view_create_info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 5648 | |
| 5649 | VkImageView view; |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5650 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, &view); |
Mark Lobodzinski | c4d306c | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5651 | |
| 5652 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5653 | FAIL() << "Did not receive Error 'Combination depth-stencil image formats can have only the....'"; |
| 5654 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5655 | } |
| 5656 | |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5657 | vkDestroyImage(m_device->device(), image_bad, NULL); |
| 5658 | vkDestroyImage(m_device->device(), image_good, NULL); |
Chia-I Wu | 69f4012 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5659 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5660 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | b46be81 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5661 | } |
Tobin Ehlis | 342b9bf | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 5662 | #endif // IMAGE_TESTS |
| 5663 | |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 5664 | int main(int argc, char **argv) { |
| 5665 | int result; |
| 5666 | |
| 5667 | ::testing::InitGoogleTest(&argc, argv); |
Tony Barbour | 0199918 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 5668 | VkTestFramework::InitArgs(&argc, argv); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 5669 | |
| 5670 | ::testing::AddGlobalTestEnvironment(new TestEnvironment); |
| 5671 | |
| 5672 | result = RUN_ALL_TESTS(); |
| 5673 | |
Tony Barbour | 0199918 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 5674 | VkTestFramework::Finish(); |
Tony Barbour | 30486ea | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 5675 | return result; |
| 5676 | } |