Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 1 | #include <vulkan.h> |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 2 | #include "vk_debug_report_lunarg.h" |
Courtney Goeltzenleuchter | 58f3eff | 2015-10-07 13:28:58 -0600 | [diff] [blame] | 3 | #include "test_common.h" |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 4 | #include "vkrenderframework.h" |
Tobin Ehlis | a0cb02e | 2015-07-03 10:15:26 -0600 | [diff] [blame] | 5 | #include "vk_layer_config.h" |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 6 | #include "../icd/common/icd-spv.h" |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 7 | |
Mark Lobodzinski | 3780e14 | 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 | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 12 | #define MEM_TRACKER_TESTS 1 |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 13 | |
Tobin Ehlis | 0788f52 | 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 | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 17 | #define SHADER_CHECKER_TESTS 1 |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 18 | #define DEVICE_LIMITS_TESTS 1 |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 19 | #define IMAGE_TESTS 1 |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 20 | |
Mark Lobodzinski | 3780e14 | 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 | 271ba75 | 2015-08-26 10:01:32 -0600 | [diff] [blame] | 34 | BsoFailLineWidth = 0x00000001, |
| 35 | BsoFailDepthBias = 0x00000002, |
Cody Northrop | 1236511 | 2015-08-17 11:10:49 -0600 | [diff] [blame] | 36 | BsoFailViewport = 0x00000004, |
Tobin Ehlis | 963a404 | 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 | 3780e14 | 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 | 75a97e6 | 2015-06-02 09:41:30 -0500 | [diff] [blame] | 52 | static const char bindStateVertShaderText[] = |
Mark Lobodzinski | 3780e14 | 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 | 75a97e6 | 2015-06-02 09:41:30 -0500 | [diff] [blame] | 62 | static const char bindStateFragShaderText[] = |
Cody Northrop | 8a3bb13 | 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 | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 71 | |
Courtney Goeltzenleuchter | 0664083 | 2015-09-04 13:52:24 -0600 | [diff] [blame] | 72 | static VkBool32 myDbgFunc( |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 73 | VkFlags msgFlags, |
| 74 | VkDbgObjectType objType, |
| 75 | uint64_t srcObject, |
Courtney Goeltzenleuchter | f579fa6 | 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 | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 81 | |
Mark Lobodzinski | 8507f2f | 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 | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 92 | class ErrorMonitor { |
| 93 | public: |
Tony Barbour | 15524c3 | 2015-04-29 17:34:29 -0600 | [diff] [blame] | 94 | ErrorMonitor() |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 95 | { |
Mike Stroyan | 4268d1f | 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 | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 98 | m_msgFlags = VK_DBG_REPORT_INFO_BIT; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 99 | m_bailout = NULL; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 100 | test_platform_thread_unlock_mutex(&m_mutex); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 101 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 102 | |
| 103 | void SetDesiredFailureMsg(VkFlags msgFlags, const char *msgString) |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 104 | { |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 105 | test_platform_thread_lock_mutex(&m_mutex); |
Mark Lobodzinski | 8507f2f | 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 | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 112 | test_platform_thread_unlock_mutex(&m_mutex); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 113 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 114 | |
| 115 | VkBool32 CheckForDesiredMsg(VkFlags msgFlags, const char *msgString) |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 116 | { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 117 | VkBool32 result = VK_FALSE; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 118 | test_platform_thread_lock_mutex(&m_mutex); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 119 | if (m_bailout != NULL) { |
| 120 | *m_bailout = true; |
| 121 | } |
Mark Lobodzinski | 8507f2f | 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 | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 132 | test_platform_thread_unlock_mutex(&m_mutex); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 133 | return result; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 134 | } |
Mark Lobodzinski | 8507f2f | 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 | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 151 | void SetBailout(bool *bailout) |
| 152 | { |
| 153 | m_bailout = bailout; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 154 | } |
| 155 | |
Mark Lobodzinski | 8507f2f | 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 | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 165 | private: |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 166 | VkFlags m_msgFlags; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 167 | string m_desiredMsg; |
| 168 | string m_failureMsg; |
| 169 | vector<string> m_otherMsgs; |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 170 | test_platform_thread_mutex m_mutex; |
| 171 | bool* m_bailout; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 172 | VkBool32 m_msgFound; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 173 | }; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 174 | |
Courtney Goeltzenleuchter | 0664083 | 2015-09-04 13:52:24 -0600 | [diff] [blame] | 175 | static VkBool32 myDbgFunc( |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 176 | VkFlags msgFlags, |
Tony Barbour | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 177 | VkDbgObjectType objType, |
| 178 | uint64_t srcObject, |
Courtney Goeltzenleuchter | f579fa6 | 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 | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 184 | { |
Courtney Goeltzenleuchter | f579fa6 | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 185 | if (msgFlags & (VK_DBG_REPORT_WARN_BIT | VK_DBG_REPORT_ERROR_BIT)) { |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 186 | ErrorMonitor *errMonitor = (ErrorMonitor *)pUserData; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 187 | return errMonitor->CheckForDesiredMsg(msgFlags, pMsg); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 188 | } |
Courtney Goeltzenleuchter | 0664083 | 2015-09-04 13:52:24 -0600 | [diff] [blame] | 189 | return false; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 190 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 191 | |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 192 | class VkLayerTest : public VkRenderFramework |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 193 | { |
| 194 | public: |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 195 | VkResult BeginCommandBuffer(VkCommandBufferObj &commandBuffer); |
| 196 | VkResult EndCommandBuffer(VkCommandBufferObj &commandBuffer); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 197 | void VKTriangleTest(const char *vertShaderText, const char *fragShaderText, BsoFailSelect failMask); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 198 | void GenericDrawPreparation(VkCommandBufferObj *commandBuffer, VkPipelineObj &pipelineobj, VkDescriptorSetObj &descriptorSet, BsoFailSelect failMask); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 199 | void GenericDrawPreparation(VkPipelineObj &pipelineobj, VkDescriptorSetObj &descriptorSet, BsoFailSelect failMask) |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 200 | { GenericDrawPreparation(m_commandBuffer, pipelineobj, descriptorSet, failMask); } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 201 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 202 | /* Convenience functions that use built-in command buffer */ |
Chia-I Wu | 3432a0c | 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 | 08c2637 | 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 | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 206 | { m_commandBuffer->Draw(vertexCount, instanceCount, firstVertex, firstInstance); } |
Courtney Goeltzenleuchter | 08c2637 | 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 | 3432a0c | 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 | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 211 | void BindVertexBuffer(VkConstantBufferObj *vertexBuffer, VkDeviceSize offset, uint32_t binding) |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 212 | { m_commandBuffer->BindVertexBuffer(vertexBuffer, offset, binding); } |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 213 | void BindIndexBuffer(VkIndexBufferObj *indexBuffer, VkDeviceSize offset) |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 214 | { m_commandBuffer->BindIndexBuffer(indexBuffer, offset); } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 215 | protected: |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 216 | ErrorMonitor *m_errorMonitor; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 217 | |
| 218 | virtual void SetUp() { |
Courtney Goeltzenleuchter | cd69eee | 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 | f579fa6 | 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 | 3fdff9e | 2015-04-23 12:55:36 -0600 | [diff] [blame] | 223 | |
Courtney Goeltzenleuchter | 05159a9 | 2015-07-30 11:32:46 -0600 | [diff] [blame] | 224 | instance_extension_names.push_back(VK_DEBUG_REPORT_EXTENSION_NAME); |
Courtney Goeltzenleuchter | c2b06fe | 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 | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 230 | // Use Threading layer first to protect others from ThreadCommandBufferCollision test |
Courtney Goeltzenleuchter | cd69eee | 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 | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 236 | instance_layer_names.push_back("DeviceLimits"); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 237 | instance_layer_names.push_back("Image"); |
Courtney Goeltzenleuchter | d971b61 | 2015-06-17 20:51:59 -0600 | [diff] [blame] | 238 | |
Courtney Goeltzenleuchter | cd69eee | 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 | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 244 | device_layer_names.push_back("DeviceLimits"); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 245 | device_layer_names.push_back("Image"); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 246 | |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 247 | this->app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 248 | this->app_info.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 249 | this->app_info.pApplicationName = "layer_tests"; |
| 250 | this->app_info.applicationVersion = 1; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 251 | this->app_info.pEngineName = "unittest"; |
| 252 | this->app_info.engineVersion = 1; |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 253 | this->app_info.apiVersion = VK_API_VERSION; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 254 | |
Tony Barbour | 15524c3 | 2015-04-29 17:34:29 -0600 | [diff] [blame] | 255 | m_errorMonitor = new ErrorMonitor; |
Courtney Goeltzenleuchter | cd69eee | 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 | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 259 | } |
| 260 | |
| 261 | virtual void TearDown() { |
| 262 | // Clean up resources before we reset |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 263 | ShutdownFramework(); |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 264 | delete m_errorMonitor; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 265 | } |
| 266 | }; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 267 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 268 | VkResult VkLayerTest::BeginCommandBuffer(VkCommandBufferObj &commandBuffer) |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 269 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 270 | VkResult result; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 271 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 272 | result = commandBuffer.BeginCommandBuffer(); |
Tony Barbour | 300a608 | 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 | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 278 | if (VK_SUCCESS == result && renderPass()) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 279 | commandBuffer.BeginRenderPass(renderPassBeginInfo()); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 280 | } |
| 281 | |
| 282 | return result; |
| 283 | } |
| 284 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 285 | VkResult VkLayerTest::EndCommandBuffer(VkCommandBufferObj &commandBuffer) |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 286 | { |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 287 | VkResult result; |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 288 | |
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 289 | if (renderPass()) { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 290 | commandBuffer.EndRenderPass(); |
Chris Forbes | 76a5eeb | 2015-06-16 14:05:59 +1200 | [diff] [blame] | 291 | } |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 292 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 293 | result = commandBuffer.EndCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 294 | |
| 295 | return result; |
| 296 | } |
| 297 | |
Mark Lobodzinski | 3780e14 | 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 | d263550 | 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 | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 338 | |
| 339 | VkPipelineObj pipelineobj(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 340 | pipelineobj.AddColorAttachment(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 341 | pipelineobj.AddShader(&vs); |
| 342 | pipelineobj.AddShader(&ps); |
Courtney Goeltzenleuchter | 507ba97 | 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 | d332f28 | 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 | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 350 | if (failMask & BsoFailViewport) { |
| 351 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_VIEWPORT); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 352 | m_viewports.clear(); |
| 353 | m_scissors.clear(); |
Courtney Goeltzenleuchter | 507ba97 | 2015-09-30 16:16:57 -0600 | [diff] [blame] | 354 | } |
| 355 | if (failMask & BsoFailScissor) { |
| 356 | pipelineobj.MakeDynamic(VK_DYNAMIC_STATE_SCISSOR); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 357 | m_scissors.clear(); |
| 358 | m_viewports.clear(); |
Courtney Goeltzenleuchter | 507ba97 | 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 | 3780e14 | 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 | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 380 | ASSERT_VK_SUCCESS(BeginCommandBuffer()); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 381 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 382 | GenericDrawPreparation(pipelineobj, descriptorSet, failMask); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 383 | |
| 384 | // render triangle |
Courtney Goeltzenleuchter | 08c2637 | 2015-09-23 12:31:50 -0600 | [diff] [blame] | 385 | Draw(3, 1, 0, 0); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 386 | |
| 387 | // finalize recording of the command buffer |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 388 | EndCommandBuffer(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 389 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 390 | QueueCommandBuffer(); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 391 | } |
| 392 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 393 | void VkLayerTest::GenericDrawPreparation(VkCommandBufferObj *commandBuffer, VkPipelineObj &pipelineobj, VkDescriptorSetObj &descriptorSet, BsoFailSelect failMask) |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 394 | { |
| 395 | if (m_depthStencil->Initialized()) { |
Chia-I Wu | 3432a0c | 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 | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 397 | } else { |
Chia-I Wu | 3432a0c | 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 | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 399 | } |
| 400 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 401 | commandBuffer->PrepareAttachments(); |
Cody Northrop | 82485a8 | 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 | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 404 | VkStencilOpState stencil = {}; |
Chia-I Wu | 1b99bb2 | 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 | eb25490 | 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 | 507ba97 | 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 | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 420 | |
Tobin Ehlis | 4bf96d1 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 421 | pipelineobj.SetDepthStencil(&ds_ci); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 422 | pipelineobj.SetViewport(m_viewports); |
| 423 | pipelineobj.SetScissor(m_scissors); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 424 | descriptorSet.CreateVKDescriptorSet(commandBuffer); |
Cody Northrop | 29a08f2 | 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 | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 427 | commandBuffer->BindPipeline(pipelineobj); |
| 428 | commandBuffer->BindDescriptorSet(descriptorSet); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 429 | } |
| 430 | |
| 431 | // ******************************************************************************************************************** |
| 432 | // ******************************************************************************************************************** |
| 433 | // ******************************************************************************************************************** |
| 434 | // ******************************************************************************************************************** |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 435 | #if MEM_TRACKER_TESTS |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 436 | TEST_F(VkLayerTest, CallResetCommandBufferBeforeCompletion) |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 437 | { |
| 438 | vk_testing::Fence testFence; |
Mark Lobodzinski | ccb2b04 | 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 | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 444 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, "Resetting CB"); |
| 445 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 446 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tony Barbour | c1eb1a5 | 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 | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 451 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 452 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 453 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 4, 0x11111111); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 454 | EndCommandBuffer(); |
Mark Lobodzinski | ccb2b04 | 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 | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 460 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 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 | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 463 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 464 | submit_info.pWaitSemaphores = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 465 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 466 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 467 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 468 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 469 | |
| 470 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 471 | ASSERT_VK_SUCCESS( err ); |
| 472 | |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 473 | // Introduce failure by calling begin again before checking fence |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 474 | vkResetCommandBuffer(m_commandBuffer->handle(), 0); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 475 | |
Mark Lobodzinski | 8507f2f | 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 | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 479 | } |
| 480 | } |
| 481 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 482 | TEST_F(VkLayerTest, CallBeginCommandBufferBeforeCompletion) |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 483 | { |
| 484 | vk_testing::Fence testFence; |
Mark Lobodzinski | ccb2b04 | 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 | 8507f2f | 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 | ccb2b04 | 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 | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 496 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 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 | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 498 | EndCommandBuffer(); |
Mark Lobodzinski | ccb2b04 | 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 | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 504 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 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 | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 507 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 508 | submit_info.pWaitSemaphores = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 509 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 510 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 511 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 512 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 513 | |
| 514 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 515 | ASSERT_VK_SUCCESS( err ); |
| 516 | |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 517 | |
Chia-I Wu | 3432a0c | 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 | 5fcc421 | 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 | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 526 | vkBeginCommandBuffer(m_commandBuffer->handle(), &info); |
Mark Lobodzinski | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 527 | |
Mark Lobodzinski | 8507f2f | 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 | ccb2b04 | 2015-05-19 10:28:29 -0500 | [diff] [blame] | 532 | } |
| 533 | } |
| 534 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 535 | TEST_F(VkLayerTest, MapMemWithoutHostVisibleBit) |
| 536 | { |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 537 | VkResult err; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 538 | bool pass; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 539 | |
Mark Lobodzinski | 8507f2f | 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 | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 543 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 3780e14 | 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 | 2306535 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 547 | VkDeviceMemory mem; |
| 548 | VkMemoryRequirements mem_reqs; |
Mark Lobodzinski | 3780e14 | 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 | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 553 | |
Tony Barbour | eb25490 | 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 | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 563 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 5c17c96 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 564 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Tony Barbour | eb25490 | 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 | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 568 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 569 | VkMemoryAllocateInfo mem_alloc = {}; |
Tony Barbour | eb25490 | 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 | 3780e14 | 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 | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 574 | mem_alloc.memoryTypeIndex = 1; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 575 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 576 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 577 | ASSERT_VK_SUCCESS(err); |
| 578 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 579 | vkGetImageMemoryRequirements(m_device->device(), |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 580 | image, |
Mark Lobodzinski | 2306535 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 581 | &mem_reqs); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 582 | |
Mark Lobodzinski | 2306535 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 583 | mem_alloc.allocationSize = mem_reqs.size; |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 584 | |
Courtney Goeltzenleuchter | 1d2f0dd | 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 | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 587 | vkDestroyImage(m_device->device(), image, NULL); |
Tony Barbour | 02fdc7d | 2015-08-04 16:13:01 -0600 | [diff] [blame] | 588 | return; |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 589 | } |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 590 | |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 591 | // allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 592 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Mark Lobodzinski | 3780e14 | 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 | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 596 | err = vkBindImageMemory(m_device->device(), image, mem, 0); |
Mark Lobodzinski | 3780e14 | 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 | 2306535 | 2015-05-29 09:32:35 -0500 | [diff] [blame] | 601 | err = vkMapMemory(m_device->device(), mem, 0, 0, 0, &mappedAddress); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 602 | |
Mark Lobodzinski | 8507f2f | 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 | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 606 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 607 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 608 | vkDestroyImage(m_device->device(), image, NULL); |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 609 | } |
| 610 | |
Tobin Ehlis | 2717d13 | 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 | 2717d13 | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 615 | // VkResult err; |
| 616 | // |
Mark Lobodzinski | 8507f2f | 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 | 2717d13 | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 619 | // |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 620 | // ASSERT_NO_FATAL_FAILURE(InitState()); |
| 621 | |
Tobin Ehlis | 2717d13 | 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 | 5c17c96 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 639 | // .samples = VK_SAMPLE_COUNT_1_BIT, |
Tobin Ehlis | 2717d13 | 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 | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 644 | // VkMemoryAllocateInfo mem_alloc = { |
Tobin Ehlis | 2717d13 | 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 | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 651 | // err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | 2717d13 | 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 | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 665 | // err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | 2717d13 | 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 | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 673 | // vkFreeMemory(m_device->device(), mem, NULL); |
Courtney Goeltzenleuchter | 0664083 | 2015-09-04 13:52:24 -0600 | [diff] [blame] | 674 | // |
Mark Lobodzinski | 8507f2f | 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 | 2717d13 | 2015-07-10 18:25:07 -0600 | [diff] [blame] | 678 | // } |
| 679 | //} |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 680 | |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 681 | TEST_F(VkLayerTest, RebindMemory) |
| 682 | { |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 683 | VkResult err; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 684 | bool pass; |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 685 | |
Mark Lobodzinski | 8507f2f | 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 | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 689 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 944aab1 | 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 | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 700 | |
Tony Barbour | eb25490 | 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 | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 710 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 5c17c96 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 711 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Tony Barbour | eb25490 | 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 | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 715 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 716 | VkMemoryAllocateInfo mem_alloc = {}; |
Tony Barbour | eb25490 | 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 | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 724 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 725 | ASSERT_VK_SUCCESS(err); |
| 726 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 727 | vkGetImageMemoryRequirements(m_device->device(), |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 728 | image, |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 729 | &mem_reqs); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 730 | |
| 731 | mem_alloc.allocationSize = mem_reqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 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 | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 734 | |
| 735 | // allocate 2 memory objects |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 736 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem1); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 737 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 738 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem2); |
Mark Lobodzinski | 944aab1 | 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 | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 742 | err = vkBindImageMemory(m_device->device(), image, mem1, 0); |
Mark Lobodzinski | 944aab1 | 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 | 67e9915 | 2015-07-10 14:10:27 -0600 | [diff] [blame] | 746 | err = vkBindImageMemory(m_device->device(), image, mem2, 0); |
Mark Lobodzinski | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 747 | |
Mark Lobodzinski | 8507f2f | 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 | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 751 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 752 | |
Chia-I Wu | f7458c5 | 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 | 944aab1 | 2015-06-05 13:59:04 -0500 | [diff] [blame] | 756 | } |
Mark Lobodzinski | 3780e14 | 2015-05-14 15:08:13 -0500 | [diff] [blame] | 757 | |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 758 | TEST_F(VkLayerTest, SubmitSignaledFence) |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 759 | { |
Courtney Goeltzenleuchter | d8e229c | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 760 | vk_testing::Fence testFence; |
Mark Lobodzinski | 8507f2f | 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 | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 764 | |
| 765 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 0b4d956 | 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 | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 769 | |
Tony Barbour | 300a608 | 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 | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 774 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 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 | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 776 | EndCommandBuffer(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 777 | |
| 778 | testFence.init(*m_device, fenceInfo); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 779 | |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 780 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 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 | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 783 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 784 | submit_info.pWaitSemaphores = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 785 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 786 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 787 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 788 | submit_info.pSignalSemaphores = NULL; |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 789 | |
| 790 | vkQueueSubmit(m_device->m_queue, 1, &submit_info, testFence.handle()); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 791 | vkQueueWaitIdle(m_device->m_queue ); |
Mark Lobodzinski | 5fcc421 | 2015-09-14 17:43:42 -0600 | [diff] [blame] | 792 | |
Mark Lobodzinski | 8507f2f | 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 | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 796 | } |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 797 | } |
| 798 | |
| 799 | TEST_F(VkLayerTest, ResetUnsignaledFence) |
| 800 | { |
| 801 | vk_testing::Fence testFence; |
Courtney Goeltzenleuchter | fb4efc6 | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 802 | VkFenceCreateInfo fenceInfo = {}; |
Tony Barbour | 0b4d956 | 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 | 8507f2f | 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 | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 809 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 810 | testFence.init(*m_device, fenceInfo); |
Chia-I Wu | d9e8e82 | 2015-07-03 11:45:55 +0800 | [diff] [blame] | 811 | VkFence fences[1] = {testFence.handle()}; |
Tony Barbour | 0b4d956 | 2015-04-09 10:48:04 -0600 | [diff] [blame] | 812 | vkResetFences(m_device->device(), 1, fences); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 813 | |
Mark Lobodzinski | 8507f2f | 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 | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 818 | } |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 819 | |
Chia-I Wu | 08accc6 | 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 | 41376e1 | 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 | 8507f2f | 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 | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 828 | |
| 829 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 830 | VkCommandBufferObj commandBuffer(m_device); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 831 | BeginCommandBuffer(); |
Tobin Ehlis | 41376e1 | 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 | 5c17c96 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 846 | .samples = VK_SAMPLE_COUNT_1_BIT, |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 847 | .tiling = VK_IMAGE_TILING_LINEAR, |
Courtney Goeltzenleuchter | 660f0ca | 2015-09-10 14:14:11 -0600 | [diff] [blame] | 848 | .usage = 0, // Not setting VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 849 | .flags = 0, |
| 850 | }; |
| 851 | |
| 852 | VkImage dsi; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 853 | vkCreateImage(m_device->device(), &ici, NULL, &dsi); |
Tobin Ehlis | 41376e1 | 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 | 4a26189 | 2015-09-10 16:38:41 -0600 | [diff] [blame] | 860 | .baseArrayLayer = 0, |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 861 | .arraySize = 1, |
| 862 | .flags = 0, |
| 863 | }; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 864 | vkCreateDepthStencilView(m_device->device(), &dsvci, NULL, &dsv); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 865 | |
| 866 | if (!m_errorMonitor->DesiredMsgFound()) { |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 867 | FAIL() << "Error received was not 'Invalid usage flag for image...'"; |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 868 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 41376e1 | 2015-07-03 08:45:14 -0600 | [diff] [blame] | 869 | } |
| 870 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 871 | #endif // 0 |
| 872 | #endif // MEM_TRACKER_TESTS |
| 873 | |
Tobin Ehlis | 4bf96d1 | 2015-06-25 11:58:41 -0600 | [diff] [blame] | 874 | #if OBJ_TRACKER_TESTS |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 875 | TEST_F(VkLayerTest, PipelineNotBound) |
| 876 | { |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 877 | VkResult err; |
| 878 | |
Mark Lobodzinski | 8507f2f | 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 | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 882 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 883 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 884 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 885 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 886 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 887 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | c9ac2b6 | 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 | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 892 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | 1b99bb2 | 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 | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 895 | |
| 896 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 897 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 898 | ASSERT_VK_SUCCESS(err); |
| 899 | |
| 900 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 901 | dsl_binding.binding = 0; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 902 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 903 | dsl_binding.arraySize = 1; |
| 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 | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 910 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | a745e51 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 911 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 912 | |
| 913 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 914 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 915 | ASSERT_VK_SUCCESS(err); |
| 916 | |
| 917 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 918 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 919 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 920 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 921 | alloc_info.descriptorPool = ds_pool; |
| 922 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 923 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | c9ac2b6 | 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 | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 929 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 930 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 931 | |
| 932 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 933 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | c9ac2b6 | 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 | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 939 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, badPipeline); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 940 | |
Mark Lobodzinski | 8507f2f | 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 | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 944 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 945 | |
Chia-I Wu | f7458c5 | 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 | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 949 | } |
| 950 | |
| 951 | TEST_F(VkLayerTest, BindInvalidMemory) |
| 952 | { |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 953 | VkResult err; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 954 | bool pass; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 955 | |
Mark Lobodzinski | 8507f2f | 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 | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 959 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | ec59830 | 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 | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 979 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 5c17c96 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 980 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Tobin Ehlis | ec59830 | 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 | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 985 | VkMemoryAllocateInfo mem_alloc = {}; |
Tobin Ehlis | ec59830 | 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 | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 991 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 992 | ASSERT_VK_SUCCESS(err); |
| 993 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 994 | vkGetImageMemoryRequirements(m_device->device(), |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 995 | image, |
| 996 | &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 997 | |
| 998 | mem_alloc.allocationSize = mem_reqs.size; |
| 999 | |
Courtney Goeltzenleuchter | 1d2f0dd | 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 | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1002 | |
| 1003 | // allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1004 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 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 | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1008 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | ec59830 | 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 | 8507f2f | 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 | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1018 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1019 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1020 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1021 | } |
| 1022 | |
| 1023 | TEST_F(VkLayerTest, BindMemoryToDestroyedObject) |
| 1024 | { |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1025 | VkResult err; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 1026 | bool pass; |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1027 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1028 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, "Invalid VkImage Object "); |
| 1029 | |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1030 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | ec59830 | 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 | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 1050 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 5c17c96 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1051 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Tobin Ehlis | ec59830 | 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 | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1056 | VkMemoryAllocateInfo mem_alloc = {}; |
Tobin Ehlis | ec59830 | 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 | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1062 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1063 | ASSERT_VK_SUCCESS(err); |
| 1064 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 1065 | vkGetImageMemoryRequirements(m_device->device(), |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1066 | image, |
| 1067 | &mem_reqs); |
Tobin Ehlis | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1068 | |
| 1069 | mem_alloc.allocationSize = mem_reqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 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 | ec59830 | 2015-09-15 15:02:17 -0600 | [diff] [blame] | 1072 | |
| 1073 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1074 | err = vkAllocateMemory(m_device->device(), &mem_alloc, NULL, &mem); |
Tobin Ehlis | ec59830 | 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 | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1078 | vkDestroyImage(m_device->device(), image, NULL); |
Tobin Ehlis | ec59830 | 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 | 8507f2f | 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 | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1089 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1090 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1091 | vkFreeMemory(m_device->device(), mem, NULL); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1092 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 1093 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 1094 | #endif // OBJ_TRACKER_TESTS |
| 1095 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 1096 | #if DRAW_STATE_TESTS |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1097 | TEST_F(VkLayerTest, LineWidthStateNotBound) |
| 1098 | { |
Mark Lobodzinski | 8507f2f | 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 | 963a404 | 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 | 8507f2f | 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 | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1109 | } |
| 1110 | } |
| 1111 | |
| 1112 | TEST_F(VkLayerTest, DepthBiasStateNotBound) |
| 1113 | { |
Mark Lobodzinski | 8507f2f | 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 | 963a404 | 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 | 8507f2f | 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 | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1124 | } |
| 1125 | } |
| 1126 | |
Cody Northrop | 4063c9a | 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 | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1128 | TEST_F(VkLayerTest, ViewportStateNotBound) |
| 1129 | { |
Mark Lobodzinski | 8507f2f | 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 | 963a404 | 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 | 8507f2f | 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 | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1140 | } |
| 1141 | } |
| 1142 | |
| 1143 | TEST_F(VkLayerTest, ScissorStateNotBound) |
| 1144 | { |
Mark Lobodzinski | 8507f2f | 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 | 963a404 | 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 | 8507f2f | 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 | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1155 | } |
| 1156 | } |
| 1157 | |
Tobin Ehlis | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1158 | TEST_F(VkLayerTest, BlendStateNotBound) |
| 1159 | { |
Mark Lobodzinski | 8507f2f | 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 | 963a404 | 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 | 8507f2f | 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 | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1170 | } |
| 1171 | } |
| 1172 | |
| 1173 | TEST_F(VkLayerTest, DepthBoundsStateNotBound) |
| 1174 | { |
Mark Lobodzinski | 8507f2f | 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 | 963a404 | 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 | 8507f2f | 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 | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1185 | } |
| 1186 | } |
| 1187 | |
| 1188 | TEST_F(VkLayerTest, StencilReadMaskNotSet) |
| 1189 | { |
Mark Lobodzinski | 8507f2f | 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 | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1193 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1194 | |
Tobin Ehlis | 963a404 | 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 | 8507f2f | 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 | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1202 | } |
| 1203 | } |
| 1204 | |
| 1205 | TEST_F(VkLayerTest, StencilWriteMaskNotSet) |
| 1206 | { |
Mark Lobodzinski | 8507f2f | 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 | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1210 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1211 | |
Tobin Ehlis | 963a404 | 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 | 8507f2f | 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 | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1219 | } |
| 1220 | } |
| 1221 | |
| 1222 | TEST_F(VkLayerTest, StencilReferenceNotSet) |
| 1223 | { |
Mark Lobodzinski | 8507f2f | 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 | 963a404 | 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 | 8507f2f | 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 | 963a404 | 2015-09-29 08:18:34 -0600 | [diff] [blame] | 1234 | } |
| 1235 | } |
| 1236 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1237 | TEST_F(VkLayerTest, CommandBufferTwoSubmits) |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1238 | { |
| 1239 | vk_testing::Fence testFence; |
Mark Lobodzinski | 8507f2f | 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 | 59278bf | 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 | 3432a0c | 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 | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1254 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 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 | 59278bf | 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 | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1262 | VkSubmitInfo submit_info; |
Chia-I Wu | f9be13c | 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 | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1265 | submit_info.waitSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1266 | submit_info.pWaitSemaphores = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1267 | submit_info.commandBufferCount = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1268 | submit_info.pCommandBuffers = &m_commandBuffer->handle(); |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1269 | submit_info.signalSemaphoreCount = 0; |
Courtney Goeltzenleuchter | 806c700 | 2015-10-27 11:22:14 -0600 | [diff] [blame] | 1270 | submit_info.pSignalSemaphores = NULL; |
| 1271 | |
Courtney Goeltzenleuchter | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 1272 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1273 | ASSERT_VK_SUCCESS( err ); |
| 1274 | |
Tobin Ehlis | 59278bf | 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 | 646b907 | 2015-10-20 18:04:07 -0600 | [diff] [blame] | 1276 | err = vkQueueSubmit( m_device->m_queue, 1, &submit_info, testFence.handle()); |
Tobin Ehlis | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1277 | |
Mark Lobodzinski | 8507f2f | 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 | 59278bf | 2015-08-18 07:10:58 -0600 | [diff] [blame] | 1281 | } |
| 1282 | } |
| 1283 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 1284 | TEST_F(VkLayerTest, BindPipelineNoRenderPass) |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1285 | { |
| 1286 | // Initiate Draw w/o a PSO bound |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1287 | VkResult err; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1288 | |
Mark Lobodzinski | 8507f2f | 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 | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1292 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1293 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1294 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1295 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1296 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1297 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | c9ac2b6 | 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 | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 1302 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | 1b99bb2 | 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 | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1305 | |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 1306 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1307 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1308 | ASSERT_VK_SUCCESS(err); |
| 1309 | |
| 1310 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1311 | dsl_binding.binding = 0; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1312 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1313 | dsl_binding.arraySize = 1; |
| 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 | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1320 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | a745e51 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1321 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1322 | |
| 1323 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1324 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1325 | ASSERT_VK_SUCCESS(err); |
| 1326 | |
| 1327 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1328 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1329 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1330 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1331 | alloc_info.descriptorPool = ds_pool; |
| 1332 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1333 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | c9ac2b6 | 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 | 5c17c96 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1338 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
Tobin Ehlis | c9ac2b6 | 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 | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1346 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1347 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 1348 | VkPipelineLayout pipeline_layout; |
| 1349 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1350 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1351 | ASSERT_VK_SUCCESS(err); |
| 1352 | |
Courtney Goeltzenleuchter | d263550 | 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 | c9ac2b6 | 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 | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1361 | |
Chia-I Wu | 3432a0c | 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 | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1367 | cmd_buf_info.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1368 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1369 | |
Chia-I Wu | 3432a0c | 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 | 8507f2f | 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 | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1376 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1377 | |
Chia-I Wu | f7458c5 | 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 | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1381 | } |
| 1382 | |
Tobin Ehlis | f93f1e3 | 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 | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1386 | VkResult err; |
| 1387 | |
Mark Lobodzinski | 8507f2f | 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 | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1391 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1392 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | f93f1e3 | 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 | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1395 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1396 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1397 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | f93f1e3 | 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 | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1402 | ds_pool_ci.flags = 0; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1403 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | 1b99bb2 | 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 | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1406 | |
| 1407 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1408 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1409 | ASSERT_VK_SUCCESS(err); |
| 1410 | |
| 1411 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1412 | dsl_binding.binding = 0; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1413 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1414 | dsl_binding.arraySize = 1; |
| 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 | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1421 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | a745e51 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1422 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1423 | |
| 1424 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1425 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1426 | ASSERT_VK_SUCCESS(err); |
| 1427 | |
| 1428 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1429 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1430 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1431 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1432 | alloc_info.descriptorPool = ds_pool; |
| 1433 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1434 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1435 | |
Mark Lobodzinski | 8507f2f | 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 | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1439 | } |
| 1440 | |
Chia-I Wu | f7458c5 | 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 | f93f1e3 | 2015-10-20 16:16:04 -0600 | [diff] [blame] | 1443 | } |
| 1444 | |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1445 | TEST_F(VkLayerTest, FreeDescriptorFromOneShotPool) |
| 1446 | { |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1447 | VkResult err; |
| 1448 | |
Mark Lobodzinski | 8507f2f | 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 | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1452 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1453 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1454 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1455 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1456 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1457 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e735c69 | 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 | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1462 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1463 | ds_pool_ci.poolSizeCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 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 | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1467 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1468 | |
| 1469 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1470 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1471 | ASSERT_VK_SUCCESS(err); |
| 1472 | |
| 1473 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1474 | dsl_binding.binding = 0; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1475 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1476 | dsl_binding.arraySize = 1; |
| 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 | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1483 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | a745e51 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1484 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1485 | |
| 1486 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1487 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1488 | ASSERT_VK_SUCCESS(err); |
| 1489 | |
| 1490 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1491 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1492 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1493 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1494 | alloc_info.descriptorPool = ds_pool; |
| 1495 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1496 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | e735c69 | 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 | 8507f2f | 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 | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1503 | } |
| 1504 | |
Chia-I Wu | f7458c5 | 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 | e735c69 | 2015-10-08 13:13:50 -0600 | [diff] [blame] | 1507 | } |
| 1508 | |
Tobin Ehlis | 49eb23d | 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 | 8507f2f | 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 | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1518 | VkDescriptorPool badPool = (VkDescriptorPool)0xbaad6001; |
| 1519 | vkResetDescriptorPool(device(), badPool); |
| 1520 | |
Mark Lobodzinski | 8507f2f | 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 | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1524 | }*/ |
| 1525 | } |
| 1526 | |
| 1527 | TEST_F(VkLayerTest, InvalidDescriptorSet) |
| 1528 | { |
Tobin Ehlis | 7d1a711 | 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 | 49eb23d | 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 | 7d1a711 | 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 | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1545 | // Create a valid cmd buffer |
| 1546 | // call vkCmdBindPipeline w/ false Pipeline |
Mark Lobodzinski | 8507f2f | 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 | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 1550 | // |
| 1551 | // ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1552 | // VkCommandBufferObj commandBuffer(m_device); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1553 | // BeginCommandBuffer(); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 1554 | // VkPipeline badPipeline = (VkPipeline)0xbaadb1be; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1555 | // vkCmdBindPipeline(commandBuffer.GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, badPipeline); |
Mark Lobodzinski | 8507f2f | 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 | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 1560 | // } |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1561 | } |
| 1562 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1563 | TEST_F(VkLayerTest, DescriptorSetNotUpdated) |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 1564 | { |
Chia-I Wu | 3432a0c | 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 | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1566 | VkResult err; |
| 1567 | |
Mark Lobodzinski | 8507f2f | 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 | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1571 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 1572 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 1573 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1574 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1575 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1576 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 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 | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 1581 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | 1b99bb2 | 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 | 713b2d7 | 2015-08-04 10:49:29 -0600 | [diff] [blame] | 1584 | |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1585 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1586 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1587 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1588 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1589 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1590 | dsl_binding.binding = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1591 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1592 | dsl_binding.arraySize = 1; |
| 1593 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1594 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1595 | |
Tony Barbour | eb25490 | 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 | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1599 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | a745e51 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1600 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1601 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1602 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1603 | ASSERT_VK_SUCCESS(err); |
| 1604 | |
| 1605 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1606 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1607 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1608 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1609 | alloc_info.descriptorPool = ds_pool; |
| 1610 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1611 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1612 | ASSERT_VK_SUCCESS(err); |
| 1613 | |
Tony Barbour | eb25490 | 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 | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1617 | pipeline_layout_ci.setLayoutCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1618 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1619 | |
| 1620 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1621 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1622 | ASSERT_VK_SUCCESS(err); |
| 1623 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 1624 | VkShaderObj vs(m_device, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
Mark Lobodzinski | 8507f2f | 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 | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1627 | |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 1628 | VkPipelineObj pipe(m_device); |
| 1629 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 1630 | pipe.AddShader(&fs); |
Tony Barbour | c95e4ac | 2015-08-04 17:05:26 -0600 | [diff] [blame] | 1631 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 1632 | |
| 1633 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 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 | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1636 | |
Mark Lobodzinski | 8507f2f | 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 | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1640 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1641 | |
Chia-I Wu | f7458c5 | 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 | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1645 | } |
| 1646 | |
Tobin Ehlis | ba31cab | 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; |
| 1674 | dsl_binding.arraySize = 1; |
| 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 |
| 1697 | |
| 1698 | VkWriteDescriptorSet descriptor_write; |
| 1699 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 1700 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
| 1701 | descriptor_write.dstSet = descriptorSet; |
| 1702 | descriptor_write.dstBinding = 0; |
| 1703 | descriptor_write.descriptorCount = 1; |
| 1704 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER; |
| 1705 | descriptor_write.pTexelBufferView = &view; |
| 1706 | |
| 1707 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 1708 | |
| 1709 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1710 | FAIL() << "Did not receive Error 'Invalid VkBufferView Object 0xbaadbeef'"; |
| 1711 | m_errorMonitor->DumpFailureMsgs(); |
| 1712 | } |
| 1713 | |
| 1714 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1715 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
| 1716 | } |
| 1717 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1718 | TEST_F(VkLayerTest, NoBeginCommandBuffer) |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1719 | { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1720 | |
| 1721 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1722 | "You must call vkBeginCommandBuffer() before this call to "); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1723 | |
| 1724 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1725 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1726 | // Call EndCommandBuffer() w/o calling BeginCommandBuffer() |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1727 | vkEndCommandBuffer(commandBuffer.GetBufferHandle()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1728 | |
| 1729 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1730 | FAIL() << "Did not recieve Error 'You must call vkBeginCommandBuffer() before this call to vkEndCommandBuffer()'"; |
| 1731 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1732 | } |
| 1733 | } |
| 1734 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1735 | TEST_F(VkLayerTest, PrimaryCommandBufferFramebufferAndRenderpass) |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1736 | { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1737 | |
| 1738 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1739 | "may not specify framebuffer or renderpass parameters"); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1740 | |
| 1741 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1742 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1743 | // Calls AllocateCommandBuffers |
| 1744 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1745 | |
| 1746 | // Force the failure by setting the Renderpass and Framebuffer fields with (fake) data |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1747 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
| 1748 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 1749 | cmd_buf_info.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1750 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 1751 | cmd_buf_info.renderPass = (VkRenderPass)0xcadecade; |
| 1752 | cmd_buf_info.framebuffer = (VkFramebuffer)0xcadecade; |
| 1753 | |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1754 | |
| 1755 | // The error should be caught by validation of the BeginCommandBuffer call |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1756 | vkBeginCommandBuffer(commandBuffer.GetBufferHandle(), &cmd_buf_info); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1757 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1758 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1759 | FAIL() << "Did not receive Error 'vkAllocateCommandBuffers(): Primary Command Buffer may not specify framebuffer or renderpass parameters'"; |
| 1760 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1761 | } |
| 1762 | } |
| 1763 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1764 | TEST_F(VkLayerTest, SecondaryCommandBufferFramebufferAndRenderpass) |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1765 | { |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1766 | VkResult err; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1767 | VkCommandBuffer draw_cmd; |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1768 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1769 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1770 | "must specify framebuffer and renderpass parameters"); |
| 1771 | |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1772 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1773 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1774 | VkCommandBufferAllocateInfo cmd = {}; |
| 1775 | cmd.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOC_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 1776 | cmd.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1777 | cmd.commandPool = m_commandPool; |
| 1778 | cmd.level = VK_COMMAND_BUFFER_LEVEL_SECONDARY; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1779 | cmd.bufferCount = 1; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 1780 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1781 | err = vkAllocateCommandBuffers(m_device->device(), &cmd, &draw_cmd); |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1782 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1783 | |
| 1784 | // Force the failure by not setting the Renderpass and Framebuffer fields |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1785 | VkCommandBufferBeginInfo cmd_buf_info = {}; |
| 1786 | cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; |
Cody Northrop | b456970 | 2015-08-04 17:35:57 -0600 | [diff] [blame] | 1787 | cmd_buf_info.pNext = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1788 | cmd_buf_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1789 | |
| 1790 | // The error should be caught by validation of the BeginCommandBuffer call |
| 1791 | vkBeginCommandBuffer(draw_cmd, &cmd_buf_info); |
| 1792 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1793 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1794 | FAIL() << "Did not receive Error 'vkAllocateCommandBuffers(): Secondary Command Buffer must specify framebuffer and renderpass parameters'"; |
| 1795 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1796 | } |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1797 | vkFreeCommandBuffers(m_device->device(), m_commandPool, 1, &draw_cmd); |
Mark Lobodzinski | d9139a6 | 2015-08-04 16:24:20 -0600 | [diff] [blame] | 1798 | } |
| 1799 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1800 | TEST_F(VkLayerTest, InvalidPipelineCreateState) |
| 1801 | { |
| 1802 | // Attempt to Create Gfx Pipeline w/o a VS |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1803 | VkResult err; |
| 1804 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1805 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1806 | "Invalid Pipeline CreateInfo State: Vtx Shader required"); |
| 1807 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1808 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1809 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 1810 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1811 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1812 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1813 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1814 | |
| 1815 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 1816 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 1817 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 1818 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1819 | ds_pool_ci.poolSizeCount = 1; |
| 1820 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 1821 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1822 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1823 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1824 | ASSERT_VK_SUCCESS(err); |
| 1825 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1826 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1827 | dsl_binding.binding = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1828 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1829 | dsl_binding.arraySize = 1; |
| 1830 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1831 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1832 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1833 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1834 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1835 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1836 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | a745e51 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1837 | ds_layout_ci.pBinding = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1838 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1839 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1840 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1841 | ASSERT_VK_SUCCESS(err); |
| 1842 | |
| 1843 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1844 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1845 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1846 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 1847 | alloc_info.descriptorPool = ds_pool; |
| 1848 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1849 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1850 | ASSERT_VK_SUCCESS(err); |
| 1851 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1852 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 1853 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1854 | pipeline_layout_ci.setLayoutCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1855 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1856 | |
| 1857 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1858 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1859 | ASSERT_VK_SUCCESS(err); |
| 1860 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 1861 | VkViewport vp = {}; // Just need dummy vp to point to |
| 1862 | VkRect2D sc = {}; // dummy scissor to point to |
| 1863 | |
| 1864 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 1865 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 1866 | vp_state_ci.scissorCount = 1; |
| 1867 | vp_state_ci.pScissors = ≻ |
| 1868 | vp_state_ci.viewportCount = 1; |
| 1869 | vp_state_ci.pViewports = &vp; |
| 1870 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1871 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 1872 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 1873 | gp_ci.pViewportState = &vp_state_ci; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1874 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 1875 | gp_ci.layout = pipeline_layout; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 1876 | gp_ci.renderPass = renderPass(); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 1877 | |
| 1878 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 1879 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
Chia-I Wu | 2bfb33c | 2015-10-26 17:24:52 +0800 | [diff] [blame] | 1880 | pc_ci.initialDataSize = 0; |
| 1881 | pc_ci.pInitialData = 0; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1882 | |
| 1883 | VkPipeline pipeline; |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 1884 | VkPipelineCache pipelineCache; |
| 1885 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1886 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Jon Ashburn | c669cc6 | 2015-07-09 15:02:25 -0600 | [diff] [blame] | 1887 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1888 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 1889 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1890 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 1891 | FAIL() << "Did not receive Error 'Invalid Pipeline CreateInfo State: Vtx Shader required'"; |
| 1892 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1893 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 1894 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1895 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 1896 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 1897 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 1898 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1899 | } |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1900 | /*// TODO : This test should be good, but needs Tess support in compiler to run |
| 1901 | TEST_F(VkLayerTest, InvalidPatchControlPoints) |
| 1902 | { |
| 1903 | // Attempt to Create Gfx Pipeline w/o a VS |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1904 | VkResult err; |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 1905 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 1906 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 1907 | "Invalid Pipeline CreateInfo State: VK_PRIMITIVE_TOPOLOGY_PATCH primitive "); |
| 1908 | |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1909 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 1910 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1911 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1912 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1913 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1914 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -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; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 1919 | ds_pool_ci.poolSizeCount = 1; |
| 1920 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1921 | |
| 1922 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1923 | err = vkCreateDescriptorPool(m_device->device(), VK_DESCRIPTOR_POOL_USAGE_NON_FREE, 1, &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1924 | ASSERT_VK_SUCCESS(err); |
| 1925 | |
| 1926 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1927 | dsl_binding.binding = 0; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1928 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 1929 | dsl_binding.arraySize = 1; |
| 1930 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 1931 | dsl_binding.pImmutableSamplers = NULL; |
| 1932 | |
| 1933 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 1934 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 1935 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1936 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | a745e51 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1937 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1938 | |
| 1939 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1940 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1941 | ASSERT_VK_SUCCESS(err); |
| 1942 | |
| 1943 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1944 | err = vkAllocateDescriptorSets(m_device->device(), ds_pool, VK_DESCRIPTOR_SET_USAGE_NON_FREE, 1, &ds_layout, &descriptorSet); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1945 | ASSERT_VK_SUCCESS(err); |
| 1946 | |
| 1947 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 1948 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 1949 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 1950 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1951 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 1952 | |
| 1953 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 1954 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1955 | ASSERT_VK_SUCCESS(err); |
| 1956 | |
| 1957 | VkPipelineShaderStageCreateInfo shaderStages[3]; |
| 1958 | memset(&shaderStages, 0, 3 * sizeof(VkPipelineShaderStageCreateInfo)); |
| 1959 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 1960 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1961 | // Just using VS txt for Tess shaders as we don't care about functionality |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 1962 | VkShaderObj tc(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, this); |
| 1963 | VkShaderObj te(m_device,bindStateVertShaderText,VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, this); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1964 | |
| 1965 | shaderStages[0].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 1966 | shaderStages[0].stage = VK_SHADER_STAGE_VERTEX_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1967 | shaderStages[0].shader = vs.handle(); |
| 1968 | shaderStages[1].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 1969 | shaderStages[1].stage = VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1970 | shaderStages[1].shader = tc.handle(); |
| 1971 | shaderStages[2].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 1972 | shaderStages[2].stage = VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1973 | shaderStages[2].shader = te.handle(); |
| 1974 | |
| 1975 | VkPipelineInputAssemblyStateCreateInfo iaCI = {}; |
| 1976 | iaCI.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
Chia-I Wu | 515eb8f | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 1977 | iaCI.topology = VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1978 | |
| 1979 | VkPipelineTessellationStateCreateInfo tsCI = {}; |
| 1980 | tsCI.sType = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO; |
| 1981 | tsCI.patchControlPoints = 0; // This will cause an error |
| 1982 | |
| 1983 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 1984 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 1985 | gp_ci.pNext = NULL; |
| 1986 | gp_ci.stageCount = 3; |
| 1987 | gp_ci.pStages = shaderStages; |
| 1988 | gp_ci.pVertexInputState = NULL; |
| 1989 | gp_ci.pInputAssemblyState = &iaCI; |
| 1990 | gp_ci.pTessellationState = &tsCI; |
| 1991 | gp_ci.pViewportState = NULL; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 1992 | gp_ci.pRasterizationState = NULL; |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 1993 | gp_ci.pMultisampleState = NULL; |
| 1994 | gp_ci.pDepthStencilState = NULL; |
| 1995 | gp_ci.pColorBlendState = NULL; |
| 1996 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 1997 | gp_ci.layout = pipeline_layout; |
| 1998 | gp_ci.renderPass = renderPass(); |
| 1999 | |
| 2000 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 2001 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 2002 | pc_ci.pNext = NULL; |
| 2003 | pc_ci.initialSize = 0; |
| 2004 | pc_ci.initialData = 0; |
| 2005 | pc_ci.maxSize = 0; |
| 2006 | |
| 2007 | VkPipeline pipeline; |
| 2008 | VkPipelineCache pipelineCache; |
| 2009 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2010 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2011 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2012 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2013 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2014 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2015 | FAIL() << "Did not receive Error 'Invalid Pipeline CreateInfo State: VK_PRIMITIVE_TOPOLOGY_PATCH primitive...'"; |
| 2016 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2017 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2018 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2019 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2020 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2021 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2022 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 912df02 | 2015-09-17 08:46:18 -0600 | [diff] [blame] | 2023 | } |
| 2024 | */ |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2025 | // Set scissor and viewport counts to different numbers |
| 2026 | TEST_F(VkLayerTest, PSOViewportScissorCountMismatch) |
| 2027 | { |
| 2028 | // Attempt to Create Gfx Pipeline w/o a VS |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2029 | VkResult err; |
| 2030 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2031 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2032 | "Gfx Pipeline viewport count (1) must match scissor count (0)."); |
| 2033 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2034 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2035 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2036 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2037 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2038 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2039 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2040 | |
| 2041 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2042 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2043 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2044 | ds_pool_ci.poolSizeCount = 1; |
| 2045 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2046 | |
| 2047 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2048 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2049 | ASSERT_VK_SUCCESS(err); |
| 2050 | |
| 2051 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2052 | dsl_binding.binding = 0; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2053 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2054 | dsl_binding.arraySize = 1; |
| 2055 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2056 | |
| 2057 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2058 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2059 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | a745e51 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2060 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2061 | |
| 2062 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2063 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2064 | ASSERT_VK_SUCCESS(err); |
| 2065 | |
| 2066 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2067 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2068 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2069 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2070 | alloc_info.descriptorPool = ds_pool; |
| 2071 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2072 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2073 | ASSERT_VK_SUCCESS(err); |
| 2074 | |
| 2075 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 2076 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2077 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2078 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 2079 | |
| 2080 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2081 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2082 | ASSERT_VK_SUCCESS(err); |
| 2083 | |
| 2084 | VkViewport vp = {}; // Just need dummy vp to point to |
| 2085 | |
| 2086 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 2087 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 2088 | vp_state_ci.scissorCount = 0; |
| 2089 | vp_state_ci.viewportCount = 1; // Count mismatch should cause error |
| 2090 | vp_state_ci.pViewports = &vp; |
| 2091 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2092 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 2093 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2094 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2095 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, this); |
| 2096 | VkShaderObj fs(m_device, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, this); // TODO - We shouldn't need a fragment shader |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2097 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2098 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 2099 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2100 | |
| 2101 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 2102 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2103 | gp_ci.stageCount = 2; |
| 2104 | gp_ci.pStages = shaderStages; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2105 | gp_ci.pViewportState = &vp_state_ci; |
| 2106 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2107 | gp_ci.layout = pipeline_layout; |
| 2108 | gp_ci.renderPass = renderPass(); |
| 2109 | |
| 2110 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 2111 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 2112 | |
| 2113 | VkPipeline pipeline; |
| 2114 | VkPipelineCache pipelineCache; |
| 2115 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2116 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2117 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2118 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2119 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2120 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2121 | FAIL() << "Did not receive Error 'Gfx Pipeline viewport count (1) must match scissor count (0).'"; |
| 2122 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2123 | } |
| 2124 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2125 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2126 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2127 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2128 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2129 | } |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2130 | // Don't set viewport state in PSO. This is an error b/c we always need this state |
| 2131 | // for the counts even if the data is going to be set dynamically. |
| 2132 | TEST_F(VkLayerTest, PSOViewportStateNotSet) |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2133 | { |
| 2134 | // Attempt to Create Gfx Pipeline w/o a VS |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2135 | VkResult err; |
| 2136 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2137 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2138 | "Gfx Pipeline pViewportState is null. Even if "); |
| 2139 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2140 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2141 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2142 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2143 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2144 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2145 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2146 | |
| 2147 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2148 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2149 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2150 | ds_pool_ci.poolSizeCount = 1; |
| 2151 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2152 | |
| 2153 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2154 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2155 | ASSERT_VK_SUCCESS(err); |
| 2156 | |
| 2157 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2158 | dsl_binding.binding = 0; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2159 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2160 | dsl_binding.arraySize = 1; |
| 2161 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2162 | |
| 2163 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2164 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2165 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | a745e51 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2166 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2167 | |
| 2168 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2169 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2170 | ASSERT_VK_SUCCESS(err); |
| 2171 | |
| 2172 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2173 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2174 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2175 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2176 | alloc_info.descriptorPool = ds_pool; |
| 2177 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2178 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2179 | ASSERT_VK_SUCCESS(err); |
| 2180 | |
| 2181 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 2182 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2183 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2184 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 2185 | |
| 2186 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2187 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2188 | ASSERT_VK_SUCCESS(err); |
| 2189 | |
| 2190 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 2191 | // Set scissor as dynamic to avoid second error |
| 2192 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 2193 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 2194 | dyn_state_ci.dynamicStateCount = 1; |
| 2195 | dyn_state_ci.pDynamicStates = &sc_state; |
| 2196 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2197 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 2198 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2199 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2200 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, this); |
| 2201 | VkShaderObj fs(m_device, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, this); // TODO - We shouldn't need a fragment shader |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2202 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2203 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 2204 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2205 | |
| 2206 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 2207 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2208 | gp_ci.stageCount = 2; |
| 2209 | gp_ci.pStages = shaderStages; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2210 | gp_ci.pViewportState = NULL; // Not setting VP state w/o dynamic vp state should cause validation error |
| 2211 | gp_ci.pDynamicState = &dyn_state_ci; |
| 2212 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2213 | gp_ci.layout = pipeline_layout; |
| 2214 | gp_ci.renderPass = renderPass(); |
| 2215 | |
| 2216 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 2217 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 2218 | |
| 2219 | VkPipeline pipeline; |
| 2220 | VkPipelineCache pipelineCache; |
| 2221 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2222 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2223 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2224 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2225 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2226 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2227 | FAIL() << "Did not receive Error 'Gfx Pipeline pViewportState is null. Even if...'"; |
| 2228 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2229 | } |
| 2230 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2231 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2232 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2233 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2234 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2235 | } |
| 2236 | // Create PSO w/o non-zero viewportCount but no viewport data |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2237 | // Then run second test where dynamic scissor count doesn't match PSO scissor count |
| 2238 | TEST_F(VkLayerTest, PSOViewportCountWithoutDataAndDynScissorMismatch) |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2239 | { |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2240 | VkResult err; |
| 2241 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2242 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2243 | "Gfx Pipeline viewportCount is 1, but pViewports is NULL. "); |
| 2244 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2245 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2246 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2247 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2248 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2249 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2250 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2251 | |
| 2252 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2253 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2254 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2255 | ds_pool_ci.poolSizeCount = 1; |
| 2256 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2257 | |
| 2258 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2259 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2260 | ASSERT_VK_SUCCESS(err); |
| 2261 | |
| 2262 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2263 | dsl_binding.binding = 0; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2264 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2265 | dsl_binding.arraySize = 1; |
| 2266 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2267 | |
| 2268 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2269 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2270 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | a745e51 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2271 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2272 | |
| 2273 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2274 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2275 | ASSERT_VK_SUCCESS(err); |
| 2276 | |
| 2277 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2278 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2279 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2280 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2281 | alloc_info.descriptorPool = ds_pool; |
| 2282 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2283 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2284 | ASSERT_VK_SUCCESS(err); |
| 2285 | |
| 2286 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 2287 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2288 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2289 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 2290 | |
| 2291 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2292 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2293 | ASSERT_VK_SUCCESS(err); |
| 2294 | |
| 2295 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 2296 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 2297 | vp_state_ci.viewportCount = 1; |
| 2298 | vp_state_ci.pViewports = NULL; // Null vp w/ count of 1 should cause error |
| 2299 | vp_state_ci.scissorCount = 1; |
| 2300 | vp_state_ci.pScissors = NULL; // Scissor is dynamic (below) so this won't cause error |
| 2301 | |
| 2302 | VkDynamicState sc_state = VK_DYNAMIC_STATE_SCISSOR; |
| 2303 | // Set scissor as dynamic to avoid that error |
| 2304 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 2305 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 2306 | dyn_state_ci.dynamicStateCount = 1; |
| 2307 | dyn_state_ci.pDynamicStates = &sc_state; |
| 2308 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2309 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 2310 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2311 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2312 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, this); |
| 2313 | VkShaderObj fs(m_device, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, this); // TODO - We shouldn't need a fragment shader |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2314 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2315 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 2316 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2317 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2318 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 2319 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 2320 | vi_ci.pNext = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2321 | vi_ci.vertexBindingDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2322 | vi_ci.pVertexBindingDescriptions = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2323 | vi_ci.vertexAttributeDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2324 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 2325 | |
| 2326 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 2327 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 2328 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 2329 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2330 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2331 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2332 | rs_ci.pNext = nullptr; |
| 2333 | |
| 2334 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 2335 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 2336 | cb_ci.pNext = nullptr; |
| 2337 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2338 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 2339 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2340 | gp_ci.stageCount = 2; |
| 2341 | gp_ci.pStages = shaderStages; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2342 | gp_ci.pVertexInputState = &vi_ci; |
| 2343 | gp_ci.pInputAssemblyState = &ia_ci; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2344 | gp_ci.pViewportState = &vp_state_ci; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2345 | gp_ci.pRasterizationState = &rs_ci; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2346 | gp_ci.pColorBlendState = &cb_ci; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2347 | gp_ci.pDynamicState = &dyn_state_ci; |
| 2348 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2349 | gp_ci.layout = pipeline_layout; |
| 2350 | gp_ci.renderPass = renderPass(); |
| 2351 | |
| 2352 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 2353 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 2354 | |
| 2355 | VkPipeline pipeline; |
| 2356 | VkPipelineCache pipelineCache; |
| 2357 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2358 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2359 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2360 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2361 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2362 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2363 | FAIL() << "Did not recieve Error 'Gfx Pipeline viewportCount is 1, but pViewports is NULL...'"; |
| 2364 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2365 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2366 | |
| 2367 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2368 | // Now hit second fail case where we set scissor w/ different count than PSO |
| 2369 | // First need to successfully create the PSO from above by setting pViewports |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2370 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2371 | "Dynamic scissorCount from vkCmdSetScissor() is 2, but PSO scissorCount is 1. These counts must match."); |
| 2372 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2373 | VkViewport vp = {}; // Just need dummy vp to point to |
| 2374 | vp_state_ci.pViewports = &vp; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2375 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2376 | ASSERT_VK_SUCCESS(err); |
| 2377 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2378 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2379 | VkRect2D scissors[2] = {}; // don't care about data |
| 2380 | // Count of 2 doesn't match PSO count of 1 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2381 | vkCmdSetScissor(m_commandBuffer->GetBufferHandle(), 2, scissors); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2382 | Draw(1, 0, 0, 0); |
| 2383 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2384 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2385 | FAIL() << "Did not receive Error 'Dynamic scissorCount from vkCmdSetScissor() is 2, but PSO scissorCount is 1...'"; |
| 2386 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2387 | } |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2388 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2389 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2390 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2391 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2392 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2393 | } |
| 2394 | // Create PSO w/o non-zero scissorCount but no scissor data |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2395 | // Then run second test where dynamic viewportCount doesn't match PSO viewportCount |
| 2396 | TEST_F(VkLayerTest, PSOScissorCountWithoutDataAndDynViewportMismatch) |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2397 | { |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2398 | VkResult err; |
| 2399 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2400 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2401 | "Gfx Pipeline scissorCount is 1, but pScissors is NULL. "); |
| 2402 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2403 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2404 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2405 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2406 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2407 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2408 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2409 | |
| 2410 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2411 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2412 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2413 | ds_pool_ci.poolSizeCount = 1; |
| 2414 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2415 | |
| 2416 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2417 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2418 | ASSERT_VK_SUCCESS(err); |
| 2419 | |
| 2420 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2421 | dsl_binding.binding = 0; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2422 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2423 | dsl_binding.arraySize = 1; |
| 2424 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2425 | |
| 2426 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2427 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2428 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | a745e51 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2429 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2430 | |
| 2431 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2432 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2433 | ASSERT_VK_SUCCESS(err); |
| 2434 | |
| 2435 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2436 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2437 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2438 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2439 | alloc_info.descriptorPool = ds_pool; |
| 2440 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2441 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2442 | ASSERT_VK_SUCCESS(err); |
| 2443 | |
| 2444 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 2445 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2446 | pipeline_layout_ci.setLayoutCount = 1; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2447 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 2448 | |
| 2449 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2450 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2451 | ASSERT_VK_SUCCESS(err); |
| 2452 | |
| 2453 | VkPipelineViewportStateCreateInfo vp_state_ci = {}; |
| 2454 | vp_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; |
| 2455 | vp_state_ci.scissorCount = 1; |
| 2456 | vp_state_ci.pScissors = NULL; // Null scissor w/ count of 1 should cause error |
| 2457 | vp_state_ci.viewportCount = 1; |
| 2458 | vp_state_ci.pViewports = NULL; // vp is dynamic (below) so this won't cause error |
| 2459 | |
| 2460 | VkDynamicState vp_state = VK_DYNAMIC_STATE_VIEWPORT; |
| 2461 | // Set scissor as dynamic to avoid that error |
| 2462 | VkPipelineDynamicStateCreateInfo dyn_state_ci = {}; |
| 2463 | dyn_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; |
| 2464 | dyn_state_ci.dynamicStateCount = 1; |
| 2465 | dyn_state_ci.pDynamicStates = &vp_state; |
| 2466 | |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2467 | VkPipelineShaderStageCreateInfo shaderStages[2]; |
| 2468 | memset(&shaderStages, 0, 2 * sizeof(VkPipelineShaderStageCreateInfo)); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2469 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 2470 | VkShaderObj vs(m_device,bindStateVertShaderText,VK_SHADER_STAGE_VERTEX_BIT, this); |
| 2471 | VkShaderObj fs(m_device, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, this); // TODO - We shouldn't need a fragment shader |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2472 | // but add it to be able to run on more devices |
Chia-I Wu | 28e0691 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2473 | shaderStages[0] = vs.GetStageCreateInfo(); |
| 2474 | shaderStages[1] = fs.GetStageCreateInfo(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2475 | |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2476 | VkPipelineVertexInputStateCreateInfo vi_ci = {}; |
| 2477 | vi_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; |
| 2478 | vi_ci.pNext = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2479 | vi_ci.vertexBindingDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2480 | vi_ci.pVertexBindingDescriptions = nullptr; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2481 | vi_ci.vertexAttributeDescriptionCount = 0; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2482 | vi_ci.pVertexAttributeDescriptions = nullptr; |
| 2483 | |
| 2484 | VkPipelineInputAssemblyStateCreateInfo ia_ci = {}; |
| 2485 | ia_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; |
| 2486 | ia_ci.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP; |
| 2487 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2488 | VkPipelineRasterizationStateCreateInfo rs_ci = {}; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2489 | rs_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2490 | rs_ci.pNext = nullptr; |
| 2491 | |
| 2492 | VkPipelineColorBlendStateCreateInfo cb_ci = {}; |
| 2493 | cb_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; |
| 2494 | cb_ci.pNext = nullptr; |
| 2495 | |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2496 | VkGraphicsPipelineCreateInfo gp_ci = {}; |
| 2497 | gp_ci.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
Cody Northrop | eb3a6c1 | 2015-10-05 14:44:45 -0600 | [diff] [blame] | 2498 | gp_ci.stageCount = 2; |
| 2499 | gp_ci.pStages = shaderStages; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2500 | gp_ci.pVertexInputState = &vi_ci; |
| 2501 | gp_ci.pInputAssemblyState = &ia_ci; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2502 | gp_ci.pViewportState = &vp_state_ci; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2503 | gp_ci.pRasterizationState = &rs_ci; |
Cody Northrop | f6622dc | 2015-10-06 10:33:21 -0600 | [diff] [blame] | 2504 | gp_ci.pColorBlendState = &cb_ci; |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2505 | gp_ci.pDynamicState = &dyn_state_ci; |
| 2506 | gp_ci.flags = VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT; |
| 2507 | gp_ci.layout = pipeline_layout; |
| 2508 | gp_ci.renderPass = renderPass(); |
| 2509 | |
| 2510 | VkPipelineCacheCreateInfo pc_ci = {}; |
| 2511 | pc_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; |
| 2512 | |
| 2513 | VkPipeline pipeline; |
| 2514 | VkPipelineCache pipelineCache; |
| 2515 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2516 | err = vkCreatePipelineCache(m_device->device(), &pc_ci, NULL, &pipelineCache); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2517 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2518 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2519 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2520 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2521 | FAIL() << "Did not recieve Error 'Gfx Pipeline scissorCount is 1, but pScissors is NULL...'"; |
| 2522 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2523 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2524 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2525 | // Now hit second fail case where we set scissor w/ different count than PSO |
| 2526 | // First need to successfully create the PSO from above by setting pViewports |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2527 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2528 | "Dynamic viewportCount from vkCmdSetViewport() is 2, but PSO viewportCount is 1. These counts must match."); |
| 2529 | |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2530 | VkRect2D sc = {}; // Just need dummy vp to point to |
| 2531 | vp_state_ci.pScissors = ≻ |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2532 | err = vkCreateGraphicsPipelines(m_device->device(), pipelineCache, 1, &gp_ci, NULL, &pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2533 | ASSERT_VK_SUCCESS(err); |
| 2534 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2535 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2536 | VkViewport viewports[2] = {}; // don't care about data |
| 2537 | // Count of 2 doesn't match PSO count of 1 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2538 | vkCmdSetViewport(m_commandBuffer->GetBufferHandle(), 2, viewports); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2539 | Draw(1, 0, 0, 0); |
| 2540 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2541 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2542 | FAIL() << "Did not receive Error 'Dynamic viewportCount from vkCmdSetViewport() is 2, but PSO viewportCount is 1...'"; |
| 2543 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 2544 | } |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2545 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2546 | vkDestroyPipelineCache(m_device->device(), pipelineCache, NULL); |
| 2547 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 2548 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2549 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | e68360f | 2015-10-01 11:15:13 -0600 | [diff] [blame] | 2550 | } |
| 2551 | |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 2552 | TEST_F(VkLayerTest, NullRenderPass) |
| 2553 | { |
| 2554 | // Bind a NULL RenderPass |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2555 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2556 | "You cannot use a NULL RenderPass object in vkCmdBeginRenderPass()"); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 2557 | |
| 2558 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2559 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 2560 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 2561 | BeginCommandBuffer(); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 2562 | // Don't care about RenderPass handle b/c error should be flagged before that |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2563 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), NULL, VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 2564 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2565 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2566 | FAIL() << "Did not receive Error 'You cannot use a NULL RenderPass object in vkCmdBeginRenderPass()'"; |
| 2567 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 2568 | } |
| 2569 | } |
| 2570 | |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2571 | TEST_F(VkLayerTest, RenderPassWithinRenderPass) |
| 2572 | { |
| 2573 | // Bind a BeginRenderPass within an active RenderPass |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2574 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2575 | "It is invalid to issue this call inside an active render pass"); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2576 | |
| 2577 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2578 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2579 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 2580 | BeginCommandBuffer(); |
Tobin Ehlis | 98aa0ed | 2015-06-25 16:27:19 -0600 | [diff] [blame] | 2581 | // Just create a dummy Renderpass that's non-NULL so we can get to the proper error |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2582 | VkRenderPassBeginInfo rp_begin = {}; |
| 2583 | rp_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; |
| 2584 | rp_begin.pNext = NULL; |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 2585 | rp_begin.renderPass = renderPass(); |
| 2586 | rp_begin.framebuffer = framebuffer(); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 2587 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2588 | vkCmdBeginRenderPass(m_commandBuffer->GetBufferHandle(), &rp_begin, VK_SUBPASS_CONTENTS_INLINE); |
Tobin Ehlis | af1f3a4 | 2015-06-25 15:46:59 -0600 | [diff] [blame] | 2589 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2590 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2591 | FAIL() << "Did not receive Error 'It is invalid to issue this call inside an active render pass...'"; |
| 2592 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 2593 | } |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2594 | } |
| 2595 | |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2596 | TEST_F(VkLayerTest, FillBufferWithinRenderPass) |
| 2597 | { |
| 2598 | // Call CmdFillBuffer within an active renderpass |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2599 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2600 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2601 | |
| 2602 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2603 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2604 | |
| 2605 | // Renderpass is started here |
| 2606 | BeginCommandBuffer(); |
| 2607 | |
| 2608 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2609 | vk_testing::Buffer dstBuffer; |
| 2610 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2611 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2612 | m_commandBuffer->FillBuffer(dstBuffer.handle(), 0, 4, 0x11111111); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2613 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2614 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2615 | FAIL() << "Did not receive Error 'It is invalid to issue this call inside an active render pass...'"; |
| 2616 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2617 | } |
| 2618 | } |
| 2619 | |
| 2620 | TEST_F(VkLayerTest, UpdateBufferWithinRenderPass) |
| 2621 | { |
| 2622 | // Call CmdUpdateBuffer within an active renderpass |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2623 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2624 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2625 | |
| 2626 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2627 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2628 | |
| 2629 | // Renderpass is started here |
| 2630 | BeginCommandBuffer(); |
| 2631 | |
| 2632 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2633 | vk_testing::Buffer dstBuffer; |
| 2634 | dstBuffer.init_as_dst(*m_device, (VkDeviceSize)1024, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2635 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2636 | VkDeviceSize dstOffset = 0; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2637 | VkDeviceSize dataSize = 1024; |
| 2638 | const uint32_t *pData = NULL; |
| 2639 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2640 | vkCmdUpdateBuffer(m_commandBuffer->GetBufferHandle(), dstBuffer.handle(), dstOffset, dataSize, pData); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2641 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2642 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2643 | FAIL() << "Did not receive Error 'It is invalid to issue this call inside an active render pass...'"; |
| 2644 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2645 | } |
| 2646 | } |
| 2647 | |
| 2648 | TEST_F(VkLayerTest, ClearColorImageWithinRenderPass) |
| 2649 | { |
| 2650 | // Call CmdClearColorImage within an active RenderPass |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2651 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2652 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2653 | |
| 2654 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2655 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2656 | |
| 2657 | // Renderpass is started here |
| 2658 | BeginCommandBuffer(); |
| 2659 | |
| 2660 | VkClearColorValue clear_color = {0}; |
| 2661 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 2662 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 2663 | const int32_t tex_width = 32; |
| 2664 | const int32_t tex_height = 32; |
| 2665 | VkImageCreateInfo image_create_info = {}; |
| 2666 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 2667 | image_create_info.pNext = NULL; |
| 2668 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2669 | image_create_info.format = tex_format; |
| 2670 | image_create_info.extent.width = tex_width; |
| 2671 | image_create_info.extent.height = tex_height; |
| 2672 | image_create_info.extent.depth = 1; |
| 2673 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 2674 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 5c17c96 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2675 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2676 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 2677 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 2678 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2679 | vk_testing::Image dstImage; |
| 2680 | dstImage.init(*m_device, (const VkImageCreateInfo&)image_create_info, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2681 | |
| 2682 | const VkImageSubresourceRange range = |
| 2683 | vk_testing::Image::subresource_range(image_create_info, VK_IMAGE_ASPECT_COLOR_BIT); |
| 2684 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2685 | vkCmdClearColorImage(m_commandBuffer->GetBufferHandle(), |
| 2686 | dstImage.handle(), |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2687 | VK_IMAGE_LAYOUT_GENERAL, |
| 2688 | &clear_color, |
| 2689 | 1, |
| 2690 | &range); |
| 2691 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2692 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2693 | FAIL() << "Did not receive Error 'It is invalid to issue this call inside an active render pass...'"; |
| 2694 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2695 | } |
| 2696 | } |
| 2697 | |
| 2698 | TEST_F(VkLayerTest, ClearDepthStencilImageWithinRenderPass) |
| 2699 | { |
| 2700 | // Call CmdClearDepthStencilImage within an active RenderPass |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2701 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2702 | "It is invalid to issue this call inside an active render pass"); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2703 | |
| 2704 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2705 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2706 | |
| 2707 | // Renderpass is started here |
| 2708 | BeginCommandBuffer(); |
| 2709 | |
| 2710 | VkClearDepthStencilValue clear_value = {0}; |
| 2711 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 2712 | VkImageCreateInfo image_create_info = vk_testing::Image::create_info(); |
| 2713 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 2714 | image_create_info.format = VK_FORMAT_D24_UNORM_S8_UINT; |
| 2715 | image_create_info.extent.width = 64; |
| 2716 | image_create_info.extent.height = 64; |
| 2717 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 2718 | image_create_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 2719 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2720 | vk_testing::Image dstImage; |
| 2721 | dstImage.init(*m_device, (const VkImageCreateInfo&)image_create_info, reqs); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2722 | |
| 2723 | const VkImageSubresourceRange range = |
| 2724 | vk_testing::Image::subresource_range(image_create_info, VK_IMAGE_ASPECT_DEPTH_BIT); |
| 2725 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2726 | vkCmdClearDepthStencilImage(m_commandBuffer->GetBufferHandle(), |
| 2727 | dstImage.handle(), |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2728 | VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, |
| 2729 | &clear_value, |
| 2730 | 1, |
| 2731 | &range); |
| 2732 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2733 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2734 | FAIL() << "Did not receive Error 'It is invalid to issue this call inside an active render pass...'"; |
| 2735 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2736 | } |
| 2737 | } |
| 2738 | |
| 2739 | TEST_F(VkLayerTest, ClearColorAttachmentsOutsideRenderPass) |
| 2740 | { |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 2741 | // Call CmdClearAttachmentss outside of an active RenderPass |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2742 | VkResult err; |
| 2743 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2744 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2745 | "vkCmdClearAttachments: This call must be issued inside an active render pass"); |
| 2746 | |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2747 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2748 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2749 | |
| 2750 | // Start no RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2751 | err = m_commandBuffer->BeginCommandBuffer(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2752 | ASSERT_VK_SUCCESS(err); |
| 2753 | |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 2754 | VkClearAttachment color_attachment; |
| 2755 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 2756 | color_attachment.clearValue.color.float32[0] = 0; |
| 2757 | color_attachment.clearValue.color.float32[1] = 0; |
| 2758 | color_attachment.clearValue.color.float32[2] = 0; |
| 2759 | color_attachment.clearValue.color.float32[3] = 0; |
| 2760 | color_attachment.colorAttachment = 0; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 2761 | VkClearRect clear_rect = { { { 0, 0 }, { 32, 32 } } }; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2762 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 2763 | 1, &color_attachment, |
| 2764 | 1, &clear_rect); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2765 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2766 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2767 | FAIL() << "Did not receive Error 'vkCmdClearAttachments: This call must be issued inside an active render pass.'"; |
| 2768 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | d563950 | 2015-09-24 09:51:47 -0600 | [diff] [blame] | 2769 | } |
| 2770 | } |
| 2771 | |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2772 | TEST_F(VkLayerTest, InvalidDynamicStateObject) |
| 2773 | { |
| 2774 | // Create a valid cmd buffer |
| 2775 | // call vkCmdBindDynamicStateObject w/ false DS Obj |
Tobin Ehlis | 7d1a711 | 2015-05-27 14:32:28 -0600 | [diff] [blame] | 2776 | // TODO : Simple check for bad object should be added to ObjectTracker to catch this case |
| 2777 | // The DS check for this is after driver has been called to validate DS internal data struct |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2778 | } |
Tobin Ehlis | 1056d45 | 2015-05-27 14:55:35 -0600 | [diff] [blame] | 2779 | |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 2780 | TEST_F(VkLayerTest, IdxBufferAlignmentError) |
| 2781 | { |
| 2782 | // Bind a BeginRenderPass within an active RenderPass |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 2783 | VkResult err; |
| 2784 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2785 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2786 | "vkCmdBindIndexBuffer() offset (0x7) does not fall on "); |
| 2787 | |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 2788 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2789 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 2790 | uint32_t qfi = 0; |
| 2791 | VkBufferCreateInfo buffCI = {}; |
| 2792 | buffCI.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; |
| 2793 | buffCI.size = 1024; |
| 2794 | buffCI.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2795 | buffCI.queueFamilyIndexCount = 1; |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 2796 | buffCI.pQueueFamilyIndices = &qfi; |
| 2797 | |
| 2798 | VkBuffer ib; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2799 | err = vkCreateBuffer(m_device->device(), &buffCI, NULL, &ib); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 2800 | ASSERT_VK_SUCCESS(err); |
| 2801 | |
| 2802 | BeginCommandBuffer(); |
| 2803 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2804 | //vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 2805 | // Should error before calling to driver so don't care about actual data |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2806 | vkCmdBindIndexBuffer(m_commandBuffer->GetBufferHandle(), ib, 7, VK_INDEX_TYPE_UINT16); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 2807 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2808 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2809 | FAIL() << "Did not receive Error 'vkCmdBindIndexBuffer() offset (0x7) does not fall on ...'"; |
| 2810 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 2811 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2812 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2813 | vkDestroyBuffer(m_device->device(), ib, NULL); |
Tobin Ehlis | c4c2318 | 2015-09-17 12:24:13 -0600 | [diff] [blame] | 2814 | } |
| 2815 | |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 2816 | TEST_F(VkLayerTest, ExecuteCommandsPrimaryCB) |
| 2817 | { |
| 2818 | // Attempt vkCmdExecuteCommands w/ a primary cmd buffer (should only be secondary) |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2819 | |
| 2820 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2821 | "vkCmdExecuteCommands() called w/ Primary Cmd Buffer "); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 2822 | |
| 2823 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 2824 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 2825 | |
| 2826 | BeginCommandBuffer(); |
| 2827 | //ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2828 | VkCommandBuffer primCB = m_commandBuffer->GetBufferHandle(); |
| 2829 | vkCmdExecuteCommands(m_commandBuffer->GetBufferHandle(), 1, &primCB); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 2830 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2831 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2832 | FAIL() << "Did not receive Error 'vkCmdExecuteCommands() called w/ Primary Cmd Buffer '"; |
| 2833 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 4b34ddc | 2015-09-17 14:18:16 -0600 | [diff] [blame] | 2834 | } |
| 2835 | } |
| 2836 | |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2837 | TEST_F(VkLayerTest, DSTypeMismatch) |
| 2838 | { |
| 2839 | // Create DS w/ layout of one type and attempt Update w/ mis-matched type |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2840 | VkResult err; |
| 2841 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2842 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2843 | "Write descriptor update has descriptor type VK_DESCRIPTOR_TYPE_SAMPLER that does not match "); |
| 2844 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2845 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2846 | //VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2847 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2848 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2849 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2850 | |
| 2851 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2852 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2853 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 2854 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2855 | ds_pool_ci.poolSizeCount = 1; |
| 2856 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2857 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2858 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2859 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2860 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2861 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2862 | dsl_binding.binding = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2863 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2864 | dsl_binding.arraySize = 1; |
| 2865 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2866 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2867 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2868 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2869 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2870 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2871 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | a745e51 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2872 | ds_layout_ci.pBinding = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2873 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2874 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2875 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2876 | ASSERT_VK_SUCCESS(err); |
| 2877 | |
| 2878 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2879 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2880 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2881 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2882 | alloc_info.descriptorPool = ds_pool; |
| 2883 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2884 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2885 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2886 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2887 | VkSamplerCreateInfo sampler_ci = {}; |
| 2888 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 2889 | sampler_ci.pNext = NULL; |
Chia-I Wu | b99df44 | 2015-10-26 16:49:32 +0800 | [diff] [blame] | 2890 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 2891 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 2892 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_BASE; |
Chia-I Wu | 1efb7e5 | 2015-10-26 17:32:47 +0800 | [diff] [blame] | 2893 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 2894 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 2895 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2896 | sampler_ci.mipLodBias = 1.0; |
| 2897 | sampler_ci.maxAnisotropy = 1; |
| 2898 | sampler_ci.compareEnable = VK_FALSE; |
| 2899 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 2900 | sampler_ci.minLod = 1.0; |
| 2901 | sampler_ci.maxLod = 1.0; |
| 2902 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
Mark Lobodzinski | 52ac658 | 2015-09-01 15:42:56 -0600 | [diff] [blame] | 2903 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
| 2904 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2905 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2906 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2907 | ASSERT_VK_SUCCESS(err); |
| 2908 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 2909 | VkDescriptorImageInfo info = {}; |
| 2910 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 2911 | |
| 2912 | VkWriteDescriptorSet descriptor_write; |
| 2913 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 2914 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2915 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2916 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2917 | // This is a mismatched type for the layout which expects BUFFER |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 2918 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 2919 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 2920 | |
| 2921 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 2922 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2923 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 2924 | FAIL() << "Did not receive Error 'Write descriptor update has descriptor type VK_DESCRIPTOR_TYPE_SAMPLER that does not match...'"; |
| 2925 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2926 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 2927 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2928 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 2929 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 2930 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 2931 | } |
| 2932 | |
| 2933 | TEST_F(VkLayerTest, DSUpdateOutOfBounds) |
| 2934 | { |
| 2935 | // For overlapping Update, have arrayIndex exceed that of layout |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2936 | VkResult err; |
| 2937 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 2938 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 2939 | "Descriptor update type of VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET is out of bounds for matching binding"); |
| 2940 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2941 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2942 | //VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2943 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2944 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2945 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2946 | |
| 2947 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 2948 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 2949 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 2950 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 2951 | ds_pool_ci.poolSizeCount = 1; |
| 2952 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2953 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2954 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2955 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2956 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2957 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2958 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2959 | dsl_binding.binding = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2960 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 2961 | dsl_binding.arraySize = 1; |
| 2962 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 2963 | dsl_binding.pImmutableSamplers = NULL; |
| 2964 | |
| 2965 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 2966 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 2967 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2968 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | a745e51 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 2969 | ds_layout_ci.pBinding = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2970 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2971 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 2972 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2973 | ASSERT_VK_SUCCESS(err); |
| 2974 | |
| 2975 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2976 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2977 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 2978 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 2979 | alloc_info.descriptorPool = ds_pool; |
| 2980 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 2981 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2982 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 2983 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2984 | VkSamplerCreateInfo sampler_ci = {}; |
| 2985 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 2986 | sampler_ci.pNext = NULL; |
Chia-I Wu | b99df44 | 2015-10-26 16:49:32 +0800 | [diff] [blame] | 2987 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 2988 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 2989 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_BASE; |
Chia-I Wu | 1efb7e5 | 2015-10-26 17:32:47 +0800 | [diff] [blame] | 2990 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 2991 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 2992 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 2993 | sampler_ci.mipLodBias = 1.0; |
| 2994 | sampler_ci.maxAnisotropy = 1; |
| 2995 | sampler_ci.compareEnable = VK_FALSE; |
| 2996 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 2997 | sampler_ci.minLod = 1.0; |
| 2998 | sampler_ci.maxLod = 1.0; |
| 2999 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
Mark Lobodzinski | 52ac658 | 2015-09-01 15:42:56 -0600 | [diff] [blame] | 3000 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3001 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3002 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3003 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3004 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3005 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3006 | VkDescriptorImageInfo info = {}; |
| 3007 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3008 | |
| 3009 | VkWriteDescriptorSet descriptor_write; |
| 3010 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3011 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3012 | descriptor_write.dstSet = descriptorSet; |
| 3013 | descriptor_write.dstArrayElement = 1; /* This index out of bounds for the update */ |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3014 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3015 | // This is the wrong type, but out of bounds will be flagged first |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3016 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3017 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3018 | |
| 3019 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3020 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3021 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3022 | FAIL() << "Did not receive Error 'Descriptor update type of VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET is out of bounds for matching binding...'"; |
| 3023 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3024 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3025 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3026 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3027 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3028 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3029 | } |
| 3030 | |
| 3031 | TEST_F(VkLayerTest, InvalidDSUpdateIndex) |
| 3032 | { |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3033 | // Create layout w/ count of 1 and attempt update to that layout w/ binding index 2 |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3034 | VkResult err; |
| 3035 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3036 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3037 | " does not have binding to match update binding "); |
| 3038 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3039 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3040 | //VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3041 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3042 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3043 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3044 | |
| 3045 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3046 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3047 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3048 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3049 | ds_pool_ci.poolSizeCount = 1; |
| 3050 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3051 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3052 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3053 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3054 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3055 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3056 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3057 | dsl_binding.binding = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3058 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3059 | dsl_binding.arraySize = 1; |
| 3060 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3061 | dsl_binding.pImmutableSamplers = NULL; |
| 3062 | |
| 3063 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3064 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3065 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3066 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | a745e51 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3067 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3068 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3069 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3070 | ASSERT_VK_SUCCESS(err); |
| 3071 | |
| 3072 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3073 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3074 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3075 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3076 | alloc_info.descriptorPool = ds_pool; |
| 3077 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3078 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3079 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3080 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3081 | VkSamplerCreateInfo sampler_ci = {}; |
| 3082 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3083 | sampler_ci.pNext = NULL; |
Chia-I Wu | b99df44 | 2015-10-26 16:49:32 +0800 | [diff] [blame] | 3084 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 3085 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 3086 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_BASE; |
Chia-I Wu | 1efb7e5 | 2015-10-26 17:32:47 +0800 | [diff] [blame] | 3087 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3088 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3089 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3090 | sampler_ci.mipLodBias = 1.0; |
| 3091 | sampler_ci.maxAnisotropy = 1; |
| 3092 | sampler_ci.compareEnable = VK_FALSE; |
| 3093 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3094 | sampler_ci.minLod = 1.0; |
| 3095 | sampler_ci.maxLod = 1.0; |
| 3096 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
Mark Lobodzinski | 52ac658 | 2015-09-01 15:42:56 -0600 | [diff] [blame] | 3097 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3098 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3099 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3100 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3101 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3102 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3103 | VkDescriptorImageInfo info = {}; |
| 3104 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3105 | |
| 3106 | VkWriteDescriptorSet descriptor_write; |
| 3107 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3108 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3109 | descriptor_write.dstSet = descriptorSet; |
| 3110 | descriptor_write.dstBinding = 2; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3111 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3112 | // This is the wrong type, but out of bounds will be flagged first |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3113 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3114 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3115 | |
| 3116 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3117 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3118 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3119 | FAIL() << "Did not receive Error 'Descriptor Set <blah> does not have binding to match update binding '"; |
| 3120 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3121 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3122 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3123 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3124 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3125 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3126 | } |
| 3127 | |
| 3128 | TEST_F(VkLayerTest, InvalidDSUpdateStruct) |
| 3129 | { |
| 3130 | // Call UpdateDS w/ struct type other than valid VK_STRUCTUR_TYPE_UPDATE_* types |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3131 | VkResult err; |
| 3132 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3133 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3134 | "Unexpected UPDATE struct of type "); |
| 3135 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3136 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3137 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3138 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3139 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3140 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3141 | |
| 3142 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3143 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3144 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3145 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3146 | ds_pool_ci.poolSizeCount = 1; |
| 3147 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3148 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3149 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3150 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3151 | ASSERT_VK_SUCCESS(err); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3152 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3153 | dsl_binding.binding = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3154 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3155 | dsl_binding.arraySize = 1; |
| 3156 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3157 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3158 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3159 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3160 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3161 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3162 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | a745e51 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3163 | ds_layout_ci.pBinding = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3164 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3165 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3166 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3167 | ASSERT_VK_SUCCESS(err); |
| 3168 | |
| 3169 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3170 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3171 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3172 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3173 | alloc_info.descriptorPool = ds_pool; |
| 3174 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3175 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3176 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3177 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3178 | VkSamplerCreateInfo sampler_ci = {}; |
| 3179 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3180 | sampler_ci.pNext = NULL; |
Chia-I Wu | b99df44 | 2015-10-26 16:49:32 +0800 | [diff] [blame] | 3181 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 3182 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 3183 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_BASE; |
Chia-I Wu | 1efb7e5 | 2015-10-26 17:32:47 +0800 | [diff] [blame] | 3184 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3185 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3186 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3187 | sampler_ci.mipLodBias = 1.0; |
| 3188 | sampler_ci.maxAnisotropy = 1; |
| 3189 | sampler_ci.compareEnable = VK_FALSE; |
| 3190 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3191 | sampler_ci.minLod = 1.0; |
| 3192 | sampler_ci.maxLod = 1.0; |
| 3193 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
Mark Lobodzinski | 52ac658 | 2015-09-01 15:42:56 -0600 | [diff] [blame] | 3194 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3195 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3196 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3197 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3198 | |
| 3199 | |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3200 | VkDescriptorImageInfo info = {}; |
| 3201 | info.sampler = sampler; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3202 | |
| 3203 | VkWriteDescriptorSet descriptor_write; |
| 3204 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3205 | descriptor_write.sType = (VkStructureType)0x99999999; /* Intentionally broken struct type */ |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3206 | descriptor_write.dstSet = descriptorSet; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3207 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3208 | // This is the wrong type, but out of bounds will be flagged first |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3209 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
Courtney Goeltzenleuchter | 4cb6d92 | 2015-10-23 13:38:14 -0600 | [diff] [blame] | 3210 | descriptor_write.pImageInfo = &info; |
Chia-I Wu | 9d00ed7 | 2015-05-25 16:27:55 +0800 | [diff] [blame] | 3211 | |
| 3212 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3213 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3214 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3215 | FAIL() << "Did not receive Error 'Unexpected UPDATE struct of type '"; |
| 3216 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3217 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3218 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3219 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3220 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3221 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3222 | } |
| 3223 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3224 | TEST_F(VkLayerTest, SampleDescriptorUpdateError) |
| 3225 | { |
| 3226 | // Create a single Sampler descriptor and send it an invalid Sampler |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3227 | VkResult err; |
| 3228 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3229 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3230 | "Attempt to update descriptor with invalid sampler 0xbaadbeef"); |
| 3231 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3232 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3233 | // TODO : Farm Descriptor setup code to helper function(s) to reduce copied code |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3234 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3235 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3236 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3237 | |
| 3238 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3239 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3240 | ds_pool_ci.pNext = NULL; |
| 3241 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3242 | ds_pool_ci.poolSizeCount = 1; |
| 3243 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3244 | |
| 3245 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3246 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3247 | ASSERT_VK_SUCCESS(err); |
| 3248 | |
| 3249 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3250 | dsl_binding.binding = 0; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3251 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 3252 | dsl_binding.arraySize = 1; |
| 3253 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3254 | dsl_binding.pImmutableSamplers = NULL; |
| 3255 | |
| 3256 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3257 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3258 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3259 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | a745e51 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3260 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3261 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3262 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3263 | ASSERT_VK_SUCCESS(err); |
| 3264 | |
| 3265 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3266 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3267 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3268 | alloc_info.setLayoutCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3269 | alloc_info.descriptorPool = ds_pool; |
| 3270 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3271 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3272 | ASSERT_VK_SUCCESS(err); |
| 3273 | |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 3274 | VkSampler sampler = (VkSampler) 0xbaadbeef; // Sampler with invalid handle |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3275 | |
| 3276 | VkDescriptorImageInfo descriptor_info; |
| 3277 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 3278 | descriptor_info.sampler = sampler; |
| 3279 | |
| 3280 | VkWriteDescriptorSet descriptor_write; |
| 3281 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3282 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3283 | descriptor_write.dstSet = descriptorSet; |
| 3284 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3285 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3286 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 3287 | descriptor_write.pImageInfo = &descriptor_info; |
| 3288 | |
| 3289 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3290 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3291 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3292 | FAIL() << "Did not receive Error 'Attempt to update descriptor with invalid sampler...'"; |
| 3293 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3294 | } |
| 3295 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3296 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3297 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3298 | } |
| 3299 | |
| 3300 | TEST_F(VkLayerTest, ImageViewDescriptorUpdateError) |
| 3301 | { |
| 3302 | // Create a single combined Image/Sampler descriptor and send it an invalid imageView |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3303 | VkResult err; |
| 3304 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3305 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3306 | "Attempt to update descriptor with invalid imageView 0xbaadbeef"); |
| 3307 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3308 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3309 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3310 | ds_type_count.type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3311 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3312 | |
| 3313 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3314 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3315 | ds_pool_ci.pNext = NULL; |
| 3316 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3317 | ds_pool_ci.poolSizeCount = 1; |
| 3318 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3319 | |
| 3320 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3321 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3322 | ASSERT_VK_SUCCESS(err); |
| 3323 | |
| 3324 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3325 | dsl_binding.binding = 0; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3326 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 3327 | dsl_binding.arraySize = 1; |
| 3328 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3329 | dsl_binding.pImmutableSamplers = NULL; |
| 3330 | |
| 3331 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3332 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3333 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3334 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | a745e51 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3335 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3336 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3337 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3338 | ASSERT_VK_SUCCESS(err); |
| 3339 | |
| 3340 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3341 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3342 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3343 | alloc_info.setLayoutCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3344 | alloc_info.descriptorPool = ds_pool; |
| 3345 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3346 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3347 | ASSERT_VK_SUCCESS(err); |
| 3348 | |
| 3349 | VkSamplerCreateInfo sampler_ci = {}; |
| 3350 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3351 | sampler_ci.pNext = NULL; |
Chia-I Wu | b99df44 | 2015-10-26 16:49:32 +0800 | [diff] [blame] | 3352 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 3353 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 3354 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_BASE; |
Chia-I Wu | 1efb7e5 | 2015-10-26 17:32:47 +0800 | [diff] [blame] | 3355 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3356 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3357 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3358 | sampler_ci.mipLodBias = 1.0; |
| 3359 | sampler_ci.maxAnisotropy = 1; |
| 3360 | sampler_ci.compareEnable = VK_FALSE; |
| 3361 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3362 | sampler_ci.minLod = 1.0; |
| 3363 | sampler_ci.maxLod = 1.0; |
| 3364 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 3365 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
| 3366 | |
| 3367 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3368 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3369 | ASSERT_VK_SUCCESS(err); |
| 3370 | |
Chia-I Wu | e2fc552 | 2015-10-26 20:04:44 +0800 | [diff] [blame] | 3371 | VkImageView view = (VkImageView) 0xbaadbeef; // invalid imageView object |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3372 | |
| 3373 | VkDescriptorImageInfo descriptor_info; |
| 3374 | memset(&descriptor_info, 0, sizeof(VkDescriptorImageInfo)); |
| 3375 | descriptor_info.sampler = sampler; |
| 3376 | descriptor_info.imageView = view; |
| 3377 | |
| 3378 | VkWriteDescriptorSet descriptor_write; |
| 3379 | memset(&descriptor_write, 0, sizeof(descriptor_write)); |
| 3380 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3381 | descriptor_write.dstSet = descriptorSet; |
| 3382 | descriptor_write.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3383 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3384 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
| 3385 | descriptor_write.pImageInfo = &descriptor_info; |
| 3386 | |
| 3387 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3388 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3389 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3390 | FAIL() << "Did not receive Error 'Attempt to update descriptor with invalid imageView...'"; |
| 3391 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3392 | } |
| 3393 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3394 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3395 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3396 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 3397 | } |
| 3398 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3399 | TEST_F(VkLayerTest, CopyDescriptorUpdateErrors) |
| 3400 | { |
| 3401 | // Create DS w/ layout of 2 types, write update 1 and attempt to copy-update into the other |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3402 | VkResult err; |
| 3403 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3404 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3405 | "Copy descriptor update index 0, update count #1, has src update descriptor type VK_DESCRIPTOR_TYPE_SAMPLER "); |
| 3406 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3407 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3408 | //VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3409 | VkDescriptorPoolSize ds_type_count[2] = {}; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3410 | ds_type_count[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3411 | ds_type_count[0].descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3412 | ds_type_count[1].type = VK_DESCRIPTOR_TYPE_SAMPLER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3413 | ds_type_count[1].descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3414 | |
| 3415 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3416 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3417 | ds_pool_ci.pNext = NULL; |
| 3418 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3419 | ds_pool_ci.poolSizeCount = 2; |
| 3420 | ds_pool_ci.pPoolSizes = ds_type_count; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3421 | |
| 3422 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3423 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3424 | ASSERT_VK_SUCCESS(err); |
| 3425 | VkDescriptorSetLayoutBinding dsl_binding[2] = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3426 | dsl_binding[0].binding = 0; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3427 | dsl_binding[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3428 | dsl_binding[0].arraySize = 1; |
| 3429 | dsl_binding[0].stageFlags = VK_SHADER_STAGE_ALL; |
| 3430 | dsl_binding[0].pImmutableSamplers = NULL; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3431 | dsl_binding[1].binding = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3432 | dsl_binding[1].descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 3433 | dsl_binding[1].arraySize = 1; |
| 3434 | dsl_binding[1].stageFlags = VK_SHADER_STAGE_ALL; |
| 3435 | dsl_binding[1].pImmutableSamplers = NULL; |
| 3436 | |
| 3437 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3438 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3439 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3440 | ds_layout_ci.bindingCount = 2; |
Chia-I Wu | a745e51 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3441 | ds_layout_ci.pBinding = dsl_binding; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3442 | |
| 3443 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3444 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3445 | ASSERT_VK_SUCCESS(err); |
| 3446 | |
| 3447 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3448 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3449 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3450 | alloc_info.setLayoutCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3451 | alloc_info.descriptorPool = ds_pool; |
| 3452 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3453 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3454 | ASSERT_VK_SUCCESS(err); |
| 3455 | |
| 3456 | VkSamplerCreateInfo sampler_ci = {}; |
| 3457 | sampler_ci.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 3458 | sampler_ci.pNext = NULL; |
Chia-I Wu | b99df44 | 2015-10-26 16:49:32 +0800 | [diff] [blame] | 3459 | sampler_ci.magFilter = VK_FILTER_NEAREST; |
| 3460 | sampler_ci.minFilter = VK_FILTER_NEAREST; |
| 3461 | sampler_ci.mipmapMode = VK_SAMPLER_MIPMAP_MODE_BASE; |
Chia-I Wu | 1efb7e5 | 2015-10-26 17:32:47 +0800 | [diff] [blame] | 3462 | sampler_ci.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3463 | sampler_ci.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
| 3464 | sampler_ci.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3465 | sampler_ci.mipLodBias = 1.0; |
| 3466 | sampler_ci.maxAnisotropy = 1; |
| 3467 | sampler_ci.compareEnable = VK_FALSE; |
| 3468 | sampler_ci.compareOp = VK_COMPARE_OP_NEVER; |
| 3469 | sampler_ci.minLod = 1.0; |
| 3470 | sampler_ci.maxLod = 1.0; |
| 3471 | sampler_ci.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE; |
| 3472 | sampler_ci.unnormalizedCoordinates = VK_FALSE; |
| 3473 | |
| 3474 | VkSampler sampler; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3475 | err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3476 | ASSERT_VK_SUCCESS(err); |
| 3477 | |
| 3478 | VkDescriptorImageInfo info = {}; |
| 3479 | info.sampler = sampler; |
| 3480 | |
| 3481 | VkWriteDescriptorSet descriptor_write; |
| 3482 | memset(&descriptor_write, 0, sizeof(VkWriteDescriptorSet)); |
| 3483 | descriptor_write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3484 | descriptor_write.dstSet = descriptorSet; |
| 3485 | descriptor_write.dstBinding = 1; // SAMPLER binding from layout above |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3486 | descriptor_write.descriptorCount = 1; |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3487 | descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER; |
| 3488 | descriptor_write.pImageInfo = &info; |
| 3489 | // This write update should succeed |
| 3490 | vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL); |
| 3491 | // Now perform a copy update that fails due to type mismatch |
| 3492 | VkCopyDescriptorSet copy_ds_update; |
| 3493 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 3494 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 3495 | copy_ds_update.srcSet = descriptorSet; |
| 3496 | copy_ds_update.srcBinding = 1; // copy from SAMPLER binding |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3497 | copy_ds_update.dstSet = descriptorSet; |
| 3498 | copy_ds_update.dstBinding = 0; // ERROR : copy to UNIFORM binding |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3499 | copy_ds_update.descriptorCount = 1; // copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3500 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 3501 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3502 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3503 | FAIL() << "Did not receive Error 'Copy descriptor update index 0, update count #1, has src update descriptor type_DESCRIPTOR_TYPE_SAMPLER'"; |
| 3504 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3505 | } |
| 3506 | // Now perform a copy update that fails due to binding out of bounds |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3507 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3508 | "Copy descriptor update 0 has srcBinding 3 which is out of bounds "); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3509 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 3510 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 3511 | copy_ds_update.srcSet = descriptorSet; |
| 3512 | copy_ds_update.srcBinding = 3; // ERROR : Invalid binding for matching layout |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3513 | copy_ds_update.dstSet = descriptorSet; |
| 3514 | copy_ds_update.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3515 | copy_ds_update.descriptorCount = 1; // copy 1 descriptor |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3516 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 3517 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3518 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3519 | FAIL() << "Did not receive Error 'Copy descriptor update 0 has srcBinding 3 which is out of bounds...'"; |
| 3520 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3521 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3522 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3523 | // Now perform a copy update that fails due to binding out of bounds |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3524 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3525 | "Copy descriptor src update is out of bounds for matching binding 1 "); |
| 3526 | |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3527 | memset(©_ds_update, 0, sizeof(VkCopyDescriptorSet)); |
| 3528 | copy_ds_update.sType = VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET; |
| 3529 | copy_ds_update.srcSet = descriptorSet; |
| 3530 | copy_ds_update.srcBinding = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3531 | copy_ds_update.dstSet = descriptorSet; |
| 3532 | copy_ds_update.dstBinding = 0; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3533 | copy_ds_update.descriptorCount = 5; // ERROR copy 5 descriptors (out of bounds for layout) |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3534 | vkUpdateDescriptorSets(m_device->device(), 0, NULL, 1, ©_ds_update); |
| 3535 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3536 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3537 | FAIL() << "Did not receive Error 'Copy descriptor src update is out of bounds for matching binding 1...'"; |
| 3538 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3539 | } |
| 3540 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3541 | vkDestroySampler(m_device->device(), sampler, NULL); |
| 3542 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3543 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 04356f9 | 2015-10-27 16:35:27 -0600 | [diff] [blame] | 3544 | } |
| 3545 | |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3546 | TEST_F(VkLayerTest, NumSamplesMismatch) |
| 3547 | { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3548 | // Create CommandBuffer where MSAA samples doesn't match RenderPass sampleCount |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3549 | VkResult err; |
| 3550 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3551 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3552 | "Num samples mismatch! "); |
| 3553 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3554 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3555 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3556 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3557 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3558 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3559 | |
| 3560 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3561 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3562 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3563 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3564 | ds_pool_ci.poolSizeCount = 1; |
| 3565 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3566 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3567 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3568 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3569 | ASSERT_VK_SUCCESS(err); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3570 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3571 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3572 | dsl_binding.binding = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3573 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3574 | dsl_binding.arraySize = 1; |
| 3575 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3576 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3577 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3578 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3579 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3580 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3581 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | a745e51 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3582 | ds_layout_ci.pBinding = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3583 | |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3584 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3585 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3586 | ASSERT_VK_SUCCESS(err); |
| 3587 | |
| 3588 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3589 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3590 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3591 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3592 | alloc_info.descriptorPool = ds_pool; |
| 3593 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3594 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3595 | ASSERT_VK_SUCCESS(err); |
| 3596 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3597 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 3598 | pipe_ms_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 3599 | pipe_ms_state_ci.pNext = NULL; |
Chia-I Wu | 5c17c96 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3600 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3601 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 3602 | pipe_ms_state_ci.minSampleShading = 1.0; |
Cody Northrop | 02e61ed | 2015-08-04 14:34:54 -0600 | [diff] [blame] | 3603 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3604 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3605 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 3606 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3607 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3608 | pipeline_layout_ci.setLayoutCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3609 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3610 | |
| 3611 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3612 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3613 | ASSERT_VK_SUCCESS(err); |
| 3614 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 3615 | VkShaderObj vs(m_device, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 3616 | VkShaderObj fs(m_device, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, this); // TODO - We shouldn't need a fragment shader |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 3617 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 3618 | VkPipelineObj pipe(m_device); |
| 3619 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 3620 | pipe.AddShader(&fs); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 3621 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 3622 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3623 | |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 3624 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3625 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3626 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3627 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3628 | FAIL() << "Did not recieve Error 'Num samples mismatch!...'"; |
| 3629 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 3b78066 | 2015-05-28 12:11:26 -0600 | [diff] [blame] | 3630 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3631 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3632 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3633 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3634 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 49eb23d | 2015-05-22 12:38:55 -0600 | [diff] [blame] | 3635 | } |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3636 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3637 | TEST_F(VkLayerTest, ClearCmdNoDraw) |
| 3638 | { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3639 | // Create CommandBuffer where we add ClearCmd for FB Color attachment prior to issuing a Draw |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3640 | VkResult err; |
| 3641 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3642 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_WARN_BIT, |
| 3643 | "vkCmdClearAttachments() issued on CB object "); |
| 3644 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3645 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3646 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3647 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3648 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3649 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3650 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3651 | |
| 3652 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3653 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3654 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3655 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3656 | ds_pool_ci.poolSizeCount = 1; |
| 3657 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3658 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3659 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3660 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3661 | ASSERT_VK_SUCCESS(err); |
| 3662 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3663 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3664 | dsl_binding.binding = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3665 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3666 | dsl_binding.arraySize = 1; |
| 3667 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3668 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3669 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3670 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3671 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3672 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3673 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | a745e51 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3674 | ds_layout_ci.pBinding = &dsl_binding; |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3675 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3676 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3677 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3678 | ASSERT_VK_SUCCESS(err); |
| 3679 | |
| 3680 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3681 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3682 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3683 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3684 | alloc_info.descriptorPool = ds_pool; |
| 3685 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3686 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3687 | ASSERT_VK_SUCCESS(err); |
| 3688 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3689 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 3690 | pipe_ms_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 3691 | pipe_ms_state_ci.pNext = NULL; |
Chia-I Wu | 5c17c96 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3692 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_4_BIT; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3693 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 3694 | pipe_ms_state_ci.minSampleShading = 1.0; |
Cody Northrop | 02e61ed | 2015-08-04 14:34:54 -0600 | [diff] [blame] | 3695 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3696 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3697 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 3698 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3699 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3700 | pipeline_layout_ci.setLayoutCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3701 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3702 | |
| 3703 | VkPipelineLayout pipeline_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3704 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3705 | ASSERT_VK_SUCCESS(err); |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3706 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 3707 | VkShaderObj vs(m_device, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3708 | // TODO - We shouldn't need a fragment shader but add it to be able to run on more devices |
| 3709 | VkShaderObj fs(m_device, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
| 3710 | |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 3711 | VkPipelineObj pipe(m_device); |
| 3712 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 3713 | pipe.AddShader(&fs); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 3714 | pipe.SetMSAA(&pipe_ms_state_ci); |
| 3715 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 3716 | |
| 3717 | BeginCommandBuffer(); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3718 | |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3719 | // Main thing we care about for this test is that the VkImage obj we're clearing matches Color Attachment of FB |
| 3720 | // Also pass down other dummy params to keep driver and paramchecker happy |
Courtney Goeltzenleuchter | c9323e0 | 2015-10-15 16:51:05 -0600 | [diff] [blame] | 3721 | VkClearAttachment color_attachment; |
| 3722 | color_attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 3723 | color_attachment.clearValue.color.float32[0] = 1.0; |
| 3724 | color_attachment.clearValue.color.float32[1] = 1.0; |
| 3725 | color_attachment.clearValue.color.float32[2] = 1.0; |
| 3726 | color_attachment.clearValue.color.float32[3] = 1.0; |
| 3727 | color_attachment.colorAttachment = 0; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 3728 | VkClearRect clear_rect = { { { 0, 0 }, { (int)m_width, (int)m_height } } }; |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3729 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3730 | vkCmdClearAttachments(m_commandBuffer->GetBufferHandle(), 1, &color_attachment, 1, &clear_rect); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3731 | |
| 3732 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3733 | FAIL() << "Did not receive Error 'vkCommandClearAttachments() issued on CB object...'"; |
| 3734 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3735 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3736 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3737 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3738 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3739 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 53eddda | 2015-07-01 16:46:13 -0600 | [diff] [blame] | 3740 | } |
| 3741 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3742 | TEST_F(VkLayerTest, VtxBufferBadIndex) |
| 3743 | { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3744 | // Create CommandBuffer where MSAA samples doesn't match RenderPass sampleCount |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3745 | VkResult err; |
| 3746 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3747 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3748 | "Vtx Buffer Index 1 was bound, but no vtx buffers are attached to PSO."); |
| 3749 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3750 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 3751 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3752 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3753 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3754 | VkDescriptorPoolSize ds_type_count = {}; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3755 | ds_type_count.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3756 | ds_type_count.descriptorCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3757 | |
| 3758 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 3759 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 3760 | ds_pool_ci.pNext = NULL; |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3761 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 3762 | ds_pool_ci.poolSizeCount = 1; |
| 3763 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3764 | |
Courtney Goeltzenleuchter | fe908d3 | 2015-09-16 16:12:45 -0600 | [diff] [blame] | 3765 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3766 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3767 | ASSERT_VK_SUCCESS(err); |
| 3768 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3769 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3770 | dsl_binding.binding = 0; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3771 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 3772 | dsl_binding.arraySize = 1; |
| 3773 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 3774 | dsl_binding.pImmutableSamplers = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3775 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3776 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 3777 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 3778 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3779 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | a745e51 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3780 | ds_layout_ci.pBinding = &dsl_binding; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3781 | |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3782 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3783 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3784 | ASSERT_VK_SUCCESS(err); |
| 3785 | |
| 3786 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3787 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3788 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3789 | alloc_info.setLayoutCount = 1; |
Courtney Goeltzenleuchter | bee18a9 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 3790 | alloc_info.descriptorPool = ds_pool; |
| 3791 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3792 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3793 | ASSERT_VK_SUCCESS(err); |
| 3794 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3795 | VkPipelineMultisampleStateCreateInfo pipe_ms_state_ci = {}; |
| 3796 | pipe_ms_state_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; |
| 3797 | pipe_ms_state_ci.pNext = NULL; |
Chia-I Wu | 5c17c96 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3798 | pipe_ms_state_ci.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3799 | pipe_ms_state_ci.sampleShadingEnable = 0; |
| 3800 | pipe_ms_state_ci.minSampleShading = 1.0; |
Cody Northrop | 02e61ed | 2015-08-04 14:34:54 -0600 | [diff] [blame] | 3801 | pipe_ms_state_ci.pSampleMask = NULL; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3802 | |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3803 | VkPipelineLayoutCreateInfo pipeline_layout_ci = {}; |
| 3804 | pipeline_layout_ci.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 3805 | pipeline_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 3806 | pipeline_layout_ci.setLayoutCount = 1; |
Tony Barbour | eb25490 | 2015-07-15 12:50:33 -0600 | [diff] [blame] | 3807 | pipeline_layout_ci.pSetLayouts = &ds_layout; |
| 3808 | VkPipelineLayout pipeline_layout; |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3809 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3810 | err = vkCreatePipelineLayout(m_device->device(), &pipeline_layout_ci, NULL, &pipeline_layout); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3811 | ASSERT_VK_SUCCESS(err); |
| 3812 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 3813 | VkShaderObj vs(m_device, bindStateVertShaderText, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 3814 | VkShaderObj fs(m_device, bindStateFragShaderText, VK_SHADER_STAGE_FRAGMENT_BIT, this); // TODO - We shouldn't need a fragment shader |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 3815 | // but add it to be able to run on more devices |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 3816 | VkPipelineObj pipe(m_device); |
| 3817 | pipe.AddShader(&vs); |
Tony Barbour | 1c94d37 | 2015-08-06 11:21:08 -0600 | [diff] [blame] | 3818 | pipe.AddShader(&fs); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 3819 | pipe.SetMSAA(&pipe_ms_state_ci); |
Tobin Ehlis | d332f28 | 2015-10-02 11:00:56 -0600 | [diff] [blame] | 3820 | pipe.SetViewport(m_viewports); |
| 3821 | pipe.SetScissor(m_scissors); |
Tony Barbour | 62e1a5b | 2015-08-06 10:16:07 -0600 | [diff] [blame] | 3822 | pipe.CreateVKPipeline(pipeline_layout, renderPass()); |
Tony Barbour | fe3351b | 2015-07-28 10:17:20 -0600 | [diff] [blame] | 3823 | |
| 3824 | BeginCommandBuffer(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3825 | vkCmdBindPipeline(m_commandBuffer->GetBufferHandle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle()); |
Tobin Ehlis | f7bf450 | 2015-09-09 15:12:35 -0600 | [diff] [blame] | 3826 | // Don't care about actual data, just need to get to draw to flag error |
| 3827 | static const float vbo_data[3] = {1.f, 0.f, 1.f}; |
| 3828 | VkConstantBufferObj vbo(m_device, sizeof(vbo_data), sizeof(float), (const void*) &vbo_data); |
| 3829 | BindVertexBuffer(&vbo, (VkDeviceSize)0, 1); // VBO idx 1, but no VBO in PSO |
Courtney Goeltzenleuchter | 08c2637 | 2015-09-23 12:31:50 -0600 | [diff] [blame] | 3830 | Draw(1, 0, 0, 0); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3831 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3832 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3833 | FAIL() << "Did not receive Error 'Vtx Buffer Index 0 was bound, but no vtx buffers are attached to PSO.'"; |
| 3834 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3835 | } |
Mike Stroyan | d1c84a5 | 2015-08-18 14:40:24 -0600 | [diff] [blame] | 3836 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3837 | vkDestroyPipelineLayout(m_device->device(), pipeline_layout, NULL); |
| 3838 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 3839 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | 502480b | 2015-06-24 15:53:07 -0600 | [diff] [blame] | 3840 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3841 | #endif // DRAW_STATE_TESTS |
| 3842 | |
Tobin Ehlis | 0788f52 | 2015-05-26 16:11:58 -0600 | [diff] [blame] | 3843 | #if THREADING_TESTS |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3844 | #if GTEST_IS_THREADSAFE |
| 3845 | struct thread_data_struct { |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3846 | VkCommandBuffer commandBuffer; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3847 | VkEvent event; |
| 3848 | bool bailout; |
| 3849 | }; |
| 3850 | |
| 3851 | extern "C" void *AddToCommandBuffer(void *arg) |
| 3852 | { |
| 3853 | struct thread_data_struct *data = (struct thread_data_struct *) arg; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3854 | |
| 3855 | for (int i = 0; i<10000; i++) { |
Chia-I Wu | 89d0f94 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 3856 | vkCmdSetEvent(data->commandBuffer, data->event, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3857 | if (data->bailout) { |
| 3858 | break; |
| 3859 | } |
| 3860 | } |
| 3861 | return NULL; |
| 3862 | } |
| 3863 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3864 | TEST_F(VkLayerTest, ThreadCommandBufferCollision) |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3865 | { |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 3866 | test_platform_thread thread; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3867 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3868 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, "THREADING ERROR"); |
| 3869 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3870 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3871 | ASSERT_NO_FATAL_FAILURE(InitViewport()); |
| 3872 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3873 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3874 | // Calls AllocateCommandBuffers |
| 3875 | VkCommandBufferObj commandBuffer(m_device, m_commandPool); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 3876 | |
| 3877 | // Avoid creating RenderPass |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3878 | commandBuffer.BeginCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3879 | |
| 3880 | VkEventCreateInfo event_info; |
| 3881 | VkEvent event; |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3882 | VkResult err; |
| 3883 | |
| 3884 | memset(&event_info, 0, sizeof(event_info)); |
| 3885 | event_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO; |
| 3886 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3887 | err = vkCreateEvent(device(), &event_info, NULL, &event); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3888 | ASSERT_VK_SUCCESS(err); |
| 3889 | |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3890 | err = vkResetEvent(device(), event); |
| 3891 | ASSERT_VK_SUCCESS(err); |
| 3892 | |
| 3893 | struct thread_data_struct data; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3894 | data.commandBuffer = commandBuffer.GetBufferHandle(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3895 | data.event = event; |
| 3896 | data.bailout = false; |
| 3897 | m_errorMonitor->SetBailout(&data.bailout); |
| 3898 | // Add many entries to command buffer from another thread. |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 3899 | test_platform_thread_create(&thread, AddToCommandBuffer, (void *)&data); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3900 | // Add many entries to command buffer from this thread at the same time. |
| 3901 | AddToCommandBuffer(&data); |
Mark Lobodzinski | 5495d13 | 2015-09-30 16:19:16 -0600 | [diff] [blame] | 3902 | |
Mike Stroyan | 4268d1f | 2015-07-13 14:45:35 -0600 | [diff] [blame] | 3903 | test_platform_thread_join(thread, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 3904 | commandBuffer.EndCommandBuffer(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3905 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3906 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3907 | FAIL() << "Did not receive Error 'THREADING ERROR' from using one VkCommandBufferObj in two threads"; |
| 3908 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3909 | } |
| 3910 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3911 | vkDestroyEvent(device(), event, NULL); |
Mike Stroyan | accf769 | 2015-05-12 16:00:45 -0600 | [diff] [blame] | 3912 | } |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 3913 | #endif // GTEST_IS_THREADSAFE |
| 3914 | #endif // THREADING_TESTS |
| 3915 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 3916 | #if SHADER_CHECKER_TESTS |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3917 | TEST_F(VkLayerTest, InvalidSPIRVCodeSize) |
| 3918 | { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3919 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3920 | "Shader is not SPIR-V"); |
| 3921 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3922 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3923 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3924 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3925 | VkShaderModule module; |
| 3926 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 3927 | struct icd_spv_header spv; |
| 3928 | |
| 3929 | spv.magic = ICD_SPV_MAGIC; |
| 3930 | spv.version = ICD_SPV_VERSION; |
| 3931 | spv.gen_magic = 0; |
| 3932 | |
| 3933 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 3934 | moduleCreateInfo.pNext = NULL; |
Chia-I Wu | 8094f19 | 2015-10-26 19:22:06 +0800 | [diff] [blame] | 3935 | moduleCreateInfo.pCode = (const uint32_t *) &spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3936 | moduleCreateInfo.codeSize = 4; |
| 3937 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3938 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3939 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3940 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3941 | FAIL() << "Did not recieive Error 'Shader is not SPIR-V'"; |
| 3942 | m_errorMonitor->DumpFailureMsgs(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3943 | } |
| 3944 | } |
| 3945 | |
| 3946 | TEST_F(VkLayerTest, InvalidSPIRVMagic) |
| 3947 | { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3948 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3949 | "Shader is not SPIR-V"); |
| 3950 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3951 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3952 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3953 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3954 | VkShaderModule module; |
| 3955 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 3956 | struct icd_spv_header spv; |
| 3957 | |
| 3958 | spv.magic = ~ICD_SPV_MAGIC; |
| 3959 | spv.version = ICD_SPV_VERSION; |
| 3960 | spv.gen_magic = 0; |
| 3961 | |
| 3962 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 3963 | moduleCreateInfo.pNext = NULL; |
Chia-I Wu | 8094f19 | 2015-10-26 19:22:06 +0800 | [diff] [blame] | 3964 | moduleCreateInfo.pCode = (const uint32_t *) &spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3965 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 3966 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3967 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3968 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3969 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 3970 | FAIL() << "Did not recieive Error 'Shader is not SPIR-V'"; |
| 3971 | m_errorMonitor->DumpFailureMsgs(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3972 | } |
| 3973 | } |
| 3974 | |
| 3975 | TEST_F(VkLayerTest, InvalidSPIRVVersion) |
| 3976 | { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3977 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 3978 | "Shader is not SPIR-V"); |
| 3979 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3980 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 3981 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 3982 | |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3983 | VkShaderModule module; |
| 3984 | VkShaderModuleCreateInfo moduleCreateInfo; |
| 3985 | struct icd_spv_header spv; |
| 3986 | |
| 3987 | spv.magic = ICD_SPV_MAGIC; |
| 3988 | spv.version = ~ICD_SPV_VERSION; |
| 3989 | spv.gen_magic = 0; |
| 3990 | |
| 3991 | moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; |
| 3992 | moduleCreateInfo.pNext = NULL; |
| 3993 | |
Chia-I Wu | 8094f19 | 2015-10-26 19:22:06 +0800 | [diff] [blame] | 3994 | moduleCreateInfo.pCode = (const uint32_t *) &spv; |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3995 | moduleCreateInfo.codeSize = sizeof(spv) + 10; |
| 3996 | moduleCreateInfo.flags = 0; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 3997 | vkCreateShaderModule(m_device->device(), &moduleCreateInfo, NULL, &module); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 3998 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 3999 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4000 | FAIL() << "Did not recieive Error 'Shader is not SPIR-V'"; |
| 4001 | m_errorMonitor->DumpFailureMsgs(); |
Courtney Goeltzenleuchter | 00c52b2 | 2015-09-16 12:58:29 -0600 | [diff] [blame] | 4002 | } |
| 4003 | } |
| 4004 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4005 | TEST_F(VkLayerTest, CreatePipelineVertexOutputNotConsumed) |
| 4006 | { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4007 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_WARN_BIT, |
| 4008 | "not consumed by fragment shader"); |
| 4009 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4010 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4011 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4012 | |
| 4013 | char const *vsSource = |
| 4014 | "#version 140\n" |
| 4015 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4016 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4017 | "\n" |
| 4018 | "layout(location=0) out float x;\n" |
| 4019 | "void main(){\n" |
| 4020 | " gl_Position = vec4(1);\n" |
| 4021 | " x = 0;\n" |
| 4022 | "}\n"; |
| 4023 | char const *fsSource = |
| 4024 | "#version 140\n" |
| 4025 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4026 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4027 | "\n" |
| 4028 | "layout(location=0) out vec4 color;\n" |
| 4029 | "void main(){\n" |
| 4030 | " color = vec4(1);\n" |
| 4031 | "}\n"; |
| 4032 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4033 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4034 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4035 | |
| 4036 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4037 | pipe.AddColorAttachment(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4038 | pipe.AddShader(&vs); |
| 4039 | pipe.AddShader(&fs); |
| 4040 | |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4041 | VkDescriptorSetObj descriptorSet(m_device); |
| 4042 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4043 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4044 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4045 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4046 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4047 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4048 | FAIL() << "Did not receive Warning 'not consumed by fragment shader'"; |
| 4049 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4050 | } |
| 4051 | } |
Chris Forbes | 9f7ff63 | 2015-05-25 11:13:08 +1200 | [diff] [blame] | 4052 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4053 | TEST_F(VkLayerTest, CreatePipelineFragmentInputNotProvided) |
| 4054 | { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4055 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4056 | "not written by vertex shader"); |
| 4057 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4058 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4059 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4060 | |
| 4061 | char const *vsSource = |
| 4062 | "#version 140\n" |
| 4063 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4064 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4065 | "\n" |
| 4066 | "void main(){\n" |
| 4067 | " gl_Position = vec4(1);\n" |
| 4068 | "}\n"; |
| 4069 | char const *fsSource = |
| 4070 | "#version 140\n" |
| 4071 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4072 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4073 | "\n" |
| 4074 | "layout(location=0) in float x;\n" |
| 4075 | "layout(location=0) out vec4 color;\n" |
| 4076 | "void main(){\n" |
| 4077 | " color = vec4(x);\n" |
| 4078 | "}\n"; |
| 4079 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4080 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4081 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4082 | |
| 4083 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4084 | pipe.AddColorAttachment(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4085 | pipe.AddShader(&vs); |
| 4086 | pipe.AddShader(&fs); |
| 4087 | |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4088 | VkDescriptorSetObj descriptorSet(m_device); |
| 4089 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4090 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4091 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4092 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4093 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4094 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4095 | FAIL() << "Did not receive Error 'not written by vertex shader'"; |
| 4096 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 59cb88d | 2015-05-25 11:13:13 +1200 | [diff] [blame] | 4097 | } |
| 4098 | } |
| 4099 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4100 | TEST_F(VkLayerTest, CreatePipelineVsFsTypeMismatch) |
| 4101 | { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4102 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4103 | "Type mismatch on location 0"); |
| 4104 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4105 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4106 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4107 | |
| 4108 | char const *vsSource = |
| 4109 | "#version 140\n" |
| 4110 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4111 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4112 | "\n" |
| 4113 | "layout(location=0) out int x;\n" |
| 4114 | "void main(){\n" |
| 4115 | " x = 0;\n" |
| 4116 | " gl_Position = vec4(1);\n" |
| 4117 | "}\n"; |
| 4118 | char const *fsSource = |
| 4119 | "#version 140\n" |
| 4120 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4121 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4122 | "\n" |
| 4123 | "layout(location=0) in float x;\n" /* VS writes int */ |
| 4124 | "layout(location=0) out vec4 color;\n" |
| 4125 | "void main(){\n" |
| 4126 | " color = vec4(x);\n" |
| 4127 | "}\n"; |
| 4128 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4129 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4130 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4131 | |
| 4132 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4133 | pipe.AddColorAttachment(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4134 | pipe.AddShader(&vs); |
| 4135 | pipe.AddShader(&fs); |
| 4136 | |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4137 | VkDescriptorSetObj descriptorSet(m_device); |
| 4138 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4139 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4140 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4141 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4142 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4143 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4144 | FAIL() << "Did not receive Error 'Type mismatch on location 0'"; |
| 4145 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | b56af56 | 2015-05-25 11:13:17 +1200 | [diff] [blame] | 4146 | } |
| 4147 | } |
| 4148 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4149 | TEST_F(VkLayerTest, CreatePipelineAttribNotConsumed) |
| 4150 | { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4151 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_WARN_BIT, |
| 4152 | "location 0 not consumed by VS"); |
| 4153 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4154 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4155 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4156 | |
| 4157 | VkVertexInputBindingDescription input_binding; |
| 4158 | memset(&input_binding, 0, sizeof(input_binding)); |
| 4159 | |
| 4160 | VkVertexInputAttributeDescription input_attrib; |
| 4161 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 4162 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 4163 | |
| 4164 | char const *vsSource = |
| 4165 | "#version 140\n" |
| 4166 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4167 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4168 | "\n" |
| 4169 | "void main(){\n" |
| 4170 | " gl_Position = vec4(1);\n" |
| 4171 | "}\n"; |
| 4172 | char const *fsSource = |
| 4173 | "#version 140\n" |
| 4174 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4175 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4176 | "\n" |
| 4177 | "layout(location=0) out vec4 color;\n" |
| 4178 | "void main(){\n" |
| 4179 | " color = vec4(1);\n" |
| 4180 | "}\n"; |
| 4181 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4182 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4183 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4184 | |
| 4185 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4186 | pipe.AddColorAttachment(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4187 | pipe.AddShader(&vs); |
| 4188 | pipe.AddShader(&fs); |
| 4189 | |
| 4190 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 4191 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 4192 | |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4193 | VkDescriptorSetObj descriptorSet(m_device); |
| 4194 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4195 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4196 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4197 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4198 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4199 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4200 | FAIL() << "Did not receive Warning 'location 0 not consumed by VS'"; |
| 4201 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | de136e0 | 2015-05-25 11:13:28 +1200 | [diff] [blame] | 4202 | } |
| 4203 | } |
| 4204 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4205 | TEST_F(VkLayerTest, CreatePipelineAttribNotProvided) |
| 4206 | { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4207 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4208 | "VS consumes input at location 0 but not provided"); |
| 4209 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4210 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4211 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4212 | |
| 4213 | char const *vsSource = |
| 4214 | "#version 140\n" |
| 4215 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4216 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4217 | "\n" |
| 4218 | "layout(location=0) in vec4 x;\n" /* not provided */ |
| 4219 | "void main(){\n" |
| 4220 | " gl_Position = x;\n" |
| 4221 | "}\n"; |
| 4222 | char const *fsSource = |
| 4223 | "#version 140\n" |
| 4224 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4225 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4226 | "\n" |
| 4227 | "layout(location=0) out vec4 color;\n" |
| 4228 | "void main(){\n" |
| 4229 | " color = vec4(1);\n" |
| 4230 | "}\n"; |
| 4231 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4232 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4233 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4234 | |
| 4235 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4236 | pipe.AddColorAttachment(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4237 | pipe.AddShader(&vs); |
| 4238 | pipe.AddShader(&fs); |
| 4239 | |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4240 | VkDescriptorSetObj descriptorSet(m_device); |
| 4241 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4242 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4243 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4244 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4245 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4246 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4247 | FAIL() << "Did not receive Error 'VS consumes input at location 0 but not provided'"; |
| 4248 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 62e8e50 | 2015-05-25 11:13:29 +1200 | [diff] [blame] | 4249 | } |
| 4250 | } |
| 4251 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4252 | TEST_F(VkLayerTest, CreatePipelineAttribTypeMismatch) |
| 4253 | { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4254 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4255 | "location 0 does not match VS input type"); |
| 4256 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4257 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4258 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4259 | |
| 4260 | VkVertexInputBindingDescription input_binding; |
| 4261 | memset(&input_binding, 0, sizeof(input_binding)); |
| 4262 | |
| 4263 | VkVertexInputAttributeDescription input_attrib; |
| 4264 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 4265 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 4266 | |
| 4267 | char const *vsSource = |
| 4268 | "#version 140\n" |
| 4269 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4270 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4271 | "\n" |
| 4272 | "layout(location=0) in int x;\n" /* attrib provided float */ |
| 4273 | "void main(){\n" |
| 4274 | " gl_Position = vec4(x);\n" |
| 4275 | "}\n"; |
| 4276 | char const *fsSource = |
| 4277 | "#version 140\n" |
| 4278 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4279 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4280 | "\n" |
| 4281 | "layout(location=0) out vec4 color;\n" |
| 4282 | "void main(){\n" |
| 4283 | " color = vec4(1);\n" |
| 4284 | "}\n"; |
| 4285 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4286 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4287 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4288 | |
| 4289 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4290 | pipe.AddColorAttachment(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4291 | pipe.AddShader(&vs); |
| 4292 | pipe.AddShader(&fs); |
| 4293 | |
| 4294 | pipe.AddVertexInputBindings(&input_binding, 1); |
| 4295 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 4296 | |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4297 | VkDescriptorSetObj descriptorSet(m_device); |
| 4298 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4299 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4300 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4301 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4302 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4303 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4304 | FAIL() << "Did not receive Error 'location 0 does not match VS input type'"; |
| 4305 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | c97d98e | 2015-05-25 11:13:31 +1200 | [diff] [blame] | 4306 | } |
| 4307 | } |
| 4308 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4309 | TEST_F(VkLayerTest, CreatePipelineAttribBindingConflict) |
| 4310 | { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4311 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4312 | "Duplicate vertex input binding descriptions for binding 0"); |
| 4313 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4314 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | c9ac2b6 | 2015-09-11 12:57:55 -0600 | [diff] [blame] | 4315 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4316 | |
| 4317 | /* Two binding descriptions for binding 0 */ |
| 4318 | VkVertexInputBindingDescription input_bindings[2]; |
| 4319 | memset(input_bindings, 0, sizeof(input_bindings)); |
| 4320 | |
| 4321 | VkVertexInputAttributeDescription input_attrib; |
| 4322 | memset(&input_attrib, 0, sizeof(input_attrib)); |
| 4323 | input_attrib.format = VK_FORMAT_R32_SFLOAT; |
| 4324 | |
| 4325 | char const *vsSource = |
| 4326 | "#version 140\n" |
| 4327 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4328 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4329 | "\n" |
| 4330 | "layout(location=0) in float x;\n" /* attrib provided float */ |
| 4331 | "void main(){\n" |
| 4332 | " gl_Position = vec4(x);\n" |
| 4333 | "}\n"; |
| 4334 | char const *fsSource = |
| 4335 | "#version 140\n" |
| 4336 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4337 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4338 | "\n" |
| 4339 | "layout(location=0) out vec4 color;\n" |
| 4340 | "void main(){\n" |
| 4341 | " color = vec4(1);\n" |
| 4342 | "}\n"; |
| 4343 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4344 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4345 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4346 | |
| 4347 | VkPipelineObj pipe(m_device); |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4348 | pipe.AddColorAttachment(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4349 | pipe.AddShader(&vs); |
| 4350 | pipe.AddShader(&fs); |
| 4351 | |
| 4352 | pipe.AddVertexInputBindings(input_bindings, 2); |
| 4353 | pipe.AddVertexInputAttribs(&input_attrib, 1); |
| 4354 | |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4355 | VkDescriptorSetObj descriptorSet(m_device); |
| 4356 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4357 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4358 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4359 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4360 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4361 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4362 | FAIL() << "Did not receive Error 'Duplicate vertex input binding descriptions for binding 0'"; |
| 4363 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 280ba2c | 2015-06-12 11:16:41 +1200 | [diff] [blame] | 4364 | } |
| 4365 | } |
Chris Forbes | 8f68b56 | 2015-05-25 11:13:32 +1200 | [diff] [blame] | 4366 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4367 | /* TODO: would be nice to test the mixed broadcast & custom case, but the GLSL->SPV compiler |
| 4368 | * rejects it. */ |
| 4369 | |
| 4370 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotWritten) |
| 4371 | { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4372 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4373 | "Attachment 0 not written by FS"); |
| 4374 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4375 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4376 | |
| 4377 | char const *vsSource = |
| 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 | "void main(){\n" |
| 4383 | " gl_Position = vec4(1);\n" |
| 4384 | "}\n"; |
| 4385 | char const *fsSource = |
| 4386 | "#version 140\n" |
| 4387 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4388 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4389 | "\n" |
| 4390 | "void main(){\n" |
| 4391 | "}\n"; |
| 4392 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4393 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4394 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4395 | |
| 4396 | VkPipelineObj pipe(m_device); |
| 4397 | pipe.AddShader(&vs); |
| 4398 | pipe.AddShader(&fs); |
| 4399 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4400 | /* set up CB 0, not written */ |
| 4401 | pipe.AddColorAttachment(); |
| 4402 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4403 | |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4404 | VkDescriptorSetObj descriptorSet(m_device); |
| 4405 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4406 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4407 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4408 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4409 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4410 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4411 | FAIL() << "Did not receive Error 'Attachment 0 not written by FS'"; |
| 4412 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 4d6d1e5 | 2015-05-25 11:13:40 +1200 | [diff] [blame] | 4413 | } |
| 4414 | } |
| 4415 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4416 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputNotConsumed) |
| 4417 | { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4418 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_WARN_BIT, |
| 4419 | "FS writes to output location 1 with no matching attachment"); |
| 4420 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4421 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4422 | |
| 4423 | char const *vsSource = |
| 4424 | "#version 140\n" |
| 4425 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4426 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4427 | "\n" |
| 4428 | "void main(){\n" |
| 4429 | " gl_Position = vec4(1);\n" |
| 4430 | "}\n"; |
| 4431 | char const *fsSource = |
| 4432 | "#version 140\n" |
| 4433 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4434 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4435 | "\n" |
| 4436 | "layout(location=0) out vec4 x;\n" |
| 4437 | "layout(location=1) out vec4 y;\n" /* no matching attachment for this */ |
| 4438 | "void main(){\n" |
| 4439 | " x = vec4(1);\n" |
| 4440 | " y = vec4(1);\n" |
| 4441 | "}\n"; |
| 4442 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4443 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4444 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4445 | |
| 4446 | VkPipelineObj pipe(m_device); |
| 4447 | pipe.AddShader(&vs); |
| 4448 | pipe.AddShader(&fs); |
| 4449 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4450 | /* set up CB 0, not written */ |
| 4451 | pipe.AddColorAttachment(); |
| 4452 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4453 | /* FS writes CB 1, but we don't configure it */ |
| 4454 | |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4455 | VkDescriptorSetObj descriptorSet(m_device); |
| 4456 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4457 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4458 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4459 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4460 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4461 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4462 | FAIL() << "Did not receive Error 'FS writes to output location 1 with no matching attachment'"; |
| 4463 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | f3fffaa | 2015-05-25 11:13:43 +1200 | [diff] [blame] | 4464 | } |
| 4465 | } |
| 4466 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4467 | TEST_F(VkLayerTest, CreatePipelineFragmentOutputTypeMismatch) |
| 4468 | { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4469 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4470 | "does not match FS output type"); |
| 4471 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4472 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4473 | |
| 4474 | char const *vsSource = |
| 4475 | "#version 140\n" |
| 4476 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4477 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4478 | "\n" |
| 4479 | "void main(){\n" |
| 4480 | " gl_Position = vec4(1);\n" |
| 4481 | "}\n"; |
| 4482 | char const *fsSource = |
| 4483 | "#version 140\n" |
| 4484 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4485 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4486 | "\n" |
| 4487 | "layout(location=0) out ivec4 x;\n" /* not UNORM */ |
| 4488 | "void main(){\n" |
| 4489 | " x = ivec4(1);\n" |
| 4490 | "}\n"; |
| 4491 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4492 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4493 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4494 | |
| 4495 | VkPipelineObj pipe(m_device); |
| 4496 | pipe.AddShader(&vs); |
| 4497 | pipe.AddShader(&fs); |
| 4498 | |
Chia-I Wu | 08accc6 | 2015-07-07 11:50:03 +0800 | [diff] [blame] | 4499 | /* set up CB 0; type is UNORM by default */ |
| 4500 | pipe.AddColorAttachment(); |
| 4501 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4502 | |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4503 | VkDescriptorSetObj descriptorSet(m_device); |
| 4504 | descriptorSet.AppendDummy(); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4505 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4506 | |
Tony Barbour | 5781e8f | 2015-08-04 16:23:11 -0600 | [diff] [blame] | 4507 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4508 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4509 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4510 | FAIL() << "Did not receive Error 'does not match FS output type'"; |
| 4511 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4512 | } |
| 4513 | } |
Chris Forbes | 7b1b893 | 2015-06-05 14:43:36 +1200 | [diff] [blame] | 4514 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 4515 | TEST_F(VkLayerTest, CreatePipelineUniformBlockNotProvided) |
| 4516 | { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4517 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4518 | "not declared in pipeline layout"); |
| 4519 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 4520 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 4521 | |
| 4522 | char const *vsSource = |
| 4523 | "#version 140\n" |
| 4524 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4525 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4526 | "\n" |
| 4527 | "void main(){\n" |
| 4528 | " gl_Position = vec4(1);\n" |
| 4529 | "}\n"; |
| 4530 | char const *fsSource = |
| 4531 | "#version 140\n" |
| 4532 | "#extension GL_ARB_separate_shader_objects: require\n" |
| 4533 | "#extension GL_ARB_shading_language_420pack: require\n" |
| 4534 | "\n" |
| 4535 | "layout(location=0) out vec4 x;\n" |
| 4536 | "layout(set=0) layout(binding=0) uniform foo { int x; int y; } bar;\n" |
| 4537 | "void main(){\n" |
| 4538 | " x = vec4(bar.y);\n" |
| 4539 | "}\n"; |
| 4540 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 4541 | |
Courtney Goeltzenleuchter | d263550 | 2015-10-21 17:08:06 -0600 | [diff] [blame] | 4542 | VkShaderObj vs(m_device, vsSource, VK_SHADER_STAGE_VERTEX_BIT, this); |
| 4543 | VkShaderObj fs(m_device, fsSource, VK_SHADER_STAGE_FRAGMENT_BIT, this); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 4544 | |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 4545 | VkPipelineObj pipe(m_device); |
| 4546 | pipe.AddShader(&vs); |
| 4547 | pipe.AddShader(&fs); |
| 4548 | |
| 4549 | /* set up CB 0; type is UNORM by default */ |
| 4550 | pipe.AddColorAttachment(); |
| 4551 | ASSERT_NO_FATAL_FAILURE(InitRenderTarget()); |
| 4552 | |
| 4553 | VkDescriptorSetObj descriptorSet(m_device); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4554 | descriptorSet.CreateVKDescriptorSet(m_commandBuffer); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 4555 | |
| 4556 | pipe.CreateVKPipeline(descriptorSet.GetPipelineLayout(), renderPass()); |
| 4557 | |
| 4558 | /* should have generated an error -- pipeline layout does not |
| 4559 | * provide a uniform buffer in 0.0 |
| 4560 | */ |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4561 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4562 | FAIL() << "Did not receive Error 'not declared in pipeline layout'"; |
| 4563 | m_errorMonitor->DumpFailureMsgs(); |
Chris Forbes | 556c76c | 2015-08-14 12:04:59 +1200 | [diff] [blame] | 4564 | } |
| 4565 | } |
| 4566 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4567 | #endif // SHADER_CHECKER_TESTS |
| 4568 | |
| 4569 | #if DEVICE_LIMITS_TESTS |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4570 | TEST_F(VkLayerTest, CreateImageLimitsViolationWidth) |
| 4571 | { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4572 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4573 | "CreateImage extents exceed allowable limits for format"); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4574 | |
| 4575 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4576 | |
| 4577 | // Create an image |
| 4578 | VkImage image; |
| 4579 | |
| 4580 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 4581 | const int32_t tex_width = 32; |
| 4582 | const int32_t tex_height = 32; |
| 4583 | |
| 4584 | VkImageCreateInfo image_create_info = {}; |
| 4585 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4586 | image_create_info.pNext = NULL; |
| 4587 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4588 | image_create_info.format = tex_format; |
| 4589 | image_create_info.extent.width = tex_width; |
| 4590 | image_create_info.extent.height = tex_height; |
| 4591 | image_create_info.extent.depth = 1; |
| 4592 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 4593 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 5c17c96 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4594 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4595 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 4596 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 4597 | image_create_info.flags = 0; |
| 4598 | |
| 4599 | // Introduce error by sending down a bogus width extent |
| 4600 | image_create_info.extent.width = 65536; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4601 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4602 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4603 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4604 | FAIL() << "Did not receive Error 'CreateImage extents exceed allowable limits for format'"; |
| 4605 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4606 | } |
| 4607 | } |
| 4608 | |
| 4609 | TEST_F(VkLayerTest, CreateImageResourceSizeViolation) |
| 4610 | { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4611 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4612 | "CreateImage resource size exceeds allowable maximum"); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4613 | |
| 4614 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4615 | |
| 4616 | // Create an image |
| 4617 | VkImage image; |
| 4618 | |
| 4619 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 4620 | const int32_t tex_width = 32; |
| 4621 | const int32_t tex_height = 32; |
| 4622 | |
| 4623 | VkImageCreateInfo image_create_info = {}; |
| 4624 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4625 | image_create_info.pNext = NULL; |
| 4626 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4627 | image_create_info.format = tex_format; |
| 4628 | image_create_info.extent.width = tex_width; |
| 4629 | image_create_info.extent.height = tex_height; |
| 4630 | image_create_info.extent.depth = 1; |
| 4631 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 4632 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 5c17c96 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4633 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4634 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 4635 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 4636 | image_create_info.flags = 0; |
| 4637 | |
| 4638 | // Introduce error by sending down individually allowable values that result in a surface size |
| 4639 | // exceeding the device maximum |
| 4640 | image_create_info.extent.width = 8192; |
| 4641 | image_create_info.extent.height = 8192; |
| 4642 | image_create_info.extent.depth = 16; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 4643 | image_create_info.arrayLayers = 4; |
Chia-I Wu | 5c17c96 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4644 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4645 | image_create_info.format = VK_FORMAT_R8G8B8A8_UNORM; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4646 | vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4647 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4648 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4649 | FAIL() << "Did not receive Error 'CreateImage resource size exceeds allowable maximum'"; |
| 4650 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | 6f2274e | 2015-09-22 09:33:21 -0600 | [diff] [blame] | 4651 | } |
| 4652 | } |
| 4653 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4654 | TEST_F(VkLayerTest, UpdateBufferAlignment) |
| 4655 | { |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4656 | uint32_t updateData[] = { 1, 2, 3, 4, 5, 6, 7, 8 }; |
| 4657 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4658 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4659 | "dstOffset, is not a multiple of 4"); |
| 4660 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4661 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4662 | |
| 4663 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 4664 | vk_testing::Buffer buffer; |
| 4665 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 4666 | |
| 4667 | BeginCommandBuffer(); |
| 4668 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4669 | m_commandBuffer->UpdateBuffer(buffer.handle(), 1, 4, updateData); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4670 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4671 | FAIL() << "Did not receive Error 'vkCommandUpdateBuffer parameter, VkDeviceSize dstOffset, is not a multiple of 4'"; |
| 4672 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4673 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4674 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4675 | // Introduce failure by using size that is not multiple of 4 |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4676 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4677 | "dataSize, is not a multiple of 4"); |
| 4678 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4679 | m_commandBuffer->UpdateBuffer(buffer.handle(), 0, 6, updateData); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4680 | |
| 4681 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4682 | FAIL() << "Did not receive Error 'vkCommandUpdateBuffer parameter, VkDeviceSize dataSize, is not a multiple of 4'"; |
| 4683 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4684 | } |
| 4685 | EndCommandBuffer(); |
| 4686 | } |
| 4687 | |
| 4688 | TEST_F(VkLayerTest, FillBufferAlignment) |
| 4689 | { |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4690 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4691 | "dstOffset, is not a multiple of 4"); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4692 | |
| 4693 | ASSERT_NO_FATAL_FAILURE(InitState()); |
| 4694 | |
| 4695 | VkMemoryPropertyFlags reqs = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; |
| 4696 | vk_testing::Buffer buffer; |
| 4697 | buffer.init_as_dst(*m_device, (VkDeviceSize)20, reqs); |
| 4698 | |
| 4699 | BeginCommandBuffer(); |
| 4700 | // Introduce failure by using offset that is not multiple of 4 |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4701 | m_commandBuffer->FillBuffer(buffer.handle(), 1, 4, 0x11111111); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4702 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4703 | FAIL() << "Did not receive Error 'vkCommandFillBuffer parameter, VkDeviceSize dstOffset, is not a multiple of 4'"; |
| 4704 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4705 | } |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4706 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4707 | // Introduce failure by using size that is not multiple of 4 |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4708 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4709 | "size, is not a multiple of 4"); |
| 4710 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4711 | m_commandBuffer->FillBuffer(buffer.handle(), 0, 6, 0x11111111); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4712 | |
| 4713 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4714 | FAIL() << "Did not receive Error 'vkCommandFillBuffer parameter, VkDeviceSize size, is not a multiple of 4'"; |
| 4715 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4716 | } |
| 4717 | EndCommandBuffer(); |
| 4718 | } |
| 4719 | |
Mark Lobodzinski | 209b529 | 2015-09-17 09:44:05 -0600 | [diff] [blame] | 4720 | #endif // DEVICE_LIMITS_TESTS |
Chris Forbes | a36d69e | 2015-05-25 11:13:44 +1200 | [diff] [blame] | 4721 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4722 | #if IMAGE_TESTS |
| 4723 | TEST_F(VkLayerTest, InvalidImageView) |
| 4724 | { |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4725 | VkResult err; |
| 4726 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4727 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4728 | "vkCreateImageView called with baseMipLevel 10 "); |
| 4729 | |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4730 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4731 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4732 | // Create an image and try to create a view with bad baseMipLevel |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4733 | VkImage image; |
| 4734 | |
| 4735 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 4736 | const int32_t tex_width = 32; |
| 4737 | const int32_t tex_height = 32; |
| 4738 | |
| 4739 | VkImageCreateInfo image_create_info = {}; |
| 4740 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4741 | image_create_info.pNext = NULL; |
| 4742 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4743 | image_create_info.format = tex_format; |
| 4744 | image_create_info.extent.width = tex_width; |
| 4745 | image_create_info.extent.height = tex_height; |
| 4746 | image_create_info.extent.depth = 1; |
| 4747 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 4748 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 5c17c96 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4749 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4750 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 4751 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 4752 | image_create_info.flags = 0; |
| 4753 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4754 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4755 | ASSERT_VK_SUCCESS(err); |
| 4756 | |
| 4757 | VkImageViewCreateInfo image_view_create_info = {}; |
| 4758 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4759 | image_view_create_info.image = image; |
| 4760 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 4761 | image_view_create_info.format = tex_format; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4762 | image_view_create_info.subresourceRange.layerCount = 1; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4763 | image_view_create_info.subresourceRange.baseMipLevel = 10; // cause an error |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4764 | image_view_create_info.subresourceRange.levelCount = 1; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 4765 | image_view_create_info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4766 | |
| 4767 | VkImageView view; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4768 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, &view); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4769 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4770 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4771 | FAIL() << "Did not receive Error 'vkCreateImageView called with baseMipLevel 10...'"; |
| 4772 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 4773 | } |
| 4774 | } |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4775 | |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 4776 | TEST_F(VkLayerTest, InvalidImageViewAspect) |
| 4777 | { |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 4778 | VkResult err; |
| 4779 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4780 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4781 | "vkCreateImageView: Color image formats must have ONLY the VK_IMAGE_ASPECT_COLOR_BIT set"); |
| 4782 | |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 4783 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 4784 | |
| 4785 | // Create an image and try to create a view with an invalid aspectMask |
| 4786 | VkImage image; |
| 4787 | |
| 4788 | const VkFormat tex_format = VK_FORMAT_B8G8R8A8_UNORM; |
| 4789 | const int32_t tex_width = 32; |
| 4790 | const int32_t tex_height = 32; |
| 4791 | |
| 4792 | VkImageCreateInfo image_create_info = {}; |
| 4793 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4794 | image_create_info.pNext = NULL; |
| 4795 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4796 | image_create_info.format = tex_format; |
| 4797 | image_create_info.extent.width = tex_width; |
| 4798 | image_create_info.extent.height = tex_height; |
| 4799 | image_create_info.extent.depth = 1; |
| 4800 | image_create_info.mipLevels = 1; |
Chia-I Wu | 5c17c96 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4801 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 4802 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
| 4803 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT; |
| 4804 | image_create_info.flags = 0; |
| 4805 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4806 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 4807 | ASSERT_VK_SUCCESS(err); |
| 4808 | |
| 4809 | VkImageViewCreateInfo image_view_create_info = {}; |
| 4810 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4811 | image_view_create_info.image = image; |
| 4812 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 4813 | image_view_create_info.format = tex_format; |
| 4814 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4815 | image_view_create_info.subresourceRange.levelCount = 1; |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 4816 | // Cause an error by setting an invalid image aspect |
| 4817 | image_view_create_info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_METADATA_BIT; |
| 4818 | |
| 4819 | VkImageView view; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4820 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, &view); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 4821 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4822 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4823 | FAIL() << "Did not receive Error 'VkCreateImageView: Color image formats must have ...'"; |
| 4824 | m_errorMonitor->DumpFailureMsgs(); |
Mark Lobodzinski | dc86b85 | 2015-10-23 14:20:31 -0600 | [diff] [blame] | 4825 | } |
| 4826 | } |
| 4827 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4828 | TEST_F(VkLayerTest, CopyImageTypeMismatch) |
| 4829 | { |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4830 | VkResult err; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 4831 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4832 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4833 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4834 | "vkCmdCopyImage called with unmatched source and dest image types"); |
| 4835 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4836 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4837 | |
| 4838 | // Create two images of different types and try to copy between them |
| 4839 | VkImage srcImage; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4840 | VkImage dstImage; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4841 | VkDeviceMemory srcMem; |
| 4842 | VkDeviceMemory destMem; |
| 4843 | VkMemoryRequirements memReqs; |
| 4844 | |
| 4845 | VkImageCreateInfo image_create_info = {}; |
| 4846 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4847 | image_create_info.pNext = NULL; |
| 4848 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4849 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 4850 | image_create_info.extent.width = 32; |
| 4851 | image_create_info.extent.height = 32; |
| 4852 | image_create_info.extent.depth = 1; |
| 4853 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 4854 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 5c17c96 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4855 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4856 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4857 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4858 | image_create_info.flags = 0; |
| 4859 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4860 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4861 | ASSERT_VK_SUCCESS(err); |
| 4862 | |
| 4863 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4864 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4865 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4866 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4867 | ASSERT_VK_SUCCESS(err); |
| 4868 | |
| 4869 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4870 | VkMemoryAllocateInfo memAlloc = {}; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4871 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 4872 | memAlloc.pNext = NULL; |
| 4873 | memAlloc.allocationSize = 0; |
| 4874 | memAlloc.memoryTypeIndex = 0; |
| 4875 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 4876 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4877 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 4878 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 4879 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4880 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4881 | ASSERT_VK_SUCCESS(err); |
| 4882 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4883 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4884 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 4885 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4886 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4887 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4888 | ASSERT_VK_SUCCESS(err); |
| 4889 | |
| 4890 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 4891 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4892 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4893 | ASSERT_VK_SUCCESS(err); |
| 4894 | |
| 4895 | BeginCommandBuffer(); |
| 4896 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 4897 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4898 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 4899 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4900 | copyRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4901 | copyRegion.srcOffset.x = 0; |
| 4902 | copyRegion.srcOffset.y = 0; |
| 4903 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 4904 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4905 | copyRegion.dstSubresource.mipLevel = 0; |
| 4906 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 4907 | copyRegion.dstSubresource.layerCount = 0; |
| 4908 | copyRegion.dstOffset.x = 0; |
| 4909 | copyRegion.dstOffset.y = 0; |
| 4910 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4911 | copyRegion.extent.width = 1; |
| 4912 | copyRegion.extent.height = 1; |
| 4913 | copyRegion.extent.depth = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4914 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4915 | EndCommandBuffer(); |
| 4916 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4917 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 4918 | FAIL() << "Did not receive Error 'vkCmdCopyImage called with unmatched source and dest image types'"; |
| 4919 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4920 | } |
| 4921 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4922 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4923 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4924 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 4925 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4926 | } |
| 4927 | |
| 4928 | TEST_F(VkLayerTest, CopyImageFormatSizeMismatch) |
| 4929 | { |
| 4930 | // TODO : Create two images with different format sizes and vkCmdCopyImage between them |
| 4931 | } |
| 4932 | |
| 4933 | TEST_F(VkLayerTest, CopyImageDepthStencilFormatMismatch) |
| 4934 | { |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4935 | VkResult err; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 4936 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4937 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 4938 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 4939 | "vkCmdCopyImage called with unmatched source and dest image types"); |
| 4940 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4941 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4942 | |
| 4943 | // Create two images of different types and try to copy between them |
| 4944 | VkImage srcImage; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4945 | VkImage dstImage; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4946 | VkDeviceMemory srcMem; |
| 4947 | VkDeviceMemory destMem; |
| 4948 | VkMemoryRequirements memReqs; |
| 4949 | |
| 4950 | VkImageCreateInfo image_create_info = {}; |
| 4951 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 4952 | image_create_info.pNext = NULL; |
| 4953 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 4954 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 4955 | image_create_info.extent.width = 32; |
| 4956 | image_create_info.extent.height = 32; |
| 4957 | image_create_info.extent.depth = 1; |
| 4958 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 4959 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 5c17c96 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 4960 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4961 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4962 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4963 | image_create_info.flags = 0; |
| 4964 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 4965 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4966 | ASSERT_VK_SUCCESS(err); |
| 4967 | |
| 4968 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4969 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4970 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4971 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4972 | ASSERT_VK_SUCCESS(err); |
| 4973 | |
| 4974 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4975 | VkMemoryAllocateInfo memAlloc = {}; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4976 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 4977 | memAlloc.pNext = NULL; |
| 4978 | memAlloc.allocationSize = 0; |
| 4979 | memAlloc.memoryTypeIndex = 0; |
| 4980 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 4981 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4982 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 4983 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 4984 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4985 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4986 | ASSERT_VK_SUCCESS(err); |
| 4987 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4988 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4989 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 4990 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 4991 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4992 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4993 | ASSERT_VK_SUCCESS(err); |
| 4994 | |
| 4995 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 4996 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 4997 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 4998 | ASSERT_VK_SUCCESS(err); |
| 4999 | |
| 5000 | BeginCommandBuffer(); |
| 5001 | VkImageCopy copyRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5002 | copyRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5003 | copyRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5004 | copyRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5005 | copyRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5006 | copyRegion.srcOffset.x = 0; |
| 5007 | copyRegion.srcOffset.y = 0; |
| 5008 | copyRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5009 | copyRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5010 | copyRegion.dstSubresource.mipLevel = 0; |
| 5011 | copyRegion.dstSubresource.baseArrayLayer = 0; |
| 5012 | copyRegion.dstSubresource.layerCount = 0; |
| 5013 | copyRegion.dstOffset.x = 0; |
| 5014 | copyRegion.dstOffset.y = 0; |
| 5015 | copyRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5016 | copyRegion.extent.width = 1; |
| 5017 | copyRegion.extent.height = 1; |
| 5018 | copyRegion.extent.depth = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5019 | m_commandBuffer->CopyImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, VK_IMAGE_LAYOUT_GENERAL, 1, ©Region); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5020 | EndCommandBuffer(); |
| 5021 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5022 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5023 | FAIL() << "Did not receive Error 'vkCmdCopyImage called with unmatched source and dest image types'"; |
| 5024 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5025 | } |
| 5026 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5027 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5028 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5029 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 5030 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5031 | } |
| 5032 | |
| 5033 | TEST_F(VkLayerTest, ResolveImageLowSampleCount) |
| 5034 | { |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5035 | VkResult err; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5036 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5037 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5038 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 5039 | "vkCmdResolveImage called with source sample count less than 2."); |
| 5040 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5041 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5042 | |
| 5043 | // Create two images of sample count 1 and try to Resolve between them |
| 5044 | VkImage srcImage; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5045 | VkImage dstImage; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5046 | VkDeviceMemory srcMem; |
| 5047 | VkDeviceMemory destMem; |
| 5048 | VkMemoryRequirements memReqs; |
| 5049 | |
| 5050 | VkImageCreateInfo image_create_info = {}; |
| 5051 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5052 | image_create_info.pNext = NULL; |
| 5053 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5054 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5055 | image_create_info.extent.width = 32; |
| 5056 | image_create_info.extent.height = 1; |
| 5057 | image_create_info.extent.depth = 1; |
| 5058 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 5059 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 5c17c96 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5060 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5061 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5062 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5063 | image_create_info.flags = 0; |
| 5064 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5065 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5066 | ASSERT_VK_SUCCESS(err); |
| 5067 | |
| 5068 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5069 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5070 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5071 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5072 | ASSERT_VK_SUCCESS(err); |
| 5073 | |
| 5074 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5075 | VkMemoryAllocateInfo memAlloc = {}; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5076 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 5077 | memAlloc.pNext = NULL; |
| 5078 | memAlloc.allocationSize = 0; |
| 5079 | memAlloc.memoryTypeIndex = 0; |
| 5080 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 5081 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5082 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5083 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5084 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5085 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5086 | ASSERT_VK_SUCCESS(err); |
| 5087 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5088 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5089 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5090 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5091 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5092 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5093 | ASSERT_VK_SUCCESS(err); |
| 5094 | |
| 5095 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 5096 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5097 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5098 | ASSERT_VK_SUCCESS(err); |
| 5099 | |
| 5100 | BeginCommandBuffer(); |
| 5101 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
| 5102 | //VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 5103 | //VK_IMAGE_LAYOUT_GENERAL = 1, |
| 5104 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5105 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5106 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5107 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5108 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5109 | resolveRegion.srcOffset.x = 0; |
| 5110 | resolveRegion.srcOffset.y = 0; |
| 5111 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5112 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5113 | resolveRegion.dstSubresource.mipLevel = 0; |
| 5114 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 5115 | resolveRegion.dstSubresource.layerCount = 0; |
| 5116 | resolveRegion.dstOffset.x = 0; |
| 5117 | resolveRegion.dstOffset.y = 0; |
| 5118 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5119 | resolveRegion.extent.width = 1; |
| 5120 | resolveRegion.extent.height = 1; |
| 5121 | resolveRegion.extent.depth = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5122 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5123 | EndCommandBuffer(); |
| 5124 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5125 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5126 | FAIL() << "Did not receive Error 'vkCmdResolveImage called with source sample count less than 2.'"; |
| 5127 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5128 | } |
| 5129 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5130 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5131 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5132 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 5133 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5134 | } |
| 5135 | |
| 5136 | TEST_F(VkLayerTest, ResolveImageHighSampleCount) |
| 5137 | { |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5138 | VkResult err; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5139 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5140 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5141 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 5142 | "vkCmdResolveImage called with dest sample count greater than 1."); |
| 5143 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5144 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5145 | |
| 5146 | // Create two images of sample count 2 and try to Resolve between them |
| 5147 | VkImage srcImage; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5148 | VkImage dstImage; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5149 | VkDeviceMemory srcMem; |
| 5150 | VkDeviceMemory destMem; |
| 5151 | VkMemoryRequirements memReqs; |
| 5152 | |
| 5153 | VkImageCreateInfo image_create_info = {}; |
| 5154 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5155 | image_create_info.pNext = NULL; |
| 5156 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5157 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5158 | image_create_info.extent.width = 32; |
| 5159 | image_create_info.extent.height = 1; |
| 5160 | image_create_info.extent.depth = 1; |
| 5161 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 5162 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 5c17c96 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5163 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5164 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
Cody Northrop | 72458c0 | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 5165 | // Note: Some implementations expect color attachment usage for any multisample surface |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5166 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5167 | image_create_info.flags = 0; |
| 5168 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5169 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5170 | ASSERT_VK_SUCCESS(err); |
| 5171 | |
| 5172 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
Cody Northrop | 72458c0 | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 5173 | // Note: Some implementations expect color attachment usage for any multisample surface |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5174 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5175 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5176 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5177 | ASSERT_VK_SUCCESS(err); |
| 5178 | |
| 5179 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5180 | VkMemoryAllocateInfo memAlloc = {}; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5181 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 5182 | memAlloc.pNext = NULL; |
| 5183 | memAlloc.allocationSize = 0; |
| 5184 | memAlloc.memoryTypeIndex = 0; |
| 5185 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 5186 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5187 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5188 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5189 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5190 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5191 | ASSERT_VK_SUCCESS(err); |
| 5192 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5193 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5194 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5195 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5196 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5197 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5198 | ASSERT_VK_SUCCESS(err); |
| 5199 | |
| 5200 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 5201 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5202 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5203 | ASSERT_VK_SUCCESS(err); |
| 5204 | |
| 5205 | BeginCommandBuffer(); |
| 5206 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
| 5207 | //VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 5208 | //VK_IMAGE_LAYOUT_GENERAL = 1, |
| 5209 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5210 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5211 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5212 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5213 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5214 | resolveRegion.srcOffset.x = 0; |
| 5215 | resolveRegion.srcOffset.y = 0; |
| 5216 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5217 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5218 | resolveRegion.dstSubresource.mipLevel = 0; |
| 5219 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 5220 | resolveRegion.dstSubresource.layerCount = 0; |
| 5221 | resolveRegion.dstOffset.x = 0; |
| 5222 | resolveRegion.dstOffset.y = 0; |
| 5223 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5224 | resolveRegion.extent.width = 1; |
| 5225 | resolveRegion.extent.height = 1; |
| 5226 | resolveRegion.extent.depth = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5227 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5228 | EndCommandBuffer(); |
| 5229 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5230 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5231 | FAIL() << "Did not receive Error 'vkCmdResolveImage called with dest sample count greater than 1.'"; |
| 5232 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5233 | } |
| 5234 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5235 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5236 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5237 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 5238 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5239 | } |
| 5240 | |
| 5241 | TEST_F(VkLayerTest, ResolveImageFormatMismatch) |
| 5242 | { |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5243 | VkResult err; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5244 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5245 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5246 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 5247 | "vkCmdResolveImage called with unmatched source and dest formats."); |
| 5248 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5249 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5250 | |
| 5251 | // Create two images of different types and try to copy between them |
| 5252 | VkImage srcImage; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5253 | VkImage dstImage; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5254 | VkDeviceMemory srcMem; |
| 5255 | VkDeviceMemory destMem; |
| 5256 | VkMemoryRequirements memReqs; |
| 5257 | |
| 5258 | VkImageCreateInfo image_create_info = {}; |
| 5259 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5260 | image_create_info.pNext = NULL; |
| 5261 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5262 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5263 | image_create_info.extent.width = 32; |
| 5264 | image_create_info.extent.height = 1; |
| 5265 | image_create_info.extent.depth = 1; |
| 5266 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 5267 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 5c17c96 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5268 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5269 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
Cody Northrop | 72458c0 | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 5270 | // Note: Some implementations expect color attachment usage for any multisample surface |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5271 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5272 | image_create_info.flags = 0; |
| 5273 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5274 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5275 | ASSERT_VK_SUCCESS(err); |
| 5276 | |
Cody Northrop | 72458c0 | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 5277 | // Set format to something other than source image |
| 5278 | image_create_info.format = VK_FORMAT_R32_SFLOAT; |
| 5279 | // Note: Some implementations expect color attachment usage for any multisample surface |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5280 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Chia-I Wu | 5c17c96 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5281 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5282 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5283 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5284 | ASSERT_VK_SUCCESS(err); |
| 5285 | |
| 5286 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5287 | VkMemoryAllocateInfo memAlloc = {}; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5288 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 5289 | memAlloc.pNext = NULL; |
| 5290 | memAlloc.allocationSize = 0; |
| 5291 | memAlloc.memoryTypeIndex = 0; |
| 5292 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 5293 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5294 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5295 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5296 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5297 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5298 | ASSERT_VK_SUCCESS(err); |
| 5299 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5300 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5301 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5302 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5303 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5304 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5305 | ASSERT_VK_SUCCESS(err); |
| 5306 | |
| 5307 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 5308 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5309 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5310 | ASSERT_VK_SUCCESS(err); |
| 5311 | |
| 5312 | BeginCommandBuffer(); |
| 5313 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
| 5314 | //VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 5315 | //VK_IMAGE_LAYOUT_GENERAL = 1, |
| 5316 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5317 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5318 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5319 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5320 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5321 | resolveRegion.srcOffset.x = 0; |
| 5322 | resolveRegion.srcOffset.y = 0; |
| 5323 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5324 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5325 | resolveRegion.dstSubresource.mipLevel = 0; |
| 5326 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 5327 | resolveRegion.dstSubresource.layerCount = 0; |
| 5328 | resolveRegion.dstOffset.x = 0; |
| 5329 | resolveRegion.dstOffset.y = 0; |
| 5330 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5331 | resolveRegion.extent.width = 1; |
| 5332 | resolveRegion.extent.height = 1; |
| 5333 | resolveRegion.extent.depth = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5334 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5335 | EndCommandBuffer(); |
| 5336 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5337 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5338 | FAIL() << "Did not receive Error 'vkCmdResolveImage called with unmatched source and dest formats.'"; |
| 5339 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5340 | } |
| 5341 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5342 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5343 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5344 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 5345 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5346 | } |
| 5347 | |
| 5348 | TEST_F(VkLayerTest, ResolveImageTypeMismatch) |
| 5349 | { |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5350 | VkResult err; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5351 | bool pass; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5352 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5353 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 5354 | "vkCmdResolveImage called with unmatched source and dest image types."); |
| 5355 | |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5356 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5357 | |
| 5358 | // Create two images of different types and try to copy between them |
| 5359 | VkImage srcImage; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5360 | VkImage dstImage; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5361 | VkDeviceMemory srcMem; |
| 5362 | VkDeviceMemory destMem; |
| 5363 | VkMemoryRequirements memReqs; |
| 5364 | |
| 5365 | VkImageCreateInfo image_create_info = {}; |
| 5366 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5367 | image_create_info.pNext = NULL; |
| 5368 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5369 | image_create_info.format = VK_FORMAT_B8G8R8A8_UNORM; |
| 5370 | image_create_info.extent.width = 32; |
| 5371 | image_create_info.extent.height = 1; |
| 5372 | image_create_info.extent.depth = 1; |
| 5373 | image_create_info.mipLevels = 1; |
Courtney Goeltzenleuchter | 5d2aed4 | 2015-10-21 17:57:31 -0600 | [diff] [blame] | 5374 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 5c17c96 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5375 | image_create_info.samples = VK_SAMPLE_COUNT_2_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5376 | image_create_info.tiling = VK_IMAGE_TILING_LINEAR; |
Cody Northrop | 72458c0 | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 5377 | // Note: Some implementations expect color attachment usage for any multisample surface |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5378 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5379 | image_create_info.flags = 0; |
| 5380 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5381 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &srcImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5382 | ASSERT_VK_SUCCESS(err); |
| 5383 | |
| 5384 | image_create_info.imageType = VK_IMAGE_TYPE_1D; |
Cody Northrop | 72458c0 | 2015-10-27 13:50:04 -0600 | [diff] [blame] | 5385 | // Note: Some implementations expect color attachment usage for any multisample surface |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5386 | image_create_info.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Chia-I Wu | 5c17c96 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5387 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5388 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5389 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &dstImage); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5390 | ASSERT_VK_SUCCESS(err); |
| 5391 | |
| 5392 | // Allocate memory |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5393 | VkMemoryAllocateInfo memAlloc = {}; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5394 | memAlloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 5395 | memAlloc.pNext = NULL; |
| 5396 | memAlloc.allocationSize = 0; |
| 5397 | memAlloc.memoryTypeIndex = 0; |
| 5398 | |
Courtney Goeltzenleuchter | 06d8947 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 5399 | vkGetImageMemoryRequirements(m_device->device(), srcImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5400 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5401 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5402 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5403 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &srcMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5404 | ASSERT_VK_SUCCESS(err); |
| 5405 | |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5406 | vkGetImageMemoryRequirements(m_device->device(), dstImage, &memReqs); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5407 | memAlloc.allocationSize = memReqs.size; |
Courtney Goeltzenleuchter | 1d2f0dd | 2015-10-22 11:03:31 -0600 | [diff] [blame] | 5408 | pass = m_device->phy().set_memory_type(memReqs.memoryTypeBits, &memAlloc, 0); |
| 5409 | ASSERT_TRUE(pass); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5410 | err = vkAllocateMemory(m_device->device(), &memAlloc, NULL, &destMem); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5411 | ASSERT_VK_SUCCESS(err); |
| 5412 | |
| 5413 | err = vkBindImageMemory(m_device->device(), srcImage, srcMem, 0); |
| 5414 | ASSERT_VK_SUCCESS(err); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5415 | err = vkBindImageMemory(m_device->device(), dstImage, destMem, 0); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5416 | ASSERT_VK_SUCCESS(err); |
| 5417 | |
| 5418 | BeginCommandBuffer(); |
| 5419 | // Need memory barrier to VK_IMAGE_LAYOUT_GENERAL for source and dest? |
| 5420 | //VK_IMAGE_LAYOUT_UNDEFINED = 0, |
| 5421 | //VK_IMAGE_LAYOUT_GENERAL = 1, |
| 5422 | VkImageResolve resolveRegion; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5423 | resolveRegion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5424 | resolveRegion.srcSubresource.mipLevel = 0; |
Courtney Goeltzenleuchter | 8367ce0 | 2015-10-16 09:46:00 -0600 | [diff] [blame] | 5425 | resolveRegion.srcSubresource.baseArrayLayer = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5426 | resolveRegion.srcSubresource.layerCount = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5427 | resolveRegion.srcOffset.x = 0; |
| 5428 | resolveRegion.srcOffset.y = 0; |
| 5429 | resolveRegion.srcOffset.z = 0; |
Chia-I Wu | ab83a0e | 2015-10-27 19:00:15 +0800 | [diff] [blame] | 5430 | resolveRegion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5431 | resolveRegion.dstSubresource.mipLevel = 0; |
| 5432 | resolveRegion.dstSubresource.baseArrayLayer = 0; |
| 5433 | resolveRegion.dstSubresource.layerCount = 0; |
| 5434 | resolveRegion.dstOffset.x = 0; |
| 5435 | resolveRegion.dstOffset.y = 0; |
| 5436 | resolveRegion.dstOffset.z = 0; |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5437 | resolveRegion.extent.width = 1; |
| 5438 | resolveRegion.extent.height = 1; |
| 5439 | resolveRegion.extent.depth = 1; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5440 | m_commandBuffer->ResolveImage(srcImage, VK_IMAGE_LAYOUT_GENERAL, dstImage, VK_IMAGE_LAYOUT_GENERAL, 1, &resolveRegion); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5441 | EndCommandBuffer(); |
| 5442 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5443 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5444 | FAIL() << "Did not receive Error 'vkCmdResolveImage called with unmatched source and dest image types.'"; |
| 5445 | m_errorMonitor->DumpFailureMsgs(); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5446 | } |
| 5447 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5448 | vkDestroyImage(m_device->device(), srcImage, NULL); |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5449 | vkDestroyImage(m_device->device(), dstImage, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5450 | vkFreeMemory(m_device->device(), srcMem, NULL); |
| 5451 | vkFreeMemory(m_device->device(), destMem, NULL); |
Mike Stroyan | a308243 | 2015-09-25 13:39:21 -0600 | [diff] [blame] | 5452 | } |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5453 | |
| 5454 | TEST_F(VkLayerTest, DepthStencilImageViewWithColorAspectBitError) |
| 5455 | { |
| 5456 | // Create a single Image descriptor and cause it to first hit an error due |
| 5457 | // to using a DS format, then cause it to hit error due to COLOR_BIT not set in aspect |
| 5458 | // The image format check comes 2nd in validation so we trigger it first, |
| 5459 | // then when we cause aspect fail next, bad format check will be preempted |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5460 | VkResult err; |
| 5461 | |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5462 | m_errorMonitor->SetDesiredFailureMsg(VK_DBG_REPORT_ERROR_BIT, |
| 5463 | "Combination depth/stencil image formats can have only the "); |
| 5464 | |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5465 | ASSERT_NO_FATAL_FAILURE(InitState()); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5466 | |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5467 | VkDescriptorPoolSize ds_type_count = {}; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5468 | ds_type_count.type = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5469 | ds_type_count.descriptorCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5470 | |
| 5471 | VkDescriptorPoolCreateInfo ds_pool_ci = {}; |
| 5472 | ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; |
| 5473 | ds_pool_ci.pNext = NULL; |
| 5474 | ds_pool_ci.maxSets = 1; |
Chia-I Wu | 1b99bb2 | 2015-10-27 19:25:11 +0800 | [diff] [blame] | 5475 | ds_pool_ci.poolSizeCount = 1; |
| 5476 | ds_pool_ci.pPoolSizes = &ds_type_count; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5477 | |
| 5478 | VkDescriptorPool ds_pool; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5479 | err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5480 | ASSERT_VK_SUCCESS(err); |
| 5481 | |
| 5482 | VkDescriptorSetLayoutBinding dsl_binding = {}; |
Chia-I Wu | d46e6ae | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5483 | dsl_binding.binding = 0; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5484 | dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; |
| 5485 | dsl_binding.arraySize = 1; |
| 5486 | dsl_binding.stageFlags = VK_SHADER_STAGE_ALL; |
| 5487 | dsl_binding.pImmutableSamplers = NULL; |
| 5488 | |
| 5489 | VkDescriptorSetLayoutCreateInfo ds_layout_ci = {}; |
| 5490 | ds_layout_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
| 5491 | ds_layout_ci.pNext = NULL; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5492 | ds_layout_ci.bindingCount = 1; |
Chia-I Wu | a745e51 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5493 | ds_layout_ci.pBinding = &dsl_binding; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5494 | VkDescriptorSetLayout ds_layout; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5495 | err = vkCreateDescriptorSetLayout(m_device->device(), &ds_layout_ci, NULL, &ds_layout); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5496 | ASSERT_VK_SUCCESS(err); |
| 5497 | |
| 5498 | VkDescriptorSet descriptorSet; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5499 | VkDescriptorSetAllocateInfo alloc_info = {}; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5500 | alloc_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOC_INFO; |
Chia-I Wu | d50a7d7 | 2015-10-26 20:48:51 +0800 | [diff] [blame] | 5501 | alloc_info.setLayoutCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5502 | alloc_info.descriptorPool = ds_pool; |
| 5503 | alloc_info.pSetLayouts = &ds_layout; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5504 | err = vkAllocateDescriptorSets(m_device->device(), &alloc_info, &descriptorSet); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5505 | ASSERT_VK_SUCCESS(err); |
| 5506 | |
| 5507 | VkImage image_bad; |
| 5508 | VkImage image_good; |
| 5509 | // One bad format and one good format for Color attachment |
| 5510 | const VkFormat tex_format_bad = VK_FORMAT_D32_SFLOAT_S8_UINT; |
| 5511 | const VkFormat tex_format_good = VK_FORMAT_B8G8R8A8_UNORM; |
| 5512 | const int32_t tex_width = 32; |
| 5513 | const int32_t tex_height = 32; |
| 5514 | |
| 5515 | VkImageCreateInfo image_create_info = {}; |
| 5516 | image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5517 | image_create_info.pNext = NULL; |
| 5518 | image_create_info.imageType = VK_IMAGE_TYPE_2D; |
| 5519 | image_create_info.format = tex_format_bad; |
| 5520 | image_create_info.extent.width = tex_width; |
| 5521 | image_create_info.extent.height = tex_height; |
| 5522 | image_create_info.extent.depth = 1; |
| 5523 | image_create_info.mipLevels = 1; |
| 5524 | image_create_info.arrayLayers = 1; |
Chia-I Wu | 5c17c96 | 2015-10-31 00:31:16 +0800 | [diff] [blame] | 5525 | image_create_info.samples = VK_SAMPLE_COUNT_1_BIT; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5526 | image_create_info.tiling = VK_IMAGE_TILING_OPTIMAL; |
| 5527 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 5528 | image_create_info.flags = 0; |
| 5529 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5530 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image_bad); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5531 | ASSERT_VK_SUCCESS(err); |
| 5532 | image_create_info.format = tex_format_good; |
| 5533 | image_create_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5534 | err = vkCreateImage(m_device->device(), &image_create_info, NULL, &image_good); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5535 | ASSERT_VK_SUCCESS(err); |
| 5536 | |
| 5537 | VkImageViewCreateInfo image_view_create_info = {}; |
| 5538 | image_view_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; |
| 5539 | image_view_create_info.image = image_bad; |
| 5540 | image_view_create_info.viewType = VK_IMAGE_VIEW_TYPE_2D; |
| 5541 | image_view_create_info.format = tex_format_bad; |
| 5542 | image_view_create_info.subresourceRange.baseArrayLayer = 0; |
| 5543 | image_view_create_info.subresourceRange.baseMipLevel = 0; |
Chia-I Wu | 3432a0c | 2015-10-27 18:04:07 +0800 | [diff] [blame] | 5544 | image_view_create_info.subresourceRange.layerCount = 1; |
| 5545 | image_view_create_info.subresourceRange.levelCount = 1; |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5546 | image_view_create_info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; |
| 5547 | |
| 5548 | VkImageView view; |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5549 | err = vkCreateImageView(m_device->device(), &image_view_create_info, NULL, &view); |
Mark Lobodzinski | 8507f2f | 2015-10-29 09:02:49 -0600 | [diff] [blame] | 5550 | |
| 5551 | if (!m_errorMonitor->DesiredMsgFound()) { |
| 5552 | FAIL() << "Did not receive Error 'Combination depth-stencil image formats can have only the....'"; |
| 5553 | m_errorMonitor->DumpFailureMsgs(); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5554 | } |
| 5555 | |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5556 | vkDestroyImage(m_device->device(), image_bad, NULL); |
| 5557 | vkDestroyImage(m_device->device(), image_good, NULL); |
Chia-I Wu | f7458c5 | 2015-10-26 21:10:41 +0800 | [diff] [blame] | 5558 | vkDestroyDescriptorSetLayout(m_device->device(), ds_layout, NULL); |
| 5559 | vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL); |
Tobin Ehlis | a1c2856 | 2015-10-23 16:00:08 -0600 | [diff] [blame] | 5560 | } |
Tobin Ehlis | cde0889 | 2015-09-22 10:11:37 -0600 | [diff] [blame] | 5561 | #endif // IMAGE_TESTS |
| 5562 | |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 5563 | int main(int argc, char **argv) { |
| 5564 | int result; |
| 5565 | |
| 5566 | ::testing::InitGoogleTest(&argc, argv); |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 5567 | VkTestFramework::InitArgs(&argc, argv); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 5568 | |
| 5569 | ::testing::AddGlobalTestEnvironment(new TestEnvironment); |
| 5570 | |
| 5571 | result = RUN_ALL_TESTS(); |
| 5572 | |
Tony Barbour | 6918cd5 | 2015-04-09 12:58:51 -0600 | [diff] [blame] | 5573 | VkTestFramework::Finish(); |
Tony Barbour | 300a608 | 2015-04-07 13:44:53 -0600 | [diff] [blame] | 5574 | return result; |
| 5575 | } |